15parser = argparse.ArgumentParser(description=
"Test periodic boundary conditions")
17 "-j",
"--parallel-builds", dest=
"j", type=int, default=-1, help=
"Parallel builds"
30 dest=
"clean_temporary_directories",
32 help=
"Remove temporary directories before script starts",
40 help=
"End of simulation",
48 help=
"Global timestep size",
56 help=
"Plot delta (0 switches off)",
64 help=
"Cell size (default 0.1)",
70 default=
"../../../../",
71 help=
"Peano4 directory",
79 help=
"Switch on assertions",
87 help=
"Switch on debug assertions",
89args = parser.parse_args()
102 namespace=[
"tests",
"exaparty",
"periodicBoundaryConditions1D"],
103 project_name=
"periodicBoundaryConditions1D",
104 executable=
"periodicBCTest1D",
109 name=
"GenericParticle",
111 initial_time_step_size=args.timestep_size,
112 particles_per_cell=0,
113 min_h=args.cell_size,
115 add_partid=(
not args.asserts),
117particle_set = project.add_particle_species(particle)
121 build_mode = peano4.api.output.CompileMode.DEBUG
123 build_mode = peano4.api.output.CompileMode.ASSERTS
125 build_mode = peano4.api.output.CompileMode.RELEASE
128domain_size = [1, 1, 1]
129periodic_boundary_conditions = [
True,
False,
False]
132project.set_global_simulation_parameters(
133 dimensions=dimensions,
135 domain_size=domain_size,
136 min_end_time=args.end_time,
138 first_plot_time_stamp=0.0,
139 time_in_between_plots=args.plot_delta,
140 periodic_BC=periodic_boundary_conditions,
144project.set_load_balancing(
145 "toolbox::loadbalancing::strategies::SpreadOutHierarchically",
146 "new toolbox::loadbalancing::DefaultConfiguration()",
149project.set_Peano4_installation(args.peanodir, build_mode)
173search_radius = args.cell_size / 100.0
174initialisation_snippet = (
176 /* Internal search radius used by Peano.
177 * Not really used here. */
178 particle->setSearchRadius("""
181 particle->setA( {0.} );
183 if( particle->getX(0) > 0.5 ){
184 particle->setV( {-1.} );
186 particle->setV( {1.} );
189 // hack to get a somewhat flexible, but always unique
190 // and reproducible particle ID: Assume we have a 1600^3
191 // uniform grid particle distribution. (1600^3 is close)
192 // to the numeric limits of integers.
194 double boxsize_x = """
195 + str(domain_size[0])
197 double offset_x = """
201 double dx = boxsize_x / 1600.;
203 int id = (int) ((particle->getX(0) - offset_x) / dx + 0.5);
204 particle->setPartid(id);
209coords = np.array([[0.21, 0.5, 0.0], [0.81, 0.5, 0.0]])
211project.algorithm_step_initial_conditions.add_action_set(
213 particle_set=particle_set,
214 initialisation_call=initialisation_snippet,
246 "globaldata::{}::getSpecies().getMinTimeStamp()".format(particle.name),
248particle_plotter.add_attribute_to_plot(particle.velocity, dimensions)
249particle_plotter.add_attribute_to_plot(particle.partid, 1)
250project.algorithm_step_plot.add_action_set(particle_plotter)
262peano4_project = project.generate_Peano4_project(verbose=args.verbose)
263peano4_project.output.makefile.add_CXX_flag(
"-D" +
"HYDRO_DIMENSION=1")
265peano4_project.constants.export_const_with_type(
266 "GLOBAL_TIME_STEP_SIZE", str(args.timestep_size),
"double"
270if args.clean_temporary_directories:
271 dirs = [
"vertexdata/",
"repositories/",
"globaldata/",
"observers/"]
275peano4_project.generate(
276 overwrite=peano4.api.output.Overwrite.Always, throw_away_data_after_generation=
True
278peano4_project.build(make_clean_first=
True, number_of_parallel_builds=args.j)
283 for f
in os.listdir(
".")
284 if f.endswith(
".peano-patch-file")
or f.endswith(
".vtu")
or f.endswith(
".pvd")
286for f
in output_files:
For constructor's time_stamp_evaluation argument.