27 parser = argparse.ArgumentParser(
28 description=
"ExaHyPE 2 - Acoustic Application Script"
41 help=
"Number of space dimensions.",
48 help=
"Time step size for fixed time-stepping.",
52 "--time-step-relaxation",
55 help=
"Time step relaxation safety factor for adaptive time-stepping.",
62 help=
"Specify size of domain in meters as [x, y] as string (e.g. [10, 10], [7e6, 4e6]).",
69 help=
"Specify offset of domain in meters as [x, y] as string (e.g. [-10, -10], [-7e6, -4e6]).",
77 help=
"Use stateless PDE terms (GPU offloading requires a GPU enabled Peano build and an enclave solver).",
84 help=
"Output path for project solution output. The project will create a new folder at the given path. Default is 'solution'.",
89 "--periodic-boundary-conditions-x",
91 help=
"Use periodic boundary conditions in the x-axis.",
95 "--periodic-boundary-conditions-y",
97 help=
"Use periodic boundary conditions in the y-axis.",
101 "--periodic-boundary-conditions-z",
103 help=
"Use periodic boundary conditions in the z-axis.",
109 choices=peano4.api.output.CompileModes,
110 default=peano4.api.output.CompileModes[0],
111 help=
"|".join(peano4.api.output.CompileModes),
119 help=
"End time of the simulation.",
123 "--number-of-snapshots",
126 help=
"Number of snapshots (plots).",
133 help=
"Number of finite volumes per axis (dimension) per patch.",
139 help=
"Order of time discretisation for Runge-Kutta scheme.",
145 help=
"Order of space discretisation for Discontinuous Galerkin.",
153 help=
"Determines maximum size of a single cell on each axis.",
160 help=
"Number of AMR grid levels on top of max. size of a cell.",
166 choices=[e.name
for e
in exahype2.solvers.Storage],
168 help=
"The storage scheme to use."
171 available_load_balancing_strategies = [
174 "SpreadOutHierarchically",
175 "SpreadOutOnceGridStagnates",
176 "RecursiveBipartition",
177 "SplitOversizedTree",
178 "cascade::SpreadOut_RecursiveBipartition",
179 "cascade::SpreadOut_SplitOversizedTree",
183 "--load-balancing-strategy",
184 choices=available_load_balancing_strategies,
185 default=
"SpreadOutOnceGridStagnates",
186 help=
"|".join(available_load_balancing_strategies),
190 "--load-balancing-quality",
193 help=
"The quality of the load balancing.",
199 help=
"Number of trees (partitions) per rank after initial decomposition.",
205 help=
"Number of threads per rank.",
212 help=
"Number of enclave tasks to fuse into one meta task.",
219 help=
"MPI timeout in seconds.",
225 help=
"Enable a floating-point exception handler.",
231 help=
"Do not compile the code after generation.",
237 help=
"Peano directory",
245 "unknowns": {
"p": 1,
"u": 1,
"v": 1,
"w": 1}
246 if args.dimensions == 3
247 else {
"p": 1,
"u": 1,
"v": 1},
248 "auxiliary_variables": 0,
252 solver_params.update(
254 "pde_terms_without_state":
True,
258 if "Fixed" in args.solver:
259 solver_params.update(
261 "normalised_time_step_size": args.time_step_size,
264 elif "Adaptive" in args.solver:
265 solver_params.update(
267 "time_step_relaxation": args.time_step_relaxation,
271 max_h = (1.1 * min(args.width[0:args.dimensions]) / (3.0**args.min_depth))
272 min_h = max_h * 3.0 ** (-args.amr_levels)
274 if "FV" in args.solver:
275 solver_params.update(
277 "patch_size": args.patch_size,
278 "max_volume_h": max_h,
279 "min_volume_h": min_h,
282 implementation_params = {
283 "initial_conditions": exahype2.solvers.PDETerms.User_Defined_Implementation,
284 "boundary_conditions": exahype2.solvers.PDETerms.User_Defined_Implementation,
285 "refinement_criterion": exahype2.solvers.PDETerms.User_Defined_Implementation,
286 "flux":
"applications::exahype2::acoustic::flux(Q, faceCentre, volumeH, t, dt, normal, F);",
287 "eigenvalues":
"applications::exahype2::acoustic::maxEigenvalue(Q, faceCentre, volumeH, t, dt, normal, maxEigenvalue);",
288 "source_term":
"applications::exahype2::acoustic::sourceTerm(Q, volumeCentre, volumeH, t, dt, S);",
290 elif "ADERDG" in args.solver:
291 solver_params.update(
293 "order": args.dg_order,
298 implementation_params = {
299 "initial_conditions": exahype2.solvers.PDETerms.User_Defined_Implementation,
300 "boundary_conditions": exahype2.solvers.PDETerms.User_Defined_Implementation,
301 "refinement_criterion": exahype2.solvers.PDETerms.User_Defined_Implementation,
302 "flux":
"applications::exahype2::acoustic::flux(Q, x, h, t, dt, normal, F);",
304 double lambda[NumberOfUnknowns] = {0.};
305 applications::exahype2::acoustic::maxEigenvalue(Q, x, h, t, dt, normal, lambda);
306 return *std::max_element(lambda, lambda+NumberOfUnknowns);""",
307 "source_term":
"applications::exahype2::acoustic::sourceTerm(Q, x, 0.0, t, 0.0, S);",
311 solver.plot_description =
", ".join(solver_params[
"unknowns"].keys()) +
", "
312 if solver_params[
"auxiliary_variables"] != 0:
313 solver.plot_description +=
", ".join(solver_params[
"auxiliary_variables"].keys())
314 solver.set_implementation(**implementation_params)
315 solver.switch_storage_scheme(exahype2.solvers.Storage[args.storage], exahype2.solvers.Storage[args.storage])
317 if "ADERDG" in args.solver:
318 solver.add_kernel_optimisations(is_linear =
True,)
323 project = exahype2.Project(
324 namespace=[
"applications",
"exahype2",
"acoustic"],
325 project_name=
"Acoustic",
327 executable=f
"Acoustic.{args.build_mode}",
330 project.add_solver(solver)
332 if args.number_of_snapshots <= 0:
333 time_in_between_plots = 0.0
335 time_in_between_plots = args.end_time / args.number_of_snapshots
336 project.set_output_path(args.output)
338 project.set_global_simulation_parameters(
339 dimensions=args.dimensions,
340 size=args.width[0:args.dimensions],
341 offset=args.offset[0:args.dimensions],
342 min_end_time=args.end_time,
343 max_end_time=args.end_time,
344 first_plot_time_stamp=0.0,
345 time_in_between_plots=time_in_between_plots,
347 args.periodic_boundary_conditions_x,
348 args.periodic_boundary_conditions_y,
349 args.periodic_boundary_conditions_z,
353 if args.load_balancing_strategy !=
"None":
354 strategy = f
"toolbox::loadbalancing::strategies::{args.load_balancing_strategy}"
355 assume_periodic_boundary_conditions = any([
356 args.periodic_boundary_conditions_x,
357 args.periodic_boundary_conditions_y,
358 args.periodic_boundary_conditions_z,
361 f
"new ::exahype2::LoadBalancingConfiguration("
362 f
"{args.load_balancing_quality},"
364 f
"{'true' if assume_periodic_boundary_conditions else 'false'},"
368 project.set_load_balancing(strategy, configuration)
370 project.set_number_of_threads(args.threads)
372 project.set_multicore_orchestration(
373 "tarch::multicore::orchestration::Hardcoded::createFuseAll(%s, 0)"
374 % str(args.fuse_tasks)
376 project.additional_includes.append(
"tarch/multicore/orchestration/Hardcoded.h")
378 project.set_timeout(args.timeout)
380 project.set_Peano4_installation(args.peano_dir, mode=peano4.api.output.string_to_mode(args.build_mode))
381 project = project.generate_Peano4_project(verbose=
True)
384 project.set_fenv_handler(
"FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW")