Peano
Loading...
Searching...
No Matches
UpdateCell.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 Update a Finite Volume patch (solver._patch) from its halo-augmented
12 reconstruction (solver._patch_with_halo, see
13 toolbox.blockstructured.api.ReconstructPatchWithHalo) by applying the
14 solver's numerical scheme (Rusanov flux, explicit Euler time stepping)
15 once per volume.
16
17 Global time stepping: all cells share one time stamp and time step
18 size, which are taken from the solver (getMinTimeStamp() and
19 getMinTimeStepSize()) rather than from per-cell bookkeeping.
20
21 The compute kernel returns the maximum eigenvalue over the patch it has
22 just updated. The action set stores it in the cell data
23 solver._max_eigenvalue. exahype2.api.fv.actionsets.ComputeGlobalCFLCondition
24 reduces these values in a subsequent mesh traversal and derives the
25 next time step size from them.
26
27 """
28
29 def __init__(self, solver, guard, max_eigenvalue=None):
30 """!
31
32 @param solver: exahype2.api.Solver
33 Has to have solver._patch, solver._patch_with_halo and
34 solver._max_eigenvalue set - @see
35 exahype2.api.fv.RusanovWithExplicitEuler.
36
37 @param guard: str
38 C++ boolean expression, evaluated per cell in touchCellFirstTime,
39 guarding whether that cell's patch is updated. Typically the
40 output of the solver's grid_selector (@see
41 peano4.api.toolbox.GridSelector).
42
43 @param max_eigenvalue: peano4.api.datamodel.DaStGen2
44 The cell data the maximum eigenvalue goes into (first entry).
45 Defaults to solver._max_eigenvalue.
46
47 """
48 AbstractFVActionSet.__init__(self, solver)
49 self.guard = guard
50 self._max_eigenvalue = max_eigenvalue if max_eigenvalue is not None else solver._max_eigenvalue
51
52 def get_body_of_operation(self, operation_name):
53 result = ""
54 if operation_name == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
55 result = f"""
56 double timeStamp = repositories::{self._solver.get_name_of_global_instance()}.getMinTimeStamp();
57 double timeStepSize = repositories::{self._solver.get_name_of_global_instance()}.getMinTimeStepSize();
58 ::exahype2::CellData patchData(fineGridCell{self._solver._patch_with_halo.name}.value, marker.x(), marker.h(), timeStamp, timeStepSize, fineGridCell{self._solver._patch.name}.value);
59 {self._solver.compute_kernel_call}
60
61 fineGridCell{self._max_eigenvalue.name}.setMaxEigenvalue( 0, patchData.maxEigenvalue[0] );
62"""
63 return result
64
65 def get_guard_of_operation(self, operation_name):
66 if operation_name == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
67 return self.guard
68 return "true"
69
71 return __name__.replace(".py", "").replace(".", "_")
Update a Finite Volume patch (solver._patch) from its halo-augmented reconstruction (solver....
Definition UpdateCell.py:8
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
Definition UpdateCell.py:52
__init__(self, solver, guard, max_eigenvalue=None)
Definition UpdateCell.py:29
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...
Definition UpdateCell.py:70
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
Definition UpdateCell.py:65