Peano
Loading...
Searching...
No Matches
ccz4.py
Go to the documentation of this file.
1import os
2import argparse
3
4import peano4
5import exahype2
6
8import dastgen2
9
10from Probe_file_gene import tracer_seeds_generate
11
13import numpy as np
14#todo no mpmath here so rkdg not working
15
16def CoordListFromFile(file,scale):
17 f=open(file)
18 data=[]
19 tem=f.readlines()
20 for line in tem:
21 data.append(list(map(float,line.split(' ')[1:])))
22 print(len(data))
23 data=np.array(data)
24 return data*scale
25
26
27modes = {
28 "release": peano4.output.CompileMode.Release,
29 "trace": peano4.output.CompileMode.Trace,
30 "assert": peano4.output.CompileMode.Asserts, "stats": peano4.output.CompileMode.Stats,
31 "debug": peano4.output.CompileMode.Debug,
32}
33
34floatparams = {
35 "GLMc0":1.5, "GLMc":1.2, "GLMd":2.0, "GLMepsA":1.0, "GLMepsP":1.0,
36 "GLMepsD":1.0,
37 "itau":1.0, "k1":0.1, "k2":0.0, "k3":0.5, "eta":1.0,
38 "f":0.75, "g":0.0, "xi":1.0, "e":1.0, "c":1.0, "mu":0.2, "ds":1.0,
39 "sk":1.0, "bs":1.0,
40 "domain_r":0.5, "smoothing":0.0, "KOSigma":4.0 #, \
41 #"itau":1.0, "k1":0.1, "k2":0.0, "k3":0.5, "eta":1.0,
42 #"f":1.0, "g":0.0, "xi":1.0, "e":1.0, "c":1.0, "mu":0.2, "ds":1.0,
43 #"sk":1.0, "bs":1.0#, \
44 #"par_b":666.0, "center_offset_x":-1.0, "center_offset_y":0.0, "center_offset_z":0.0, \
45 #"target_m_plus":1.0, "par_p_plus_x":0.0, "par_p_plus_y":0.0, "par_p_plus_z":0.0, \
46 #"par_s_plus_x":0.0, "par_s_plus_y":0.0, "par_s_plus_z":0.0, \
47 #"target_m_minus":1.0, "par_p_minus_x":0.0, "par_p_minus_y":0.0, "par_p_minus_z":0.0, \
48 #"par_s_minus_x":0.0, "par_s_minus_y":0.0, "par_s_minus_z":0.0, \
49 #"tp_epsilon":1e-6
50}
51
52intparams = {"BBHType":2, "LapseType":1, "tp_grid_setup":0, "swi":99, "ReSwi":0, "source":0}
53#sss
54if __name__ == "__main__":
55 parser = argparse.ArgumentParser(description='ExaHyPE 2 - CCZ4 script')
56 parser.add_argument("-maxh", "--max-h", dest="max_h", type=float, required="True", help="upper limit for refinement. Refers to volume size, i.e. not to patch size" )
57 parser.add_argument("-minh", "--min-h", dest="min_h", type=float, default=0, help="lower limit for refinement (set to 0 to make it equal to max_h - default). Refers to volume size, i.e. not to patch size" )
58 parser.add_argument("-ps", "--patch-size", dest="patch_size", type=int, default=6, help="Patch size, i.e. number of volumes per patch per direction" )
59 parser.add_argument("-plt", "--plot-step-size", dest="plot_step_size", type=float, default=0.04, help="Plot step size (0 to switch it off)" )
60 parser.add_argument("-m", "--mode", dest="mode", default="release", help="|".join(modes.keys()) )
61 parser.add_argument( "--gpu", dest="GPU", default=False, action="store_true", help="Run with accelerator support" )
62 parser.add_argument("-ext", "--extension", dest="extension", choices=["none", "adm", "Psi4","phy-debug", "PT"], default="none", help="Pick extension, i.e. what should be plotted on top. Default is none" )
63 parser.add_argument("-impl", "--implementation", dest="implementation", choices=["fv-global-fixed", "fv-global-adaptive", "fv-global-fixed-enclave", "fv-global-adaptive-enclave","fv-subcyling-adaptive-enclave","fv-local-enclave", "fv-musclhancock", "fd4-rk1-adaptive", "fd4-rk1-adaptive-enclave", "fd4-rk1-fixed", "fd4-rk4-adaptive", "fd4-rk4-fixed", "RKDG"], required="True", help="Pick solver type" )
64 parser.add_argument("-no-pbc", "--no-periodic-boundary-conditions", dest="periodic_bc", action="store_false", default=True, help="switch on or off the periodic BC" )
65 parser.add_argument("-sommerfeld", "--sommerfeld-boundary-conditions", dest="sommerfeld_bc", action="store_true", default=False, help="switch on or off the Sommerfeld radiative BC" )
66 parser.add_argument("-AMRMarker", "--AMR-marker", dest="marker", choices=["none", "poisson"], default="none", help="switch on or off the AMR boundary marker" )
67 parser.add_argument("-et", "--end-time", dest="end_time", type=float, default=1.0, help="End (terminal) time" )
68 parser.add_argument("-pst", "--plot-start-time", dest="plot_start_time", type=float, default=0.0, help="start time for plot" )
69 parser.add_argument("-s", "--scenario", dest="scenario", choices=["gauge", "dia_gauge", "linear", "single-puncture","two-punctures", "flat"], required="True", help="Scenario" )
70 parser.add_argument("-cfl", "--CFL-ratio", dest="cfl", type=float, default=0.1, help="Set CFL ratio" )
71 parser.add_argument("-tracer", "--add-tracer", dest="add_tracer", type=int, default=0, help="Add tracers and specify the seeds. 0-switch off, 1-static point tracer, 2-moving point tracer" )
72 parser.add_argument("-tn", "--tracer-name", dest="tra_name", type=str, default="de", help="name of output tracer file (temporary)" )
73 parser.add_argument("-exn", "--exe-name", dest="exe_name", type=str, default="", help="name of output executable file" )
74 parser.add_argument("-outdir", "--output-directory", dest="path", type=str, default="./", help="specify the output directory, include the patch file and tracer file" )
75 parser.add_argument("-interp", "--interpolation", dest="interpolation", choices=["constant","order-2","linear-constant-extrap","linear-linear-extrap","linear-con-extrap-lin-normal-interp","linear-lin-extrap-lin-normal-interp"], default="linear-lin-extrap-lin-normal-interp", help="interpolation scheme for AMR" )
76 parser.add_argument("-restrict", "--restriction", dest="restriction", choices=["average", "inject" ], default="average", help="restriction scheme for AMR" )
77
78
79 for k, v in floatparams.items(): parser.add_argument("--{}".format(k), dest="CCZ4{}".format(k), type=float, default=v, help="default: %(default)s")
80 for k, v in intparams.items():
81 if k=="ReSwi":
82 parser.add_argument("--{}".format(k), dest="CCZ4{}".format(k), type=int, default=v, help="default: %(default)s, choose refinement criterion, 0-no refinement, 1-radius based, 2-SBH phi gradient based, 3-BBH phi gradient based. Notice: 2 and 3 only work with -ext Full")
83 else: parser.add_argument("--{}".format(k), dest="CCZ4{}".format(k), type=int, default=v, help="default: %(default)s")
84
85 args = parser.parse_args()
86
87 SuperClass = None
88
89 print(args.implementation)
90 if args.implementation=="fv-global-fixed":
92 if args.implementation=="fv-global-adaptive":
94 if args.implementation=="fv-global-fixed-enclave":
96 if args.implementation=="fv-global-adaptive-enclave":
98 if args.implementation=="fv-subcyling-adaptive-enclave":
100 if args.implementation=="fv-local-enclave":
102 if args.implementation=="fv-musclhancock":
104 if args.implementation=="fd4-rk1-adaptive" or args.implementation=="fd4-rk4-adaptive":
106 if args.implementation=="fd4-rk1-adaptive-enclave":
108 if args.implementation=="fd4-rk1-fixed" or args.implementation=="fd4-rk4-fixed":
110 if args.implementation=="RKDG":
112
113
114 class CCZ4Solver( SuperClass ):
115 def __init__(self, name, patch_size, min_volume_h, max_volume_h, cfl, domain_r, KOSig):
116 unknowns = {
117 "G":6, #0-5
118 "K":6, #6-11
119 "theta":1, #12
120 "Z":3, #13-15
121 "lapse":1, #16
122 "shift":3, #17-19
123 "b":3, #20-22
124 "dLapse":3, #23-25
125 "dxShift":3,#26-28
126 "dyShift":3,#29-31
127 "dzShift":3,#32-34
128 "dxG":6, #35-40
129 "dyG":6, #41-46
130 "dzG":6, #47-52
131 "traceK":1, #53
132 "phi":1, #54
133 "P":3, #55-57
134 "K0":1, #58
135 }
136
137 number_of_unknowns = sum(unknowns.values())
138
139 self._my_user_includes = """
140#include "../CCZ4Kernels.h"
141"""
142
144 SuperClass.__init__(
145 self,
146 name=name, patch_size=patch_size,
147 unknowns=number_of_unknowns,
148 auxiliary_variables=0,
149 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
150 normalised_time_step_size=1e-2
151 )
153 SuperClass.__init__(
154 self,
155 name=name, patch_size=patch_size,
156 unknowns=number_of_unknowns,
157 auxiliary_variables=0,
158 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
159 time_step_size=1e-2,
160 use_gpu =args.GPU #=="fv-fixed-gpu" else False
161 )
163 SuperClass.__init__(
164 self,
165 name=name, patch_size=patch_size,
166 unknowns=number_of_unknowns,
167 auxiliary_variables=0,
168 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
169 time_step_relaxation=cfl
170 )
172 if args.implementation=="fd4-rk1-adaptive" or args.implementation=="fd4-rk1-adaptive-enclave":
173 rk_order = 1
174 else:
175 rk_order = 4
176 SuperClass.__init__(
177 self,
178 name=name, patch_size=patch_size, rk_order=rk_order,
179 unknowns=number_of_unknowns,
180 auxiliary_variables=0,
181 min_meshcell_h=min_volume_h, max_meshcell_h=max_volume_h,
182 time_step_relaxation=cfl,
183 KOSigma=KOSig
184 )
186 if args.implementation=="fd4-rk1-adaptive" or args.implementation=="fd4-rk1-adaptive-enclave":
187 rk_order = 1
188 else:
189 rk_order = 4
190 SuperClass.__init__(
191 self,
192 name=name, patch_size=patch_size, rk_order=rk_order,
193 unknowns=number_of_unknowns,
194 auxiliary_variables=0,
195 min_meshcell_h=min_volume_h, max_meshcell_h=max_volume_h,
196 time_step_relaxation=cfl,
197 KOSigma=KOSig,
198 pde_terms_without_state=True
199 )
200 elif SuperClass==exahype2.solvers.rkfd.fd4.GlobalFixedTimeStep or SuperClass==exahype2.solvers.rkfd.fd4.GlobalFixedTimeStepWithEnclaveTasking:
201 if args.implementation=="fd4-rk1-fixed":
202 rk_order = 1
203 else:
204 rk_order = 4
205 SuperClass.__init__(
206 self,
207 name=name, patch_size=patch_size, rk_order=rk_order,
208 unknowns=number_of_unknowns,
209 auxiliary_variables=0,
210 min_meshcell_h=min_volume_h, max_meshcell_h=max_volume_h,
211 normalised_time_step_size=0.01,
212 KOSigma=KOSig
213 )
215 SuperClass.__init__(
216 self,
217 name=name,
218 rk_order = 2,
220 face_projections = exahype2.solvers.rkdg.FaceProjections.Solution,
221 unknowns=number_of_unknowns,
222 auxiliary_variables=0,
223 min_cell_h=min_volume_h, max_cell_h=max_volume_h, #not a good name, but use for now.
224 time_step_relaxation=cfl
225 )
226 else:
227 SuperClass.__init__(
228 self,
229 name=name, patch_size=patch_size,
230 unknowns=number_of_unknowns,
231 auxiliary_variables=0,
232 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
233 time_step_relaxation=cfl
234 #use_gpu =args.GPU #=="fv-fixed-gpu" else False
235# use_gpu = True if args.implementation=="fv-adaptive-gpu" else False
236 )
237
238 self._patch_size = patch_size
239 self._domain_r = domain_r
240
241 self.set_implementation(
242 boundary_conditions=exahype2.solvers.PDETerms.User_Defined_Implementation,
243 ncp=exahype2.solvers.PDETerms.User_Defined_Implementation,
244 flux=exahype2.solvers.PDETerms.None_Implementation,
245 source_term=exahype2.solvers.PDETerms.User_Defined_Implementation,
246 refinement_criterion = exahype2.solvers.PDETerms.User_Defined_Implementation,
247 eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation
248 )
249
255 compute_max_eigenvalue_of_next_time_step = True,
256 solver_variant = exahype2.solvers.rkfd.kernels.SolverVariant.Multicore,
257 kernel_variant = exahype2.solvers.rkfd.kernels.KernelVariant.BatchedAoSHeap,
258 KOSigma = self._KO_Sigma
259 )
260
261 self.switch_to_heap_storage(True,True)
262
264{
265"""
266
267 if (
271 #or SuperClass==exahype2.solvers.rkfd.fd4.GlobalFixedTimeStepWithEnclaveTasking no fixed enclave version yet
272 ):
273 self.postprocess_updated_patch += """
274 #if Dimensions==2
275 constexpr int itmax = {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}} * {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}};
276 #endif
277
278 #if Dimensions==3
279 constexpr int itmax = {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}} * {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}} * {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}};
280 #endif
281"""
282 #elif SuperClass == exahype2.solvers.rkdg.rusanov.GlobalAdaptiveTimeStep: fix it after rkdg is back
283 # self.postprocess_updated_patch = """
284 #constexpr int itmax = ({{ORDER}}+1) * ({{ORDER}}+1) * ({{ORDER}}+1); // only support 3d
285#"""
286 else:
287 self.postprocess_updated_patch += """
288 #if Dimensions==2
289 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
290 #endif
291
292 #if Dimensions==3
293 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
294 #endif
295"""
296
297 self.postprocess_updated_patch += """
298 int index = 0;
299 for (int i=0;i<itmax;i++)
300 {
301 applications::exahype2::ccz4::enforceCCZ4constraints( newQ+index );
302 index += {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}};
303 }
304 }
305"""
306
307
309 SuperClass.create_action_sets(self)
310 self._action_set_couple_resolution_transitions_and_handle_dynamic_mesh_refinement.additional_includes += """
311#include "../CCZ4Kernels.h"
312 """
313
315 """
316 We take this routine to add a few additional include statements.
317 """
318 return SuperClass.get_user_action_set_includes(self) + self._my_user_includes
319
321 """
322 @add adm constriants (Hamilton and Momentum)
323 """
324 self._auxiliary_variables = 7
325
326 self._my_user_includes += """
327 #include "../CCZ4Kernels.h"
328 """
329
330 self._preprocess_reconstructed_patch = """
331 const int patchSize = """ + str( self._patch.dim[0] ) + """;
332 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
333
334 const int n_a_v=7;
335 const int overlap=3; //make sure you are using fd4 solver!
336
337 //if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()==FiniteVolumeCCZ4::SolverState::RungeKuttaSubStep0) {
338 if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction) {
339 dfor(cell,patchSize) {
340 tarch::la::Vector<Dimensions,int> currentCell = cell + tarch::la::Vector<Dimensions,int>(overlap);
341
342 double gradQ[3*59]={ 0 };
343
344 for (int d=0; d<3; d++) {
345 tarch::la::Vector<Dimensions,int> leftCell = currentCell;
346 tarch::la::Vector<Dimensions,int> rightCell = currentCell;
347 leftCell(d) -= 1;
348 rightCell(d) += 1;
349 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
350 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
351 for(int i=0; i<59; i++) {
352 gradQ[d*59+i] = ( oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - oldQWithHalo[leftCellSerialised*(59+n_a_v)+i] ) / 2.0 / volumeH;
353 }
354 }
355
356 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
357
358 double constraints[7]={0,0,0,0,0,0,0};
359 admconstraints(constraints, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ);
360 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
361 for (int i=0;i<7;i++){
362 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+i) ] = constraints[i];
363 }
364 }
365 }
366 """
367
368 self.create_data_structures()
369 self.create_action_sets()
370
371 def add_Psi4W(self):
372 """
373 add psi4 writer
374 """
375 self._auxiliary_variables = 2
376
377 self._my_user_includes += """
378 #include "../libtwopunctures/TP_PunctureTracker.h"
379 #include "../CCZ4Kernels.h"
380 """
381
382 self._preprocess_reconstructed_patch = """
383 const int patchSize = """ + str( self._patch.dim[0] ) + """;
384 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
385
386 const int n_a_v=2;
387 const int overlap=3; //make sure you are using fd4 solver!
388
389 //if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()==FiniteVolumeCCZ4::SolverState::RungeKuttaSubStep0) {
390 if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction) {
391 dfor(cell,patchSize) {
392 tarch::la::Vector<Dimensions,int> currentCell = cell + tarch::la::Vector<Dimensions,int>(overlap);
393
394 double gradQ[3*59]={ 0 };
395
396 for (int d=0; d<3; d++) {
397 tarch::la::Vector<Dimensions,int> leftCell = currentCell;
398 tarch::la::Vector<Dimensions,int> rightCell = currentCell;
399 leftCell(d) -= 1;
400 rightCell(d) += 1;
401 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
402 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
403 for(int i=0; i<59; i++) {
404 gradQ[d*59+i] = ( oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - oldQWithHalo[leftCellSerialised*(59+n_a_v)+i] ) / 2.0 / volumeH;
405 }
406 }
407
408 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
409
410 double Psi4[2]={0,0};
411 double currentPosition[3];
412 for (int d=0; d<3; d++) currentPosition[d]=marker.getOffset()(d)+(cell(d)+0.5)*volumeH;
413 Psi4Calc(Psi4, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ, currentPosition);
414 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
415 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+0) ] = Psi4[0];
416 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+1) ] = Psi4[1];
417 }
418 }
419 """
420
421 self.create_data_structures()
422 self.create_action_sets()
423
425 """
426 @add adm intermediate quantites
427 """
428 self._auxiliary_variables = 15
429
430 self._my_user_includes += """
431 #include "../CCZ4Kernels.h"
432 """
433
434 self._preprocess_reconstructed_patch = """
435 const int patchSize = """ + str( self._patch.dim[0] ) + """;
436 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
437
438 const int n_a_v=""" + str( self._auxiliary_variables ) + """;
439 const int overlap=3; //make sure you are using fd4 solver!
440
441 //if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()==FiniteVolumeCCZ4::SolverState::RungeKuttaSubStep0) {
442 if (not marker.willBeRefined() and repositories::InstanceOfFiniteVolumeCCZ4.getSolverState()!=FiniteVolumeCCZ4::SolverState::GridConstruction) {
443 dfor(cell,patchSize) {
444 tarch::la::Vector<Dimensions,int> currentCell = cell + tarch::la::Vector<Dimensions,int>(overlap);
445
446 double gradQ[3*59]={ 0 };
447
448 for (int d=0; d<3; d++) {
449 tarch::la::Vector<Dimensions,int> leftCell = currentCell;
450 tarch::la::Vector<Dimensions,int> leftCell2 = currentCell;
451 tarch::la::Vector<Dimensions,int> rightCell = currentCell;
452 tarch::la::Vector<Dimensions,int> rightCell2 = currentCell;
453 leftCell(d) -= 1; leftCell2(d) -= 2;
454 rightCell(d) += 1; rightCell2(d) += 2;
455 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*overlap);
456 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*overlap);
457 const int leftCellSerialised2 = peano4::utils::dLinearised(leftCell2, patchSize + 2*overlap);
458 const int rightCellSerialised2 = peano4::utils::dLinearised(rightCell2,patchSize + 2*overlap);
459 for(int i=0; i<59; i++) {
460 gradQ[d*59+i] = ( (2.0/3.0)*oldQWithHalo[rightCellSerialised*(59+n_a_v)+i] - (2.0/3.0)*oldQWithHalo[leftCellSerialised*(59+n_a_v)+i]
461 +(1.0/12.0)*oldQWithHalo[leftCellSerialised2*(59+n_a_v)+i] - (1.0/12.0)*oldQWithHalo[rightCellSerialised2*(59+n_a_v)+i] )/volumeH;
462 }
463 }
464
465 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*overlap);
466
467 double terms[""" + str( self._auxiliary_variables ) + """]={0,0,0,0,0,0,0};
468 TestingOutput(terms, oldQWithHalo+cellSerialised*(59+n_a_v), gradQ);
469 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, 0, 59, n_a_v);
470 for (int i=0;i<""" + str( self._auxiliary_variables ) + """;i++){
471 fineGridCellFiniteVolumeCCZ4Q.value[ enumeratorWithAuxiliaryVariables(0,cell,59+i) ] = terms[i];
472 }
473 }
474 }
475 """
476
477 self.create_data_structures()
478 self.create_action_sets()
479
481 """
482 @add
483 """
484 self._auxiliary_variables = 0
485
486 self._user_solver_includes += """
487 #include "libtwopunctures/TP_PunctureTracker.h"
488 #include "CCZ4Kernels.h"
489 #include <fstream>
490 #include <iomanip>
491 """
492
493# self._user_action_set_includes += """
494# #include "../libtwopunctures/TP_PunctureTracker.h"
495# #include "../CCZ4Kernels.h"
496# #include <fstream>
497# #include <iomanip>
498# """
499
500 self._preprocess_reconstructed_patch = """
501 const int patchSize = """ + str( self._patch.dim[0] ) + """;
502 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
503
504 std::fstream fin;
505 std::string att="_"""+args.exe_name+""".txt"; std::string p1="puncture1"; std::string p2="puncture2"; std::string tem="ztem";
506 const int n_a_v=""" + str( self._auxiliary_variables ) + """;
507 const double overlap=3;
508
509 if (tarch::la::equals(timeStamp,0.0)){//initialization
510 fin.open((p1+att),std::ios::out|std::ios::trunc);
511 fin << "2.0 0.0 0.0 0.0 0.0" << std::endl;//4.461538
512 fin.close();
513 fin.open((p2+att),std::ios::out|std::ios::trunc);
514 fin << "-2.0 0.0 0.0 0.0 0.0" << std::endl;//-5.538462
515 fin.close();
516 //fin.open((tem+att),std::ios::out|std::ios::trunc);
517 //fin << "tem file" << std::endl;
518 //fin.close();
519 } else {
520 fin.open((p1+att),std::ios::in);
521 std::string pos=getLastLine(fin);
522 fin.close();
523 double coor1[5]={0};//read in previous coordinates
524 CoorReadIn(coor1,pos);
525 fin.open((p2+att),std::ios::in);
526 std::string pos2=getLastLine(fin);
527 fin.close();
528 double coor2[5]={0};
529 CoorReadIn(coor2,pos2);
530 int inter_number=4;
531 if (marker.isContained(coor1)){
532 tarch::la::Vector<Dimensions*2,int> IndexOfCell=FindCellIndex(coor1,marker.getOffset(),volumeH,patchSize); //find where the puncture is
533 tarch::la::Vector<Dimensions,int> IndexForInterpolate[8];
534 FindInterIndex(IndexForInterpolate,IndexOfCell);//find the closest 8 cells
535 double raw[32]={0};
536 for (int i=0;i<8;i++){
537 int Lindex=peano4::utils::dLinearised(IndexForInterpolate[i], patchSize + 2*overlap);
538 for (int j=0;j<Dimensions;j++) {raw[i*inter_number+j]=oldQWithHalo[Lindex*(59+n_a_v)+17+j];} //read in corresponding beta
539 raw[i*inter_number+3]=oldQWithHalo[Lindex*(59+n_a_v)+16];
540 //std::cout << IndexForInterpolate[i](0) << " " << IndexForInterpolate[i](1) << " " << IndexForInterpolate[i](2) << std::endl;
541 //std::cout << raw[i*inter_number+0] << " " << raw[i*inter_number+1] << " " << raw[i*inter_number+2] << " " << raw[i*inter_number+3] << std::endl;
542 //::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, patchSize, overlap, 59, n_a_v);
543 //std::cout << oldQWithHalo[enumeratorWithAuxiliaryVariables(0,IndexForInterpolate[i],0)] << std::endl;
544 }
545 double result[inter_number];
546 Interpolation(result,IndexForInterpolate,raw,coor1,marker.getOffset(),volumeH,patchSize);
547
548 coor1[0]-=timeStepSize*result[0]; coor1[1]-=timeStepSize*result[1]; coor1[2]-=timeStepSize*result[2];//updates position
549 fin.open((p1+att),std::ios::app);//output
550 fin << std::setprecision (17) << coor1[0] << " " << coor1[1];
551 fin << " " << coor1[2] << " " << timeStamp << " " << result[3] << std::endl;
552 fin.close();
553 //fin.open((tem+att),std::ios::app);
554 //fin << "for cellindex" << IndexOfCell(0) << " " << IndexOfCell(1) << " " << IndexOfCell(2) << " " << IndexOfCell(3) << " " << IndexOfCell(4) << " " << IndexOfCell(5) << std::endl;
555 //for (int i=0;i<8;i++){
556 //fin << IndexForInterpolate[i](0) << " " << IndexForInterpolate[i](1) << " " << IndexForInterpolate[i](2) << std::endl;
557 //fin << raw[i*inter_number+0] << " " << raw[i*inter_number+1] << " " << raw[i*inter_number+2] << " " << raw[i*inter_number+3] << std::endl;
558 //}
559
560 //fin << "after inter" << result[0] << " " << result[1] << " " << result[2] << " " << result[3] << " " << timeStamp << std::endl;
561 //fin.close();
562 }
563 if (marker.isContained(coor2)){//do the same for the second puncutre
564 tarch::la::Vector<Dimensions*2,int> IndexOfCell=FindCellIndex(coor2,marker.getOffset(),volumeH,patchSize);
565 tarch::la::Vector<Dimensions,int> IndexForInterpolate[8];
566 FindInterIndex(IndexForInterpolate,IndexOfCell);
567 double raw[8*inter_number];
568 for (int i=0;i<8;i++){
569 int Lindex=peano4::utils::dLinearised(IndexForInterpolate[i], patchSize + 2*overlap);
570 for (int j=0;j<Dimensions;j++) {raw[i*inter_number+j]=oldQWithHalo[Lindex*(59+n_a_v)+17+j];}
571 raw[i*inter_number+3]=oldQWithHalo[Lindex*(59+n_a_v)+16];
572 }
573 double result[inter_number];
574 Interpolation(result,IndexForInterpolate,raw,coor2,marker.getOffset(),volumeH,patchSize);
575
576 coor2[0]-=timeStepSize*result[0]; coor2[1]-=timeStepSize*result[1]; coor2[2]-=timeStepSize*result[2];
577 fin.open((p2+att),std::ios::app);
578 fin << std::setprecision (17) << coor2[0] << " " << coor2[1];
579 fin << " " << coor2[2] << " " << timeStamp << " " << result[3] << std::endl;
580 fin.close();
581 }
582 }
583 """
584
585 self.create_data_structures()
586 self.create_action_sets()
587
588
589
592 userinfo = []
593 exe="peano4"
594
595 if args.exe_name!="":
596 exe += "_"
597 exe += args.exe_name
598 if not args.tra_name=="de":
599 exe += "_" + args.tra_name
600 project = exahype2.Project( ["applications", "exahype2", "ccz4"], "ccz4", executable=exe)
601
602
605 is_aderdg = False
606 is_rkdg = False
607 solver_name = "CCZ4"
608 try:
609 if SuperClass==exahype2.solvers.aderdg.NonFusedGenericRusanovFixedTimeStepSize:
610 is_aderdg = True
611 order = 3
612 unknowns = 59
613 time_step_size = 0.001
614 except Exception as e:
615 pass
616 #msg = "Warning: ADER-DG no supported on this machine"
617 #print(msg)
618 #userinfo.append((msg,e))
619
620 try:
622 is_rkdg = True
623 except Exception as e:
624 pass
625 msg = "Warning: RKDG not supported on this machine"
626 print(msg)
627 userinfo.append((msg,e))
628
629 if is_aderdg:
630 solver_name = "ADERDG" + solver_name
631 elif is_rkdg:
632 solver_name = "RKDG" + solver_name
633 else:
634 solver_name = "FiniteVolume" + solver_name
635
636
637 min_h = args.min_h
638 if min_h <=0.0:
639 print( "No minimal mesh size chosen. Set it to max mesh size (regular grid)" )
640 min_h = args.max_h
641
642 if is_aderdg:
643 my_solver = exahype2.solvers.aderdg.NonFusedGenericRusanovFixedTimeStepSize(
644 solver_name, order, unknowns, 0, #auxiliary_variables
645 exahype2.solvers.aderdg.Polynomials.Gauss_Legendre,
646 min_h, args.max_h, time_step_size,
647 flux = None,
648 ncp = exahype2.solvers.PDETerms.User_Defined_Implementation,
649 sources = exahype2.solvers.PDETerms.User_Defined_Implementation
650 )
651 else:
652 my_solver = CCZ4Solver(solver_name, args.patch_size, min_h, args.max_h, args.cfl, args.CCZ4domain_r,args.CCZ4KOSigma)
653 userinfo.append(("CFL ratio set as "+str(args.cfl), None))
654
655 userinfo.append(("The solver is "+args.implementation, None))
656
657
660 print(args.marker)
661 if args.marker=="poisson":
662 amr_label = exahype2.solvers.elliptic.AMRMarker( name="AMRMarker" )
663 project.add_solver( amr_label )
664 my_solver._auxiliary_variables+=1
665 print( "Add Poisson AMR marker for variable {}".format(my_solver._auxiliary_variables-1) )
666 amr_label.couple_with_FV_solver( my_solver, my_solver._auxiliary_variables-1 )
667
668
671
672 if args.interpolation=="order-2":
673 my_solver.overlap=2
674
675 if args.interpolation=="constant":
676 my_solver.interpolation = "piecewise_constant"
677 print( "Interpolation rule: piecewise_constant" )
678 if args.interpolation=="linear-constant-extrap":
679 my_solver.interpolation = "linear_with_constant_extrapolation"
680 print( "Interpolation rule: linear constant extrapolation" )
681 if args.interpolation=="linear-linear-extrap":
682 my_solver.interpolation = "linear_with_linear_extrapolation"
683 print( "Interpolation rule: linear extrapolation" )
684 if args.interpolation=="linear-con-extrap-lin-normal-interp":
685 my_solver.interpolation = "linear_with_constant_extrapolation_and_linear_normal_interpolation"
686 print( "Interpolation rule: linear+constant extrapolation and linear normal interpolation" )
687
688 if args.interpolation=="order-2":
689 my_solver.interpolation = "linear"
690
691 #Below are the I&R set functions for FD4
692 #These functions here do two things:
693 #1. it set the solver.interpolation parameters similar to what we do for fv, so the code know what template shoule be named.
694 #2. it computes and write the corresponding matrices for named schemes into the solver head files.
695 #notice point 2 is not needed as for build-in function (for fv) the matrices are already hard-coded.
696 tem_interp=["TP_constant","TP_linear_with_linear_extrap_normal_interp"]
697 tem_restrict=["TP_inject_normal_extrap","TP_average_normal_extrap"]
698 if ("fd4-rk" in args.implementation):
699 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_interpolation( my_solver, tem_interp[1] )
700 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_restriction( my_solver, tem_restrict[1] )
701 userinfo.append(("FD4 Interpolation: " + tem_interp[1] + " & Restriction: " + tem_restrict[1], None))
702 #if args.interpolation=="linear+enforce" or args.interpolation=="linear-slow+enforce":
703 # self.point_wise_postprocessing_of_interpolation = "examples::exahype2::ccz4::enforceCCZ4constraints(targetVolume)" )
704 #if args.restriction=="average+enforce" or args.restriction=="inject+enforce":
705 # self.point_wise_postprocessing_of_restriction = "examples::exahype2::ccz4::enforceCCZ4constraints(targetVolume)"
706
707
708
709
712 if args.extension=="adm":
713 my_solver.add_adm_constriants()
714 if args.extension=="Psi4":
715 my_solver.add_Psi4W()
716 if args.extension=="phy-debug":
717 my_solver.add_intermediate_quantities()
718 if args.extension=="PT":
719 my_solver.add_puncture_tracker()
720
721 #my_solver._auxiliary_variables = 59*3
722
723
726 for k, v in intparams.items():
727 intparams.update({k:eval("args.CCZ4{}".format(k))})
728 for k, v in floatparams.items():
729 floatparams.update({k:eval("args.CCZ4{}".format(k))})
730
731 if args.scenario=="two-punctures":
732 msg = "Periodic BC deactivated because you pick Puncture scenario\nInitialize binary black holes"
733 print(msg)
734 periodic_boundary_conditions = [False,False,False]
735 intparams.update({"swi":2}) #notice it may change, see according function in FiniteVolumeCCZ4.cpp
736 print(intparams)
737 userinfo.append((msg,None))
738 elif args.scenario=="single-puncture":
739 msg = "Periodic BC deactivated because you pick Puncture scenario\nInitialize single black hole"
740 print(msg)
741 periodic_boundary_conditions = [False,False,False]
742 intparams.update({"swi":0})
743 userinfo.append((msg,None))
744 elif args.periodic_bc==True:
745 msg = "Periodic BC set"
746 print(msg)
747 periodic_boundary_conditions = [True,True,True] # Periodic BC
748 userinfo.append((msg,None))
749 else:
750 msg = "WARNING: Periodic BC deactivated by hand"
751 print(msg)
752 periodic_boundary_conditions = [False,False,False]
753 userinfo.append((msg,None))
754
755 if args.sommerfeld_bc==True:
756 msg = "set Sommerfeld boundary condition"
757 userinfo.append((msg,None))
758 periodic_boundary_conditions = [False,False,False]
759 if args.scenario=="single-puncture": #please notice the default black hole mass (1.0) is hard-coded. need to be modified accordingly if necessary.
760 my_solver._action_set_handle_boundary.TemplateHandleBoundary_KernelCalls = """
761 ::exahype2::fd::applySommerfeldConditions(
762 [&](
763 const double * __restrict__ Q,
764 const tarch::la::Vector<Dimensions,double>& faceCentre,
765 const tarch::la::Vector<Dimensions,double>& gridCellH,
766 double t,
767 double dt,
768 int normal
769 ) -> double {
770 return repositories::{{SOLVER_INSTANCE}}.maxEigenvalue( Q, faceCentre, gridCellH, t, dt, normal );
771 },
772 [&](
773 double * __restrict__ Q,
774 const tarch::la::Vector<Dimensions,double>& faceCentre,
775 const tarch::la::Vector<Dimensions,double>& gridCellH
776 ) -> void {
777 for (int i=0; i<"""+str(my_solver._unknowns+my_solver._auxiliary_variables)+"""; i++) {
778 Q[i] = 0.0;
779 }
780 Q[0] = 1.0; Q[3] = 1.0; Q[5] = 1.0;
781 //const double r=tarch::la::norm2(faceCentre);
782 //Q[16] = 0.5*(1+(1-1.0/2/r)/(1+1.0/2/r));
783 //Q[54] = 1/(1+1.0/2/r)/(1+1.0/2/r);
784 Q[16] = 1.0; Q[54] = 1.0;
785 },
786 marker.x(),
787 marker.h(),
788 {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(marker.getSelectedFaceNumber()<Dimensions ? 1 : 0),
789 repositories::{{SOLVER_INSTANCE}}.getMinTimeStepSize(),
790 {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}},
791 {{OVERLAP}},
792 {{NUMBER_OF_UNKNOWNS}},
793 {{NUMBER_OF_AUXILIARY_VARIABLES}},
794 marker.getSelectedFaceNumber(),
795 {0.0, 0.0, 0.0},
796 fineGridFace{{UNKNOWN_IDENTIFIER}}Old.value,
797 fineGridFace{{UNKNOWN_IDENTIFIER}}New.value
798 );
799 """
800 else:
801 my_solver._action_set_handle_boundary.TemplateHandleBoundary_KernelCalls = """
802 ::exahype2::fd::applySommerfeldConditions(
803 [&](
804 const double * __restrict__ Q,
805 const tarch::la::Vector<Dimensions,double>& faceCentre,
806 const tarch::la::Vector<Dimensions,double>& gridCellH,
807 double t,
808 double dt,
809 int normal
810 ) -> double {
811 return repositories::{{SOLVER_INSTANCE}}.maxEigenvalue( Q, faceCentre, gridCellH, t, dt, normal );
812 },
813 [&](
814 double * __restrict__ Q,
815 const tarch::la::Vector<Dimensions,double>& faceCentre,
816 const tarch::la::Vector<Dimensions,double>& gridCellH
817 ) -> void {
818 for (int i=0; i<"""+str(my_solver._unknowns+my_solver._auxiliary_variables)+"""; i++) {
819 Q[i] = 0.0;
820 }
821 Q[0] = 1.0; Q[3] = 1.0; Q[5] = 1.0;
822 Q[16] = 1.0; Q[54] = 1.0;
823 },
824 marker.x(),
825 marker.h(),
826 {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(marker.getSelectedFaceNumber()<Dimensions ? 1 : 0),
827 repositories::{{SOLVER_INSTANCE}}.getMinTimeStepSize(),
828 {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}},
829 {{OVERLAP}},
830 {{NUMBER_OF_UNKNOWNS}},
831 {{NUMBER_OF_AUXILIARY_VARIABLES}},
832 marker.getSelectedFaceNumber(),
833 {0.0, 0.0, 0.0},
834 fineGridFace{{UNKNOWN_IDENTIFIER}}Old.value,
835 fineGridFace{{UNKNOWN_IDENTIFIER}}New.value
836 );
837 """
838
839
840
841 solverconstants=""
842
843 if args.scenario=="gauge":
844 solverconstants+= "static constexpr int Scenario=0; /* Gauge wave */ \n "
845 userinfo.append(("picking gauge wave scenario",None))
846 floatparams.update({"sk":0.0}); floatparams.update({"bs":0.0})
847 intparams.update({"LapseType":0})
848 elif args.scenario=="dia_gauge":
849 solverconstants+= "static constexpr int Scenario=3; /* Diagonal Gauge wave */ \n "
850 userinfo.append(("picking diagonal gauge wave scenario",None))
851 floatparams.update({"sk":0.0}); floatparams.update({"bs":0.0})
852 intparams.update({"LapseType":0})
853 elif args.scenario=="linear":
854 solverconstants+= "static constexpr int Scenario=1; /* Linear wave */ \n "
855 userinfo.append(("picking linear wave scenario",None))
856 floatparams.update({"sk":0.0}); floatparams.update({"bs":0.0})
857 intparams.update({"LapseType":0})
858 elif args.scenario=="flat":
859 solverconstants+= "static constexpr int Scenario=4; /* flat spacetime */ \n "
860 userinfo.append(("picking flat scenario",None))
861 elif (args.scenario=="two-punctures") or (args.scenario=="single-puncture"):
862 solverconstants+= "static constexpr int Scenario=2; /* Two-puncture */ \n"
863 userinfo.append(("picking black hole scenario",None))
864 else:
865 raise Exception( "Scenario " + args.scenario + " is now unknown")
866
867 for k, v in floatparams.items(): solverconstants+= "static constexpr double {} = {};\n".format("CCZ4{}".format(k), v)
868 for k, v in intparams.items(): solverconstants+= "static constexpr int {} = {};\n".format("CCZ4{}".format(k), v)
869 my_solver.add_solver_constants(solverconstants)
870
871 project.add_solver(my_solver)
872
873 build_mode = modes[args.mode]
874
875 dimensions = 3
876
877
880 floatparams.update({"domain_r":args.CCZ4domain_r})
881 dr=floatparams["domain_r"]
882 offset=[-dr, -dr, -dr]; domain_size=[2*dr, 2*dr, 2*dr]
883 msg = "domain set as "+str(offset)+" and "+str(domain_size)
884 print(msg)
885 userinfo.append((msg,None))
886
887 project.set_global_simulation_parameters(
888 dimensions, # dimensions
889 offset, domain_size,
890 args.end_time, # end time
891 args.plot_start_time, args.plot_step_size, # snapshots
892 periodic_boundary_conditions,
893 8 # plotter precision
894 )
895 userinfo.append(("plot start time: "+str(args.plot_start_time)+", plot step size: "+str(args.plot_step_size),None))
896 userinfo.append(("Terminal time: "+str(args.end_time),None))
897
898 project.set_Peano4_installation("../../..", build_mode)
899
900
903 path="./"
904 if not args.path=="./":
905 path=args.path
906 #path="/cosma5/data/durham/dc-zhan3/bbh-c5-1"
907 #path="/cosma6/data/dp004/dc-zhan3/exahype2/sbh-fv3"
908 project.set_output_path(path)
909 probe_point = [-12,-12,0.0]
910 project.add_plot_filter( probe_point,[24.0,24.0,0.01],1 )
911 if args.extension=="Psi4":
912 my_solver.select_dofs_to_print = [0,12,16,17,18,53,54,59,60]
913 elif args.extension=="adm" or args.extension=="phy-debug":
914 pass
915 else:
916 pass#my_solver.select_dofs_to_print = [0,12,16,17,18,53,54]
917
918
919 #project.set_load_balancing("toolbox::loadbalancing::strategies::RecursiveSubdivision","(new ::exahype2::LoadBalancingConfiguration(0.95,100,-1,32))" )
920 #project.set_load_balancing("toolbox::loadbalancing::strategies::RecursiveBipartition","(new ::exahype2::LoadBalancingConfiguration(0.9,1000,16))" )
921 #project.set_load_balancing("toolbox::loadbalancing::strategies::RecursiveBipartition","(new ::exahype2::LoadBalancingConfiguration(0.98))" )
922 #project.set_load_balancing("toolbox::loadbalancing::strategies::SpreadOut","(new ::exahype2::LoadBalancingConfiguration(0.95))" )
923 project.set_load_balancing("toolbox::loadbalancing::strategies::SpreadOutHierarchically","(new ::exahype2::LoadBalancingConfiguration(0.98))" )
924 #project.set_load_balancing("toolbox::loadbalancing::strategies::cascade::SpreadOut_RecursiveBipartition","(new ::exahype2::LoadBalancingConfiguration(0.98))" )
925
926
927
930 if args.add_tracer==1:
931 tracer_particles = project.add_tracer( name="Tracer",attribute_count=61 )
933 particle_set=tracer_particles, coordinates=[[0,0,8.0],[0,0,-8.0],[8.0,8.0,0],[-8.0,-8.0,0]])
934 # particle_set=tracer_particles, coordinates=[[-0.1,0,0],[0.1,0,0],[0,0.1,0],[0,-0.1,0]])
935 #init_action_set = exahype2.tracer.InsertParticlesFromFile(
936 # particle_set=tracer_particles, filename="t-design.dat", scale_factor=abs(offset[0])*0.8)
937 #"Gauss_Legendre_quadrature.dat" #"t-design.dat"
938 init_action_set.priority = 0
939 project.add_action_set_to_initialisation( init_action_set )
940
941
942 # Not required anymore, as will be done by tracer routine itself. See
943 # exahype2.Project.add_tracer()
944 # -------------------------------------------------------------------
945 #project.add_action_set_to_timestepping(
946 # peano4.toolbox.particles.UpdateParallelState(
947 # particle_set=tracer_particles
948 # )
949 #)
950
951 tracer_action_set=exahype2.tracer.FiniteVolumesTracing(tracer_particles,
952 my_solver,
953 project_on_tracer_properties_kernel="::exahype2::fv::projectAllValuesOntoParticle_piecewiseLinear",
954 )
955 tracer_action_set.priority = my_solver._action_set_update_cell.priority+1
956 project.add_action_set_to_timestepping(tracer_action_set)
957 project.add_action_set_to_initialisation(tracer_action_set)
958
960 particle_set=tracer_particles,
961 solver=my_solver,
962 filename=args.path+"Tracer-test",
963 number_of_entries_between_two_db_flushes=1000,
964 output_precision=8,
965 data_delta_between_two_snapsots=1e16,
966 position_delta_between_two_snapsots=1e16,
967 time_delta_between_two_snapsots=0.02
968 )
969 dump_action_set.priority = my_solver._action_set_update_cell.priority+2
970 project.add_action_set_to_timestepping(dump_action_set)
971
972 if args.add_tracer==2:
973 tracer_particles = project.add_tracer( name="Tracer",attribute_count=59 )
975 particle_set=tracer_particles, coordinates=[[2.0,0,0],[-2.0,0,0]])
976 init_action_set.priority = 0
977 project.add_action_set_to_initialisation( init_action_set )
978
979 # Not required anymore, as will be done by tracer routine itself. See
980 # exahype2.Project.add_tracer()
981 # -------------------------------------------------------------------
982 #project.add_action_set_to_timestepping(
983 # peano4.toolbox.particles.UpdateParallelState(
984 # particle_set=tracer_particles
985 # )
986 #)
987
988 tracer_action_set=exahype2.tracer.FiniteVolumesTracing(tracer_particles,
989 my_solver,
990 project_on_tracer_properties_kernel="::exahype2::fv::projectAllValuesOntoParticle_piecewiseLinear_explicit_Euler",
991 projection_kernel_arguments="""
992 marker,
993 {{PATCH_SIZE}},
994 {{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}},
995 fineGridCell{{SOLVER_NAME}}Q.value,
996 fineGridCell{{SOLVER_NAME}}CellLabel.getTimeStepSize(),
997 {17,18,19},
998 {-1,-1,-1},
999 *p
1000 """
1001 )
1002 tracer_action_set.priority = my_solver._action_set_compute_final_linear_combination.priority+1
1003 project.add_action_set_to_timestepping(tracer_action_set)
1004 project.add_action_set_to_initialisation(tracer_action_set)
1005
1007 particle_set=tracer_particles,
1008 solver=my_solver,
1009 filename=args.path+"Tracer-test",
1010 number_of_entries_between_two_db_flushes=500,
1011 output_precision=8,
1012 data_delta_between_two_snapsots=1e16,
1013 position_delta_between_two_snapsots=1e16,
1014 time_delta_between_two_snapsots=0.02
1015 )
1016 dump_action_set.priority = my_solver._action_set_compute_final_linear_combination.priority+2
1017 project.add_action_set_to_timestepping(dump_action_set)
1018
1019
1022 peano4_project = project.generate_Peano4_project(verbose=True)
1023
1024 if args.scenario=="gauge" or args.scenario=="linear" or args.scenario=="dia_gauge" or args.scenario=="flat":
1025 pass
1026 elif args.scenario=="two-punctures" or args.scenario=="single-puncture":
1027 #
1028 # There are two different things to do when we pick a scneario: We have
1029 # to configure the solver accordingly (and keep in mind that every solver
1030 # needs its own config), and then we might have to adopt the build
1031 # environment.
1032 #
1033 peano4_project.output.makefile.add_linker_flag( "-lm -lgsl -lgslcblas" )
1034 peano4_project.output.makefile.add_cpp_file( "libtwopunctures/TP_Utilities.cpp" )
1035 peano4_project.output.makefile.add_cpp_file( "libtwopunctures/TP_Parameters.cpp" )
1036 peano4_project.output.makefile.add_cpp_file( "libtwopunctures/TP_Logging.cpp" )
1037 peano4_project.output.makefile.add_cpp_file( "libtwopunctures/TwoPunctures.cpp" )
1038 peano4_project.output.makefile.add_cpp_file( "libtwopunctures/CoordTransf.cpp" )
1039 peano4_project.output.makefile.add_cpp_file( "libtwopunctures/Equations.cpp" )
1040 peano4_project.output.makefile.add_cpp_file( "libtwopunctures/FuncAndJacobian.cpp" )
1041 peano4_project.output.makefile.add_cpp_file( "libtwopunctures/Newton.cpp" )
1042 peano4_project.output.makefile.add_CXX_flag( "-DIncludeTwoPunctures" )
1043 else:
1044 raise Exception( "Scenario " + args.scenario + " is now unknown")
1045
1046 peano4_project.output.makefile.add_CXX_flag( "-DCCZ4EINSTEIN" )
1047 peano4_project.output.makefile.add_cpp_file( "InitialValues.cpp" )
1048 peano4_project.output.makefile.add_cpp_file( "CCZ4Kernels.cpp" )
1049
1050 # NOTE these lines are required to build with the fortran routines --- this will also require to uncomment some
1051 # includes etc
1052 #
1053 # peano4_project.output.makefile.add_Fortran_flag( "-DCCZ4EINSTEIN -DDim3" )
1054 # peano4_project.output.makefile.add_Fortran_flag( "-lstdc++ -fdefault-real-8 -fdefault-double-8 -cpp -std=legacy -ffree-line-length-512 -fPIC" )
1055 # peano4_project.output.makefile.add_CXX_flag( "-fPIE -DCCZ4EINSTEIN" )
1056 # peano4_project.output.makefile.add_linker_flag( "-lstdc++ -fPIC -lgfortran" )
1057 # peano4_project.output.makefile.add_linker_flag( "-lstdc++ -fPIC -L/usr/lib/x86_64-linux-gnu -lgfortran" )
1058
1059 # This might work for Intel (not tested)
1060 #peano4_project.output.makefile.add_Fortran_flag( "-r8 -cpp -auto -qopenmp-simd -O2" )
1061 #peano4_project.output.makefile.add_linker_flag( "-lstdc++ -fPIC" )
1062 # you might need -lifcore
1063
1064 # peano4_project.output.makefile.add_Fortran_module( "MainVariables.f90" )
1065
1066 # peano4_project.output.makefile.add_Fortran_files(
1067 # ["PDE.f90 ", "EinsteinConstraints.f90 ", "Properties.f90","ADMConstraints.f90"]
1068 # )
1069
1070
1071 # peano4_project.constants.export_string( "Scenario", "gaugewave-c++" )
1072 # peano4_project.constants.add_target_begin()
1073 # for k, v in floatparams.items(): peano4_project.constants.export_constexpr_with_type("CCZ4{}".format(k), eval('args.CCZ4{}'.format(k)), "double")
1074 # peano4_project.constants.add_target_end()
1075 # peano4_project.constants.add_target_begin()
1076 # for k, v in intparams.items(): peano4_project.constants.export_constexpr_with_type("CCZ4{}".format(k), eval('args.CCZ4{}'.format(k)), "int")
1077 # peano4_project.constants.add_target_end()
1078 # project.export_const_with_type("NumberOfUnknowns", 59, "int")
1079 #peano4_project.constants.export_string( "Scenario", "linearwave-c++" )
1080
1081 peano4_project.generate( throw_away_data_after_generation=False )
1082
1083 peano4_project.build( make_clean_first = True )
1084
1085 #Report the application information
1086 userinfo.append(("the executable file name: "+exe, None))
1087 userinfo.append(("output directory: "+path, None))
1088 print("=========================================================")
1089 if not args.add_tracer==0:
1090 userinfo.append(("tracer output file: "+args.path+"Tracer-test", None))
1091 if len(userinfo) >0:
1092 print("The building information:")
1093 for msg, exception in userinfo:
1094 if exception is None:
1095 print(msg)
1096 else: print(msg, "Exception: {}".format(exception))
1097 print(intparams)
1098 print(floatparams)
1099 print("=========================================================")
postprocess_updated_patch
Definition ccz4.py:263
_source_term_implementation
Definition ccz4.py:195
__init__(self, name, patch_size, min_mesh_unit_h, max_mesh_unit_h, cfl, domain_r, KOSig)
Definition ccz4.py:88
_fused_compute_kernel_call_cpu
Definition ccz4.py:192
ExaHyPE 2 project.
Definition Project.py:14
The Gauss-Legendre Basis is by construction the only basis which yields diagonal mass matrices.
A very simple Poisson equation system solver to identify AMR transitions.
Definition AMRMarker.py:24
RKDG solver with Rusanov Riemann solver employing global adaptive time stepping.
Particle tracing over the Finite Volumes solver.
This class assumes that you have an 2MxNxN patch on your faces.
Definition DynamicAMR.py:9
add_adm_constriants(self)
@add adm constriants (Hamilton and Momentum)
Definition ccz4.py:320
CoordListFromFile(file, scale)
Definition ccz4.py:16
create_action_sets(self)
Definition ccz4.py:308
add_Psi4W(self)
add psi4 writer
Definition ccz4.py:371
add_intermediate_quantities(self)
@add adm intermediate quantites
Definition ccz4.py:424
add_puncture_tracker(self)
@add
Definition ccz4.py:480
get_user_action_set_includes(self)
We take this routine to add a few additional include statements.
Definition ccz4.py:314
create_compute_kernel_for_FD4(flux_implementation, ncp_implementation, source_implementation, compute_max_eigenvalue_of_next_time_step, solver_variant, kernel_variant, KOSigma)
I return only the unqualified function call, i.e.
Definition kernels.py:20