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