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",
"sedov3D"]
148 namespace=project_namespace, project_name=
"Sedov3D", executable=
"sedov3D"
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 = [1, 1, 1]
181periodic_boundary_conditions = [
True,
True,
True]
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 < 3.0 * dx:
223 raise ValueError(
"Too small hydro_H_max", 3.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})",
308initialisation_snippet = ICs.initialisation_snippet
311project.algorithm_step_initial_conditions.add_action_set(
313 particle_set=particle_set,
314 initialisation_call=initialisation_snippet,
315 distance_between_particles_along_one_axis=(
316 domain_size[0] / (args.particle_number)
319 additional_includes=
"""
320#include "exaparty/kernels/legacy/equation_of_state.h"
321#include "exaparty/kernels/legacy/kernel_hydro.h"
352 "globaldata::{}::getSpecies().getMinTimeStamp()".format(particle.name),
354particle_plotter.add_attribute_to_plot(particle.velocity, dimensions)
355particle_plotter.add_attribute_to_plot(particle.acceleration, dimensions)
356particle_plotter.add_attribute_to_plot(particle.mass, 1)
357particle_plotter.add_attribute_to_plot(particle.density, 1)
358particle_plotter.add_attribute_to_plot(particle.pressure, 1)
359particle_plotter.add_attribute_to_plot(particle.u, 1)
360particle_plotter.add_attribute_to_plot(particle.smoothL, 1)
361if args.asserts
or args.debug:
362 particle_plotter.add_attribute_to_plot(particle.partid, 1)
363 particle_plotter.add_attribute_to_plot(particle.density_neighbourcount, 1)
364 particle_plotter.add_attribute_to_plot(particle.force_neighbourcount, 1)
365project.algorithm_step_plot.add_action_set(particle_plotter)
380peano4_project = project.generate_Peano4_project(verbose=args.verbose)
383if GAMMA
not in gamma_hydro_list:
384 print(f
"Please check the value of GAMMA. You have chosen: {GAMMA}")
386print(
"-----------------------------------------------------------------------")
387print(
"SPH parameters summary:")
388print(f
"Effective dimensions of the Simulation: {HYDRO_DIMENSIONS}")
389print(f
"Global time-step size: {GLOBAL_TIME_STEP_SIZE}")
390print(f
"Number of particles (1D): {HYDRO_PART_NUMBER}")
391print(f
"Adiabatic index: {GAMMA}")
392print(f
"Smoothing length free factor: {particle.eta_factor}")
393print(
"-----------------------------------------------------------------------")
397peano4_project.constants.export_const_with_type(
398 "HYDRO_DIMENSIONS", str(HYDRO_DIMENSIONS),
"double"
400peano4_project.constants.export_const_with_type(
401 "HYDRO_PART_NUMBER", str(HYDRO_PART_NUMBER),
"double"
403peano4_project.constants.export_const_with_type(
404 "GLOBAL_TIME_STEP_SIZE", str(GLOBAL_TIME_STEP_SIZE),
"double"
406peano4_project.constants.export_const_with_type(
"GAMMA", GAMMA,
"double")
409peano4_project.output.makefile.add_CXX_flag(
410 "-D" +
"HYDRO_DIMENSION=" + str(HYDRO_DIMENSIONS)
412peano4_project.output.makefile.add_CXX_flag(
"-D" + GAMMA_HYDRO_SYMBOL)
413peano4_project.output.makefile.add_CXX_flag(
"-D" + KERNEL_SYMBOL)
421if args.clean_temporary_directories:
422 dirs = [
"vertexdata/",
"repositories/",
"globaldata/",
"observers/"]
428peano4_project.generate(
429 overwrite=peano4.api.output.Overwrite.Always, throw_away_data_after_generation=
True
431peano4_project.build(make_clean_first=
True, number_of_parallel_builds=args.j)
436 for f
in os.listdir(
".")
437 if f.endswith(
".peano-patch-file")
or f.endswith(
".vtu")
or f.endswith(
".pvd")
439for f
in output_files:
Initialisation snippet for the Sedov Blast problem in different spatial dimensions.
For constructor's time_stamp_evaluation argument.