Peano
Loading...
Searching...
No Matches
InitialCondition.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
3from .AbstractADERDGActionSet import AbstractADERDGActionSet
4
5import jinja2
6import peano4.solversteps
7
8
10 _Template_InitialCondition = """
11 if ({{PREDICATE}}) {
12 logTraceIn("touchCellFirstTime(...)---InitialCondition");
13 int linearisedIndex = 0;
14
15 {% if INITIALISE_PATCHES is sameas True %}
16 repositories::{{SOLVER_INSTANCE}}.initialCondition(
17 fineGridCell{{UNKNOWN_IDENTIFIER}}.value,
18 marker.x(),
19 marker.h(),
20 //0,
21 {{GRID_IS_CONSTRUCTED}}
22 );
23 {% else %}
24 dfor(index, {{ORDER}} + 1) {
25 repositories::{{SOLVER_INSTANCE}}.initialCondition(
26 fineGridCell{{UNKNOWN_IDENTIFIER}}.value + linearisedIndex,
27 ::exahype2::dg::getQuadraturePoint(
28 marker.x(),
29 marker.h(),
30 index,
31 repositories::{{SOLVER_INSTANCE}}.Order + 1,
32 kernels::{{SOLVER_NAME}}::Quadrature<{{SOLUTION_STORAGE_PRECISION}}>::nodes
33 ),
34 marker.h(),
35 //index,
36 {{GRID_IS_CONSTRUCTED}}
37 );
38 linearisedIndex += {{NUMBER_OF_UNKNOWNS}} + {{NUMBER_OF_AUXILIARY_VARIABLES}};
39 }
40 {% endif %}
41
42 #if Dimensions==2
43 constexpr int SpaceBasisSize = {{ORDER+1}} * {{ORDER+1}} * {{NUMBER_OF_UNKNOWNS+NUMBER_OF_AUXILIARY_VARIABLES}};
44 #else
45 constexpr int SpaceBasisSize = {{ORDER+1}} * {{ORDER+1}} * {{ORDER+1}} * {{NUMBER_OF_UNKNOWNS+NUMBER_OF_AUXILIARY_VARIABLES}};
46 #endif
47
48 std::copy_n(fineGridCell{{UNKNOWN_IDENTIFIER}}.value, SpaceBasisSize, fineGridCell{{UNKNOWN_IDENTIFIER}}_old.value);
49
50 {% if USE_POINT_SOURCE %}
51 repositories::{{SOLVER_INSTANCE}}.initPointSourceLocations(repositories::{{SOLVER_INSTANCE}}.pointSourceLocation);
52 {% endif %}
53
54 const double timeStamp = 0.0;
55 const double timeStepSize = 0.0;
56 {{SOLUTION_STORAGE_PRECISION}}* luh = fineGridCell{{UNKNOWN_IDENTIFIER}}.value;
57 {{COMPUTE_NEW_TIME_STEP_SIZE}}
58
59 // Relevant for tracing et al which kicks in if and only if cell has been updated
60 fineGridCell{{SOLVER_NAME}}CellLabel.setHasUpdated(true);
61
62 logTraceOut("touchCellFirstTime(...)---InitialCondition");
63 }
64"""
65
66 def __init__(self, solver, guard, grid_is_constructed):
67 super(InitialCondition, self).__init__(solver)
68 self._guard = guard
69 self._grid_is_constructed = grid_is_constructed
70 self._initialise_patches = solver._initialise_patches
71
72 def get_body_of_operation(self, operation_name):
73 result = ""
74 if (
75 operation_name
76 == peano4.solversteps.ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME
77 ):
78 d = {}
79 self._solver._init_dictionary_with_default_parameters(d)
80 self._solver.add_entries_to_text_replacement_dictionary(d)
81 d["PREDICATE"] = self._guard
82 d["GRID_IS_CONSTRUCTED"] = self._grid_is_constructed
83 d["INITIALISE_PATCHES"] = self._initialise_patches
84 result = jinja2.Template(self._Template_InitialCondition).render(**d)
85 return result
86
88 return __name__.replace(".py", "").replace(".", "_")
89
90 def get_includes(self):
91 return (
92 super(InitialCondition, self).get_includes()
93 + """
94#include "kernels/"""
95 + self._solver._name
96 + """/Quadrature.h"
97#include "kernels/"""
98 + self._solver._name
99 + """/MaxScaledEigenvalue.h"
100"""
101 )
get_action_set_name(self)
You should replicate this function in each subclass, so you get meaningful action set names (otherwis...
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
get_includes(self)
Return include statements that you need.