Peano
Loading...
Searching...
No Matches
CopyAndConvertPatch.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 TemplateCopyAndConvertDataFromRegularToLimiterAndProjectToFaces = """
10 if ( {{CONVERT_FROM_REGULAR_TO_LIMITER_AND_SEND_PREDICATE}} ) {
11 celldata::{{SOLVER_NAME}}CellLabel::Troubled_Marker ownStatus = fineGridCell{{SOLVER_NAME}}CellLabel.getTroubled_Marker();
12
13 bool sendFaceProjection = ownStatus>=celldata::{{SOLVER_NAME}}CellLabel::Troubled_Marker::REGULAR_TO_LIMITER;
14 for(int d=0; d<2*Dimensions; d++){
15 sendFaceProjection |= fineGridFaces{{SOLVER_NAME}}FaceLabel(d).getTroubled_Marker()>= facedata::{{SOLVER_NAME}}FaceLabel::Troubled_Marker::LIMITER_TO_REGULAR;
16 }
17
18 //If there's no need to send anything, skip this step
19 if(!sendFaceProjection) return;
20
21 double* regularSolverOldValues = fineGridCell{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}_old.value;
22 double* limiterSolverNewValues = fineGridCell{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}.value;
23
24 //TODO: Replace with more general conversion
25 // Converts DG into FV
26 kernels::{{SOLVER_NAME}}::projectOnFVLimiterSpaceWithoutHalo(regularSolverOldValues, limiterSolverNewValues);
27 }"""
28
29 """
30""",
31
32 TemplateCopyAndConvertDataFromLimiterToRegular = """
33 if ({{CONVERT_FROM_LIMITER_TO_REGULAR_PREDICATE}}) {
34 kernels::{{SOLVER_NAME}}::projectOnDGSpaceFromFVWithoutHalo(
35 fineGridCell{{LIMITER_SOLVER_UNKNOWN_IDENTIFIER}}.value,
36 fineGridCell{{REGULAR_SOLVER_UNKNOWN_IDENTIFIER}}.value
37 );
38 }"""
39
40 def __init__(self,solver, regularToLimiterGuard, limiterToRegularGuard):
41 super(CopyAndConvertPatch, self).__init__(solver)
42 self.regularToLimiterGuard = regularToLimiterGuard
43 self.limiterToRegularGuard = limiterToRegularGuard
44
45 def get_body_of_operation(self,operation_name):
46 result = ""
47 if operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
48 d = {}
49 self._solver._init_dictionary_with_default_parameters(d)
50 self._solver.add_entries_to_text_replacement_dictionary(d)
51 d[ "CONVERT_FROM_REGULAR_TO_LIMITER_AND_SEND_PREDICATE" ] = self.regularToLimiterGuard
52 result = jinja2.Template(self.TemplateCopyAndConvertDataFromRegularToLimiterAndProjectToFaces).render(**d)
53 elif operation_name==peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_LAST_TIME:
54 d = {}
55 self._solver._init_dictionary_with_default_parameters(d)
56 self._solver.add_entries_to_text_replacement_dictionary(d)
57 d[ "CONVERT_FROM_LIMITER_TO_REGULAR_PREDICATE"] = self.limiterToRegularGuard
58 result = jinja2.Template(self.TemplateCopyAndConvertDataFromLimiterToRegular).render(**d)
59 return result
60
62 return __name__.replace(".py", "").replace(".", "_")
63
64 def get_includes(self):
65 return (
66 super(CopyAndConvertPatch, self).get_includes()
67 + """
68#include "kernels/""" + self._solver._name + """/Limiter.h"
69#include "toolbox/blockstructured/Enumeration.h"
70#include "exahype2/fv/rusanov/rusanov.h"
71 """
72 )
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
__init__(self, solver, regularToLimiterGuard, limiterToRegularGuard)