Peano
Loading...
Searching...
No Matches
SolveRiemannProblem.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
3
4from .AbstractRungeKuttaDGActionSet import AbstractRungeKuttaDGActionSet
5
6from exahype2.solvers.ButcherTableau import ButcherTableau
7
8import peano4
9import jinja2
10
11
13 """
14 Solve the actual Riemann problem and add stuff back to the solution.
15
16 See the discussion of RungeKuttaDG for a discussion regarding the individual
17 steps.
18 """
19
20 TemplateProject = """
21 {% for PREDICATE_NO in range(0,PREDICATES|length) %}
22 if ({{PREDICATES[PREDICATE_NO]}}) {
23 // no support for local time stepping or subcycling
24 /*
25 assertionNumericalEquals2(
26 {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(0),
27 {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(1),
28 {{FACE_METADATA_ACCESSOR}}.toString(),
29 marker.toString()
30 );
31 */
32
33 // Doesn't make a difference if we pick left or right
34 const double timeStampOldSolution = {{FACE_METADATA_ACCESSOR}}.getOldTimeStamp(0);
35
36 // Set the variable
37 // double timeStepSize
38 {{COMPUTE_TIME_STEP_SIZE}}
39
40 const double timeStamp = timeStampOldSolution + {{BUTCHER_TABLEAU_RELATIVE_TIME_STEP_SIZES[PREDICATE_NO]}} * timeStepSize;
41
42 assertion5( tarch::la::greaterEquals( timeStepSize, 0.0 ), timeStamp, timeStepSize, timeStampOldSolution, {{FACE_METADATA_ACCESSOR}}.toString(), marker.toString() );
43 assertion5( tarch::la::greaterEquals( timeStamp, 0.0 ), timeStamp, timeStepSize, timeStampOldSolution, {{FACE_METADATA_ACCESSOR}}.toString(), marker.toString() );
44
45 const double* __restrict__ QIn = fineGridFace{{UNKNOWN_IDENTIFIER}}EstimateProjection.value;
46 double* __restrict__ QOut = fineGridFace{{UNKNOWN_IDENTIFIER}}RiemannSolution.value;
47
48 ::exahype2::dg::{{KERNEL_NAMESPACE}}::{{RIEMANN_COMPUTE_KERNEL_CALL}}
49 }
50 {% endfor %}
51"""
52
53
54 def __init__(self,solver):
55 """
56 guard_project: String (C++ code)
57 Predicate which controls if the solution is actually projected.
58
59 guard_safe_old_time_step: String (C++ code)
60 Predicate which controls if the projection should be copied into
61 the old solution and the time step should also be moved over.
62 """
63 super(SolveRiemannProblem,self).__init__(solver)
66
67
68 @property
69 def guards(self):
70 if self._guards==[]:
71 raise Exception("Guards are not initialised")
72 return self._guards
73
74
75 @guards.setter
76 def guards(self,new_guards):
77 if new_guards!=[] and len(new_guards)!=self._solver.number_of_Runge_Kutta_steps():
78 raise Exception( "Expect one guard per Runge Kutta step. Have {} steps but got guards {}".format(solver.number_of_Runge_Kutta_steps(),guards) )
79 self._guards = new_guards
80
81
82 def get_body_of_operation(self,operation_name):
83 result = ""
84 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_FACE_FIRST_TIME:
85 d = {}
86 self._solver._init_dictionary_with_default_parameters(d)
87 self._solver.add_entries_to_text_replacement_dictionary(d)
88 d[ "PREDICATES" ] = self.guardsguardsguards
89 d[ "BUTCHER_TABLEAU_RELATIVE_TIME_STEP_SIZES" ] = self._butcher_tableau.time_step_sizes()
90 d[ "FACE_METADATA_ACCESSOR" ] = "fineGridFace" + self._solver._face_label.name
91 result = jinja2.Template(self.TemplateProject).render(**d)
92 pass
93 return result
94
95
97 return __name__.replace(".py", "").replace(".", "_")
98
99
100 def get_includes(self):
101 return super(SolveRiemannProblem,self).get_includes() + """
102#include "exahype2/dg/rusanov/Rusanov.h"
103 """
Solve the actual Riemann problem and add stuff back to the solution.
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
__init__(self, solver)
guard_project: String (C++ code) Predicate which controls if the solution is actually projected.
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...