Peano
Loading...
Searching...
No Matches
SSInfall.py
Go to the documentation of this file.
1import os
2import sys
3import argparse
4import peano4
5import exahype2
6
8import dastgen2
9
10from Bindding import tracer_seeds_generate, read_scale_factor_table
11
13import numpy as np
14
15modes = {
16 "release": peano4.output.CompileMode.Release,
17 "trace": peano4.output.CompileMode.Trace,
18 "assert": peano4.output.CompileMode.Asserts,
19 "stats": peano4.output.CompileMode.Stats,
20 "debug": peano4.output.CompileMode.Debug,
21}
22
23floatparams = {
24 "G":1, "tilde_rho_ini":1, "r_ini":0.2, "delta_rho":0.05, "tilde_P_ini":1e-6, "gamma":5.0/3.0, "Omega_m":1, "delta_m":0.15, "r_point":0.05, "a_i":0.001, "v_scale":1.0, "domain_r":0.5, "DGP_beta":100, "DGP_zeta":100}
25
26intparams = {"swi":0, "ReSwi":0, "sample_number":10, "iseed":0, "ReSwi":0, "MassCal":0, "extrapolate_bc":0}
27
28if __name__ == "__main__":
29 parser = argparse.ArgumentParser(description='ExaHyPE 2 - SSInfall script')
30 parser.add_argument("-maxh", "--max-h", dest="max_h", type=float, required="True", help="upper limit for refinement. Refers to volume size, i.e. not to patch size" )
31 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 size, i.e. not to patch size" )
32 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" )
33 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)" )
34 parser.add_argument("-m", "--mode", dest="mode", default="release", help="|".join(modes.keys()) )
35 parser.add_argument("-ext", "--extension", dest="extension", choices=["cellcount","rhointer"], default="cellcount", help="Pick extension, i.e. the way to calculate the mass. Default is cell counting" )
36 parser.add_argument("-impl", "--implementation", dest="implementation", choices=["fv-global-fixed", "fv-global-adaptive", "fv-global-fixed-enclave", "fv-global-adaptive-enclave","fv-subcyling-adaptive-enclave","fv-local-enclave", "fv-musclhancock"], required="True", help="Pick solver type" )
37 parser.add_argument("-bc", "--boundary-condition", dest="boundary", choices=["periodic","neumann","extrapolate", "hybrid"], default="neumann", help="Pick the type of Boundary condtion" )
38 parser.add_argument("-et", "--end-time", dest="end_time", type=float, default=1.0, help="End (terminal) time" )
39 parser.add_argument("-tn", "--tracer-name", dest="tra_name", type=str, default="de", help="name of output tracer file (temporary)" )
40 parser.add_argument("-exn", "--exe-name", dest="exe_name", type=str, default="", help="name of output executable file" )
41 parser.add_argument("-outdir", "--output-directory", dest="path", type=str, default="./", help="specify the output directory, include the patch file and tracer file" )
42 parser.add_argument("-tracer", "--add-tracer", dest="add_tracer", type=int, default=0, help="Add tracers and specify the seeds. 0-switch off, 1-x axis, 2-xy plane, 3-over domain (evenly)" )
43 parser.add_argument("-iseed", "--initial-seed", dest="seed", type=str, default="tophat", help="specify the overdensity seeds. tophat/point" )
44 parser.add_argument("-eigen", "--eigenvalue-control", dest="eigen", choices=["none", "exp"], default="none", help="Modified the formula of eigenvalue to suppress initial time-stepping size" )
45 parser.add_argument("-cfl", "--CFL-ratio", dest="cfl", type=float, default=0.1, help="Set CFL ratio" )
46 parser.add_argument("-um", "--universe-model", dest="model", choices=["Ein-de", "LCDM","DGP","LCDMDGP" ], default="Ein-de", help="specify the background universe model" )
47 parser.add_argument("-interp", "--interpolation", dest="interpolation", choices=["constant", "linear-optimised", "outflow" ], default="linear-optimised", help="interpolation scheme for AMR" )
48 parser.add_argument("-restrict", "--restriction", dest="restriction", choices=["average", "inject"], default="average", help="restriction scheme for AMR" )
49 parser.add_argument("-gpu", "--with-gpu", dest="gpu", action="store_true", default=False, help="support offloading to GPU" )
50
51 for k, v in floatparams.items(): parser.add_argument("--{}".format(k), dest="{}".format(k), type=float, default=v, help="default: %(default)s")
52 for k, v in intparams.items():
53 if k=="ReSwi":
54 parser.add_argument("--{}".format(k), dest="{}".format(k), type=int, default=v, help="default: %(default)s, choose refinement criterion, 0-no refinement, 1-radius based, 2-SBH phi gradient based, 3-BBH phi gradient based. Notice: 2 and 3 only work with -ext Full")
55 else: parser.add_argument("--{}".format(k), dest="{}".format(k), type=int, default=v, help="default: %(default)s")
56
57 args = parser.parse_args()
58
59 SuperClass = None
60
61 if args.implementation=="fv-global-fixed":
63 if args.implementation=="fv-global-adaptive":
65 if args.implementation=="fv-global-fixed-enclave":
67 if args.implementation=="fv-global-adaptive-enclave":
69 if args.implementation=="fv-subcyling-adaptive-enclave":
71 if args.implementation=="fv-local-enclave":
73 if args.implementation=="fv-musclhancock":
75
76
77 class SSInfallSolver( SuperClass ):
78 def __init__(self, name, patch_size, min_volume_h, max_volume_h, cfl, domain_r):
79 unknowns = {
80 "rho":1,
81 "j":3,
82 "E":1,
83 }
84
85 number_of_unknowns = sum(unknowns.values())
86
87 print( "\n\n\n\I'm stateless: {}\n\n\n".format(args.gpu) )
89
90"""
92 SuperClass.__init__(
93 self,
94 name=name, patch_size=patch_size,
95 unknowns=number_of_unknowns,
96 auxiliary_variables=0,
97 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
98 time_step_size=1e-2
99 )
101 SuperClass.__init__(
102 self,
103 name=name, patch_size=patch_size,
104 unknowns=number_of_unknowns,
105 auxiliary_variables=0,
106 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
107 time_step_size=1e-2,
108 pde_terms_without_state=args.gpu
109 )
111 SuperClass.__init__(
112 self,
113 name=name, patch_size=patch_size,
114 unknowns=number_of_unknowns,
115 auxiliary_variables=0,
116 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
117 time_step_relaxation=cfl
118 )
119 else:
120 SuperClass.__init__(
121 self,
122 name=name, patch_size=patch_size,
123 unknowns=number_of_unknowns,
124 auxiliary_variables=0,
125 min_volume_h=min_volume_h, max_volume_h=max_volume_h,
126 time_step_relaxation=cfl,
127 #pde_terms_without_state=args.gpu
128 )
129
130 #self._solver_template_file_class_name = SuperClass.__name__
131
132 self.set_implementation(
133 boundary_conditions=exahype2.solvers.PDETerms.User_Defined_Implementation,
134 flux=exahype2.solvers.PDETerms.User_Defined_Implementation,
135 ncp=exahype2.solvers.PDETerms.None_Implementation,
136 source_term=exahype2.solvers.PDETerms.User_Defined_Implementation,
137 refinement_criterion = exahype2.solvers.PDETerms.User_Defined_Implementation
138 )
139
140 self._patch_size = patch_size
141 self._domain_r = domain_r
142
143
145 """
146 We take this routine to add a few additional include statements.
147 """
148 return SuperClass.get_user_action_set_includes(self) + self._my_user_includes
149
151 """
152
153 """
154 self._my_user_includes += """
155#include "../SSInfall.h"
156#include <math.h>
157 """
159
161 # @todo To be discussed with Han
162 self._action_set_postprocess_solution.guard = "repositories::{{SOLVER_INSTANCE}}.isLastGridSweepOfTimeStep() and repositories::{{SOLVER_INSTANCE}}.isOutsideOfLargestRadius(marker.x(),marker.h())"
163 self._action_set_postprocess_solution.add_postprocessing_kernel( """
164 double r_coor = (volumeX(0)-repositories::{{SOLVER_INSTANCE}}.OverDensityCentre(0))*(volumeX(0)-repositories::{{SOLVER_INSTANCE}}.OverDensityCentre(0))
165 + (volumeX(1)-repositories::{{SOLVER_INSTANCE}}.OverDensityCentre(1))*(volumeX(1)-repositories::{{SOLVER_INSTANCE}}.OverDensityCentre(1))
166 + (volumeX(2)-repositories::{{SOLVER_INSTANCE}}.OverDensityCentre(2))*(volumeX(2)-repositories::{{SOLVER_INSTANCE}}.OverDensityCentre(2));
167
168 r_coor=pow(r_coor,0.5);
169 repositories::{{SOLVER_INSTANCE}}.add_mass(r_coor,value[0],volumeH(0));
170""" )
171
173 const int patchSize = """ + str( self._patch.dim[0] ) + """;
174 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
175 int aux_var=""" + str( self._auxiliary_variables ) + """;
176 int real_var=5;
177 double domain_r=""" + str( self._domain_r ) + """;
178 int sample=repositories::{{SOLVER_INSTANCE}}.sample_number;
179 dfor(cell,patchSize) {
180 tarch::la::Vector<Dimensions,double> coor;
181 for (int i=0;i<Dimensions;i++) coor(i) = marker.getOffset()(i)+ (cell(i)+0.5)*volumeH;
182
183 tarch::la::Vector<Dimensions,int> currentCell = cell + tarch::la::Vector<Dimensions,int>(1);
184 const int cellSerialised = peano4::utils::dLinearised(currentCell, patchSize + 2*1);
185
186 double rho = oldQWithHalo[cellSerialised*(5+aux_var)+0];
187 double m1 = oldQWithHalo[cellSerialised*(5+aux_var)+1];
188 double m2 = oldQWithHalo[cellSerialised*(5+aux_var)+2];
189 double m3 = oldQWithHalo[cellSerialised*(5+aux_var)+3];
190 double e = oldQWithHalo[cellSerialised*(5+aux_var)+4];
191
192 double p = (5.0/3.0-1)*(e-0.5*(m1*m1+m2*m2+m3*m3)/rho);
193 if (p<0) {
194 oldQWithHalo[cellSerialised*(real_var+aux_var)+4]=0.5*(m1*m1+m2*m2+m3*m3)/rho+1e-14;
195 }
196
197 for (int d=0; d<3; d++) {
198 tarch::la::Vector<Dimensions,int> leftCell = currentCell;
199 tarch::la::Vector<Dimensions,int> rightCell = currentCell;
200 leftCell(d) -= 1;
201 rightCell(d) += 1;
202 const int leftCellSerialised = peano4::utils::dLinearised(leftCell, patchSize + 2*1);
203 const int rightCellSerialised = peano4::utils::dLinearised(rightCell,patchSize + 2*1);
204 for (int i=0; i<real_var; i++){
205 double rightgradient=oldQWithHalo[rightCellSerialised*(real_var+aux_var)+i] - oldQWithHalo[cellSerialised*(real_var+aux_var)+i];
206 double leftgradient=oldQWithHalo[cellSerialised*(real_var+aux_var)+i] - oldQWithHalo[leftCellSerialised*(real_var+aux_var)+i];
207 oldQWithHalo[cellSerialised*(real_var+aux_var)+real_var+d*real_var+i] = rightgradient < leftgradient ? rightgradient: leftgradient;
208 }
209 }
210 }
211 """
212 self.create_data_structures()
213 self.create_action_sets()
214
216 """
217
218 """
219 self._my_user_includes += """
220#include "../SSInfall.h"
221#include <math.h>
222 """
223 self._auxiliary_variables = 0
224
226 const int patchSize = """ + str( self._patch.dim[0] ) + """;
227 double volumeH = ::exahype2::fv::getVolumeLength(marker.h(),patchSize);
228 int aux_var=0;
229 int sample=repositories::{{SOLVER_INSTANCE}}.sample_number;
230 if ( marker.isContained((0,0,0)) ){
231 tarch::la::Vector<Dimensions,int> centerCell = tarch::la::Vector<Dimensions,int>(1+patchSize/2);
232 const int cellSerialised = peano4::utils::dLinearised(centerCell, patchSize + 2*1);
233 repositories::{{SOLVER_INSTANCE}}.rho_0=oldQWithHalo[cellSerialised*(5+aux_var)+0];
234 }
235 for (int i=0;i<sample;i++){
236 tarch::la::Vector<Dimensions,double> coor; coor(0)=repositories::{{SOLVER_INSTANCE}}.r_s[i];
237 if ( marker.isContained(coor) ){
238 for (int xindex=0; xindex<(patchSize+2);xindex++){
239 if ( (marker.getOffset()(0)+(xindex-1)*volumeH)<repositories::{{SOLVER_INSTANCE}}.r_s[i] and (marker.getOffset()(0)+(xindex-0.5)*volumeH)>repositories::{{SOLVER_INSTANCE}}.r_s[i] ){
240 tarch::la::Vector<Dimensions,int> cell1=tarch::la::Vector<Dimensions,int>(1+patchSize/2); cell1(0)=xindex;
241 tarch::la::Vector<Dimensions,int> cell2=tarch::la::Vector<Dimensions,int>(1+patchSize/2); cell2(0)=xindex-1;
242 double rho1=oldQWithHalo[peano4::utils::dLinearised(cell1, patchSize + 2*1)*(5+aux_var)+0], x1=marker.getOffset()(0)+(xindex-0.5)*volumeH;
243 double rho2=oldQWithHalo[peano4::utils::dLinearised(cell1, patchSize + 2*1)*(5+aux_var)+0], x2=marker.getOffset()(0)+(xindex-1.5)*volumeH;
244 repositories::{{SOLVER_INSTANCE}}.rho_x[i]=rho1*(x2-repositories::{{SOLVER_INSTANCE}}.r_s[i])/(x2-x1)+rho2*(repositories::{{SOLVER_INSTANCE}}.r_s[i]-x1)/(x2-x1);
245 }
246 else if ( (marker.getOffset()(0)+(xindex-0.5)*volumeH)<repositories::{{SOLVER_INSTANCE}}.r_s[i] and (marker.getOffset()(0)+(xindex)*volumeH)>repositories::{{SOLVER_INSTANCE}}.r_s[i] ){
247 tarch::la::Vector<Dimensions,int> cell1=tarch::la::Vector<Dimensions,int>(1+patchSize/2); cell1(0)=xindex;
248 tarch::la::Vector<Dimensions,int> cell2=tarch::la::Vector<Dimensions,int>(1+patchSize/2); cell2(0)=xindex+1;
249 double rho1=oldQWithHalo[peano4::utils::dLinearised(cell1, patchSize + 2*1)*(5+aux_var)+0], x1=marker.getOffset()(0)+(xindex-0.5)*volumeH;
250 double rho2=oldQWithHalo[peano4::utils::dLinearised(cell1, patchSize + 2*1)*(5+aux_var)+0], x2=marker.getOffset()(0)+(xindex+0.5)*volumeH;
251 repositories::{{SOLVER_INSTANCE}}.rho_x[i]=rho1*(x2-repositories::{{SOLVER_INSTANCE}}.r_s[i])/(x2-x1)+rho2*(repositories::{{SOLVER_INSTANCE}}.r_s[i]-x1)/(x2-x1);
252 }
253 }
254 }
255 }
256 """
257
258 self.create_data_structures()
259 self.create_action_sets()
260
261
264 userinfo = []
265 exe="peano4"
266
267 if args.exe_name!="":
268 exe += "_"
269 exe += args.exe_name
270 if not args.tra_name=="de":
271 exe += "_" + args.tra_name
272 project = exahype2.Project( ["applications", "exahype2", "euler", "sphericalaccretion"], "SSInfall", executable=exe)
273
274
277 is_aderdg = False
278 solver_name = "SSInfall"
279 #try:
280 # if SuperClass==exahype2.solvers.aderdg.NonFusedGenericRusanovFixedTimeStepSize:
281 # is_aderdg = True
282 # order = 3
283 # unknowns = 59
284 # time_step_size = 0.001
285 #except Exception as e:
286 # msg = "Warning: ADER-DG no supported on this machine"
287 # print(msg)
288 # userinfo.append((msg,e))
289
290 if is_aderdg:
291 solver_name = "ADERDG" + solver_name
292 else:
293 solver_name = solver_name
294
295 min_h = args.min_h
296 if min_h <=0.0:
297 print( "No minimal mesh size chosen. Set it to max mesh size (regular grid)" )
298 min_h = args.max_h
299
300 if is_aderdg:
301 my_solver = exahype2.solvers.aderdg.NonFusedGenericRusanovFixedTimeStepSize(
302 solver_name, order, unknowns, 0, #auxiliary_variables
303 exahype2.solvers.aderdg.Polynomials.Gauss_Legendre,
304 min_h, args.max_h, time_step_size,
305 flux = exahype2.solvers.PDETerms.User_Defined_Implementation,
306 ncp = exahype2.solvers.PDETerms.User_Defined_Implementation,
307 sources = exahype2.solvers.PDETerms.User_Defined_Implementation
308 )
309 else:
310 my_solver = SSInfallSolver(solver_name, args.patch_size, min_h, args.max_h,args.cfl,args.domain_r)
311 userinfo.append(("CFL ratio set as "+str(args.cfl), None))
312
313 if args.extension=="cellcount":
314 my_solver.add_mass_cal_cellcount()
315 userinfo.append(("mass calculation schme: cell counting",None))
316 elif args.extension=="rhointer":
317 my_solver.add_mass_cal_rhointer()
318 userinfo.append(("mass calculation schme: rho interpolation",None))
319
320#/ self.restriction_scheme( "averaging" )
321# self._action_set_couple_resolution_transitions_and_handle_dynamic_mesh_refinement.switch_interpolation_scheme( "linear" )
322
323 if args.interpolation=="constant":
324 my_solver.interpolation = "piecewise_constant"
325 print( "Interpolation rule: piecewise_constant" )
326 if args.interpolation=="linear-optimised":
327 my_solver.interpolation = "linear_with_linear_extrapolation_and_linear_normal_interpolation"
328 print( "Interpolation rule: linear extrapolation and linear normal interpolation" )
329 if args.interpolation=="outflow":
330 my_solver.interpolation = "outflow"
331 print( "Interpolation rule: outflow (from fine grid into coarse grid)" )
332
333 if args.restriction=="average":
334 my_solver.restriction = "averaging"
335 print( "Restiction rule: averaging" )
336 if args.restriction=="inject":
337 my_solver.restriction = "inject"
338 print( "Restiction rule: injection" )
339
340 #my_solver._auxiliary_variables = 23
341
342 #my_solver.add_derivative_calculation()
343
346 floatparams.update({"domain_r":args.domain_r})
347 #if args.ReSwi==0:
348 #offset=[-0.5, -0.5, -0.5]; domain_size=[1.0, 1.0, 1.0]
349 #offset=[-0.75, -0.75, -0.75]; domain_size=[1.5, 1.5, 1.5]
350 #offset=[-1.5, -1.5, -1.5]; domain_size=[3, 3, 3]
351 #elif args.ReSwi==2:
352 #offset=[-3, -3, -3]; domain_size=[6, 6, 6]
353 #offset=[-4.5, -4.5, -4.5]; domain_size=[9, 9, 9]
354 dr=floatparams["domain_r"]
355 offset=[-dr, -dr, -dr]; domain_size=[2*dr, 2*dr, 2*dr]
356 msg = "domain set as "+str(offset)+" and "+str(domain_size)
357 print(msg)
358 userinfo.append((msg,None))
359
360
363 for k, v in intparams.items():
364 intparams.update({k:eval("args.{}".format(k))})
365 for k, v in floatparams.items():
366 floatparams.update({k:eval("args.{}".format(k))})
367
368 if args.boundary=="periodic":
369 msg = "Periodic BC set"
370 print(msg)
371 periodic_boundary_conditions = [True,True,True] # Periodic BC
372 userinfo.append((msg,None))
373 elif args.boundary=="extrapolate":
374 msg = "Extrapolate BC set"
375 print(msg)
376 periodic_boundary_conditions = [False,False,False]
377 intparams.update({"extrapolate_bc":1})
378 userinfo.append((msg,None))
379 elif args.boundary=="hybrid":
380 msg = "hybrid BC set"
381 print(msg)
382 periodic_boundary_conditions = [False,False,False]
383 intparams.update({"extrapolate_bc":2})
384 userinfo.append((msg,None))
385 elif args.boundary=="neumann":
386 msg = "Neumann BC set"
387 print(msg)
388 periodic_boundary_conditions = [False,False,False]
389 userinfo.append((msg,None))
390
391 if args.seed=="tophat":
392 intparams.update({"iseed":0})
393 userinfo.append(("Tophat overdensity region set",None))
394 if args.seed=="point":
395 intparams.update({"iseed":1})
396 userinfo.append(("Point mass in tophat seed set",None))
397
398 if args.eigen=="exp":
399 #floatparams["C_1"]=(1*1e-4)/floatparams["tilde_P_ini"]*(floatparams["a_i"]/1e-3)**0.5
400 #floatparams["C_2"]=(10*1e-5)/floatparams["tilde_P_ini"]
401 floatparams["C_1"]=20
402 floatparams["C_2"]=50
403 userinfo.append(("Use exponential formula for eigenvalues",None))
404 if args.eigen=="none":
405 floatparams["C_1"]=0
406 floatparams["C_2"]=0
407 userinfo.append(("Use original formula for eigenvalues",None))
408
409 solverconstants=""
410 #if args.extension=="cellcount":
411 solverconstants+= "int global_cell_tot[{}]={};\n".format(args.sample_number,"{0}")
412 solverconstants+= "double global_m_tot[{}]={};\n".format(args.sample_number,"{0}")
413 solverconstants+= "int cell_tot[{}]={};\n".format(args.sample_number,"{0}")
414 solverconstants+= "double m_tot[{}]={};\n".format(args.sample_number,"{0}")
415 solverconstants+= "double m_tot_copy[{}]={};\n".format(args.sample_number,"{0}")
416 #elif args.extension=="rhointer":
417 solverconstants+= "double rho_0=0, rho_x[{}]={};\n".format(args.sample_number,"{0}")
418 solverconstants+= "double rho_x_copy[{}]={};\n".format(args.sample_number,"{0}")
419 if args.extension=="rhointer":
420 intparams.update({"MassCal":1})
421
422 r_list=np.linspace(0,(domain_size[0]+offset[0]),(args.sample_number+1))[1:]
423 solverconstants+= "double r_s[{}]={}".format(args.sample_number,"{")
424 for r in r_list:
425 solverconstants+= str(r)+", "
426 solverconstants=solverconstants[:-2]; solverconstants+= "};\n"
427
428 solverconstants+= "double interpolated_a=1.0;\n"
429
430 if args.model=="Ein-de":
431 userinfo.append(("Use Einstein-de Sitter univese background", None))
432 elif args.model=="LCDM" or args.model=="LCDMDGP":
433 scale_factor_table=read_scale_factor_table("a_LCDM_a_i=1e-3.dat")
434 point_number=len(scale_factor_table[0])
435 userinfo.append(("Use "+args.model+" univese, scale factor table with "+str(point_number)+" entries accepted", None))
436 solverconstants+= "double code_time_points[{}]={}".format(point_number,"{")
437 for time_point in scale_factor_table[0]:
438 solverconstants+= str(time_point)+", "
439 solverconstants=solverconstants[:-2]; solverconstants+= "};\n"
440 solverconstants+= "double scale_factor_points[{}]={}".format(point_number,"{")
441 for scale_factor in scale_factor_table[1]:
442 solverconstants+= str(scale_factor)+", "
443 solverconstants=solverconstants[:-2]; solverconstants+= "};\n"
444 solverconstants+= "double table_point_number="+str(point_number)+";\n"
445 floatparams.update({"Omega_m":0.3})
446 elif args.model=="DGP":
447 userinfo.append(("Use DGP modified Model+Einstein-de Sitter univese background", None))
448
449 for k, v in floatparams.items(): solverconstants+= "static constexpr double {} = {};\n".format("{}".format(k), v)
450 for k, v in intparams.items(): solverconstants+= "static constexpr int {} = {};\n".format("{}".format(k), v)
451
452 my_solver.set_solver_constants(solverconstants)
453
454 project.add_solver(my_solver)
455
456 build_mode = modes[args.mode]
457
458 dimensions = 3
459
460 project.set_global_simulation_parameters(
461 dimensions, # dimensions
462 offset, domain_size,
463 args.end_time, # end time
464 0.0, args.plot_step_size, # snapshots
465 periodic_boundary_conditions,
466 12 # plotter precision
467 )
468
469 project.set_Peano4_installation("../../../../", build_mode)
470
471
474 path="./"
475 if not args.path=="./":
476 path=args.path
477 #path="/cosma5/data/durham/dc-zhan3/SSInfall1"
478 #path="/cosma6/data/dp004/dc-zhan3/exahype2/sbh-fv3"
479 project.set_output_path(path)
480 probe_point = [-0,-0,-1e-6]
481 project.add_plot_filter( probe_point,[40.0,40.0,2e-6],1 )
482
483 project.set_load_balancing("toolbox::loadbalancing::strategies::RecursiveBipartition","(new ::exahype2::LoadBalancingConfiguration(0.9,0))" )
484
485
488 if not args.add_tracer==0:
489 tracer_name = {1:"line", 2:"slide", 3:"volume", 6:"Gauss_Legendre_quadrature", 7:"t-design"}
490 userinfo.append(("Tracer added, Type: "+tracer_name[args.add_tracer],None))
491 tracer_particles = project.add_tracer( name="MyTracer",attribute_count=5, plot=False)
492 #project.add_action_set_to_timestepping(exahype2.tracer.FiniteVolumesTracing(tracer_particles,my_solver,[17,18,19],[16],-1,time_stepping_kernel="toolbox::particles::explicitEulerWithoutInterpolation"))
493 project.add_action_set_to_timestepping(
495 tracer_particles,my_solver,
496 [17,18,19],range(5),-1,
497 #time_stepping_kernel="toolbox::particles::LinearInterp",
498 time_stepping_kernel="toolbox::particles::StaticPosition",
499 #observer_kernel="toolbox::particles::ObLinearInterp"
500 )
501 )
502 if args.add_tracer==1 or args.add_tracer==2 or args.add_tracer==3 :
503 tracer_seeds_generate(Type=args.add_tracer, a=0.0, b=(offset[0]+domain_size[0]), N_x=210,N_y=50,N_z=1)
504 project.add_action_set_to_initialisation( exahype2.tracer.InsertParticlesFromFile( particle_set=tracer_particles, filename=tracer_name[args.add_tracer]+".dat", scale_factor=1)) #"line.dat" #slide.dat #volume.dat
505
506 if path=="./": path1="."
507 else: path1=path
508 #path1="/cosma5/data/durham/dc-zhan3/tracer_test/"
509 project.add_action_set_to_timestepping(exahype2.tracer.DumpTrajectoryIntoDatabase(
510 particle_set=tracer_particles,
511 solver=my_solver,
512 filename=path1+"zz"+args.tra_name,
513 number_of_entries_between_two_db_flushes=2000,
514 output_precision=10,
515 position_delta_between_two_snapsots=1e16,
516 data_delta_between_two_snapsots=1e16,
517 time_delta_between_two_snapsots=0.02,
518 use_relative_deltas=False,
519 initial_record_time=55#args.end_time*2.0/3.0
520 #last_record_time=1e3
521 ))
522 #data_delta_between_two_snapsots,position_delta_between_two_snapsots,filename,
523 #,,-1,"zz",1000))
524
525
528 peano4_project = project.generate_Peano4_project(verbose=True)
529 if args.model=="LCDM":
530 peano4_project.output.makefile.add_CXX_flag( "-DuseTable" )
531 if args.model=="DGP":
532 peano4_project.output.makefile.add_CXX_flag( "-DDGP" )
533 if args.model=="LCDMDGP":
534 peano4_project.output.makefile.add_CXX_flag( "-DuseTable" )
535 peano4_project.output.makefile.add_CXX_flag( "-DDGP" )
536
537 #peano4_project.output.makefile.add_CXX_flag( "-DPeanoDebug=2" )
538
539 peano4_project.output.makefile.add_h_file("SSInfall.h")
540 peano4_project.output.makefile.add_cpp_file("SSInfall.cpp")
541
542 peano4_project.output.makefile.add_h_file("GravityModel.h")
543 peano4_project.output.makefile.add_cpp_file("GravityModel.cpp")
544
545 peano4_project.output.makefile.add_h_file("MassAccumulator.h")
546 peano4_project.output.makefile.add_cpp_file("MassAccumulator.cpp")
547
548 peano4_project.generate( throw_away_data_after_generation=False )
549 peano4_project.build( make_clean_first = True )
550
551 # Remind the user of warnings!
552 userinfo.append(("the executable file name: "+exe, None))
553 userinfo.append(("output directory: "+path, None))
554 print("=========================================================")
555 if not args.add_tracer==0:
556 userinfo.append(("tracer output file: "+path1+"zz"+args.tra_name, None))
557 if len(userinfo) >0:
558 print("The building infomation:")
559 for msg, exception in userinfo:
560 if exception is None:
561 print(msg)
562 else: print(msg, "Exception: {}".format(exception))
563 print(intparams)
564 print(floatparams)
565 print("=========================================================")
get_user_action_set_includes(self)
We take this routine to add a few additional include statements.
Definition SSInfall.py:144
__init__(self, name, patch_size, min_volume_h, max_volume_h, cfl, domain_r)
Definition SSInfall.py:78
ExaHyPE 2 project.
Definition Project.py:14
Particle tracing over the Finite Volumes solver.
This class assumes that you have an 2MxNxN patch on your faces.
Definition DynamicAMR.py:9