17parser = argparse.ArgumentParser(description=
"SPH test script")
24 help=
"Parallel builds",
37 dest=
"clean_temporary_directories",
39 help=
"Remove temporary directories before script starts",
44 dest=
"particle_number",
47 help=
"Particle number (1D)",
55 help=
"End of simulation",
63 help=
"Plot delta (0 switches off)",
71 help=
"Global timestep size (initial value)",
79 help=
"Value of the CFL constant",
87 help=
"Cell size (default 0.3)",
95 help=
"Cell size (default 0.3)",
101 default=
"../../../..",
102 help=
"Peano4 directory",
110 help=
"Switch on assertions",
118 help=
"Switch on full debug checks",
125 default=
"quartic_spline",
126 choices=sphtools.sph_kernel_list,
127 help=
"SPH kernel function to use.",
135 help=
"Number of trees (subdomains) (0 uses all threads)",
138args = parser.parse_args()
145project_namespace = [
"tests",
"exaparty",
"sod"]
148 namespace=project_namespace, project_name=
"Sod1D", executable=
"sod1D"
162 dimensions_hydro=hydro_dimensions,
163 cfl_factor=args.cfl_factor,
164 initial_time_step_size=args.timestep_size,
165 constant_time_step_size=
True,
166 exaparty_project_namespace=project_namespace,
167 min_h=args.cell_size_min,
168 max_h=args.cell_size_max,
180domain_size = [2, 2, 2]
181periodic_boundary_conditions = [
True,
False,
False]
184HYDRO_DIMENSIONS = hydro_dimensions
187HYDRO_PART_NUMBER = args.particle_number
190GLOBAL_TIME_STEP_SIZE = args.timestep_size
191CFL_CONSTANT = args.cfl_factor
194gamma_hydro_list = [str(5 / 3), str(7 / 5), str(4 / 3), str(2 / 1)]
195gamma_hydro_list_symbols = [
201GAMMA = gamma_hydro_list[0]
202GAMMA_HYDRO_SYMBOL = gamma_hydro_list_symbols[0]
207KERNEL_SYMBOL = sphtools.sph_kernel_macro_name[kernel]
208KERNEL_SUPPORT_RAD = sphtools.sph_kernel_H_over_h[HYDRO_DIMENSIONS - 1][kernel]
213cellsize = domain_size[0]
214while cellsize > args.cell_size_min:
218 raise ValueError(
"Suspicious depth")
220dx = domain_size[0] / args.particle_number
221hydro_H_max = 0.499 * cellsize
222if hydro_H_max < 5.0 * dx:
223 raise ValueError(
"Too small hydro_H_max", 5.0 * dx, hydro_H_max)
224hydro_h_max = exaparty.api.sphtools.sph_kernel_get_smoothing_length_from_interaction_radius(
225 hydro_H_max, kernel, hydro_dimensions
228particle.h_hydro_max = hydro_h_max
244particle.set_parameters()
250particle_set = project.add_particle_species(particle)
253 build_mode = peano4.api.output.CompileMode.DEBUG
255 build_mode = peano4.api.output.CompileMode.ASSERTS
257 build_mode = peano4.api.output.CompileMode.RELEASE
260project.set_global_simulation_parameters(
261 dimensions=dimensions,
263 domain_size=domain_size,
264 min_end_time=args.end_time,
266 first_plot_time_stamp=0.0,
267 time_in_between_plots=args.plot_delta,
268 periodic_BC=periodic_boundary_conditions,
273parallelisation =
"domain-decomposition"
279sorting =
"multiscale-sort"
281kernel_optimisation =
"no-optimisation"
282project.set_realisation(
283 parallelisation=parallelisation,
286 kernel_optimisation=kernel_optimisation,
289project.set_Peano4_installation(args.peanodir, build_mode)
291project.set_load_balancing(
292 "toolbox::loadbalancing::strategies::SpreadOutOnceGridStagnates",
293 f
"new toolbox::loadbalancing::DefaultConfiguration({args.trees})",
301project.algorithm_step_initial_conditions.add_action_set(
302 exaparty.api.input.InsertParticlesFromHDF5File(
303 particle_set=particle_set, filename=
"sodShock.hdf5"
333 "globaldata::{}::getSpecies().getMinTimeStamp()".format(particle.name),
336particle_plotter.add_attribute_to_plot(particle.velocity, dimensions)
337particle_plotter.add_attribute_to_plot(particle.acceleration, dimensions)
338particle_plotter.add_attribute_to_plot(particle.mass, 1)
339particle_plotter.add_attribute_to_plot(particle.density, 1)
340particle_plotter.add_attribute_to_plot(particle.pressure, 1)
341particle_plotter.add_attribute_to_plot(particle.u, 1)
342particle_plotter.add_attribute_to_plot(particle.smoothL, 1)
343if args.asserts
or args.debug:
344 particle_plotter.add_attribute_to_plot(particle.partid, 1)
345 particle_plotter.add_attribute_to_plot(particle.density_neighbourcount, 1)
346 particle_plotter.add_attribute_to_plot(particle.force_neighbourcount, 1)
347project.algorithm_step_plot.add_action_set(particle_plotter)
362peano4_project = project.generate_Peano4_project(verbose=args.verbose)
365if GAMMA
not in gamma_hydro_list:
366 print(f
"Please check the value of GAMMA. You have chosen: {GAMMA}")
368print(
"-----------------------------------------------------------------------")
369print(
"SPH parameters summary:")
370print(f
"Effective dimensions of the Simulation: {HYDRO_DIMENSIONS}")
371print(f
"Global time-step size: {GLOBAL_TIME_STEP_SIZE}")
372print(f
"Number of particles (1D): {HYDRO_PART_NUMBER}")
373print(f
"Adiabatic index: {GAMMA}")
374print(f
"Smoothing length free factor: {particle.eta_factor}")
375print(
"-----------------------------------------------------------------------")
379peano4_project.constants.export_const_with_type(
380 "HYDRO_DIMENSIONS", str(HYDRO_DIMENSIONS),
"double"
382peano4_project.constants.export_const_with_type(
383 "HYDRO_PART_NUMBER", str(HYDRO_PART_NUMBER),
"double"
385peano4_project.constants.export_const_with_type(
386 "GLOBAL_TIME_STEP_SIZE", str(GLOBAL_TIME_STEP_SIZE),
"double"
388peano4_project.constants.export_const_with_type(
"GAMMA", GAMMA,
"double")
391peano4_project.output.makefile.add_CXX_flag(
392 "-D" +
"HYDRO_DIMENSION=" + str(HYDRO_DIMENSIONS)
394peano4_project.output.makefile.add_CXX_flag(
"-D" + GAMMA_HYDRO_SYMBOL)
395peano4_project.output.makefile.add_CXX_flag(
"-D" + KERNEL_SYMBOL)
403if args.clean_temporary_directories:
404 dirs = [
"vertexdata/",
"repositories/",
"globaldata/",
"observers/"]
410peano4_project.generate(
411 overwrite=peano4.api.output.Overwrite.Always, throw_away_data_after_generation=
True
413peano4_project.build(make_clean_first=
True, number_of_parallel_builds=args.j)
418 for f
in os.listdir(
".")
419 if f.endswith(
".peano-patch-file")
or f.endswith(
".vtu")
or f.endswith(
".pvd")
421for f
in output_files:
For constructor's time_stamp_evaluation argument.