Peano
Loading...
Searching...
No Matches
kernel_testbed.py
Go to the documentation of this file.
1import argparse
2import dastgen2
3
4import peano4
5import exahype2
6
7
8floatparams = {
9 "GLMc0":1.5, "GLMc":1.2, "GLMd":2.0, "GLMepsA":1.0, "GLMepsP":1.0,
10 "GLMepsD":1.0,
11 "itau":1.0, "k1":0.1, "k2":0.0, "k3":0.5, "eta":1.0,
12 "f":0.75, "g":0.0, "xi":1.0, "e":1.0, "c":1.0, "mu":0.2, "ds":1.0,
13 "sk":0.0, "bs":0.0,
14 "domain_r":0.5, "smoothing":0.0, "KOSigma":8.0
15}
16
17intparams = {"BBHType":2, "LapseType":0, "tp_grid_setup":0, "swi":99, "ReSwi":1, "SO":0}
18#sss
19if __name__ == "__main__":
20 parser = argparse.ArgumentParser(description='ExaHyPE 2 - CCZ4 script')
21 parser.add_argument("-maxh", "--max-h", dest="max_h", type=float, default=0.05, help="upper limit for refinement. Refers to volume size, i.e. not to patch size" )
22 parser.add_argument("-minh", "--min-h", dest="min_h", type=float, default=0.05, help="lower limit for refinement (set to 0 to make it equal to max_h - default). Refers to volume size, i.e. not to patch size" )
23 parser.add_argument("-ps", "--patch-size", dest="patch_size", type=int, default=9, help="Patch size, i.e. number of volumes per patch per direction" )
24
25 for k, v in floatparams.items(): parser.add_argument("--{}".format(k), dest="CCZ4{}".format(k), type=float, default=v, help="default: %(default)s")
26 for k, v in intparams.items(): parser.add_argument("--{}".format(k), dest="CCZ4{}".format(k), type=int, default=v, help="default: %(default)s")
27
28 args = parser.parse_args()
29
31 def __init__(self, name, patch_size, min_volume_h, max_volume_h, cfl, domain_r, KOSig):
32 unknowns = {
33 "G":6, #0-5
34 "K":6, #6-11
35 "theta":1, #12
36 "Z":3, #13-15
37 "lapse":1, #16
38 "shift":3, #17-19
39 "b":3, #20-22
40 "dLapse":3, #23-25
41 "dxShift":3,#26-28
42 "dyShift":3,#29-31
43 "dzShift":3,#32-34
44 "dxG":6, #35-40
45 "dyG":6, #41-46
46 "dzG":6, #47-52
47 "traceK":1, #53
48 "phi":1, #54
49 "P":3, #55-57
50 "K0":1, #58
51 }
52
53 number_of_unknowns = sum(unknowns.values())
54
56#include "../../../../applications/exahype2/ccz4/CCZ4Kernels.h"
57"""
58 super(CCZ4Solver,self).__init__(
59 name=name, patch_size=patch_size,
60 unknowns=number_of_unknowns,
61 auxiliary_variables=0,
62 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
63 time_step_relaxation=cfl,
64 pde_terms_without_state=True,
65 )
66
67 self._patch_size_patch_size = patch_size
68 self._domain_r = domain_r
69
71 boundary_conditions=exahype2.solvers.PDETerms.User_Defined_Implementation,
72 ncp=exahype2.solvers.PDETerms.User_Defined_Implementation,
73 flux=exahype2.solvers.PDETerms.None_Implementation,
74 source_term=exahype2.solvers.PDETerms.User_Defined_Implementation,
75 refinement_criterion = exahype2.solvers.PDETerms.User_Defined_Implementation,
76 eigenvalues = exahype2.solvers.PDETerms.User_Defined_Implementation
77 )
78
79
81{
82 #if Dimensions==2
83 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
84 #endif
85
86 #if Dimensions==3
87 constexpr int itmax = {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}} * {{NUMBER_OF_VOLUMES_PER_AXIS}};
88 #endif
89
90 int index = 0;
91 for (int i=0;i<itmax;i++)
92 {
93 applications::exahype2::ccz4::enforceCCZ4constraints( newQ+index );
94 index += {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}};
95 }
96 }
97"""
98
100 super(CCZ4Solver,self).create_action_sets()
102#include "../../../../applications/exahype2/ccz4/CCZ4Kernels.h"
103 """
104
106 """
107 We take this routine to add a few additional include statements.
108 """
109 return super(CCZ4Solver,self).get_user_action_set_includes() + self._my_user_includes
110
111
114 userinfo = []
115 project = exahype2.Project( ["benchmarks", "exahype2", "ccz4"], "ccz4", executable="peano4_test")
116
117 my_solver = CCZ4Solver("CCZ4", args.patch_size, args.min_h, args.max_h, 0.1, args.CCZ4domain_r,args.CCZ4KOSigma)
118 userinfo.append(("CFL ratio set as "+str(0.1), None))
119 userinfo.append(("The solver is Rusanov Finite Volume with EnclaveTasking", None))
120
121
122
125 for k, v in intparams.items():
126 intparams.update({k:eval("args.CCZ4{}".format(k))})
127 for k, v in floatparams.items():
128 floatparams.update({k:eval("args.CCZ4{}".format(k))})
129
130 solverconstants=""
131 userinfo.append(("picking gauge wave scenario",None))
132
133 for k, v in floatparams.items(): solverconstants+= "static constexpr double {} = {};\n".format("CCZ4{}".format(k), v)
134 for k, v in intparams.items(): solverconstants+= "static constexpr int {} = {};\n".format("CCZ4{}".format(k), v)
135 my_solver.add_solver_constants(solverconstants)
136
137 project.add_solver(my_solver)
138
139 dimensions = 3
140
141
144 project.set_global_simulation_parameters(
145 dimensions, # dimensions
146 [-0.5,-0.5,-0.5],[1,1,1],
147 0.1, # end time
148 0, 0, # snapshots
149 [True,True,True],
150 8 # plotter precision
151 )
152
153 project.set_Peano4_installation("../../../..", peano4.output.CompileMode.Release)
154
155 project.set_output_path("./")
156 project.set_load_balancing("toolbox::loadbalancing::strategies::SpreadOutHierarchically","(new ::exahype2::LoadBalancingConfiguration(0.95,1000,16))" )
157
158
161 peano4_project = project.generate_Peano4_project(verbose=True)
162 peano4_project.output.makefile.add_header_search_path("../../../../applications/exahype2/ccz4/")
163
164 peano4_project.output.makefile.add_CXX_flag( "-DCCZ4EINSTEIN" )
165
166 peano4_project.output.makefile.add_cpp_file( "../../../../applications/exahype2/ccz4/CCZ4Kernels.cpp" )
167
168 peano4_project.generate( throw_away_data_after_generation=False )
169 peano4_project.build( make_clean_first = True )
170
171 #Report the application information
172 userinfo.append(("the executable file name: peano4_test", None))
173 print("=========================================================")
174 print("The building information:")
175 for msg, exception in userinfo: print(msg)
176 print(intparams)
177 print(floatparams)
178 print("=========================================================")
ExaHyPE 2 project.
Definition Project.py:14
set_implementation(self, boundary_conditions, refinement_criterion, initial_conditions, memory_location, use_split_loop, additional_action_set_includes, additional_user_includes)
If you pass in User_Defined, then the generator will create C++ stubs that you have to befill manuall...
_action_set_couple_resolution_transitions_and_handle_dynamic_mesh_refinement
Definition FV.py:283
postprocess_updated_patch(self)
Definition FV.py:1587
postprocess_updated_patch(self, kernel)
Define a postprocessing routine over the data.
Definition FV.py:1592
set_implementation(self, flux=None, ncp=None, eigenvalues=None, boundary_conditions=None, refinement_criterion=None, initial_conditions=None, source_term=None, memory_location=None, use_split_loop=False, additional_action_set_includes="", additional_user_includes="")
If you pass in User_Defined, then the generator will create C++ stubs that you have to befill manuall...
get_user_action_set_includes(self)
We take this routine to add a few additional include statements.
create_action_sets(self)
Adaptive mesh handing.
__init__(self, name, patch_size, min_volume_h, max_volume_h, cfl, domain_r, KOSig)
Not so nice.