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=
"Spatial dimensions (default 2)",
48 dest=
"particle_number",
51 help=
"Particle number (1D)",
59 help=
"End of simulation",
67 help=
"Global timestep size (initial value)",
75 help=
"Cell size (default 0.3)",
82 help=
"Peano4 directory",
90 help=
"Switch on assertions",
97 default=
"quartic_spline",
98 choices=sphtools.sph_kernel_list,
99 help=
"SPH kernel function to use.",
101args = parser.parse_args()
108project_namespace = [
"benchmarks",
"exaparty",
"densityTest"]
110dimensions = args.dimensions
113 namespace=project_namespace, project_name=
"test_density", executable=
"test_density"
120HYDRO_PART_NUMBER = str(args.particle_number)
124 name=
"testDensityCalculation",
125 dimensions_hydro=HYDRO_DIMENSIONS,
127 initial_time_step_size=1e-4,
128 particles_per_cell=5,
129 min_h=args.cell_size,
130 max_h=args.cell_size,
144HYDRO_PART_NUMBER = args.particle_number
147GLOBAL_TIME_STEP_SIZE = args.timestep_size
148CFL_CONSTANT = particle._cfl_factor
151gamma_hydro_list = [str(5 / 3), str(7 / 5), str(4 / 3), str(2 / 1)]
152gamma_hydro_list_symbols = [
158GAMMA = gamma_hydro_list[0]
159GAMMA_HYDRO_SYMBOL = gamma_hydro_list_symbols[0]
164KERNEL_SYMBOL = sphtools.sph_kernel_macro_name[kernel]
165KERNEL_SUPPORT_RAD = sphtools.sph_kernel_H_over_h[HYDRO_DIMENSIONS - 1][kernel]
169hydro_h_max = args.cell_size / 2
170particle.h_hydro_max = hydro_h_max
184particle.set_parameters()
190particle_set = project.add_particle_species(particle)
193 build_mode = peano4.api.output.CompileMode.ASSERTS
195 build_mode = peano4.api.output.CompileMode.RELEASE
198domain_size = [1, 1, 1]
199periodic_boundary_conditions = [
False,
False,
False]
201project.set_global_simulation_parameters(
202 dimensions=dimensions,
204 domain_size=domain_size,
205 min_end_time=args.end_time,
207 first_plot_time_stamp=0,
208 time_in_between_plots=args.end_time,
209 periodic_BC=periodic_boundary_conditions,
213project.set_Peano4_installation(args.peanodir, build_mode)
215project.set_load_balancing(
216 "toolbox::loadbalancing::strategies::RecursiveBipartition",
217 "new toolbox::loadbalancing::DefaultConfiguration()",
234initialisation_snippet = ICs.initialisation_snippet
240Npart = args.particle_number
241coords = np.zeros((Npart**HYDRO_DIMENSIONS, 3))
243if HYDRO_DIMENSIONS == 1:
245 coords[:, 0] = np.linspace(0, 1, Npart, endpoint=
False)
247elif HYDRO_DIMENSIONS == 2:
248 x = np.linspace(offset, 1, Npart, endpoint=
False)
249 y = np.linspace(offset, 1, Npart, endpoint=
False)
251 xp, yp = np.meshgrid(x, y)
252 xp = xp.reshape((np.prod(xp.shape),))
253 yp = yp.reshape((np.prod(yp.shape),))
258elif HYDRO_DIMENSIONS == 3:
259 raise NotImplementedError
261print(
"inserting particles at:", coords)
263project.algorithm_step_initial_conditions.add_action_set(
265 particle_set=particle_set,
266 initialisation_call=initialisation_snippet,
307 "globaldata::{}::getSpecies().getMinTimeStamp()".format(particle.name),
309particle_plotter.add_attribute_to_plot(particle.velocity, dimensions)
310particle_plotter.add_attribute_to_plot(particle.acceleration, dimensions)
311particle_plotter.add_attribute_to_plot(particle.mass, 1)
312particle_plotter.add_attribute_to_plot(particle.density, 1)
313particle_plotter.add_attribute_to_plot(particle.pressure, 1)
314particle_plotter.add_attribute_to_plot(particle.smoothL, 1)
316 particle_plotter.add_attribute_to_plot(particle.partid, 1)
317project.algorithm_step_plot.add_action_set(particle_plotter)
330peano4_project = project.generate_Peano4_project(verbose=args.verbose)
333if GAMMA
not in gamma_hydro_list:
334 print(f
"Please check the value of GAMMA. You have chosen: {GAMMA}")
336print(
"-----------------------------------------------------------------------")
337print(
"SPH parameters summary:")
338print(f
"Effective dimensions of the Simulation: {HYDRO_DIMENSIONS}")
339print(f
"Global time-step size: {GLOBAL_TIME_STEP_SIZE}")
340print(f
"Number of particles (1D): {HYDRO_PART_NUMBER}")
341print(f
"Adiabatic index: {GAMMA}")
342print(f
"Smoothing length free factor: {particle.eta_factor}")
343print(
"-----------------------------------------------------------------------")
347peano4_project.constants.export_const_with_type(
348 "HYDRO_DIMENSIONS", str(HYDRO_DIMENSIONS),
"double"
350peano4_project.constants.export_const_with_type(
351 "HYDRO_PART_NUMBER", str(HYDRO_PART_NUMBER),
"double"
353peano4_project.constants.export_const_with_type(
354 "GLOBAL_TIME_STEP_SIZE", str(GLOBAL_TIME_STEP_SIZE),
"double"
356peano4_project.constants.export_const_with_type(
"GAMMA", GAMMA,
"double")
359peano4_project.output.makefile.add_CXX_flag(
360 "-D" +
"HYDRO_DIMENSION=" + str(HYDRO_DIMENSIONS)
362peano4_project.output.makefile.add_CXX_flag(
"-D" + GAMMA_HYDRO_SYMBOL)
363peano4_project.output.makefile.add_CXX_flag(
"-D" + KERNEL_SYMBOL)
371if args.clean_temporary_directories:
372 dirs = [
"vertexdata/",
"repositories/",
"globaldata/",
"observers/"]
378peano4_project.generate(
379 overwrite=peano4.api.output.Overwrite.Always, throw_away_data_after_generation=
True
381peano4_project.build(make_clean_first=
True, number_of_parallel_builds=args.j)
386 for f
in os.listdir(
".")
387 if f.endswith(
".peano-patch-file")
or f.endswith(
".vtu")
or f.endswith(
".pvd")
389for f
in output_files:
Test only the density calculation algorithmic step.
Initialisation snippet for testing the calculation of the SPH density.
For constructor's time_stamp_evaluation argument.
This file is part of the ExaParty project.