11 int numberOfGridCellsPerPatchPerAxis,
14 int auxiliaryVariables,
17 bool evaluateDifferentialSource,
18 bool evaluateAlgebraicSource,
19 bool copyOldTimeStepAndScaleWithTimeStepSize,
20 DifferentialSourceTermVariant variant,
22 NonconservativeProduct DifferentialSource,
23 Source AlgebraicSource
29 bool evaluateKODissipation = KOSigma>0.0;
34 logDebug(
"timeStep_patchwise_heap_functors(...)",
"size of temp flux field=" << QOutEnumerator.size() );
37 double* tempFluxZ = (evaluateFlux and Dimensions==3) ? tarch::allocateMemory<double>( QOutEnumerator.size(),
tarch::MemoryLocation::Heap ) : nullptr;
38 double* tempDifferentialSourceX = evaluateDifferentialSource ? tarch::allocateMemory<double>( QOutEnumerator.size(),
tarch::MemoryLocation::Heap ) : nullptr;
39 double* tempDifferentialSourceY = evaluateDifferentialSource ? tarch::allocateMemory<double>( QOutEnumerator.size(),
tarch::MemoryLocation::Heap ) : nullptr;
40 double* tempDifferentialSourceZ = (evaluateDifferentialSource and Dimensions==3) ? tarch::allocateMemory<double>( QOutEnumerator.size(),
tarch::MemoryLocation::Heap ) : nullptr;
41 double* tempKODissipationX = evaluateKODissipation ? tarch::allocateMemory<double>( QOutEnumerator.size(),
tarch::MemoryLocation::Heap ) : nullptr;
42 double* tempKODissipationY = evaluateKODissipation ? tarch::allocateMemory<double>( QOutEnumerator.size(),
tarch::MemoryLocation::Heap ) : nullptr;
43 double* tempKODissipationZ = (evaluateKODissipation and Dimensions==3) ? tarch::allocateMemory<double>( QOutEnumerator.size(),
tarch::MemoryLocation::Heap ) : nullptr;
45 for (
int patchIndex=0; patchIndex<patchData.
numberOfCells; patchIndex++) {
46 const double timeStepSize = copyOldTimeStepAndScaleWithTimeStepSize ? patchData.
dt[patchIndex] : 1.0;
49 if ( Dimensions==3 and copyOldTimeStepAndScaleWithTimeStepSize ) {
50 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
51 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
52 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++)
53 for (
int unknown=0; unknown<
unknowns; unknown++) {
55 patchData.
QIn[patchIndex],
58 gridCellIndex3d(x,y,z),
60 patchData.
QOut[patchIndex],
65 else if (Dimensions==3 and not copyOldTimeStepAndScaleWithTimeStepSize){
66 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
67 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
68 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++)
70 for (
int unknown=0; unknown<
unknowns; unknown++) {
73 gridCellIndex3d(x,y,z),
75 patchData.
QOut[patchIndex],
81 else if (Dimensions==2 and copyOldTimeStepAndScaleWithTimeStepSize) {
82 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
83 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
84 for (
int unknown=0; unknown<
unknowns; unknown++) {
86 patchData.
QIn[patchIndex],
91 patchData.
QOut[patchIndex],
97 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
98 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++){
99 for (
int unknown=0; unknown<
unknowns; unknown++) {
102 gridCellIndex2d(x,y),
104 patchData.
QOut[patchIndex],
114 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
115 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
116 internal::computeAuxiliaryVariables_LoopBody(
117 patchData.
QIn[patchIndex],
122 gridCellIndex2d(x,y),
128 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
129 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
130 internal::computeAuxiliaryVariables_LoopBody(
131 patchData.
QIn[patchIndex],
136 gridCellIndex2d(x,y),
142 }
else if (Dimensions==3) {
144 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
145 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
146 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
147 internal::computeAuxiliaryVariables_LoopBody(
148 patchData.
QIn[patchIndex],
153 gridCellIndex3d(x,y,z),
159 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
160 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
161 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
162 internal::computeAuxiliaryVariables_LoopBody(
163 patchData.
QIn[patchIndex],
168 gridCellIndex3d(x,y,z),
174 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
175 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
176 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
177 internal::computeAuxiliaryVariables_LoopBody(
178 patchData.
QIn[patchIndex],
183 gridCellIndex3d(x,y,z),
194 if (Dimensions==2 and evaluateAlgebraicSource) {
195 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
196 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
198 patchData.
QIn[patchIndex],
204 gridCellIndex2d(x,y),
205 patchData.
t[patchIndex],
207 patchData.
QOut[patchIndex],
212 else if (Dimensions==3 and evaluateAlgebraicSource) {
213 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
214 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
215 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
217 patchData.
QIn[patchIndex],
223 gridCellIndex3d(x,y,z),
224 patchData.
t[patchIndex],
226 patchData.
QOut[patchIndex],
233 if (evaluateFlux and Dimensions==2) {
234 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
235 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
236 internal::computeFlux_LoopBody(
237 patchData.
QIn[patchIndex],
243 gridCellIndex2d(x,y),
244 patchData.
t[patchIndex],
251 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
252 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
253 internal::computeFlux_LoopBody(
254 patchData.
QIn[patchIndex],
260 gridCellIndex2d(x,y),
261 patchData.
t[patchIndex],
268 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
269 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
270 for (
int unknown=0; unknown<
unknowns; unknown++) {
272 internal::updateSolutionWithFlux_LoopBody(
273 tempFluxX, tempFluxY, tempFluxZ,
278 gridCellIndex2d(x,y),
281 *(patchData.
QOut + patchIndex),
286 else if (evaluateFlux and Dimensions==3) {
287 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
288 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
289 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
290 internal::computeFlux_LoopBody(
291 patchData.
QIn[patchIndex],
297 gridCellIndex3d(x,y,z),
298 patchData.
t[patchIndex],
305 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
306 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
307 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
308 internal::computeFlux_LoopBody(
309 patchData.
QIn[patchIndex],
315 gridCellIndex3d(x,y,z),
316 patchData.
t[patchIndex],
323 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
324 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
325 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
326 internal::computeFlux_LoopBody(
327 patchData.
QIn[patchIndex],
333 gridCellIndex3d(x,y,z),
334 patchData.
t[patchIndex],
342 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
343 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
344 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++)
345 for (
int unknown=0; unknown<
unknowns; unknown++) {
346 internal::updateSolutionWithFlux_LoopBody(
347 tempFluxX, tempFluxY, tempFluxZ,
352 gridCellIndex3d(x,y,z),
355 *(patchData.
QOut + patchIndex),
362 if (evaluateDifferentialSource and Dimensions==2) {
363 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
364 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
365 internal::computeDifferentialSourceTerm_LoopBody(
366 patchData.
QIn[patchIndex],
372 gridCellIndex2d(x,y),
373 patchData.
t[patchIndex],
376 tempDifferentialSourceX,
381 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
382 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
383 internal::computeDifferentialSourceTerm_LoopBody(
384 patchData.
QIn[patchIndex],
390 gridCellIndex2d(x,y),
391 patchData.
t[patchIndex],
394 tempDifferentialSourceY,
399 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
400 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
401 for (
int unknown=0; unknown<
unknowns; unknown++) {
402 internal::updateSolutionWithDifferentialSourceTerm_LoopBody(
403 tempDifferentialSourceX, tempDifferentialSourceY, tempDifferentialSourceZ,
408 gridCellIndex2d(x,y),
411 *(patchData.
QOut + patchIndex),
416 else if (evaluateDifferentialSource and Dimensions==3) {
417 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
418 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
419 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
420 internal::computeDifferentialSourceTerm_LoopBody(
421 patchData.
QIn[patchIndex],
427 gridCellIndex3d(x,y,z),
428 patchData.
t[patchIndex],
431 tempDifferentialSourceX,
436 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
437 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
438 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
439 internal::computeDifferentialSourceTerm_LoopBody(
440 patchData.
QIn[patchIndex],
446 gridCellIndex3d(x,y,z),
447 patchData.
t[patchIndex],
450 tempDifferentialSourceY,
455 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
456 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
457 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
458 internal::computeDifferentialSourceTerm_LoopBody(
459 patchData.
QIn[patchIndex],
465 gridCellIndex3d(x,y,z),
466 patchData.
t[patchIndex],
469 tempDifferentialSourceZ,
474 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
475 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
476 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++)
477 for (
int unknown=0; unknown<
unknowns; unknown++) {
478 internal::updateSolutionWithDifferentialSourceTerm_LoopBody(
479 tempDifferentialSourceX, tempDifferentialSourceY, tempDifferentialSourceZ,
484 gridCellIndex3d(x,y,z),
487 *(patchData.
QOut + patchIndex),
494 if (evaluateKODissipation and Dimensions==2) {
495 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
496 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
497 internal::computeKreissOligerDissipationTerm_LoopBody(
498 patchData.
QIn[patchIndex],
503 gridCellIndex2d(x,y),
504 patchData.
t[patchIndex],
511 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
512 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++) {
513 internal::computeKreissOligerDissipationTerm_LoopBody(
514 patchData.
QIn[patchIndex],
519 gridCellIndex2d(x,y),
520 patchData.
t[patchIndex],
527 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
528 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
529 for (
int unknown=0; unknown<
unknowns; unknown++) {
530 internal::updateSolutionWithKODissipationTerm_LoopBody(
531 KOSigma, tempKODissipationX, tempKODissipationY, tempKODissipationZ,
536 gridCellIndex2d(x,y),
539 *(patchData.
QOut + patchIndex),
544 else if (evaluateKODissipation and Dimensions==3) {
545 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
546 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
547 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
548 internal::computeKreissOligerDissipationTerm_LoopBody(
549 patchData.
QIn[patchIndex],
554 gridCellIndex3d(x,y,z),
555 patchData.
t[patchIndex],
562 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
563 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
564 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
565 internal::computeKreissOligerDissipationTerm_LoopBody(
566 patchData.
QIn[patchIndex],
571 gridCellIndex3d(x,y,z),
572 patchData.
t[patchIndex],
579 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
580 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
581 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++) {
582 internal::computeKreissOligerDissipationTerm_LoopBody(
583 patchData.
QIn[patchIndex],
588 gridCellIndex3d(x,y,z),
589 patchData.
t[patchIndex],
596 for (
int x = 0;
x < numberOfGridCellsPerPatchPerAxis;
x++)
597 for (
int y = 0;
y < numberOfGridCellsPerPatchPerAxis;
y++)
598 for (
int z = 0;
z < numberOfGridCellsPerPatchPerAxis;
z++)
599 for (
int unknown=0; unknown<
unknowns; unknown++) {
600 internal::updateSolutionWithKODissipationTerm_LoopBody(
601 KOSigma, tempKODissipationX, tempKODissipationY, tempKODissipationZ,
606 gridCellIndex3d(x,y,z),
609 *(patchData.
QOut + patchIndex),
#define assertionEquals(lhs, rhs)
#define logDebug(methodName, logMacroMessageStream)
tarch::logging::Log _log("exahype2::fv")
void timeStep_patchwise_heap_functors(::exahype2::CellData< double, double > &patchData, int numberOfGridCellsPerPatchPerAxis, int haloSize, int unknowns, int auxiliaryVariables, double KOSigma, bool evaluateFlux, bool evaluateDifferentialSource, bool evaluateAlgebraicSource, bool copyOldTimeStepAndScaleWithTimeStepSize, DifferentialSourceTermVariant variant, Flux flux, NonconservativeProduct DifferentialSource, Source AlgebraicSource)
Fourth-order Finite Differences.
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.
void freeMemory(void *data, MemoryLocation location, int device=accelerator::Device::HostDevice)
Free memory.
@ Heap
Create data on the heap of the local device.
Representation of a number of cells which contains all information that's required to process the sto...
outType ** QOut
Out values.
inType ** QIn
QIn may not be const, as some kernels delete it straightaway once the input data has been handled.
const int numberOfCells
As we store data as SoA, we have to know how big the actual arrays are.
tarch::la::Vector< Dimensions, double > * cellCentre
tarch::la::Vector< Dimensions, double > * cellSize
Array of struct enumerator.