236 self, name, patch_size, min_volume_h, max_volume_h, cfl, domain_r, KOSig
259 number_of_unknowns = sum(unknowns.values())
262#include "../CCZ4Kernels.h"
264 if SuperClass == exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStep:
268 patch_size=patch_size,
270 unknowns=number_of_unknowns,
271 auxiliary_variables=0,
272 min_meshcell_h=min_volume_h,
273 max_meshcell_h=max_volume_h,
274 time_step_relaxation=cfl,
276 reconstruction_with_rk=args.SO_flag,
280 == exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepWithEnclaveTasking
285 patch_size=patch_size,
287 unknowns=number_of_unknowns,
288 auxiliary_variables=0,
289 min_meshcell_h=min_volume_h,
290 max_meshcell_h=max_volume_h,
291 time_step_relaxation=cfl,
293 pde_terms_without_state=
True,
295 elif SuperClass==exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepInExaGRyPE:
299 patch_size=patch_size,
301 unknowns=number_of_unknowns,
302 auxiliary_variables=0,
303 min_meshcell_h=min_volume_h,
304 max_meshcell_h=max_volume_h,
305 time_step_relaxation=cfl,
307 reconstruction_with_rk=args.SO_flag
313 self.set_implementation(
314 boundary_conditions=exahype2.solvers.PDETerms.User_Defined_Implementation,
315 ncp=exahype2.solvers.PDETerms.User_Defined_Implementation,
316 flux=exahype2.solvers.PDETerms.None_Implementation,
317 source_term=exahype2.solvers.PDETerms.User_Defined_Implementation,
318 refinement_criterion=exahype2.solvers.PDETerms.User_Defined_Implementation,
319 eigenvalues=exahype2.solvers.PDETerms.User_Defined_Implementation,
324 == exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepWithEnclaveTasking
330 compute_max_eigenvalue_of_next_time_step=
True,
331 solver_variant=exahype2.solvers.rkfd.kernels.SolverVariant.Stateless,
332 kernel_variant=exahype2.solvers.rkfd.kernels.KernelVariant.BatchedAoSHeap,
333 KOSigma=self._KO_Sigma,
339 compute_max_eigenvalue_of_next_time_step=
True,
340 solver_variant=exahype2.solvers.rkfd.kernels.SolverVariant.AcceleratorWithExplicitCopy,
341 kernel_variant=exahype2.solvers.rkfd.kernels.KernelVariant.BatchedAoSHeap,
342 KOSigma=self._KO_Sigma,
349 SuperClass == exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStep
350 or SuperClass == exahype2.solvers.rkfd.fd4.GlobalFixedTimeStep
352 == exahype2.solvers.rkfd.fd4.GlobalAdaptiveTimeStepWithEnclaveTasking
356 constexpr int itmax = {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}} * {{NUMBER_OF_GRID_CELLS_PER_PATCH_PER_AXIS}};
360 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}};
370 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
374 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
380 for (int i=0;i<itmax;i++)
382 applications::exahype2::ccz4::enforceCCZ4constraints( newQ+index );
383 index += {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}};
396 We take this routine to add a few additional include statements.
408 if args.exe_name !=
"":
411 project = exahype2.Project(
412 [
"benchmarks",
"exahype2",
"ccz4"],
"ccz4", executable=exe
421 print(
"No minimal mesh size chosen. Set it to max mesh size (regular grid)")
433 userinfo.append((
"CFL ratio set as " + str(args.cfl),
None))
435 userinfo.append((
"The solver is " + args.implementation,
None))
442 if args.interpolation ==
"constant":
443 my_solver.interpolation =
"piecewise_constant"
444 print(
"Interpolation rule: piecewise_constant")
445 if args.interpolation ==
"linear-constant-extrap":
446 my_solver.interpolation =
"linear_with_constant_extrapolation"
447 print(
"Interpolation rule: linear constant extrapolation")
448 if args.interpolation ==
"linear-linear-extrap":
449 my_solver.interpolation =
"linear_with_linear_extrapolation"
450 print(
"Interpolation rule: linear extrapolation")
451 if args.interpolation ==
"linear-con-extrap-lin-normal-interp":
452 my_solver.interpolation = (
453 "linear_with_constant_extrapolation_and_linear_normal_interpolation"
456 "Interpolation rule: linear+constant extrapolation and linear normal interpolation"
459 tem_interp = [
"TP_constant",
"TP_linear_with_linear_extrap_normal_interp"]
460 tem_restrict = [
"TP_inject_normal_extrap",
"TP_average_normal_extrap"]
461 if "fd4-rk" in args.implementation:
462 if args.interpolation ==
"matrix":
463 exahype2.solvers.rkfd.fd4.switch_to_FD4_matrix_interpolation(my_solver)
464 elif args.interpolation ==
"second_order":
465 exahype2.solvers.rkfd.fd4.switch_to_FD4_second_order_interpolation(
468 elif args.interpolation ==
"third_order":
469 exahype2.solvers.rkfd.fd4.switch_to_FD4_third_order_interpolation(my_solver)
471 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_interpolation(
472 my_solver, tem_interp[1]
474 userinfo.append((
"FD4 Interpolation: " + tem_interp[1],
None))
476 if args.restriction ==
"matrix":
477 exahype2.solvers.rkfd.fd4.switch_to_FD4_matrix_restriction(my_solver)
478 elif args.restriction ==
"second_order":
479 exahype2.solvers.rkfd.fd4.switch_to_FD4_second_order_restriction(my_solver)
481 exahype2.solvers.rkfd.fd4.switch_to_FD4_tensor_product_restriction(
482 my_solver, tem_restrict[1]
484 userinfo.append((
"FD4 Restriction: " + tem_restrict[1],
None))
489 for k, v
in intparams.items():
490 intparams.update({k: eval(
"args.CCZ4{}".format(k))})
491 for k, v
in floatparams.items():
492 floatparams.update({k: eval(
"args.CCZ4{}".format(k))})
494 if args.SO_flag ==
True:
495 intparams.update({
"SO": 1})
497 if args.scenario ==
"two-punctures":
498 msg =
"Periodic BC deactivated because you pick Puncture scenario\nInitialize binary black holes"
500 periodic_boundary_conditions = [
False,
False,
False]
505 userinfo.append((msg,
None))
506 elif args.scenario ==
"single-puncture":
507 msg =
"Periodic BC deactivated because you pick Puncture scenario\nInitialize single black hole"
509 periodic_boundary_conditions = [
False,
False,
False]
510 intparams.update({
"swi": 0})
511 userinfo.append((msg,
None))
512 elif args.periodic_bc ==
True:
513 msg =
"Periodic BC set"
515 periodic_boundary_conditions = [
True,
True,
True]
516 userinfo.append((msg,
None))
518 msg =
"WARNING: Periodic BC deactivated by hand"
520 periodic_boundary_conditions = [
False,
False,
False]
521 userinfo.append((msg,
None))
525 if (args.scenario ==
"two-punctures")
or (args.scenario ==
"single-puncture"):
526 solverconstants +=
"static constexpr int Scenario=2; /* Two-puncture */ \n"
527 userinfo.append((
"picking black hole scenario",
None))
529 raise Exception(
"Scenario " + args.scenario +
" is now unknown")
531 for k, v
in floatparams.items():
532 solverconstants +=
"static constexpr double {} = {};\n".format(
533 "CCZ4{}".format(k), v
535 for k, v
in intparams.items():
536 solverconstants +=
"static constexpr int {} = {};\n".format(
537 "CCZ4{}".format(k), v
539 my_solver.add_solver_constants(solverconstants)
541 project.add_solver(my_solver)
543 build_mode = modes[args.mode]
550 floatparams.update({
"domain_r": args.CCZ4domain_r})
551 dr = floatparams[
"domain_r"]
552 offset = [-dr, -dr, -dr]
553 domain_size = [2 * dr, 2 * dr, 2 * dr]
554 msg =
"domain set as " + str(offset) +
" and " + str(domain_size)
556 userinfo.append((msg,
None))
558 project.set_global_simulation_parameters(
563 args.plot_start_time,
565 periodic_boundary_conditions,
571 + str(args.plot_start_time)
572 +
", plot step size: "
573 + str(args.plot_step_size),
577 userinfo.append((
"Terminal time: " + str(args.end_time),
None))
579 project.set_build_mode(build_mode)
585 if not args.path ==
"./":
587 project.set_output_path(path)
589 project.set_load_balancer(
"new ::exahype2::LoadBalancingConfiguration")
594 peano4_project = project.generate_Peano4_project(verbose=
True)
595 peano4_project.output.makefile.add_header_search_path(
596 "../../../applications/ccz4/"
599 if args.scenario ==
"two-punctures" or args.scenario ==
"single-puncture":
600 peano4_project.output.makefile.add_linker_flag(
"-lm -lgsl -lgslcblas")
601 peano4_project.output.makefile.add_cpp_file(
602 "../../../applications/ccz4/libtwopunctures/TP_Utilities.cpp"
604 peano4_project.output.makefile.add_cpp_file(
605 "../../../applications/ccz4/libtwopunctures/TP_Parameters.cpp"
607 peano4_project.output.makefile.add_cpp_file(
608 "../../../applications/ccz4/libtwopunctures/TP_Logging.cpp"
610 peano4_project.output.makefile.add_cpp_file(
611 "../../../applications/ccz4/libtwopunctures/TwoPunctures.cpp"
613 peano4_project.output.makefile.add_cpp_file(
614 "../../../applications/ccz4/libtwopunctures/CoordTransf.cpp"
616 peano4_project.output.makefile.add_cpp_file(
617 "../../../applications/ccz4/libtwopunctures/Equations.cpp"
619 peano4_project.output.makefile.add_cpp_file(
620 "../../../applications/ccz4/libtwopunctures/FuncAndJacobian.cpp"
622 peano4_project.output.makefile.add_cpp_file(
623 "../../../applications/ccz4/libtwopunctures/Newton.cpp"
625 peano4_project.output.makefile.add_CXX_flag(
"-DIncludeTwoPunctures")
627 raise Exception(
"Scenario " + args.scenario +
" is now unknown")
629 peano4_project.output.makefile.add_CXX_flag(
"-DCCZ4EINSTEIN")
631 peano4_project.output.makefile.add_h_file(
"CCZ4.h")
632 peano4_project.output.makefile.add_cpp_file(
"CCZ4.cpp")
633 peano4_project.output.makefile.add_cpp_file(
634 "../../../applications/ccz4/InitialValues.cpp"
636 peano4_project.output.makefile.add_cpp_file(
637 "../../../applications/ccz4/CCZ4Kernels.cpp"
640 peano4_project.generate(throw_away_data_after_generation=
False)
641 peano4_project.build(make_clean_first=
True)
644 userinfo.append((
"the executable file name: " + exe,
None))
645 userinfo.append((
"output directory: " + path,
None))
646 print(
"=========================================================")
647 if len(userinfo) > 0:
648 print(
"The building information:")
649 for msg, exception
in userinfo:
650 if exception
is None:
653 print(msg,
"Exception: {}".format(exception))
656 print(
"=========================================================")