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",
"sedov1D"]
148 namespace=project_namespace, project_name=
"Sedov1D", executable=
"sedov1D"
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,
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"
280sorting =
"bucket-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
310coords = np.ones((args.particle_number, 2)) * 0.5
311for i
in range(args.particle_number):
312 coords[i, 0] = (i + 0.5) / (args.particle_number + 1)
316project.algorithm_step_initial_conditions.add_action_set(
318 particle_set=particle_set,
320 initialisation_call=initialisation_snippet,
321 additional_includes=
"""
322#include "exaparty/kernels/legacy/equation_of_state.h"
323#include "exaparty/kernels/legacy/kernel_hydro.h"
354 "globaldata::{}::getSpecies().getMinTimeStamp()".format(particle.name),
357particle_plotter.add_attribute_to_plot(particle.velocity, dimensions)
358particle_plotter.add_attribute_to_plot(particle.acceleration, dimensions)
359particle_plotter.add_attribute_to_plot(particle.mass, 1)
360particle_plotter.add_attribute_to_plot(particle.density, 1)
361particle_plotter.add_attribute_to_plot(particle.pressure, 1)
362particle_plotter.add_attribute_to_plot(particle.u, 1)
363particle_plotter.add_attribute_to_plot(particle.smoothL, 1)
364if args.asserts
or args.debug:
365 particle_plotter.add_attribute_to_plot(particle.partid, 1)
366 particle_plotter.add_attribute_to_plot(particle.density_neighbourcount, 1)
367 particle_plotter.add_attribute_to_plot(particle.force_neighbourcount, 1)
368project.algorithm_step_plot.add_action_set(particle_plotter)
383peano4_project = project.generate_Peano4_project(verbose=args.verbose)
386if GAMMA
not in gamma_hydro_list:
387 print(f
"Please check the value of GAMMA. You have chosen: {GAMMA}")
389print(
"-----------------------------------------------------------------------")
390print(
"SPH parameters summary:")
391print(f
"Effective dimensions of the Simulation: {HYDRO_DIMENSIONS}")
392print(f
"Global time-step size: {GLOBAL_TIME_STEP_SIZE}")
393print(f
"Number of particles (1D): {HYDRO_PART_NUMBER}")
394print(f
"Adiabatic index: {GAMMA}")
395print(f
"Smoothing length free factor: {particle.eta_factor}")
396print(
"-----------------------------------------------------------------------")
400peano4_project.constants.export_const_with_type(
401 "HYDRO_DIMENSIONS", str(HYDRO_DIMENSIONS),
"double"
403peano4_project.constants.export_const_with_type(
404 "HYDRO_PART_NUMBER", str(HYDRO_PART_NUMBER),
"double"
406peano4_project.constants.export_const_with_type(
407 "GLOBAL_TIME_STEP_SIZE", str(GLOBAL_TIME_STEP_SIZE),
"double"
409peano4_project.constants.export_const_with_type(
"GAMMA", GAMMA,
"double")
412peano4_project.output.makefile.add_CXX_flag(
413 "-D" +
"HYDRO_DIMENSION=" + str(HYDRO_DIMENSIONS)
415peano4_project.output.makefile.add_CXX_flag(
"-D" + GAMMA_HYDRO_SYMBOL)
416peano4_project.output.makefile.add_CXX_flag(
"-D" + KERNEL_SYMBOL)
424if args.clean_temporary_directories:
425 dirs = [
"vertexdata/",
"repositories/",
"globaldata/",
"observers/"]
431peano4_project.generate(
432 overwrite=peano4.api.output.Overwrite.Always, throw_away_data_after_generation=
True
434peano4_project.build(make_clean_first=
True, number_of_parallel_builds=args.j)
439 for f
in os.listdir(
".")
440 if f.endswith(
".peano-patch-file")
or f.endswith(
".vtu")
or f.endswith(
".pvd")
442for f
in output_files:
Initialisation snippet for the Sedov Blast problem in different spatial dimensions.
For constructor's time_stamp_evaluation argument.