Peano
Loading...
Searching...
No Matches
SpreadLimiterStatus.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
5
6import peano4.solversteps
7import jinja2
9 TemplateSpreadLimiterStatus = """
10 if ( {{PREDICATE}} ) {
11 if(fineGridCell{{SOLVER_NAME}}CellLabel.getTroubled_Marker()==celldata::{{SOLVER_NAME}}CellLabel::Troubled_Marker::TROUBLED) return;
12
13 bool hasTroubledNeighbour = false;
14 for(int d=0; d<2*Dimensions; d++){
15 hasTroubledNeighbour |= fineGridFaces{{SOLVER_NAME}}FaceLabel(d).getTroubled_Marker()==facedata::{{SOLVER_NAME}}FaceLabel::Troubled_Marker::TROUBLED;
16 }
17
18 if(hasTroubledNeighbour){
19 fineGridCell{{SOLVER_NAME}}CellLabel.setTroubled_Marker(celldata::{{SOLVER_NAME}}CellLabel::Troubled_Marker::LIMITER_TO_REGULAR);
20 for(int d=0; d<2*Dimensions; d++){
21 fineGridFaces{{SOLVER_NAME}}FaceLabel(d).setTroubled_Marker(
22 std::max(fineGridFaces{{SOLVER_NAME}}FaceLabel(d).getTroubled_Marker(),
23 facedata::{{SOLVER_NAME}}FaceLabel::Troubled_Marker::LIMITER_TO_REGULAR
24 )
25 );
26 }
27 }
28 }
29"""
30
31 def __init__(self,solver,guard):
32 super(SpreadLimiterStatus,self).__init__(solver)
33 self.guard = guard
34
35 def get_body_of_operation(self,operation_name):
36 result = ""
37 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
38 d = {}
39 self._solver._init_dictionary_with_default_parameters(d)
40 self._solver.add_entries_to_text_replacement_dictionary(d)
41 d[ "PREDICATE" ] = self.guard
42 result = jinja2.Template(self.TemplateSpreadLimiterStatus).render(**d)
43 pass
44 return result
45
47 return __name__.replace(".py", "").replace(".", "_")
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.