Peano
Loading...
Searching...
No Matches
ComputeMaxEigenvalue.py
Go to the documentation of this file.
1# This file is part of the ExaHyPE2 project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from ...AuxiliaryVariables import code_to_assemble_kernel_input
4import peano4.api
5
6from .AbstractRKFD4ActionSet import AbstractRKFD4ActionSet
7
8
10 """!
11
12 Store the maximum eigenvalue over all grid cells of a patch
13
14 The action set runs after the final linear combination of a Runge-Kutta
15 step, i.e. it sees the solution of the next time step in solver._patch.
16 It stores the maximum eigenvalue in the cell data solver._max_eigenvalue.
17 It does nothing else: the reduction over the cells is a task of its own
18 (@ref exahype2.api.rkfd4.actionsets.ReduceMaxEigenvalue), and
19 exahype2.api.rkfd4.actionsets.ComputeTimeStepSize derives the next time
20 step size from its outcome. Why: The eigenvalue per cell stays available
21 for others, and the cell update, the eigenvalue and the reduction are
22 independent steps of the task graph that the compiler can overlap.
23
24 """
25
26 def __init__(self, solver, guard):
27 """!
28
29 @param solver: exahype2.api.Solver
30 Has to have an exahype2.api.rkfd4.CentralDifferencesWithRungeKutta
31 with adaptive time stepping as numerical scheme, which has already
32 constructed its kernel calls.
33
34 @param guard: str
35 C++ boolean expression, evaluated per cell in touchCellFirstTime.
36
37 """
38 AbstractRKFD4ActionSet.__init__(self, solver)
39 self.guard = guard
40
41 def get_body_of_operation(self, operation_name):
42 if (
43 operation_name
44 != peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
45 ):
46 return ""
47 instance = self._solver.get_name_of_global_instance()
48 unknowns = f"fineGridCell{self._solver._patch.name}.value"
49 return f"""
50 {code_to_assemble_kernel_input(self._solver, "kernelIn", unknowns, 0, lambda auxiliary: f"fineGridCell{auxiliary.patch.name}.value")}
51 ::exahype2::CellData patchData(
52 {"kernelIn.data()" if self._solver.auxiliary_variables else unknowns},
53 marker.x(),
54 marker.h(),
55 repositories::{instance}.getMinTimeStamp(),
56 repositories::{instance}.getMinTimeStepSize(),
57 fineGridCell{self._solver._patch.name}.value
58 );
59 {self._solver.numerical_scheme.max_eigenvalue_kernel_call}
60 fineGridCell{self._solver._max_eigenvalue.name}.setMaxEigenvalue( 0, patchData.maxEigenvalue[0] );
61"""
62
63 def get_guard_of_operation(self, operation_name):
64 if (
65 operation_name
66 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
67 ):
68 return self.guard
69 return "true"
70
72 return __name__.replace(".py", "").replace(".", "_")
Base class of the action sets of exahype2.api.rkfd4 which work against the solver.
Store the maximum eigenvalue over all grid cells of a patch.
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...