Peano
Loading...
Searching...
No Matches
ReconstructPatchAndApplyFunctor.py
Go to the documentation of this file.
1# This file is part of the Peano project. For conditions of distribution and
2# use, please see the copyright notice at www.peano-framework.org
3from peano4.api.solversteps.ActionSet import ActionSet
4
5from .ReconstructPatchWithHalo import ReconstructPatchWithHalo
6
7
9 """!
10
11 ReconstructPatchWithHalo plus a functor invoked once the reconstruction
12 (into reconstructed_patch) is done - @see ReconstructPatchWithHalo for the
13 reconstruction itself, which this class does not repeat. The functor gets
14 access to the reconstructed data (oldQWithHalo, aliasing
15 reconstructed_patch's own accessor - no separate scratch array is
16 allocated) and writes its result into patch's own accessor (newQ).
17
18 If you want to swap the functor, please replace self.functor_implementation,
19 and ensure that all external references (text replacements) are already
20 resolved. Consult _add_action_set_entries_to_dictionary() for details.
21
22 """
23
24 def __init__(self,
25 patch,
26 patch_overlap,
27 reconstructed_patch,
28 functor_implementation,
29 guard="true",
30 add_assertions_to_halo_exchange = True,
31 additional_includes = ""
32 ):
33 """!
34
35 patch, patch_overlap, reconstructed_patch, guard, add_assertions_to_halo_exchange, additional_includes:
36 @see ReconstructPatchWithHalo.
37
38 ## Functor_implementation
39
40 The functor implementation is a plain C/C++
41
42 - If you want to use brackets in your implementation, please use double brackets {{ }} as
43 the template system otherwise gets confused.
44 - The following C++ variables are defined:
45
46 oldQWithHalo
47 newQ
48
49 Both are plain double pointers.
50
51 """
52 super(ReconstructPatchAndApplyFunctor,self).__init__(
53 patch, patch_overlap, reconstructed_patch, guard, add_assertions_to_halo_exchange, additional_includes
54 )
55 self.functor_implementation = functor_implementation
56
57
59 """!
60
61 Befill dictionary - @see ReconstructPatchWithHalo._add_action_set_entries_to_dictionary(),
62 which this calls first. On top of that, this one also resolves the
63 functor implementation (CELL_FUNCTOR_IMPLEMENTATION).
64
65 Please note that we do not replace entries in the functor implementation:
66 The overall code created by this action set consists of different parts
67 realised as different templates. The templates are subject to a text
68 replacement system and then are concatenated. One of the things that is
69 replaced within the templates is the actual functor implementation
70 (CELL_FUNCTOR_IMPLEMENTATION). If this one contains again free parameters,
71 it is your responsibility to first resolve those parameters, and then to
72 reset the functor in this routine.
73
74 If you want to replace the functor, you can hence either first call this
75 routine and then change d["CELL_FUNCTOR_IMPLEMENTATION"] or you set
76 self.functor_implementation and then you call this routine, i.e. the
77 superclass.
78
79 """
80 super(ReconstructPatchAndApplyFunctor,self)._add_action_set_entries_to_dictionary(d)
81 d[ "CELL_FUNCTOR_IMPLEMENTATION" ] = self.functor_implementation
82
83
85 return __name__.replace(".py", "").replace(".", "_")
86
87
88 _Template_TouchCellFirstTime_Core = """
89 double* newQ = {CELL_ACCESSOR}.value;
90 {CELL_FUNCTOR_IMPLEMENTATION}
91"""
92
93
94 def get_body_of_operation(self,operation_name):
95 result = "\n"
96 if operation_name==ActionSet.OPERATION_TOUCH_CELL_FIRST_TIME:
97 d = {}
99 result = self._Template_TouchCellFirstTime_Preamble.format(**d)
100 result += self._Template_TouchCellFirstTime_Fill_Patch.format(**d)
101 result += self._Template_TouchCellFirstTime_Fill_Halos.format(**d)
102 result += self._Template_TouchCellFirstTime_Core.format(**d)
103 result += self._Template_TouchCellFirstTime_Epilogue.format(**d)
104 pass
105 return result
ReconstructPatchWithHalo plus a functor invoked once the reconstruction (into reconstructed_patch) is...
__init__(self, patch, patch_overlap, reconstructed_patch, functor_implementation, guard="true", add_assertions_to_halo_exchange=True, additional_includes="")
patch, patch_overlap, reconstructed_patch, guard, add_assertions_to_halo_exchange,...
get_body_of_operation(self, operation_name)
Return actual C++ code snippets to be inserted into C++ code.
Reconstruct a cell patch together with its halo into a separate, already-declared reconstructed_patch...
Action set (reactions to events)
Definition ActionSet.py:6