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