2 #include "exahype2/fd/FD_Helper.cpph"
9 template <void (*recompute_LoopBody)(
11 const ::exahype2::enumerator::AoSLexicographicEnumerator& QInEnumerator,
12 const tarch::la::Vector<DIMENSIONS,double>& patchCentre,
13 const tarch::la::Vector<DIMENSIONS,double>& patchSize,
15 const tarch::la::Vector<DIMENSIONS,int>& volumeIndex,
18 void recomputeAuxiliaryVariablesFD4(
19 ::exahype2::CellData<double, double>& patchData,
20 int numberOfGridCellsPerPatchPerAxis,
23 int auxiliaryVariables
25 assertion( haloSize >= 3 );
26 ::exahype2::enumerator::AoSLexicographicEnumerator QInEnumerator (1,numberOfGridCellsPerPatchPerAxis,haloSize,
unknowns,auxiliaryVariables);
28 for (
int patchIndex=0; patchIndex<patchData.numberOfCells; patchIndex++) {
30 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
31 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
33 patchData.QIn[patchIndex],
35 patchData.cellCentre[patchIndex],
36 patchData.cellSize[patchIndex],
43 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
44 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
46 patchData.QIn[patchIndex],
48 patchData.cellCentre[patchIndex],
49 patchData.cellSize[patchIndex],
57 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
58 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
59 for (
int z = 0; z < numberOfGridCellsPerPatchPerAxis; z++) {
61 patchData.QIn[patchIndex],
63 patchData.cellCentre[patchIndex],
64 patchData.cellSize[patchIndex],
66 gridCellIndex3d(
x,
y,z),
71 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
72 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
73 for (
int z = 0; z < numberOfGridCellsPerPatchPerAxis; z++) {
75 patchData.QIn[patchIndex],
77 patchData.cellCentre[patchIndex],
78 patchData.cellSize[patchIndex],
80 gridCellIndex3d(
x,
y,z),
85 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
86 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
87 for (
int z = 0; z < numberOfGridCellsPerPatchPerAxis; z++) {
89 patchData.QIn[patchIndex],
91 patchData.cellCentre[patchIndex],
92 patchData.cellSize[patchIndex],
94 gridCellIndex3d(
x,
y,z),
105 ::exahype2::CellData<double, double>& patchData,
106 int numberOfGridCellsPerPatchPerAxis,
109 int auxiliaryVariables
111 recomputeAuxiliaryVariablesFD4<internal::recomputeAuxiliaryVariablesFD4_centralDifferences_LoopBody>(
113 numberOfGridCellsPerPatchPerAxis,
122 ::exahype2::CellData<double, double>& patchData,
123 int numberOfGridCellsPerPatchPerAxis,
126 int auxiliaryVariables
128 recomputeAuxiliaryVariablesFD4<internal::recomputeAuxiliaryVariablesFD4_leftDifferences_LoopBody>(
130 numberOfGridCellsPerPatchPerAxis,
139 ::exahype2::CellData<double, double>& patchData,
140 int numberOfGridCellsPerPatchPerAxis,
143 int auxiliaryVariables
145 recomputeAuxiliaryVariablesFD4<internal::recomputeAuxiliaryVariablesFD4_rightDifferences_LoopBody>(
147 numberOfGridCellsPerPatchPerAxis,
156 ::exahype2::CellData<double, double>& patchData,
157 int numberOfGridCellsPerPatchPerAxis,
160 int auxiliaryVariables
162 assertion( haloSize >= 3 );
163 ::exahype2::enumerator::AoSLexicographicEnumerator QInEnumerator (1,numberOfGridCellsPerPatchPerAxis,haloSize,
unknowns,auxiliaryVariables);
165 for (
int patchIndex=0; patchIndex<patchData.numberOfCells; patchIndex++) {
167 for (
int x = -1;
x < numberOfGridCellsPerPatchPerAxis+1;
x++)
168 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
170 patchData.QIn[patchIndex],
172 patchData.cellCentre[patchIndex],
173 patchData.cellSize[patchIndex],
175 gridCellIndex2d(
x,
y),
180 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
181 for (
int y = -1;
y < numberOfGridCellsPerPatchPerAxis+1;
y++) {
183 patchData.QIn[patchIndex],
185 patchData.cellCentre[patchIndex],
186 patchData.cellSize[patchIndex],
188 gridCellIndex2d(
x,
y),
194 for (
int x = -1;
x < numberOfGridCellsPerPatchPerAxis+1;
x++)
195 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
196 for (
int z = 0; z < numberOfGridCellsPerPatchPerAxis; z++) {
198 patchData.QIn[patchIndex],
200 patchData.cellCentre[patchIndex],
201 patchData.cellSize[patchIndex],
203 gridCellIndex3d(
x,
y,z),
208 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
209 for (
int y = -1;
y < numberOfGridCellsPerPatchPerAxis+1;
y++)
210 for (
int z = 0; z < numberOfGridCellsPerPatchPerAxis; z++) {
212 patchData.QIn[patchIndex],
214 patchData.cellCentre[patchIndex],
215 patchData.cellSize[patchIndex],
217 gridCellIndex3d(
x,
y,z),
222 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
223 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
224 for (
int z = -1; z < numberOfGridCellsPerPatchPerAxis+1; z++) {
226 patchData.QIn[patchIndex],
228 patchData.cellCentre[patchIndex],
229 patchData.cellSize[patchIndex],
231 gridCellIndex3d(
x,
y,z),
242 const ::exahype2::enumerator::AoSLexicographicEnumerator& QInEnumerator,
243 const tarch::la::Vector<DIMENSIONS,double>& patchCentre,
244 const tarch::la::Vector<DIMENSIONS,double>& patchSize,
246 const tarch::la::Vector<DIMENSIONS,int>& volumeIndex,
249 tarch::la::Vector<DIMENSIONS,int> centralVolume = volumeIndex;
250 tarch::la::Vector<DIMENSIONS,int> leftAdjacentVolume = volumeIndex;
251 tarch::la::Vector<DIMENSIONS,int> rightAdjacentVolume = volumeIndex;
253 rightAdjacentVolume(normal)++;
254 leftAdjacentVolume(normal)--;
256 double cellSize = patchSize(normal) / QInEnumerator._numberOfDoFsPerAxisInCell;
258 auto finiteDifferences = [&](
int source,
int target) {
259 double dx = QIn[ QInEnumerator(patchIndex, rightAdjacentVolume,
source) ]
260 - QIn[ QInEnumerator(patchIndex, leftAdjacentVolume,
source) ];
261 QIn[ QInEnumerator(patchIndex,centralVolume,target) ] = dx / 2.0 /
cellSize;
264 finiteDifferences(16,23+normal);
265 finiteDifferences(54,55+normal);
267 for (
int i=0; i<3; i++) {
268 finiteDifferences(17+i,26+3*normal+i);
271 for (
int i=0; i<3; i++)
272 for (
int j=i;
j<3;
j++) {
273 int k = (i==0?
j:i+
j+1);
274 finiteDifferences(k,35+6*normal+k);
283 const ::exahype2::enumerator::AoSLexicographicEnumerator& QInEnumerator,
284 const tarch::la::Vector<DIMENSIONS,double>& patchCentre,
285 const tarch::la::Vector<DIMENSIONS,double>& patchSize,
287 const tarch::la::Vector<DIMENSIONS,int>& volumeIndex,
290 tarch::la::Vector<DIMENSIONS,int> centralVolume = volumeIndex;
291 tarch::la::Vector<DIMENSIONS,int> leftAdjacentVolume = volumeIndex;
293 leftAdjacentVolume(normal)--;
295 double cellSize = patchSize(normal) / QInEnumerator._numberOfDoFsPerAxisInCell;
297 auto finiteDifferences = [&](
int source,
int target) {
298 double dx = QIn[ QInEnumerator(patchIndex, centralVolume,
source) ]
299 - QIn[ QInEnumerator(patchIndex, leftAdjacentVolume,
source) ];
300 QIn[ QInEnumerator(patchIndex,centralVolume,target) ] = dx /
cellSize;
303 finiteDifferences(16,23+normal);
304 finiteDifferences(54,55+normal);
306 for (
int i=0; i<3; i++) {
307 finiteDifferences(17+i,26+3*normal+i);
310 for (
int i=0; i<3; i++)
311 for (
int j=i;
j<3;
j++) {
312 int k = (i==0?
j:i+
j+1);
313 finiteDifferences(k,35+6*normal+k);
322 const ::exahype2::enumerator::AoSLexicographicEnumerator& QInEnumerator,
323 const tarch::la::Vector<DIMENSIONS,double>& patchCentre,
324 const tarch::la::Vector<DIMENSIONS,double>& patchSize,
326 const tarch::la::Vector<DIMENSIONS,int>& volumeIndex,
329 tarch::la::Vector<DIMENSIONS,int> centralVolume = volumeIndex;
330 tarch::la::Vector<DIMENSIONS,int> rightAdjacentVolume = volumeIndex;
332 rightAdjacentVolume(normal)++;
334 double cellSize = patchSize(normal) / QInEnumerator._numberOfDoFsPerAxisInCell;
336 auto finiteDifferences = [&](
int source,
int target) {
337 double dx = QIn[ QInEnumerator(patchIndex, rightAdjacentVolume,
source) ]
338 - QIn[ QInEnumerator(patchIndex, centralVolume,
source) ];
339 QIn[ QInEnumerator(patchIndex,centralVolume,target) ] = dx /
cellSize;
342 finiteDifferences(16,23+normal);
343 finiteDifferences(54,55+normal);
345 for (
int i=0; i<3; i++) {
346 finiteDifferences(17+i,26+3*normal+i);
349 for (
int i=0; i<3; i++)
350 for (
int j=i;
j<3;
j++) {
351 int k = (i==0?
j:i+
j+1);
352 finiteDifferences(k,35+6*normal+k);
359 const ::exahype2::enumerator::AoSLexicographicEnumerator& QInEnumerator,
360 const tarch::la::Vector<DIMENSIONS,double>& patchCentre,
361 const tarch::la::Vector<DIMENSIONS,double>& patchSize,
363 const tarch::la::Vector<DIMENSIONS,int>& volumeIndex,
366 tarch::la::Vector<DIMENSIONS,int> centralVolume = volumeIndex;
367 tarch::la::Vector<DIMENSIONS,int> leftAdjacentVolume1 = volumeIndex;
368 tarch::la::Vector<DIMENSIONS,int> leftAdjacentVolume2 = volumeIndex;
369 tarch::la::Vector<DIMENSIONS,int> rightAdjacentVolume1 = volumeIndex;
370 tarch::la::Vector<DIMENSIONS,int> rightAdjacentVolume2 = volumeIndex;
372 rightAdjacentVolume1(normal)++;
373 rightAdjacentVolume2(normal)++;
374 rightAdjacentVolume2(normal)++;
375 leftAdjacentVolume1(normal)--;
376 leftAdjacentVolume2(normal)--;
377 leftAdjacentVolume2(normal)--;
379 double cellsize = patchSize(normal) / QInEnumerator._numberOfDoFsPerAxisInCell;
380 double gradcoef = 1.0/(12.0*cellsize);
382 QIn[ QInEnumerator(patchIndex,centralVolume,23+normal) ] = gradcoef * QIn[ QInEnumerator(patchIndex, leftAdjacentVolume2,16) ] -
383 8.0*gradcoef * QIn[ QInEnumerator(patchIndex, leftAdjacentVolume1,16) ] +
384 8.0*gradcoef * QIn[ QInEnumerator(patchIndex,rightAdjacentVolume1,16) ] -
385 gradcoef * QIn[ QInEnumerator(patchIndex,rightAdjacentVolume2,16) ];
388 QIn[ QInEnumerator(patchIndex,centralVolume,55+normal) ] = gradcoef * QIn[ QInEnumerator(patchIndex, leftAdjacentVolume2,54) ] -
389 8.0*gradcoef * QIn[ QInEnumerator(patchIndex, leftAdjacentVolume1,54) ] +
390 8.0*gradcoef * QIn[ QInEnumerator(patchIndex,rightAdjacentVolume1,54) ] -
391 gradcoef * QIn[ QInEnumerator(patchIndex,rightAdjacentVolume2,54) ];
393 for (
int i=0; i<3; i++) {
394 QIn[ QInEnumerator(patchIndex,centralVolume,26+3*normal+i) ] = gradcoef * QIn[ QInEnumerator(patchIndex, leftAdjacentVolume2,17+i) ] -
395 8.0*gradcoef * QIn[ QInEnumerator(patchIndex, leftAdjacentVolume1,17+i) ] +
396 8.0*gradcoef * QIn[ QInEnumerator(patchIndex,rightAdjacentVolume1,17+i) ] -
397 gradcoef * QIn[ QInEnumerator(patchIndex,rightAdjacentVolume2,17+i) ];
400 for (
int i=0; i<3; i++)
401 for (
int j=i;
j<3;
j++) {
402 int k = (i==0?
j:i+
j+1);
403 QIn[ QInEnumerator(patchIndex,centralVolume,35+6*normal+k) ] = 0.5*gradcoef * QIn[ QInEnumerator(patchIndex, leftAdjacentVolume2,k) ] -
404 4.0*gradcoef * QIn[ QInEnumerator(patchIndex, leftAdjacentVolume1,k) ] +
405 4.0*gradcoef * QIn[ QInEnumerator(patchIndex,rightAdjacentVolume1,k) ] -
406 0.5*gradcoef * QIn[ QInEnumerator(patchIndex,rightAdjacentVolume2,k) ];
const tarch::la::Vector< DIMENSIONS, double > cellSize
void recomputeAuxiliaryVariablesFD4_4thOrder_LoopBody(double *NOALIAS QIn, const ::exahype2::enumerator::AoSLexicographicEnumerator &QInEnumerator, const tarch::la::Vector< DIMENSIONS, double > &patchCentre, const tarch::la::Vector< DIMENSIONS, double > &patchSize, int patchIndex, const tarch::la::Vector< DIMENSIONS, int > &volumeIndex, int normal)
Recompute auxiliary variables.
void recomputeAuxiliaryVariablesFD4_rightDifferences_LoopBody(double *NOALIAS QIn, const ::exahype2::enumerator::AoSLexicographicEnumerator &QInEnumerator, const tarch::la::Vector< DIMENSIONS, double > &patchCentre, const tarch::la::Vector< DIMENSIONS, double > &patchSize, int patchIndex, const tarch::la::Vector< DIMENSIONS, int > &volumeIndex, int normal)
void recomputeAuxiliaryVariablesFD4_leftDifferences_LoopBody(double *NOALIAS QIn, const ::exahype2::enumerator::AoSLexicographicEnumerator &QInEnumerator, const tarch::la::Vector< DIMENSIONS, double > &patchCentre, const tarch::la::Vector< DIMENSIONS, double > &patchSize, int patchIndex, const tarch::la::Vector< DIMENSIONS, int > &volumeIndex, int normal)
void recomputeAuxiliaryVariablesFD4_centralDifferences_LoopBody(double *NOALIAS QIn, const ::exahype2::enumerator::AoSLexicographicEnumerator &QInEnumerator, const tarch::la::Vector< DIMENSIONS, double > &patchCentre, const tarch::la::Vector< DIMENSIONS, double > &patchSize, int patchIndex, const tarch::la::Vector< DIMENSIONS, int > &volumeIndex, int normal)
void recomputeAuxiliaryVariablesFD4_rightDifferences(::exahype2::CellData< double, double > &patchData, int numberOfGridCellsPerPatchPerAxis, int haloSize, int unknowns, int auxiliaryVariables)
static void source(double *S, const double *const Q, const int CCZ4LapseType, const double CCZ4ds, const double CCZ4c, const double CCZ4e, const double CCZ4f, const double CCZ4bs, const double CCZ4sk, const double CCZ4xi, const double CCZ4itau, const double CCZ4eta, const double CCZ4k1, const double CCZ4k2, const double CCZ4k3, const double CCZ4SO)
The source term is one out of two terms that we use in our CCZ4 formulation.
void recomputeAuxiliaryVariablesFD4_4thOrder(::exahype2::CellData< double, double > &patchData, int numberOfGridCellsPerPatchPerAxis, int haloSize, int unknowns, int auxiliaryVariables)
Recompute auxiliary variables for FD4 scheme with a 4th order scheme.
void recomputeAuxiliaryVariablesFD4_centralDifferences(::exahype2::CellData< double, double > &patchData, int numberOfGridCellsPerPatchPerAxis, int haloSize, int unknowns, int auxiliaryVariables)
void recomputeAuxiliaryVariablesFD4_leftDifferences(::exahype2::CellData< double, double > &patchData, int numberOfGridCellsPerPatchPerAxis, int haloSize, int unknowns, int auxiliaryVariables)