27 parser = argparse.ArgumentParser(
28 description=
"ExaHyPE 2 - Elastic 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": {
"v": args.dimensions,
"sigma": args.dimensions + 1},
246 "auxiliary_variables": 0,
250 solver_params.update(
252 "pde_terms_without_state":
True,
256 if "Fixed" in args.solver:
257 solver_params.update(
259 "normalised_time_step_size": args.time_step_size,
262 elif "Adaptive" in args.solver:
263 solver_params.update(
265 "time_step_relaxation": args.time_step_relaxation,
269 max_h = (1.1 * min(args.width[0:args.dimensions]) / (3.0**args.min_depth))
270 min_h = max_h * 3.0 ** (-args.amr_levels)
272 if "FV" in args.solver:
273 solver_params.update(
275 "patch_size": args.patch_size,
276 "max_volume_h": max_h,
277 "min_volume_h": min_h,
280 implementation_params = {
281 "initial_conditions": exahype2.solvers.PDETerms.User_Defined_Implementation,
282 "boundary_conditions": exahype2.solvers.PDETerms.User_Defined_Implementation,
283 "refinement_criterion": exahype2.solvers.PDETerms.User_Defined_Implementation,
284 "flux":
"applications::exahype2::elastic::flux(Q, faceCentre, volumeH, t, dt, normal, F);",
285 "eigenvalues":
"applications::exahype2::elastic::maxEigenvalue(Q, faceCentre, volumeH, t, dt, normal, maxEigenvalue);",
286 "source_term":
"applications::exahype2::elastic::sourceTerm(Q, volumeCentre, volumeH, t, dt, S);",
288 elif "ADERDG" in args.solver:
289 solver_params.update(
291 "order": args.dg_order,
296 implementation_params = {
297 "initial_conditions": exahype2.solvers.PDETerms.User_Defined_Implementation,
298 "boundary_conditions": exahype2.solvers.PDETerms.User_Defined_Implementation,
299 "refinement_criterion": exahype2.solvers.PDETerms.User_Defined_Implementation,
300 "flux":
"applications::exahype2::elastic::flux(Q, x, h, t, dt, normal, F);",
302 double lambda[NumberOfUnknowns] = {0.};
303 applications::exahype2::elastic::maxEigenvalue(Q, x, h, t, dt, normal, lambda);
304 return *std::max_element(lambda, lambda+NumberOfUnknowns);""",
305 "source_term":
"applications::exahype2::elastic::sourceTerm(Q, x, 0.0, t, 0.0, S);",
309 solver.plot_description =
", ".join(solver_params[
"unknowns"].keys()) +
", "
310 if solver_params[
"auxiliary_variables"] != 0:
311 solver.plot_description +=
", ".join(solver_params[
"auxiliary_variables"].keys())
312 solver.set_implementation(**implementation_params)
313 solver.switch_storage_scheme(exahype2.solvers.Storage[args.storage], exahype2.solvers.Storage[args.storage])
315 if "ADERDG" in args.solver:
316 solver.add_kernel_optimisations(is_linear =
True,)
321 project = exahype2.Project(
322 namespace=[
"applications",
"exahype2",
"elastic"],
323 project_name=
"Elastic",
325 executable=f
"Elastic.{args.build_mode}",
328 project.add_solver(solver)
330 if args.number_of_snapshots <= 0:
331 time_in_between_plots = 0.0
333 time_in_between_plots = args.end_time / args.number_of_snapshots
334 project.set_output_path(args.output)
336 project.set_global_simulation_parameters(
337 dimensions=args.dimensions,
338 size=args.width[0:args.dimensions],
339 offset=args.offset[0:args.dimensions],
340 min_end_time=args.end_time,
341 max_end_time=args.end_time,
342 first_plot_time_stamp=0.0,
343 time_in_between_plots=time_in_between_plots,
345 args.periodic_boundary_conditions_x,
346 args.periodic_boundary_conditions_y,
347 args.periodic_boundary_conditions_z,
351 if args.load_balancing_strategy !=
"None":
352 strategy = f
"toolbox::loadbalancing::strategies::{args.load_balancing_strategy}"
353 assume_periodic_boundary_conditions = any([
354 args.periodic_boundary_conditions_x,
355 args.periodic_boundary_conditions_y,
356 args.periodic_boundary_conditions_z,
359 f
"new ::exahype2::LoadBalancingConfiguration("
360 f
"{args.load_balancing_quality},"
362 f
"{'true' if assume_periodic_boundary_conditions else 'false'},"
366 project.set_load_balancing(strategy, configuration)
368 project.set_number_of_threads(args.threads)
370 project.set_multicore_orchestration(
371 "tarch::multicore::orchestration::Hardcoded::createFuseAll(%s, 0)"
372 % str(args.fuse_tasks)
374 project.additional_includes.append(
"tarch/multicore/orchestration/Hardcoded.h")
376 project.set_timeout(args.timeout)
378 project.set_Peano4_installation(args.peano_dir, mode=peano4.api.output.string_to_mode(args.build_mode))
379 project = project.generate_Peano4_project(verbose=
True)
382 project.set_fenv_handler(
"FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW")