Peano
Loading...
Searching...
No Matches
VerifyTroubledness.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 .AbstractLimiterActionSet import AbstractLimiterActionSet
5from exahype2.solvers.PDETerms import PDETerms
6
7import peano4.solversteps
8import jinja2
9
10from .kernels import check_troubledness
11
13 TemplateVerifyTroubledness = """
14
15 if ( {{PREDICATE}} ) {
16
17
18 const double timeStamp = fineGridCell{{REGULAR_SOLVER_NAME}}CellLabel.getTimeStamp();
19 const double timeStepSize = fineGridCell{{REGULAR_SOLVER_NAME}}CellLabel.getTimeStepSize();
20
21 bool isUnTroubled = true;
22
23 auto* luh = fineGridCell{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}.value;
24
25
26 {% if USE_PAC %}
27
28 int linearisedIndex = 0;
29 dfor( index, {{ORDER}}+1 ) {
30
31 isUnTroubled &= repositories::{{SOLVER_INSTANCE}}.isPhysicallyAdmissible(
32 luh + linearisedIndex,
33 ::exahype2::dg::getQuadraturePoint(
34 marker.x(), marker.h(), index, repositories::{{REGULAR_SOLVER_INSTANCE}}.Order+1,
35 kernels::{{REGULAR_SOLVER_NAME}}::Quadrature<{{REGULAR_SOLVER_STORAGE_PRECISION}}>::nodes
36 ),
37 marker.h(),
38 timeStamp+timeStepSize
39 );
40
41 linearisedIndex += repositories::{{REGULAR_SOLVER_INSTANCE}}.NumberOfUnknowns + repositories::{{REGULAR_SOLVER_INSTANCE}}.NumberOfAuxiliaryVariables;
42 }
43
44 {% endif %}
45
46
47 if(!isUnTroubled){
48 repositories::{{SOLVER_INSTANCE}}.addTroubledCell();
49 fineGridCell{{SOLVER_NAME}}CellLabel.setTroubled_Marker(celldata::{{SOLVER_NAME}}CellLabel::Troubled_Marker::TROUBLED);
50 for(int d=0; d<2*DIMENSIONS; d++){
51 fineGridFaces{{SOLVER_NAME}}FaceLabel(d).setTroubled_Marker(facedata::{{SOLVER_NAME}}FaceLabel::Troubled_Marker::TROUBLED);
52 }
53 }
54
55 fineGridCell{{LIMITER_SOLVER_NAME}}CellLabel.setTimeStamp(timeStamp);
56 fineGridCell{{LIMITER_SOLVER_NAME}}CellLabel.setTimeStepSize(timeStepSize);
57
58 fineGridCell{{LIMITER_SOLVER_NAME}}CellLabel.setHasUpdated(true);
59
60 }
61
62"""
63
64 def __init__(self, solver, guard, use_PAC=False):
65 super(VerifyTroubledness,self).__init__(solver)
66 self.guard = guard
67
68 self.use_PAC = use_PAC
69
70 def get_body_of_operation(self,operation_name):
71 result = ""
72 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_LAST_TIME:
73 d = {}
74 self._solver._init_dictionary_with_default_parameters(d)
75 self._solver.add_entries_to_text_replacement_dictionary(d)
76 d["PREDICATE" ] = self.guard
77 d["USE_PAC"] = self.use_PAC
78
79 result = jinja2.Template(self.TemplateVerifyTroubledness).render(**d)
80 pass
81 return result
82
83
85 return __name__.replace(".py", "").replace(".", "_")
86
87 def get_includes(self):
88 return ( super(VerifyTroubledness, self).get_includes() + """
89#include "kernels/"""
90 + self._solver._regular_solver._name
91 + """/Quadrature.h"
92#include "exahype2/dg/DGUtils.h"
93 """)
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...