Peano
Loading...
Searching...
No Matches
LoopBody.cpph
Go to the documentation of this file.
1#include "exahype2/Solver.h"
3
5#include "tarch/Assertions.h"
7
8#if defined(GPUOffloadingOMP)
9#pragma omp declare target
10#endif
11template <class QInEnumeratorType, class QOutEnumeratorType>
13 const double* __restrict__ QIn,
14 const QInEnumeratorType& QInEnumerator,
15 int patchIndex,
16 const tarch::la::Vector<Dimensions,int>& volumeIndex,
17 int unknown,
18 double* __restrict__ QOut,
19 const QOutEnumeratorType& QOutEnumerator
20) {
21 QOut[ QOutEnumerator(patchIndex,volumeIndex,unknown) ] = QIn[ QInEnumerator(patchIndex,volumeIndex,unknown) ];
22}
23#if defined(GPUOffloadingOMP)
24#pragma omp end declare target
25#endif
26
27#if defined(GPUOffloadingOMP)
28#pragma omp declare target
29#endif
30template <class QOutEnumeratorType>
32 int patchIndex,
33 const tarch::la::Vector<Dimensions,int>& volumeIndex,
34 int unknown,
35 double* __restrict__ QOut,
36 const QOutEnumeratorType& QOutEnumerator
37) {
38 QOut[ QOutEnumerator(patchIndex,volumeIndex,unknown) ] = 0.0;
39}
40#if defined(GPUOffloadingOMP)
41#pragma omp end declare target
42#endif
43
44template <class QInEnumeratorType, class QOutEnumeratorType>
46 const double* __restrict__ QIn,
47 const QInEnumeratorType& QInEnumerator,
48 exahype2::fd::Source AlgebraicSource,
49 const tarch::la::Vector<Dimensions,double>& patchCentre,
51 int patchIndex,
52 const tarch::la::Vector<Dimensions,int>& volumeIndex,
53 double t,
54 double dt,
55 double* __restrict__ QOut,
56 const QOutEnumeratorType& QOutEnumerator
57) {
58 double* QInGathered = new double[QInEnumerator._unknowns+QInEnumerator._numberOfAuxiliaryVariables];
59 double* QAlgebraicSourceGathered = new double[QInEnumerator._unknowns];
60
61 // gather
62 for (int unknown=0; unknown<QInEnumerator._unknowns+QInEnumerator._numberOfAuxiliaryVariables; unknown++) {
63 QInGathered[unknown] = QIn[ QInEnumerator(patchIndex,volumeIndex,unknown) ];
64 }
65
66 AlgebraicSource(
67 QInGathered,
68 ::exahype2::fd::getGridCellCentre( patchCentre, patchSize, QInEnumerator._numberOfDoFsPerAxisInCell, volumeIndex ),
69 ::exahype2::fd::getGridCellSize( patchSize, QInEnumerator._numberOfDoFsPerAxisInCell ),
70 t,
71 dt,
72 QAlgebraicSourceGathered
73 );
74
75 for (int unknown=0; unknown<QOutEnumerator._unknowns; unknown++) {
76 QOut[ QOutEnumerator(patchIndex,volumeIndex,unknown) ] += dt * QAlgebraicSourceGathered[unknown];
78 QOut[ QOutEnumerator(patchIndex, volumeIndex,unknown) ]==QOut[ QOutEnumerator(patchIndex, volumeIndex,unknown) ],
79 dt, unknown, volumeIndex,
80 QOutEnumerator(patchIndex,volumeIndex,unknown)
81 );
82 }
83
84 delete[] QInGathered;
85 delete[] QAlgebraicSourceGathered;
86}
87
88template <typename Solver, class QInEnumeratorType, class QOutEnumeratorType>
90 const double* __restrict__ QIn,
91 const QInEnumeratorType& QInEnumerator,
92 const tarch::la::Vector<Dimensions,double>& patchCentre,
94 int patchIndex,
95 const tarch::la::Vector<Dimensions,int>& volumeIndex,
96 double t,
97 double dt,
98 double* __restrict__ QOut,
99 const QOutEnumeratorType& QOutEnumerator
100) {
101 double* QInGathered = new double[QInEnumerator._unknowns+QInEnumerator._numberOfAuxiliaryVariables];
102 double* QAlgebraicSourceGathered = new double[QInEnumerator._unknowns];
103
104 // gather
105 for (int unknown=0; unknown<QInEnumerator._unknowns+QInEnumerator._numberOfAuxiliaryVariables; unknown++) {
106 QInGathered[unknown] = QIn[ QInEnumerator(patchIndex,volumeIndex,unknown) ];
107 }
108
109 Solver::sourceTerm(
110 QInGathered,
111 ::exahype2::fd::getGridCellCentre( patchCentre, patchSize, QInEnumerator._numberOfDoFsPerAxisInCell, volumeIndex ),
112 ::exahype2::fd::getGridCellSize( patchSize, QInEnumerator._numberOfDoFsPerAxisInCell ),
113 t,
114 dt,
115 QAlgebraicSourceGathered,
117 );
118
119 for (int unknown=0; unknown<QOutEnumerator._unknowns; unknown++) {
120 QOut[ QOutEnumerator(patchIndex,volumeIndex,unknown) ] += dt * QAlgebraicSourceGathered[unknown];
122 QOut[ QOutEnumerator(patchIndex, volumeIndex,unknown) ]==QOut[ QOutEnumerator(patchIndex, volumeIndex,unknown) ],
123 dt, unknown, volumeIndex,
124 QOutEnumerator(patchIndex,volumeIndex,unknown)
125 );
126 }
127
128 delete[] QInGathered;
129 delete[] QAlgebraicSourceGathered;
130}
131
132template <typename Solver>
134 const double* __restrict__ QIn,
136 const tarch::la::Vector<Dimensions,double>& patchCentre,
138 int patchIndex,
139 const tarch::la::Vector<Dimensions,int>& volumeIndex,
140 double t,
141 double dt,
142 double* __restrict__ QOut,
144) {
145 double* QAlgebraicSourceGathered = new double[QInEnumerator._unknowns];
146
147 Solver::sourceTerm(
148 & (QIn[ QInEnumerator(patchIndex,volumeIndex,0) ]),
149 ::exahype2::fd::getGridCellCentre( patchCentre, patchSize, QInEnumerator._numberOfDoFsPerAxisInCell, volumeIndex ),
151 t,
152 dt,
153 QAlgebraicSourceGathered,
155 );
156
157 for (int unknown=0; unknown<QOutEnumerator._unknowns; unknown++) {
158 QOut[ QOutEnumerator(patchIndex,volumeIndex,unknown) ] += dt * QAlgebraicSourceGathered[unknown];
160 QOut[ QOutEnumerator(patchIndex, volumeIndex,unknown) ]==QOut[ QOutEnumerator(patchIndex, volumeIndex,unknown) ],
161 dt, unknown, volumeIndex,
162 QOutEnumerator(patchIndex,volumeIndex,unknown)
163 );
164 }
165
166 delete[] QAlgebraicSourceGathered;
167}
168
169template <class QOutEnumeratorType>
171 const double* __restrict__ QOut,
172 const QOutEnumeratorType& QOutEnumerator,
173 exahype2::fd::MaxEigenvalue maxEigenvalue,
174 const tarch::la::Vector<Dimensions,double>& patchCentre,
176 int patchIndex,
177 const tarch::la::Vector<Dimensions,int>& volumeIndex,
178 double t,
179 double dt
180) {
181 double* QGathered = new double[QOutEnumerator._unknowns+QOutEnumerator._numberOfAuxiliaryVariables];
182
183 // gather
184 #if defined(SharedOMP)
185 #pragma omp simd
186 #endif
187 for (int unknown=0; unknown<QOutEnumerator._unknowns+QOutEnumerator._numberOfAuxiliaryVariables; unknown++) {
188 QGathered[unknown] = QOut[ QOutEnumerator(patchIndex,volumeIndex,unknown) ];
189 }
190
191 double result = 0.0;
192 for (int normal=0; normal<Dimensions; normal++) {
193 result = std::max(
194 result,
196 QGathered,
197 ::exahype2::fd::getGridCellCentre( patchCentre, patchSize, QOutEnumerator._numberOfDoFsPerAxisInCell, volumeIndex ),
198 ::exahype2::fd::getGridCellSize( patchSize, QOutEnumerator._numberOfDoFsPerAxisInCell ),
199 t,
200 dt,
201 normal,
203 )
204 );
205 }
206
207 delete[] QGathered;
208
209 return result;
210}
211
212template <typename Solver>
214 const double* __restrict__ QOut,
216 const tarch::la::Vector<Dimensions,double>& patchCentre,
218 int patchIndex,
219 const tarch::la::Vector<Dimensions,int>& volumeIndex,
220 double t,
221 double dt
222) {
223 double result = 0.0;
224 for (int normal=0; normal<Dimensions; normal++) {
225 result = std::max(
226 result,
227 Solver::maxEigenvalue(
228 &( QOut[ QOutEnumerator(patchIndex,volumeIndex,0) ] ),
229 ::exahype2::fd::getGridCellCentre( patchCentre, patchSize, QOutEnumerator._numberOfDoFsPerAxisInCell, volumeIndex ),
231 t,
232 dt,
233 normal,
235 )
236 );
237 }
238 return result;
239}
#define assertion4(expr, param0, param1, param2, param3)
float dt
Definition DSL_test.py:5
KeywordToAvoidDuplicateSymbolsForInlinedFunctions double maxEigenvalue(const double *const Q, int normal, const double CCZ4e, const double CCZ4ds, const double CCZ4GLMc, const double CCZ4GLMd) InlineMethod
static void copySolution_LoopBody(const double *__restrict__ QIn, const QInEnumeratorType &QInEnumerator, int patchIndex, const tarch::la::Vector< Dimensions, int > &volumeIndex, int unknown, double *__restrict__ QOut, const QOutEnumeratorType &QOutEnumerator) InlineMethod
static void addAlgebraicSourceTerm_LoopBody(const double *__restrict__ QIn, const QInEnumeratorType &QInEnumerator, exahype2::fd::Source AlgebraicSource, const tarch::la::Vector< Dimensions, double > &patchCentre, const tarch::la::Vector< Dimensions, double > &patchSize, int patchIndex, const tarch::la::Vector< Dimensions, int > &volumeIndex, double t, double dt, double *__restrict__ QOut, const QOutEnumeratorType &QOutEnumerator) InlineMethod
Copy previous solution over into new time step and add source term.
static void clearSolution_LoopBody(int patchIndex, const tarch::la::Vector< Dimensions, int > &volumeIndex, int unknown, double *__restrict__ QOut, const QOutEnumeratorType &QOutEnumerator) InlineMethod
The complicated way to write =0.
static double reduceMaxEigenvalue_LoopBody(const double *__restrict__ QOut, const QOutEnumeratorType &QOutEnumerator, exahype2::fd::MaxEigenvalue maxEigenvalue, const tarch::la::Vector< Dimensions, double > &patchCentre, const tarch::la::Vector< Dimensions, double > &patchSize, int patchIndex, const tarch::la::Vector< Dimensions, int > &volumeIndex, double t, double dt) InlineMethod
std::function< void(const double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &gridCellX, const tarch::la::Vector< Dimensions, double > &gridCellH, double t, double dt, double *__restrict__ AlgeSrc) Source)
Definition Functors.h:20
static tarch::la::Vector< 2, double > getGridCellCentre(const tarch::la::Vector< 2, double > &x, const tarch::la::Vector< 2, double > &h, int numberOfGridCellsPerPatchPerAxis, const tarch::la::Vector< 2, int > &index)
In ExaHyPE's Finite Volume setup, a cell hosts a patch of Finite Volumes.
Definition PatchUtils.h:77
static tarch::la::Vector< 2, double > getGridCellSize(const tarch::la::Vector< 2, double > &h, int numberOfGridCellsPerPatchPerAxis)
Definition PatchUtils.h:22
std::function< double(const double *__restrict__ Q, const tarch::la::Vector< Dimensions, double > &gridCellX, const tarch::la::Vector< Dimensions, double > &gridCellH, double t, double dt, int normal) MaxEigenvalue)
The max eigenvalue is used if and only if you have adaptive time stepping.
Definition Functors.h:53
Simple vector class.
Definition Vector.h:150