Peano
Loading...
Searching...
No Matches
ReduceMaxEigenvalue.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 .AbstractFVActionSet import AbstractFVActionSet
4
5import peano4.api
6
7
9 """!
10
11 Reduce the maximum eigenvalues of the cells into the solver
12
13 exahype2.api.fv.actionsets.ComputeMaxEigenvalue stores the maximum
14 eigenvalue per cell. The action set visits each cell and hands the
15 first entry of this value to the solver's reduceMaxEigenvalue(), which
16 takes the maximum over all cells and threads of the rank (@ref
17 exahype2.api.fv.MaxEigenvalueReduction). It writes the global datum from
18 which exahype2.api.fv.actionsets.ComputeGlobalCFLCondition derives the
19 next time step size at the end of the time step. The action set does not
20 touch anything else.
21
22 """
23
24 def __init__(self, solver, guard, max_eigenvalue=None):
25 """!
26
27 @param solver: exahype2.api.Solver
28 Has to host the reduction (@ref exahype2.api.fv.MaxEigenvalueReduction).
29
30 @param guard: str
31 C++ boolean expression, evaluated per cell in touchCellFirstTime.
32 Has to match the guard of exahype2.api.fv.actionsets.ComputeMaxEigenvalue.
33
34 @param max_eigenvalue: peano4.api.datamodel.DaStGen2
35 The cell data holding the maximum eigenvalue (first entry).
36 Defaults to solver._max_eigenvalue.
37
38 """
39 AbstractFVActionSet.__init__(self, solver)
40 self.guard = guard
42 max_eigenvalue if max_eigenvalue is not None else solver._max_eigenvalue
43 )
44
45 def get_body_of_operation(self, operation_name):
46 if (
47 operation_name
48 != peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
49 ):
50 return ""
51 return f"""
52 repositories::{self._solver.get_name_of_global_instance()}.reduceMaxEigenvalue( fineGridCell{self._max_eigenvalue.name}.getMaxEigenvalue(0) );
53"""
54
55 def get_guard_of_operation(self, operation_name):
56 if (
57 operation_name
58 == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
59 ):
60 return self.guard
61 return "true"
62
64 return __name__.replace(".py", "").replace(".", "_")
Reduce the maximum eigenvalues of the cells into the solver.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...