Peano
Loading...
Searching...
No Matches
ccz4.py
Go to the documentation of this file.
1import os
2import argparse
3import dastgen2
4import shutil
5import numpy as np
6
7import peano4.api
8import exahype2
10from toolbox.blockstructured.api.DynamicAMR import DynamicAMR
11
12
13from Probe_file_gene import tracer_seeds_generate
14from ComputeFirstDerivatives import ComputeFirstDerivativesFD4RK
15import CCZ4Helper
16
17
18
19modes = {
20 "release": peano4.api.output.CompileMode.RELEASE,
21 "trace": peano4.api.output.CompileMode.TRACE,
22 "assert": peano4.api.output.CompileMode.ASSERTS,
23 "stats": peano4.api.output.CompileMode.STATS,
24 "debug": peano4.api.output.CompileMode.DEBUG,
25}
26
27floatparams = {
28 "GLMc0":1.5, "GLMc":1.2, "GLMd":2.0, "GLMepsA":1.0, "GLMepsP":1.0,
29 "GLMepsD":1.0,
30 "itau":1.0, "k1":0.1, "k2":0.0, "k3":0.5, "eta":1.0,
31 "f":0.75, "g":0.0, "xi":1.0, "e":1.0, "c":1.0, "mu":0.2, "ds":1.0,
32 "sk":1.0, "bs":1.0,
33 "domain_r":0.5, "smoothing":0.0, "KOSigma":8.0 #, \
34}
35
36intparams = {"BBHType":2, "LapseType":1, "tp_grid_setup":0, "swi":99, "ReSwi":0, "SO":0}
37#
38if __name__ == "__main__":
39 parser = argparse.ArgumentParser(description='ExaHyPE 2 - CCZ4 script')
40 parser.add_argument("-maxh", "--max-h", dest="max_h", type=float, required="True", help="upper limit for refinement. Refers to volume/meshcell size, i.e. not to patch size" )
41 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/meshcell size, i.e. not to patch size" )
42 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" )
43 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)" )
44 parser.add_argument("-m", "--mode", dest="mode", default="release", help="|".join(modes.keys()) )
45 parser.add_argument( "--gpu", dest="GPU", default=False, action="store_true", help="Run with accelerator support" )
46 parser.add_argument( "--gpu-persistance", dest="gpu_persistance", default=False, action="store_true", help="Keep data on the GPU for longer where possible" )
47 parser.add_argument("-ext", "--extension", dest="extension", choices=["none", "adm", "Psi4"], default="none", help="Pick extension, i.e. what should be plotted on top of the evolving solution. Default is none" )
48 parser.add_argument("-impl", "--implementation", dest="implementation", choices=["fv-adaptive", "fd4-rk1-adaptive", "fd4-rk1-adaptive-enclave", "fd4-rk1-fixed", "fd4-rk4-adaptive", "fd4-rk2-adaptive", "RKDG", "fd4-rk1-dsl", "fd4-rk2-dsl", "fd4-rk4-dsl", "fd4-rk1-dsl-enclave", "fd4-rk2-dsl-enclave", "fd4-rk4-dsl-enclave"], required="True", help="Pick solver type" )
49 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" )
50 parser.add_argument("-sommerfeld", "--sommerfeld-boundary-conditions", dest="sommerfeld_bc", action="store_true", default=False, help="switch on or off the Sommerfeld radiative BC" )
51 parser.add_argument("-et", "--end-time", dest="end_time", type=float, default=1.0, help="End (terminal) time" )
52 parser.add_argument("-pst", "--plot-start-time", dest="plot_start_time", type=float, default=0.0, help="start time for plot" )
53 parser.add_argument("-s", "--scenario", dest="scenario", choices=["gauge", "dia_gauge", "linear", "single-puncture","two-punctures", "flat"], required="True", help="Scenario" )
54 parser.add_argument("-cfl", "--CFL-ratio", dest="cfl", type=float, default=0.1, help="Set CFL ratio" )
55 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" )
56 parser.add_argument("-tn", "--tracer-name", dest="tra_name", type=str, default="de", help="name of output tracer file (temporary)" )
57 parser.add_argument("-exn", "--exe-name", dest="exe_name", type=str, default="", help="name of output executable file" )
58 parser.add_argument("-outdir", "--output-directory", dest="path", type=str, default="./", help="specify the output directory, include the patch file and tracer file" )
59 parser.add_argument("-so", "--second-order", dest="SO_flag", default=False, action="store_true", help="enable double communication per timestep, used in the soccz4 formulation.")
60 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", "matrix", "second_order"], default="linear-lin-extrap-lin-normal-interp", help="interpolation scheme for AMR" )
61 parser.add_argument("-restrict", "--restriction", dest="restriction", choices=["average", "inject", "matrix", "second_order" ], default="average", help="restriction scheme for AMR" )
62 parser.add_argument("-restart", "--restart-timestamp", dest="restart_timestamp", default=0.0, type=float, help="specify the timestamp you would like to restart. The first checkpointed timestamp will be used to restart the simulation. Default is 0.0 (switch off)" )
63 parser.add_argument("-checkdir", "--checkpoint-directory", dest="checkpoint_path", type=str, default="./", help="specify where the code read the checkpoint files FROM, default is the same directory of output above." )
64 parser.add_argument("-clt", "--checkpoint-step-size", dest="checkpoint_step_size", type=float, default=0, help="checkpoint step size (0 to switch it off)" )
65
66
67 for k, v in floatparams.items(): parser.add_argument("--{}".format(k), dest="CCZ4{}".format(k), type=float, default=v, help="default: %(default)s")
68 for k, v in intparams.items():
69 if k=="ReSwi":
70 parser.add_argument("--{}".format(k), dest="CCZ4{}".format(k), type=int, default=v, help="default: %(default)s, choose refinement criterion.")
71 else: parser.add_argument("--{}".format(k), dest="CCZ4{}".format(k), type=int, default=v, help="default: %(default)s")
72
73 args = parser.parse_args()
74
75 SuperClass = None
76
77 if args.implementation=="fv-adaptive":
78 SuperClass = exahype2.solvers.fv.rusanov.GlobalAdaptiveTimeStep
79 if ("fd4-rk" in args.implementation) and not ("enclave" in args.implementation):
80 SuperClass = exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStep
81 if args.implementation=="fd4-rk1-dsl" or args.implementation=="fd4-rk4-dsl" or args.implementation=="fd4-rk2-dsl":
82 SuperClass = exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepInExaGRyPE
83 if args.implementation=="fd4-rk1-dsl-enclave" or args.implementation=="fd4-rk4-dsl-enclave" or args.implementation=="fd4-rk2-dsl-enclave":
84 SuperClass = exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepInExaGRyPEWithEnclaveTasking
85 if args.implementation=="fd4-rk1-adaptive-enclave":
86 SuperClass = exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepWithEnclaveTasking
87
88
90 def __init__(self, name, patch_size, min_mesh_unit_h, max_mesh_unit_h, cfl, domain_r, KOSig):
91 unknowns = {
92 "G":6, #0-5
93 "K":6, #6-11
94 "theta":1, #12
95 "Z":3, #13-15
96 "lapse":1, #16
97 "shift":3, #17-19
98 "b":3, #20-22
99 "dLapse":3, #23-25
100 "dxShift":3,#26-28
101 "dyShift":3,#29-31
102 "dzShift":3,#32-34
103 "dxG":6, #35-40
104 "dyG":6, #41-46
105 "dzG":6, #47-52
106 "traceK":1, #53
107 "phi":1, #54
108 "P":3, #55-57
109 "K0":1, #58
110 }
111
112 number_of_unknowns = sum(unknowns.values())
113
115#include "exagrype/ccz4/Kernels.h"
116"""
117 if SuperClass==exahype2.solvers.fv.rusanov.GlobalAdaptiveTimeStep:
118 SuperClass.__init__(
119 self,
120 name=name, patch_size=patch_size,
121 unknowns=number_of_unknowns,
122 auxiliary_variables=0,
123 min_volume_h=min_mesh_unit_h, max_volume_h=max_mesh_unit_h,
124 time_step_relaxation=cfl
125 )
126 elif SuperClass==exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepInExaGRyPE:
127 if args.implementation=="fd4-rk1-dsl":
128 rk_order = 1
129 elif args.implementation=="fd4-rk2-dsl":
130 rk_order = 2
131 else:
132 rk_order = 4
133 SuperClass.__init__(
134 self,
135 name=name, patch_size=patch_size, rk_order=rk_order,
136 unknowns=number_of_unknowns,
137 auxiliary_variables=0,
138 min_meshcell_h=min_mesh_unit_h, max_meshcell_h=max_mesh_unit_h,
139 time_step_relaxation=cfl,
140 KOSigma=KOSig,
141 reconstruction_with_rk=args.SO_flag
142 )
143 elif SuperClass==exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepInExaGRyPEWithEnclaveTasking:
144 if args.implementation=="fd4-rk1-dsl-enclave":
145 rk_order = 1
146 elif args.implementation=="fd4-rk2-dsl-enclave":
147 rk_order = 2
148 else:
149 rk_order = 4
150 SuperClass.__init__(
151 self,
152 name=name, patch_size=patch_size, rk_order=rk_order,
153 unknowns=number_of_unknowns,
154 auxiliary_variables=0,
155 min_meshcell_h=min_mesh_unit_h, max_meshcell_h=max_mesh_unit_h,
156 time_step_relaxation=cfl,
157 KOSigma=KOSig,
158 reconstruction_with_rk=args.SO_flag
159 )
160 elif SuperClass==exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStep:
161 rk_order = int(args.implementation[6])
162 SuperClass.__init__(
163 self,
164 name=name, patch_size=patch_size, rk_order=rk_order,
165 unknowns=number_of_unknowns,
166 auxiliary_variables=0,
167 min_meshcell_h=min_mesh_unit_h, max_meshcell_h=max_mesh_unit_h,
168 time_step_relaxation=cfl,
169 KOSigma=KOSig,
170 reconstruction_with_rk=args.SO_flag#,
171 #plot_grid_properties=True
172 )
173 elif SuperClass==exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepWithEnclaveTasking:
174 rk_order = int(args.implementation[6])
175 SuperClass.__init__(
176 self,
177 name=name, patch_size=patch_size, rk_order=rk_order,
178 unknowns=number_of_unknowns,
179 auxiliary_variables=0,
180 min_meshcell_h=min_mesh_unit_h, max_meshcell_h=max_mesh_unit_h,
181 time_step_relaxation=cfl,
182 KOSigma=KOSig,
183 pde_terms_without_state=True
184 )
185 else: # only rkdg left. i.e., SuperClass == exahype2.solvers.rkdg.rusanov.GlobalAdaptiveTimeStep:
186 SuperClass.__init__(
187 self,
188 name=name,
189 rk_order = 2,
190 polynomials = exahype2.solvers.GaussLegendreBasis(2),
191 face_projections = exahype2.solvers.rkdg.FaceProjections.Solution,
192 unknowns=number_of_unknowns,
193 auxiliary_variables=0,
194 min_cell_h=min_mesh_unit_h, max_cell_h=max_mesh_unit_h,
195 time_step_relaxation=cfl
196 )
197
198 self._patch_size = patch_size
199 self._domain_r = domain_r
200
201 self.set_implementation(
202 boundary_conditions=exahype2.solvers.PDETerms.User_Defined_Implementation,
203 ncp=exahype2.solvers.PDETerms.User_Defined_Implementation,
204 flux=exahype2.solvers.PDETerms.None_Implementation,
205 source_term=exahype2.solvers.PDETerms.User_Defined_Implementation,
206 refinement_criterion = exahype2.solvers.PDETerms.User_Defined_Implementation,
207 eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation,
208 reconstruction_with_rk = args.SO_flag
209 )
210
211 if SuperClass==exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepWithEnclaveTasking:
212 self._fused_compute_kernel_call_cpu = exahype2.solvers.rkfd.fd4.kernels.create_compute_kernel_for_FD4(
216 compute_max_eigenvalue_of_next_time_step = True,
217 solver_variant = exahype2.solvers.rkfd.kernels.SolverVariant.Multicore,
218 kernel_variant = exahype2.solvers.rkfd.kernels.KernelVariant.BatchedAoSHeap,
219 KOSigma = self._KO_Sigma
220 )
221
222 if SuperClass==exahype2.solvers.fv.rusanov.GlobalAdaptiveTimeStep:
223 self.postprocess_updated_patch += """{
224 #if Dimensions==2
225 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
226 #endif
227
228 #if Dimensions==3
229 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
230 #endif
231
232 int index = 0;
233 for (int i=0;i<itmax;i++)
234 {
235 exagrype::ccz4::enforceCCZ4constraints( newQ+index );
236 index += {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}};
237 }
238 }
239"""
240 else:
241 self.postprocess_updated_patch += CCZ4Helper.get_body_of_enforceCCZ4constraint()
242
244 SuperClass.create_action_sets(self)
245 self._action_set_couple_resolution_transitions_and_handle_dynamic_mesh_refinement.additional_includes += """
246#include "exagrype/ccz4/Kernels.h"
247 """
248
250 """!
251 We take this routine to add a few additional include statements.
252 """
253 return SuperClass.get_user_action_set_includes(self) + self._my_user_includes
254
256 """!
257 Add adm constriants (Hamilton and Momentum)
258 """
260
261 self._my_user_includes += """
262 #include "exagrype/ccz4/Kernels.h"
263 """
264
266 self._patch.dim[0], self._auxiliary_variables, args.SO_flag)
267
268 self.create_data_structures()
269 self.create_action_sets()
270
271 def add_Psi4W(self):
272 """
273 add psi4 writer
274 """
275 self._auxiliary_variables = 2
276
277 self._my_user_includes += """
278 #include "exagrype/twopunctures/TP_PunctureTracker.h"
279 #include "exagrype/ccz4/Kernels.h"
280 """
281
283 self._patch.dim[0], self._auxiliary_variables, args.SO_flag)
284
285 self.create_data_structures()
286 self.create_action_sets()
287
288
291 userinfo = []
292 exe="peano4"
293
294 if args.exe_name!="":
295 exe += "_"
296 exe += args.exe_name
297 if not args.tra_name=="de":
298 exe += "_" + args.tra_name
299 project = exahype2.Project( ["applications", "exahype2", "ccz4"], "ccz4", executable=exe)
300
301
304 is_aderdg = False
305 is_rkdg = False
306 solver_name = "CCZ4"
307
308 min_h = args.min_h
309 if min_h <=0.0:
310 print( "No minimal mesh size chosen. Set it to max mesh size (regular grid)" )
311 min_h = args.max_h
312
313 my_solver = CCZ4Solver(solver_name, args.patch_size, min_h, args.max_h, args.cfl, args.CCZ4domain_r,args.CCZ4KOSigma)
314 userinfo.append(("CFL ratio set as "+str(args.cfl), None))
315 userinfo.append(("The solver is "+args.implementation, None))
316
317
320
321 #Below are the I&R set functions for FD4
322 #These functions here do two things:
323 #1. it set the solver.interpolation parameters similar to what we do for fv, so the code know what template shoule be named.
324 #2. it computes and write the corresponding matrices for named schemes into the solver head files.
325 #notice point 2 is not needed as for build-in function (for fv) the matrices are already hard-coded.
326 interp_strategies=["TP_constant","TP_linear_with_linear_extrap_normal_interp"]
327 restrict_strategies=["TP_inject_normal_extrap","TP_average_normal_extrap"]
328 if ("fd4-rk" in args.implementation):
329 if args.interpolation == "matrix":
330 exahype2.solvers.rkfd.fd4.switch_to_FD4_matrix_interpolation( my_solver )
331 elif args.interpolation == "second_order":
332 exahype2.solvers.rkfd.fd4.switch_to_FD4_second_order_interpolation( my_solver )
333 else:
334 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_interpolation( my_solver, interp_strategies[1] )
335 userinfo.append(("FD4 Interpolation: " + interp_strategies[1], None))
336
337 if args.restriction == "matrix":
338 exahype2.solvers.rkfd.fd4.switch_to_FD4_matrix_restriction( my_solver )
339 elif args.interpolation == "second_order":
340 exahype2.solvers.rkfd.fd4.switch_to_FD4_second_order_restriction( my_solver )
341 else:
342 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_restriction( my_solver, restrict_strategies[1] )
343 userinfo.append(("FD4 Restriction: " + restrict_strategies[1], None))
344
345
348 if args.extension=="adm":
349 my_solver.add_adm_constriants()
350 if args.extension=="Psi4":
351 my_solver.add_Psi4W()
352
353
356 for k, v in intparams.items():
357 intparams.update({k:eval("args.CCZ4{}".format(k))})
358 for k, v in floatparams.items():
359 floatparams.update({k:eval("args.CCZ4{}".format(k))})
360
361 if args.SO_flag==True:
362 intparams.update({"SO":1})
363
364 if args.scenario=="two-punctures":
365 msg = "Periodic BC deactivated because you pick Puncture scenario\nInitialize binary black holes"
366 print(msg)
367 periodic_boundary_conditions = [False,False,False]
368 intparams.update({"swi":2}) #notice it may change, see according function in CCZ4.cpp
369 print(intparams)
370 userinfo.append((msg,None))
371 elif args.scenario=="single-puncture":
372 msg = "Periodic BC deactivated because you pick Puncture scenario\nInitialize single black hole"
373 print(msg)
374 periodic_boundary_conditions = [False,False,False]
375 intparams.update({"swi":0})
376 userinfo.append((msg,None))
377 elif args.periodic_bc==True:
378 msg = "Periodic BC set"
379 print(msg)
380 periodic_boundary_conditions = [True,True,True] # Periodic BC
381 userinfo.append((msg,None))
382 else:
383 msg = "WARNING: Periodic BC deactivated by hand"
384 print(msg)
385 periodic_boundary_conditions = [False,False,False]
386 userinfo.append((msg,None))
387
388 if args.sommerfeld_bc==True:
389 msg = "set Sommerfeld boundary condition"
390 userinfo.append((msg,None))
391 periodic_boundary_conditions = [False,False,False]
392 my_solver._action_set_handle_boundary.TemplateHandleBoundary_KernelCalls = CCZ4Helper.get_body_of_SommerfeldCondition(
393 args.scenario,
394 my_solver._unknowns,
395 my_solver._auxiliary_variables,
396 args.restart_timestamp)
397
398 solverconstants=""
399
400 if args.scenario=="gauge":
401 solverconstants+= "static constexpr int Scenario=0; /* Gauge wave */ \n "
402 userinfo.append(("picking gauge wave scenario",None))
403 floatparams.update({"sk":0.0}); floatparams.update({"bs":0.0})
404 intparams.update({"LapseType":0})
405 elif args.scenario=="dia_gauge":
406 solverconstants+= "static constexpr int Scenario=3; /* Diagonal Gauge wave */ \n "
407 userinfo.append(("picking diagonal gauge wave scenario",None))
408 floatparams.update({"sk":0.0}); floatparams.update({"bs":0.0})
409 intparams.update({"LapseType":0})
410 elif args.scenario=="linear":
411 solverconstants+= "static constexpr int Scenario=1; /* Linear wave */ \n "
412 userinfo.append(("picking linear wave scenario",None))
413 floatparams.update({"sk":0.0}); floatparams.update({"bs":0.0})
414 intparams.update({"LapseType":0})
415 elif args.scenario=="flat":
416 solverconstants+= "static constexpr int Scenario=4; /* flat spacetime */ \n "
417 userinfo.append(("picking flat scenario",None))
418 elif (args.scenario=="two-punctures") or (args.scenario=="single-puncture"):
419 solverconstants+= "static constexpr int Scenario=2; /* Two-puncture */ \n"
420 userinfo.append(("picking black hole scenario",None))
421 else:
422 raise Exception( "Scenario " + args.scenario + " is now unknown")
423
424 for k, v in floatparams.items(): solverconstants+= "static constexpr double {} = {};\n".format("CCZ4{}".format(k), v)
425 for k, v in intparams.items(): solverconstants+= "static constexpr int {} = {};\n".format("CCZ4{}".format(k), v)
426 my_solver.add_solver_constants(solverconstants)
427
428 project.add_solver(my_solver)
429
430 build_mode = modes[args.mode]
431
432 dimensions = 3
433
434
437 floatparams.update({"domain_r":args.CCZ4domain_r})
438 dr=floatparams["domain_r"]
439 offset=[-dr, -dr, -dr]; domain_size=[2*dr, 2*dr, 2*dr]
440 msg = "domain set as "+str(offset)+" and "+str(domain_size)
441 print(msg)
442 userinfo.append((msg,None))
443
444 project.set_global_simulation_parameters(
445 dimensions, # dimensions
446 offset, domain_size,
447 args.end_time, # end time
448 args.plot_start_time, args.plot_step_size, # snapshots
449 periodic_boundary_conditions,
450 8, # plotter precision
451 first_checkpoint_time_stamp=args.restart_timestamp + 0.0,
452 time_in_between_checkpoints=args.checkpoint_step_size
453 )
454
455 if not args.restart_timestamp==0.0:
456 if not args.checkpoint_path=="./":
457 cpath=args.checkpoint_path
458 elif not args.path=="./":
459 cpath=args.path
460 else:
461 cpath="./"
462 project.set_restart_from_checkpoint(expected_restart_timestamp=args.restart_timestamp, checkpoint_path=cpath)
463
464 userinfo.append(("plot start time: "+str(args.plot_start_time)+", plot step size: "+str(args.plot_step_size),None))
465 userinfo.append(("Terminal time: "+str(args.end_time),None))
466
467 project.set_Peano4_installation("../../..", build_mode)
468
469
472 path="./"
473 if not args.path=="./":
474 path=args.path
475 #path="/cosma5/data/durham/dc-zhan3/bbh-c5-1"
476 #path="/cosma6/data/dp004/dc-zhan3/exahype2/sbh-fv3"
477 project.set_output_path(path)
478 if not os.path.exists(path):
479 os.makedirs(path)
480
481 probe_point = [-100, -100, 0.0]
482 project.add_plot_filter( probe_point,[200.0, 200.0, 0.01], 1 )
483 #if args.extension=="Psi4":
484 # my_solver.select_dofs_to_print = [0,12,16,17,18,53,54,59,60]
485 #elif args.extension=="adm" or args.extension=="phy-debug":
486 # pass
487 #else:
488 # pass#my_solver.select_dofs_to_print = [0,12,16,17,18,53,54]
489
490 project.set_load_balancing("toolbox::loadbalancing::strategies::SpreadOutHierarchically","(new ::exahype2::LoadBalancingConfiguration(0.95))" )
491 #project.set_load_balancing("toolbox::loadbalancing::strategies::SpreadOutOnceGridStagnates","(new ::exahype2::LoadBalancingConfiguration(0.95))" )
492
493
496 if args.add_tracer==1:
497 tracer_particles = project.add_tracer( name="Tracer",attribute_count=59 )
498 init_action_set = exahype2.tracer.InsertParticlesByCoordinates(
499 # particle_set=tracer_particles, coordinates=[[0,0,8.0],[0,0,-8.0],[8.0,8.0,0],[-8.0,-8.0,0]])
500 particle_set=tracer_particles, coordinates=[[-0.1,0,0],[0.1,0,0],[0,0.1,0],[0,-0.1,0]])
501 #init_action_set = exahype2.tracer.InsertParticlesFromFile(
502 # particle_set=tracer_particles, filename="t-design.dat", scale_factor=abs(offset[0])*0.8)
503 #"Gauss_Legendre_quadrature.dat" #"t-design.dat"
504 init_action_set.descend_invocation_order = 0
505 project.add_action_set_to_initialisation( init_action_set )
506
507 tracer_action_set=exahype2.tracer.FiniteVolumesTracing(tracer_particles,
508 my_solver,
509 project_on_tracer_properties_kernel="::exahype2::fv::projectAllValuesOntoParticle_piecewiseLinear",
510 )
511 tracer_action_set.descend_invocation_order = my_solver._action_set_update_cell.descend_invocation_order+1
512 project.add_action_set_to_timestepping(tracer_action_set)
513 project.add_action_set_to_initialisation(tracer_action_set)
514
515 dump_action_set=exahype2.tracer.DumpTracerIntoDatabase(
516 particle_set=tracer_particles,
517 solver=my_solver,
518 filename=args.path+"Tracer-test",
519 number_of_entries_between_two_db_flushes=1000,
520 output_precision=8,
521 data_delta_between_two_snapsots=1e16,
522 position_delta_between_two_snapsots=1e16,
523 time_delta_between_two_snapsots=0.02,
524 clear_database_after_flush = True
525 )
526 dump_action_set.descend_invocation_order = my_solver._action_set_update_cell.descend_invocation_order+2
527 project.add_action_set_to_timestepping(dump_action_set)
528
529 if args.add_tracer==2:
530 if args.CCZ4BBHType == 2:
531 puncture_position = [[2.0,0,0],[-2.0,0,0]]
532 elif args.CCZ4BBHType == 3:
533 puncture_position = [[3.5,0,0],[-3.5,0,0]]
534 tracer_particles = project.add_tracer( name="Tracer",attribute_count=59 )
535 init_action_set = exahype2.tracer.InsertParticlesByCoordinates(
536 particle_set=tracer_particles, coordinates=puncture_position)
537 init_action_set.descend_invocation_order = 0
538 project.add_action_set_to_initialisation( init_action_set )
539
540 tracer_action_set=exahype2.tracer.FiniteVolumesTracing(tracer_particles,
541 my_solver,
542 project_on_tracer_properties_kernel="::exahype2::fv::projectAllValuesOntoParticle_piecewiseLinear_explicit_Euler",
543 projection_kernel_arguments="""marker,
544 {{PATCH_SIZE}},
545 {{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}},
546 fineGridCell{{SOLVER_NAME}}Q.value,
547 fineGridCell{{SOLVER_NAME}}CellLabel.getTimeStepSize(),
548 {17,18,19},
549 {-1,-1,-1},
550 *p
551 """
552 )
553 tracer_action_set.descend_invocation_order = my_solver._action_set_compute_final_linear_combination.descend_invocation_order+1
554 project.add_action_set_to_timestepping(tracer_action_set)
555 project.add_action_set_to_initialisation(tracer_action_set)
556
557 dump_action_set=exahype2.tracer.DumpTracerIntoDatabase(
558 particle_set=tracer_particles,
559 solver=my_solver,
560 filename=args.path+"Tracer-BHTracker",
561 number_of_entries_between_two_db_flushes=1000,
562 output_precision=8,
563 data_delta_between_two_snapsots=1e16,
564 position_delta_between_two_snapsots=1e16,
565 time_delta_between_two_snapsots=0.02,
566 clear_database_after_flush = True
567 )
568 dump_action_set.descend_invocation_order = my_solver._action_set_compute_final_linear_combination.descend_invocation_order+2
569 project.add_action_set_to_timestepping(dump_action_set)
570
571
574 peano4_project = project.generate_Peano4_project(verbose=True)
575
576 if args.scenario=="gauge" or args.scenario=="linear" or args.scenario=="dia_gauge" or args.scenario=="flat":
577 pass
578 elif args.scenario=="two-punctures" or args.scenario=="single-puncture":
579 #
580 # There are two different things to do when we pick a scneario: We have
581 # to configure the solver accordingly (and keep in mind that every solver
582 # needs its own config), and then we might have to adopt the build
583 # environment.
584 #
585 # TwoPunctures is part of the ExaGRyPE library (configure Peano with --with-gsl).
586 peano4_project.output.makefile.add_CXX_flag( "-DIncludeTwoPunctures" )
587 else:
588 raise Exception( "Scenario " + args.scenario + " is now unknown")
589
590 peano4_project.output.makefile.add_CXX_flag( "-DCCZ4EINSTEIN" )
591
592 peano4_project.generate( throw_away_data_after_generation=False )
593 peano4_project.build( make_clean_first = True )
594
595 #Report the application information
596 userinfo.append(("the executable file name: "+exe, None))
597 userinfo.append(("output directory: "+path, None))
598 print("=========================================================")
599 if not args.add_tracer==0:
600 userinfo.append(("tracer output file: "+args.path+"Tracer-test", None))
601 if not args.restart_timestamp==0.0:
602 userinfo.append(("the code will restart from the first checkpoint after timestamp "+str(args.restart_timestamp), None))
603 if len(userinfo) >0:
604 print("The building information:")
605 for msg, exception in userinfo:
606 if exception is None:
607 print(msg)
608 else: print(msg, "Exception: {}".format(exception))
609 print(intparams)
610 print(floatparams)
611 print("=========================================================")
get_user_action_set_includes(self)
We take this routine to add a few additional include statements.
Definition ccz4.py:249
_source_term_implementation
Definition ccz4.py:215
add_adm_constriants(self)
Add adm constriants (Hamilton and Momentum)
Definition ccz4.py:255
create_action_sets(self)
Definition ccz4.py:243
__init__(self, name, patch_size, min_mesh_unit_h, max_mesh_unit_h, cfl, domain_r, KOSig)
Definition ccz4.py:90
_preprocess_reconstructed_patch
Definition ccz4.py:265
add_Psi4W(self)
add psi4 writer
Definition ccz4.py:271
_fused_compute_kernel_call_cpu
Definition ccz4.py:212
get_body_of_adm_constraints(patch_size, number_of_output_variable, so_flag)
Definition CCZ4Helper.py:21
get_body_of_SommerfeldCondition(scenario, unknowns, auxiliary_variables, restart_time=-1)
get_body_of_enforceCCZ4constraint()
Definition CCZ4Helper.py:1
get_body_of_Psi_Calc(patch_size, number_of_output_variable, so_flag)
Definition CCZ4Helper.py:80
SuperClass
Definition ccz4.py:75
int
Definition ccz4.py:42
str
Definition ccz4.py:56