4from .AbstractRKFDActionSet
import AbstractRKFDActionSet
14 Computes a linear combination of all of the estimates according to the
17 The linear combination is a volumetric representation which includes both
18 the degrees of freedom and the auxiliary variables. However, the auxiliary
19 variables are not developing over time. In Runge-Kutta, I have estimates
20 for the right-hand side, i.e. for the derivatives
22 @f$ \partial _t Q = F(Q) @f$
24 This is the stuff stored in RhsEstimates. It does not comprise any auxiliary
25 variables. So I have to copy the auxiliary variables from the last valid
26 time step every time I reconstruct a new guess.
30 TemplateLinearCombination =
"""
32 // double timeStepSize
33 {{COMPUTE_TIME_STEP_SIZE}}
35 {% for PREDICATE_NO in range(0,PREDICATES|length) %}
36 if ({{PREDICATES[PREDICATE_NO]}}) {
37 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithAuxiliaryVariables ( 1, {{ORDER}}+1, 0, {{NUMBER_OF_UNKNOWNS}}, {{NUMBER_OF_AUXILIARY_VARIABLES}});
38 ::exahype2::enumerator::AoSLexicographicEnumerator enumeratorWithoutAuxiliaryVariables( {{RK_STEPS}}, {{ORDER}}+1, 0, {{NUMBER_OF_UNKNOWNS}}, 0 );
40 dfor( dof, {{ORDER}}+1 ) {
41 for (int unknown=0; unknown<{{NUMBER_OF_UNKNOWNS}}; unknown++) {
42 fineGridCell{{UNKNOWN_IDENTIFIER}}LinearCombination.value[ enumeratorWithAuxiliaryVariables(0,dof,unknown) ] =
43 fineGridCell{{UNKNOWN_IDENTIFIER}}.value[ enumeratorWithAuxiliaryVariables(0,dof,unknown) ];
45 {% for WEIGHT_NO in range(0,BUTCHER_TABLEAU_WEIGHTS[PREDICATE_NO]|length) %}
46 {% if BUTCHER_TABLEAU_WEIGHTS[PREDICATE_NO][WEIGHT_NO]!=0 %}
47 fineGridCell{{UNKNOWN_IDENTIFIER}}LinearCombination.value[ enumeratorWithAuxiliaryVariables(0,dof,unknown) ] +=
48 {{BUTCHER_TABLEAU_RELATIVE_TIME_STEP_SIZES[PREDICATE_NO]}} * timeStepSize * {{BUTCHER_TABLEAU_WEIGHTS[PREDICATE_NO][WEIGHT_NO]}} *
49 fineGridCell{{UNKNOWN_IDENTIFIER}}RhsEstimates.value[ enumeratorWithoutAuxiliaryVariables({{WEIGHT_NO}},dof,unknown) ];
53 for (int unknown={{NUMBER_OF_UNKNOWNS}}; unknown<{{NUMBER_OF_UNKNOWNS}}+{{NUMBER_OF_AUXILIARY_VARIABLES}}; unknown++) {
54 fineGridCell{{UNKNOWN_IDENTIFIER}}LinearCombination.value[ enumeratorWithAuxiliaryVariables(0,dof,unknown) ] =
55 fineGridCell{{UNKNOWN_IDENTIFIER}}.value[ enumeratorWithAuxiliaryVariables(0,dof,unknown) ];
65 guard: [String] (C++ code)
66 Sequence of predicates which determine when we compute the respective RK
67 linear combination. Can be empty.
70 super(LinearCombinationOfEstimates,self).
__init__(solver)
78 raise Exception(
"Guards are not initialised" )
84 if new_guards!=[]
and len(new_guards)!=self.
_solver.number_of_Runge_Kutta_steps():
85 raise Exception(
"Expect one guard per Runge Kutta step. Have {} steps but got guards {}".format(solver.number_of_Runge_Kutta_steps(),guards) )
91 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
93 self.
_solver._init_dictionary_with_default_parameters(d)
94 self.
_solver.add_entries_to_text_replacement_dictionary(d)
97 d[
"BUTCHER_TABLEAU_RELATIVE_TIME_STEP_SIZES" ] = self.
_butcher_tableau.time_step_sizes()
104 return __name__.replace(
".py",
"").replace(
".",
"_")
108 return super(LinearCombinationOfEstimates,self).
get_includes() +
"""
109#include "exahype2/enumerator/AoSLexicographicEnumerator.h"
Computes a linear combination of all of the estimates according to the Butcher Tableau.
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...
__init__(self, solver)
guard: [String] (C++ code) Sequence of predicates which determine when we compute the respective RK l...
get_includes(self)
Return include statements that you need.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
str TemplateLinearCombination