18parser = argparse.ArgumentParser(description=
"SPH benchmarking script")
20 "-j",
"--parallel-builds", dest=
"j", type=int, default=-1, help=
"Parallel builds"
33 dest=
"clean_temporary_directories",
35 help=
"Remove temporary directories before script starts",
43 help=
"Cell size (default 0.3)",
49 default=
"../../../..",
50 help=
"Peano4 directory",
58 help=
"Switch on assertions",
66 help=
"Switch on assertions",
72 default=
"test_sml_3D.hdf5",
73 help=
"Initial conditions hdf5 file",
81 help=
"Number of neighbours to search for",
89 help=
"Threshold for convergence of smoothing length",
96 default=
"quartic_spline",
97 help=
"SPH kernel function to use.",
98 choices=exaparty.api.sphtools.sph_kernel_list,
101args = parser.parse_args()
110project_namespace = [
"tests",
"exaparty",
"testSML3D"]
113 namespace=project_namespace, project_name=
"TestSML3D", executable=
"testSML"
120domain_size = [1, 1, 1]
121periodic_boundary_conditions = [
False,
False,
False]
135 dimensions_hydro=hydro_dimensions,
136 cfl_factor=cfl_factor,
137 initial_time_step_size=init_dt,
138 constant_time_step_size=
True,
139 exaparty_project_namespace=project_namespace,
140 particles_per_cell=20,
141 min_h=args.cell_size,
142 max_h=args.cell_size,
155HYDRO_DIMENSIONS = hydro_dimensions
158hfile = h5py.File(args.ic_filename,
"r")
159header = hfile[
"Header"]
160npart = header.attrs[
"NumPart_ThisFile"][0]
161npart_base = header.attrs[
"NumPart_base"][0]
163HYDRO_PART_NUMBER = npart
166GLOBAL_TIME_STEP_SIZE = init_dt
167CFL_CONSTANT = cfl_factor
170gamma_hydro_list = [str(5 / 3), str(7 / 5), str(4 / 3), str(2 / 1)]
171gamma_hydro_list_symbols = [
177GAMMA = gamma_hydro_list[0]
178GAMMA_HYDRO_SYMBOL = gamma_hydro_list_symbols[0]
181KERNEL_SYMBOL = exaparty.api.sphtools.sph_kernel_macro_name[kernel]
184dx = domain_size[0] / npart_base
186hydro_h_max = exaparty.api.sphtools.sph_kernel_get_smoothing_length_from_search_radius(
187 hydro_H_max, kernel, hydro_dimensions
189particle.h_hydro_max = hydro_h_max
194particle.eta_factor = exaparty.api.sphtools.eta_from_number_of_neighbours(
195 nneigh, kernel=kernel, ndim=hydro_dimensions
198particle.h_hydro_min = 1e-10
199particle.h_max_iterations = 50
200particle.h_tolerance = h_tol
209particle.set_parameters()
215particle_set = project.add_particle_species(particle)
218 build_mode = peano4.api.output.CompileMode.DEBUG
220 build_mode = peano4.api.output.CompileMode.ASSERTS
222 build_mode = peano4.api.output.CompileMode.RELEASE
225project.set_global_simulation_parameters(
226 dimensions=dimensions,
228 domain_size=domain_size,
229 min_end_time=init_dt,
230 max_end_time=init_dt,
231 first_plot_time_stamp=0.0,
232 time_in_between_plots=init_dt,
233 periodic_BC=periodic_boundary_conditions,
237project.set_Peano4_installation(args.peanodir, build_mode)
249project.algorithm_step_initial_conditions.add_action_set(
250 exaparty.api.input.InsertParticlesFromHDF5File(
251 particle_set=particle_set, filename=args.ic_filename
282 "globaldata::{}::getSpecies().getMinTimeStamp()".format(particle.name),
285particle_plotter.add_attribute_to_plot(particle.velocity, dimensions)
286particle_plotter.add_attribute_to_plot(particle.acceleration, dimensions)
287particle_plotter.add_attribute_to_plot(particle.mass, 1)
288particle_plotter.add_attribute_to_plot(particle.density, 1)
289particle_plotter.add_attribute_to_plot(particle.pressure, 1)
290particle_plotter.add_attribute_to_plot(particle.u, 1)
291particle_plotter.add_attribute_to_plot(particle.smoothL, 1)
292if args.asserts
or args.debug:
293 particle_plotter.add_attribute_to_plot(particle.partid, 1)
294project.algorithm_step_plot.add_action_set(particle_plotter)
309peano4_project = project.generate_Peano4_project(verbose=args.verbose)
312if GAMMA
not in gamma_hydro_list:
313 print(f
"Please check the value of GAMMA. You have chosen: {GAMMA}")
315print(
"-----------------------------------------------------------------------")
316print(
"SPH parameters summary:")
317print(f
"Effective dimensions of the Simulation: {HYDRO_DIMENSIONS}")
318print(f
"Global time-step size: {GLOBAL_TIME_STEP_SIZE}")
319print(f
"Number of particles (1D): {HYDRO_PART_NUMBER}")
320print(f
"Adiabatic index: {GAMMA}")
321print(f
"Smoothing length free factor: {particle.eta_factor}")
322print(
"-----------------------------------------------------------------------")
326peano4_project.constants.export_const_with_type(
327 "HYDRO_DIMENSIONS", str(HYDRO_DIMENSIONS),
"double"
329peano4_project.constants.export_const_with_type(
330 "HYDRO_PART_NUMBER", str(HYDRO_PART_NUMBER),
"double"
332peano4_project.constants.export_const_with_type(
333 "GLOBAL_TIME_STEP_SIZE", str(GLOBAL_TIME_STEP_SIZE),
"double"
335peano4_project.constants.export_const_with_type(
"GAMMA", GAMMA,
"double")
338peano4_project.output.makefile.add_CXX_flag(
339 "-D" +
"HYDRO_DIMENSION=" + str(HYDRO_DIMENSIONS)
341peano4_project.output.makefile.add_CXX_flag(
"-D" + GAMMA_HYDRO_SYMBOL)
342peano4_project.output.makefile.add_CXX_flag(
"-D" + KERNEL_SYMBOL)
350if args.clean_temporary_directories:
351 dirs = [
"vertexdata/",
"repositories/",
"globaldata/",
"observers/"]
357peano4_project.generate(
358 overwrite=peano4.api.output.Overwrite.Always, throw_away_data_after_generation=
True
360peano4_project.build(make_clean_first=
True, number_of_parallel_builds=args.j)
365 for f
in os.listdir(
".")
366 if f.endswith(
".peano-patch-file")
or f.endswith(
".vtu")
or f.endswith(
".pvd")
368for f
in output_files:
For constructor's time_stamp_evaluation argument.