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
5from ...AuxiliaryVariables import (
6 code_to_assemble_kernel_input,
7 code_to_allocate_kernel_output,
8 code_to_copy_back_kernel_output,
9)
10import peano4.api
11
12
14 """!
15
16 Update a Finite Volume patch (solver._patch) from its halo-augmented
17 reconstruction (solver._patch_with_halo, see
18 toolbox.blockstructured.api.ReconstructPatchWithHalo) by applying the
19 solver's numerical scheme (Rusanov flux, explicit Euler time stepping)
20 once per volume.
21
22 Global time stepping: all cells share one time stamp and time step
23 size, which are taken from the solver (getMinTimeStamp() and
24 getMinTimeStepSize()) rather than from per-cell bookkeeping.
25
26 The kernel does not return any eigenvalue: exahype2.api.fv.actionsets.ComputeMaxEigenvalue
27 determines it in a task of its own, and
28 exahype2.api.fv.actionsets.ComputeGlobalCFLCondition derives the next
29 time step size from it.
30
31 """
32
33 def __init__(self, solver, guard):
34 """!
35
36 @param solver: exahype2.api.Solver
37 Has to have solver._patch and
38 solver._patch_with_halo set - @see
39 exahype2.api.fv.RusanovWithExplicitEuler.
40
41 @param guard: str
42 C++ boolean expression, evaluated per cell in touchCellFirstTime,
43 guarding whether that cell's patch is updated. Typically the
44 output of the solver's grid_selector (@see
45 peano4.api.toolbox.GridSelector).
46
47 """
48 AbstractFVActionSet.__init__(self, solver)
49 self.guard = guard
50
51 def get_body_of_operation(self, operation_name):
52 result = ""
53 if operation_name == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
54 solver = self._solver
55 unknowns_in = f"fineGridCell{solver._patch_with_halo.name}.value"
56 unknowns_out = f"fineGridCell{solver._patch.name}.value"
57 has_parameters = len(solver.auxiliary_variables) > 0
58 kernel_in = "kernelIn.data()" if has_parameters else unknowns_in
59 kernel_out = "kernelOut.data()" if has_parameters else unknowns_out
60 result = f"""
61 double timeStamp = repositories::{solver.get_name_of_global_instance()}.getMinTimeStamp();
62 double timeStepSize = repositories::{solver.get_name_of_global_instance()}.getMinTimeStepSize();
63 {code_to_assemble_kernel_input(solver, "kernelIn", unknowns_in, solver.numerical_scheme.halo_size)}
64 {code_to_allocate_kernel_output(solver, "kernelOut")}
65 ::exahype2::CellData patchData({kernel_in}, marker.x(), marker.h(), timeStamp, timeStepSize, {kernel_out});
66 {solver.compute_kernel_call}
67 {code_to_copy_back_kernel_output(solver, "kernelOut", unknowns_out)}
68
69"""
70 return result
71
72 def get_guard_of_operation(self, operation_name):
73 if operation_name == peano4.api.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
74 return self.guard
75 return "true"
76
78 return __name__.replace(".py", "").replace(".", "_")
Update a Finite Volume patch (solver._patch) from its halo-augmented reconstruction (solver....
Definition UpdateCell.py:13
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
Definition UpdateCell.py:51
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...
Definition UpdateCell.py:77
get_guard_of_operation(self, operation_name)
Return the guard of an operation.
Definition UpdateCell.py:72