23 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch;
24 const int numberOfPatches = 3 * 3;
26 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
27 * numberOfDoFsPerAxisInPatch;
28 const int numberOfPatches = 3 * 3 * 3;
32 patchSize * numberOfPatches,
37 dfor3(patchIndex)
dfor(volumeIndex, numberOfDoFsPerAxisInPatch) {
39 sourceCell = (volumeIndex + patchIndex * numberOfDoFsPerAxisInPatch) / 3;
42 numberOfDoFsPerAxisInPatch
44 (*result)(currentRow, sourceCellLinearised) = 1.0;
50 "createPiecewiseConstantInterpolationMatrix(int)",
51 "created new volumetric matrix for "
52 << numberOfDoFsPerAxisInPatch <<
": " << result->
toString()
59 [[maybe_unused]]
int numberOfDoFsPerAxisInPatch,
60 [[maybe_unused]]
int normal,
61 [[maybe_unused]]
int overlap
68 numberOfDoFsPerAxisInPatch,
76 int numberOfDoFsPerAxisInPatch,
94 pattern = numberOfDoFsPerAxisInPatch;
97 pattern = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch;
101 P->insertEmptyColumns(pattern, pattern, pattern);
102 P->replicateRows(pattern, 2, pattern,
false);
104 "createInterpolationMatrixFrom1dTemplateByInsertingZeroColsAndRows(...)",
105 "matrix for normal=" << normal <<
": " <<
P->toString()
113 int numberOfDoFsPerAxisInPatch,
131 pattern = numberOfDoFsPerAxisInPatch;
134 pattern = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch;
143 P->replicateCols(pattern, 2, 0,
false);
144 P->replicateRows(pattern, 2, 0,
false);
146 "createInterpolationMatrixFrom1dTemplateByLinearInterpolationAlongNormal(...)",
147 "matrix for normal=" << normal <<
": " <<
P->toString()
154 int numberOfDoFsPerAxisInPatch,
156 bool extrapolateLinearly,
157 bool interpolateLinearlyBetweenRealAndRestrictedVolumes
162 {{1.0 / 3.0, 2.0 / 3.0, 0.0},
163 {0.0, 3.0 / 3.0, 0.0},
164 {0.0, 2.0 / 3.0, 1.0 / 3.0}}
168 P1d.removeColumn(numberOfDoFsPerAxisInPatch);
170 if (extrapolateLinearly) {
171 P1d(0, 0) = 2.0 / 3.0 + 1.0 / 3.0 * 2.0;
172 P1d(0, 1) = -1.0 / 3.0;
174 numberOfDoFsPerAxisInPatch * 3 - 1,
175 numberOfDoFsPerAxisInPatch - 1
176 ) = 2.0 / 3.0 + 1.0 / 3.0 * 2.0;
178 numberOfDoFsPerAxisInPatch * 3 - 1,
179 numberOfDoFsPerAxisInPatch - 2
185 numberOfDoFsPerAxisInPatch * 3 - 1,
186 numberOfDoFsPerAxisInPatch - 1
189 numberOfDoFsPerAxisInPatch * 3 - 1,
190 numberOfDoFsPerAxisInPatch - 2
195 "createLinearInterpolationMatrix(...)",
196 "1d matrix: " << P1d.toString()
199 if (interpolateLinearlyBetweenRealAndRestrictedVolumes) {
202 numberOfDoFsPerAxisInPatch,
208 numberOfDoFsPerAxisInPatch,
216 int numberOfDoFsPerAxisInPatch,
217 bool extrapolateLinearly
220 "createLinearInterpolationMatrix(...)",
221 numberOfDoFsPerAxisInPatch
226 {{1.0 / 3.0, 2.0 / 3.0, 0.0},
227 {0.0, 3.0 / 3.0, 0.0},
228 {0.0, 2.0 / 3.0, 1.0 / 3.0}}
232 P1d.removeColumn(numberOfDoFsPerAxisInPatch);
234 if (extrapolateLinearly) {
235 P1d(0, 0) = 2.0 / 3.0 + 1.0 / 3.0 * 2.0;
236 P1d(0, 1) = -1.0 / 3.0;
238 numberOfDoFsPerAxisInPatch * 3 - 1,
239 numberOfDoFsPerAxisInPatch - 1
240 ) = 2.0 / 3.0 + 1.0 / 3.0 * 2.0;
242 numberOfDoFsPerAxisInPatch * 3 - 1,
243 numberOfDoFsPerAxisInPatch - 2
249 numberOfDoFsPerAxisInPatch * 3 - 1,
250 numberOfDoFsPerAxisInPatch - 1
253 numberOfDoFsPerAxisInPatch * 3 - 1,
254 numberOfDoFsPerAxisInPatch - 2
259 "createLinearInterpolationMatrix(...)",
260 "1d interpolation matrix: " << P1d.toString(
true)
265 "createLinearInterpolationMatrix(...)",
266 "2d interpolation matrix: " << P2d.
toString(
true)
269 logTraceOut(
"createLinearInterpolationMatrix(...)");
280 int numberOfDoFsPerAxisInPatch,
283 const double* __restrict__ fineGridCellValuesLeft,
284 const double* __restrict__ fineGridCellValuesRight,
285 double* fineGridFaceValues
288 "projectInterpolatedFineCellsOnHaloLayer_AoS(...)",
290 numberOfDoFsPerAxisInPatch,
294 const int normal = marker.getSelectedFaceNumber() % Dimensions;
296 dfore(kFine, numberOfDoFsPerAxisInPatch, normal, 0) {
297 for (
int iFine = 0; iFine < overlap; iFine++) {
301 fineVolumeLeftDest(normal) = iFine;
302 fineVolumeLeftSrc(normal) = numberOfDoFsPerAxisInPatch - overlap + iFine;
307 fineVolumeRightDest(normal) = iFine + overlap;
308 fineVolumeRightSrc(normal) = iFine;
312 numberOfDoFsPerAxisInPatch,
318 numberOfDoFsPerAxisInPatch,
324 numberOfDoFsPerAxisInPatch
328 numberOfDoFsPerAxisInPatch
331 for (
int j = 0; j < unknowns; j++) {
332 fineGridFaceValues[fineVolumeLeftDestLinearised * unknowns + j]
333 = fineGridCellValuesLeft[fineVolumeLeftSrcLinearised * unknowns + j];
334 fineGridFaceValues[fineVolumeRightDestLinearised * unknowns + j]
335 = fineGridCellValuesRight
336 [fineVolumeRightSrcLinearised * unknowns + j];
341 logTraceOut(
"projectInterpolatedFineCellsOnHaloLayer_AoS(...)");
351 int numberOfDoFsPerAxisInPatch,
354 const double* __restrict__ coarseGridFaceValues,
355 double* __restrict__ fineGridFaceValues
358 "interpolateHaloLayer_AoS_piecewise_constant(...)",
360 numberOfDoFsPerAxisInPatch,
365 const int normal = marker.getSelectedFaceNumber() % Dimensions;
369 key(numberOfDoFsPerAxisInPatch, overlap, normal);
372 if (faceInterpolationMap.count(key) == 0) {
373 faceInterpolationMap[key] = internal::
374 createPiecewiseConstantInterpolationMatrix(
375 numberOfDoFsPerAxisInPatch,
384 const int patchSize = numberOfDoFsPerAxisInPatch * 2 * overlap;
386 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
391 "interpolateHaloLayer_AoS_piecewise_constant(...)",
392 marker.toString() <<
": " <<
P->toString()
395 P->batchedMultiplyAoS(
397 coarseGridFaceValues,
401 marker.getRelativePositionWithinFatherCell(),
406 logTraceOut(
"interpolateHaloLayer_AoS_piecewise_constant(...)");
411 int numberOfDoFsPerAxisInPatch,
414 const double* __restrict__ coarseGridCellValues,
415 const double* __restrict__ coarseGridFaceValues,
416 double* __restrict__ fineGridFaceValues
419 "interpolateHaloLayer_AoS_piecewise_constant(...)",
421 numberOfDoFsPerAxisInPatch,
426 if (marker.isInteriorFaceWithinPatch()) {
428 const int patchSize = numberOfDoFsPerAxisInPatch
429 * numberOfDoFsPerAxisInPatch;
431 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
432 * numberOfDoFsPerAxisInPatch;
435 double* leftAdjacentPatchData = tarch::allocateMemory<double>(
436 patchSize * unknowns,
439 double* rightAdjacentPatchData = tarch::allocateMemory<double>(
440 patchSize * unknowns,
445 leftAdjacentPatchIndex = marker.getRelativePositionWithinFatherCell();
447 rightAdjacentPatchIndex = marker.getRelativePositionWithinFatherCell();
448 leftAdjacentPatchIndex(marker.getSelectedFaceNumber() % Dimensions)--;
450 internal::interpolateCell_AoS_piecewise_constant(
451 leftAdjacentPatchIndex,
452 numberOfDoFsPerAxisInPatch,
454 coarseGridCellValues,
455 leftAdjacentPatchData
457 internal::interpolateCell_AoS_piecewise_constant(
458 rightAdjacentPatchIndex,
459 numberOfDoFsPerAxisInPatch,
461 coarseGridCellValues,
462 rightAdjacentPatchData
465 internal::projectInterpolatedFineCellsOnHaloLayer_AoS(
467 numberOfDoFsPerAxisInPatch,
470 leftAdjacentPatchData,
471 rightAdjacentPatchData,
480 numberOfDoFsPerAxisInPatch,
483 coarseGridFaceValues,
488 logTraceOut(
"interpolateHaloLayer_AoS_piecewise_constant(...)");
493 int numberOfDoFsPerAxisInPatch,
495 const double* __restrict__ coarseGridCellValues,
496 double* __restrict__ fineGridCellValues
499 "interpolateCell_AoS_piecewise_constant(...)",
501 numberOfDoFsPerAxisInPatch,
505 internal::interpolateCell_AoS_piecewise_constant(
506 marker.getRelativePositionWithinFatherCell(),
507 numberOfDoFsPerAxisInPatch,
509 coarseGridCellValues,
513 logTraceOut(
"interpolateCell_AoS_piecewise_constant(...)");
518 int numberOfDoFsPerAxisInPatch,
520 const double* __restrict__ coarseGridCellValues,
521 double* __restrict__ fineGridCellValues
523 static internal::CellInterpolationMap cellInterpolationMap;
524 internal::CellInterpolationOperatorKey key(numberOfDoFsPerAxisInPatch);
527 if (cellInterpolationMap.count(key) == 0) {
528 cellInterpolationMap[key] = internal::
529 createPiecewiseConstantInterpolationMatrix(numberOfDoFsPerAxisInPatch);
535 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch;
537 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
538 * numberOfDoFsPerAxisInPatch;
543 coarseGridCellValues,
546 serialiseMarkerIn3x3PatchAssembly(
547 relativePositionWithinFatherCell,
548 numberOfDoFsPerAxisInPatch
561 int numberOfDoFsPerAxisInPatch,
564 const double* __restrict__ coarseGridFaceValues,
565 double* __restrict__ fineGridFaceValues
568 "interpolateHaloLayer_AoS_linear_with_constant_extrapolation(...)",
570 numberOfDoFsPerAxisInPatch,
575 const int normal = marker.getSelectedFaceNumber() % Dimensions;
579 key(numberOfDoFsPerAxisInPatch, overlap, normal);
584 if (faceInterpolationMap.count(key) == 0) {
585 faceInterpolationMap[key] = internal::createLinearInterpolationMatrix(
586 numberOfDoFsPerAxisInPatch,
596 const int patchSize = numberOfDoFsPerAxisInPatch * 2 * overlap;
598 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
603 "interpolateHaloLayer_AoS_linear_with_constant_extrapolation(...)",
604 marker.toString() <<
": " <<
P->toString()
607 P->batchedMultiplyAoS(
609 coarseGridFaceValues,
613 marker.getRelativePositionWithinFatherCell(),
618 logTraceOut(
"interpolateHaloLayer_AoS_linear_with_constant_extrapolation(...)"
625 int numberOfDoFsPerAxisInPatch,
628 const double* __restrict__ coarseGridCellValues,
629 const double* __restrict__ coarseGridFaceValues,
630 double* __restrict__ fineGridFaceValues
633 "interpolateHaloLayer_AoS_linear_with_constant_extrapolation(...)",
635 numberOfDoFsPerAxisInPatch,
640 if (marker.isInteriorFaceWithinPatch()) {
642 const int patchSize = numberOfDoFsPerAxisInPatch
643 * numberOfDoFsPerAxisInPatch;
645 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
646 * numberOfDoFsPerAxisInPatch;
649 double* leftAdjacentPatchData = tarch::allocateMemory<double>(
650 patchSize * unknowns,
653 double* rightAdjacentPatchData = tarch::allocateMemory<double>(
654 patchSize * unknowns,
659 leftAdjacentPatchIndex = marker.getRelativePositionWithinFatherCell();
661 rightAdjacentPatchIndex = marker.getRelativePositionWithinFatherCell();
662 leftAdjacentPatchIndex(marker.getSelectedFaceNumber() % Dimensions)--;
664 internal::interpolateCell_AoS_linear(
665 leftAdjacentPatchIndex,
666 numberOfDoFsPerAxisInPatch,
668 coarseGridCellValues,
669 leftAdjacentPatchData,
672 internal::interpolateCell_AoS_linear(
673 rightAdjacentPatchIndex,
674 numberOfDoFsPerAxisInPatch,
676 coarseGridCellValues,
677 rightAdjacentPatchData,
681 internal::projectInterpolatedFineCellsOnHaloLayer_AoS(
683 numberOfDoFsPerAxisInPatch,
686 leftAdjacentPatchData,
687 rightAdjacentPatchData,
696 numberOfDoFsPerAxisInPatch,
699 coarseGridFaceValues,
704 logTraceOut(
"interpolateHaloLayer_AoS_linear_with_constant_extrapolation(...)"
711 int numberOfDoFsPerAxisInPatch,
713 const double* __restrict__ coarseGridCellValues,
714 double* __restrict__ fineGridCellValues
717 "interpolateCell_AoS_linear_with_constant_extrapolation(...)",
719 numberOfDoFsPerAxisInPatch,
723 internal::interpolateCell_AoS_linear(
724 marker.getRelativePositionWithinFatherCell(),
725 numberOfDoFsPerAxisInPatch,
727 coarseGridCellValues,
732 logTraceOut(
"interpolateCell_AoS_linear_with_constant_extrapolation(...)");
738 int numberOfDoFsPerAxisInPatch,
741 const double* __restrict__ coarseGridFaceValues,
742 double* __restrict__ fineGridFaceValues
745 "interpolateHaloLayer_AoS_linear_with_linear_extrapolation(...)",
747 numberOfDoFsPerAxisInPatch,
752 const int normal = marker.getSelectedFaceNumber() % Dimensions;
756 key(numberOfDoFsPerAxisInPatch, overlap, normal);
761 if (faceInterpolationMap.count(key) == 0) {
762 faceInterpolationMap[key] = internal::createLinearInterpolationMatrix(
763 numberOfDoFsPerAxisInPatch,
773 const int patchSize = numberOfDoFsPerAxisInPatch * 2 * overlap;
775 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
780 "interpolateHaloLayer_AoS_linear_with_constant_extrapolation(...)",
781 marker.toString() <<
": " <<
P->toString()
784 P->batchedMultiplyAoS(
786 coarseGridFaceValues,
790 marker.getRelativePositionWithinFatherCell(),
795 logTraceOut(
"interpolateHaloLayer_AoS_linear_with_linear_extrapolation(...)");
801 int numberOfDoFsPerAxisInPatch,
804 const double* __restrict__ coarseGridCellValues,
805 const double* __restrict__ coarseGridFaceValues,
806 double* __restrict__ fineGridFaceValues
809 "interpolateHaloLayer_AoS_linear_with_linear_extrapolation(...)",
811 numberOfDoFsPerAxisInPatch,
816 if (marker.isInteriorFaceWithinPatch()) {
818 const int patchSize = numberOfDoFsPerAxisInPatch
819 * numberOfDoFsPerAxisInPatch;
821 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
822 * numberOfDoFsPerAxisInPatch;
825 double* leftAdjacentPatchData = tarch::allocateMemory<double>(
826 patchSize * unknowns,
829 double* rightAdjacentPatchData = tarch::allocateMemory<double>(
830 patchSize * unknowns,
835 leftAdjacentPatchIndex = marker.getRelativePositionWithinFatherCell();
837 rightAdjacentPatchIndex = marker.getRelativePositionWithinFatherCell();
838 leftAdjacentPatchIndex(marker.getSelectedFaceNumber() % Dimensions)--;
840 internal::interpolateCell_AoS_linear(
841 leftAdjacentPatchIndex,
842 numberOfDoFsPerAxisInPatch,
844 coarseGridCellValues,
845 leftAdjacentPatchData,
848 internal::interpolateCell_AoS_linear(
849 rightAdjacentPatchIndex,
850 numberOfDoFsPerAxisInPatch,
852 coarseGridCellValues,
853 rightAdjacentPatchData,
857 internal::projectInterpolatedFineCellsOnHaloLayer_AoS(
859 numberOfDoFsPerAxisInPatch,
862 leftAdjacentPatchData,
863 rightAdjacentPatchData,
872 numberOfDoFsPerAxisInPatch,
875 coarseGridFaceValues,
880 logTraceOut(
"interpolateHaloLayer_AoS_linear_with_linear_extrapolation(...)");
886 int numberOfDoFsPerAxisInPatch,
888 const double* __restrict__ coarseGridCellValues,
889 double* __restrict__ fineGridCellValues
892 "interpolateCell_AoS_linear_with_linear_extrapolation(...)",
894 numberOfDoFsPerAxisInPatch,
898 internal::interpolateCell_AoS_linear(
899 marker.getRelativePositionWithinFatherCell(),
900 numberOfDoFsPerAxisInPatch,
902 coarseGridCellValues,
907 logTraceOut(
"interpolateCell_AoS_linear_with_linear_extrapolation(...)");
913 int numberOfDoFsPerAxisInPatch,
916 const double* __restrict__ coarseGridFaceValues,
917 double* __restrict__ fineGridFaceValues
920 "interpolateHaloLayer_AoS_linear_with_constant_extrapolation_and_linear_normal_interpolation(...)",
922 numberOfDoFsPerAxisInPatch,
927 const int normal = marker.getSelectedFaceNumber() % Dimensions;
931 key(numberOfDoFsPerAxisInPatch, overlap, normal);
936 if (faceInterpolationMap.count(key) == 0) {
937 faceInterpolationMap[key] = internal::createLinearInterpolationMatrix(
938 numberOfDoFsPerAxisInPatch,
948 const int patchSize = numberOfDoFsPerAxisInPatch * 2 * overlap;
950 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
955 "interpolateHaloLayer_AoS_linear_with_constant_extrapolation_and_linear_normal_interpolation(...)",
956 marker.toString() <<
": " <<
P->toString()
959 P->batchedMultiplyAoS(
961 coarseGridFaceValues,
965 marker.getRelativePositionWithinFatherCell(),
971 "interpolateHaloLayer_AoS_linear_with_constant_extrapolation_and_linear_normal_interpolation(...)"
978 int numberOfDoFsPerAxisInPatch,
981 const double* __restrict__ coarseGridCellValues,
982 const double* __restrict__ coarseGridFaceValues,
983 double* __restrict__ fineGridFaceValues
986 "interpolateHaloLayer_AoS_linear_with_constant_extrapolation_and_linear_normal_interpolation(...)",
988 numberOfDoFsPerAxisInPatch,
993 if (marker.isInteriorFaceWithinPatch()) {
995 const int patchSize = numberOfDoFsPerAxisInPatch
996 * numberOfDoFsPerAxisInPatch;
998 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
999 * numberOfDoFsPerAxisInPatch;
1002 double* leftAdjacentPatchData = tarch::allocateMemory<double>(
1003 patchSize * unknowns,
1006 double* rightAdjacentPatchData = tarch::allocateMemory<double>(
1007 patchSize * unknowns,
1012 leftAdjacentPatchIndex = marker.getRelativePositionWithinFatherCell();
1014 rightAdjacentPatchIndex = marker.getRelativePositionWithinFatherCell();
1015 leftAdjacentPatchIndex(marker.getSelectedFaceNumber() % Dimensions)--;
1017 internal::interpolateCell_AoS_linear(
1018 leftAdjacentPatchIndex,
1019 numberOfDoFsPerAxisInPatch,
1021 coarseGridCellValues,
1022 leftAdjacentPatchData,
1025 internal::interpolateCell_AoS_linear(
1026 rightAdjacentPatchIndex,
1027 numberOfDoFsPerAxisInPatch,
1029 coarseGridCellValues,
1030 rightAdjacentPatchData,
1034 internal::projectInterpolatedFineCellsOnHaloLayer_AoS(
1036 numberOfDoFsPerAxisInPatch,
1039 leftAdjacentPatchData,
1040 rightAdjacentPatchData,
1049 numberOfDoFsPerAxisInPatch,
1052 coarseGridFaceValues,
1058 "interpolateHaloLayer_AoS_linear_with_constant_extrapolation_and_linear_normal_interpolation(...)"
1065 int numberOfDoFsPerAxisInPatch,
1067 const double* __restrict__ coarseGridCellValues,
1068 double* __restrict__ fineGridCellValues
1071 "interpolateCell_AoS_linear_with_constant_extrapolation_and_linear_normal_interpolation(...)",
1073 numberOfDoFsPerAxisInPatch,
1077 internal::interpolateCell_AoS_linear(
1078 marker.getRelativePositionWithinFatherCell(),
1079 numberOfDoFsPerAxisInPatch,
1081 coarseGridCellValues,
1087 "interpolateCell_AoS_linear_with_constant_extrapolation_and_linear_normal_interpolation(...)"
1094 int numberOfDoFsPerAxisInPatch,
1097 const double* __restrict__ coarseGridFaceValues,
1098 double* __restrict__ fineGridFaceValues
1101 "interpolateHaloLayer_AoS_linear_with_linear_extrapolation_and_linear_normal_interpolation(...)",
1103 numberOfDoFsPerAxisInPatch,
1108 const int normal = marker.getSelectedFaceNumber() % Dimensions;
1112 key(numberOfDoFsPerAxisInPatch, overlap, normal);
1117 if (faceInterpolationMap.count(key) == 0) {
1118 faceInterpolationMap[key] = internal::createLinearInterpolationMatrix(
1119 numberOfDoFsPerAxisInPatch,
1129 const int patchSize = numberOfDoFsPerAxisInPatch * 2 * overlap;
1131 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
1136 "interpolateHaloLayer_AoS_linear_with_constant_extrapolation_and_linear_normal_interpolation(...)",
1137 marker.toString() <<
": " <<
P->toString()
1140 P->batchedMultiplyAoS(
1142 coarseGridFaceValues,
1146 marker.getRelativePositionWithinFatherCell(),
1152 "interpolateHaloLayer_AoS_linear_with_linear_extrapolation_and_linear_normal_interpolation(...)"
1159 int numberOfDoFsPerAxisInPatch,
1162 const double* __restrict__ coarseGridCellValues,
1163 const double* __restrict__ coarseGridFaceValues,
1164 double* __restrict__ fineGridFaceValues
1167 "interpolateHaloLayer_AoS_linear_with_linear_extrapolation_and_linear_normal_interpolation(...)",
1169 numberOfDoFsPerAxisInPatch,
1174 if (marker.isInteriorFaceWithinPatch()) {
1176 const int patchSize = numberOfDoFsPerAxisInPatch
1177 * numberOfDoFsPerAxisInPatch;
1179 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
1180 * numberOfDoFsPerAxisInPatch;
1183 double* leftAdjacentPatchData = tarch::allocateMemory<double>(
1184 patchSize * unknowns,
1187 double* rightAdjacentPatchData = tarch::allocateMemory<double>(
1188 patchSize * unknowns,
1193 leftAdjacentPatchIndex = marker.getRelativePositionWithinFatherCell();
1195 rightAdjacentPatchIndex = marker.getRelativePositionWithinFatherCell();
1196 leftAdjacentPatchIndex(marker.getSelectedFaceNumber() % Dimensions)--;
1198 internal::interpolateCell_AoS_linear(
1199 leftAdjacentPatchIndex,
1200 numberOfDoFsPerAxisInPatch,
1202 coarseGridCellValues,
1203 leftAdjacentPatchData,
1206 internal::interpolateCell_AoS_linear(
1207 rightAdjacentPatchIndex,
1208 numberOfDoFsPerAxisInPatch,
1210 coarseGridCellValues,
1211 rightAdjacentPatchData,
1215 internal::projectInterpolatedFineCellsOnHaloLayer_AoS(
1217 numberOfDoFsPerAxisInPatch,
1220 leftAdjacentPatchData,
1221 rightAdjacentPatchData,
1230 numberOfDoFsPerAxisInPatch,
1233 coarseGridFaceValues,
1239 "interpolateHaloLayer_AoS_linear_with_linear_extrapolation_and_linear_normal_interpolation(...)"
1246 int numberOfDoFsPerAxisInSourcePatch,
1247 int numberOfDoFsPerAxisInDestinationPatch,
1248 int haloSourcePatch,
1249 int haloDestinationPatch,
1251 const double* __restrict__ sourceValues,
1252 double* __restrict__ destinationValues,
1256 numberOfDoFsPerAxisInDestinationPatch > numberOfDoFsPerAxisInSourcePatch
1259 simtDforWithSchedulerInstructions(
1261 numberOfDoFsPerAxisInDestinationPatch + 2 * haloDestinationPatch,
1263 )
const int baseIndexDestination
1266 numberOfDoFsPerAxisInDestinationPatch + 2 * haloDestinationPatch
1269 for (
int unknown = 0; unknown < unknowns; unknown++) {
1270 destinationValues[baseIndexDestination + unknown] = 0.0;
1273 dfor(sourceVolume, numberOfDoFsPerAxisInSourcePatch + 2 * haloSourcePatch) {
1278 tarch::la::convertScalar<double>(sourceVolume
1284 1.0 / numberOfDoFsPerAxisInDestinationPatch
1286 tarch::la::convertScalar<double>(destinationVolume
1290 int outsidePatchAlongCoordinateAxis = 0;
1291 for (
int d = 0; d < Dimensions; d++) {
1296 if (sourceVolume(d) < haloSourcePatch)
1297 outsidePatchAlongCoordinateAxis++;
1298 if (sourceVolume(d) >= haloSourcePatch + numberOfDoFsPerAxisInSourcePatch)
1299 outsidePatchAlongCoordinateAxis++;
1301 const bool isFromUnitialisedDiagonal = outsidePatchAlongCoordinateAxis > 1;
1303 double weight = 1.0;
1304 for (
int d = 0; d < Dimensions; d++) {
1305 double distanceAlongCoordinateAxis =
std::abs(
1306 normalisedDestinationPosition(d) - normalisedSourcePosition(d)
1308 double h = 1.0 /
static_cast<double>(numberOfDoFsPerAxisInSourcePatch);
1309 distanceAlongCoordinateAxis = 1.0 - distanceAlongCoordinateAxis / h;
1310 weight *= std::max(0.0, distanceAlongCoordinateAxis);
1312#if !defined(SharedSYCL)
1318 if (isFromUnitialisedDiagonal) {
1320 for (
int d = 0; d < Dimensions; d++) {
1321 amendedSourceVolume(d
1322 ) = std::max(amendedSourceVolume(d), haloSourcePatch);
1323 amendedSourceVolume(d) = std::min(
1324 amendedSourceVolume(d),
1325 haloSourcePatch + numberOfDoFsPerAxisInSourcePatch - 1
1331 amendedSourceVolume,
1332 numberOfDoFsPerAxisInSourcePatch + 2 * haloSourcePatch
1335 for (
int unknown = 0; unknown < unknowns; unknown++) {
1336 destinationValues[baseIndexDestination + unknown]
1337 += weight * sourceValues[baseIndexSource + unknown];
1346 int numberOfDoFsPerAxisInSourcePatch,
1347 int numberOfDoFsPerAxisInDestinationPatch,
1348 int haloSourcePatch,
1349 int haloDestinationPatch,
1351 const double* __restrict__ interpolationData,
1352 const int* __restrict__ columnIndices,
1353 const int* __restrict__ rowIndices,
1354 const double* __restrict__ sourceValues,
1355 double* __restrict__ destinationValues,
1359 = (numberOfDoFsPerAxisInDestinationPatch + 2 * haloDestinationPatch)
1360 * (numberOfDoFsPerAxisInDestinationPatch + 2 * haloDestinationPatch)
1361 * (numberOfDoFsPerAxisInDestinationPatch + 2 * haloDestinationPatch);
1363 for (
int row = 0; row < destinationSize; row++) {
1364 for (
int unknown = 0; unknown < unknowns; unknown++) {
1365 destinationValues[row * unknowns + unknown] = 0.0;
1367 for (
int column = rowIndices[row]; column < rowIndices[row + 1]; column++) {
1368 for (
int unknown = 0; unknown < unknowns; unknown++) {
1369 destinationValues[row * unknowns + unknown]
1370 += interpolationData[column]
1371 * sourceValues[columnIndices[column] * unknowns + unknown];
1379 int numberOfDoFsPerAxisInSourcePatch,
1380 int numberOfDoFsPerAxisInDestinationPatch,
1381 int haloSourcePatch,
1382 int haloDestinationPatch,
1384 const double* __restrict__ sourceValues,
1385 double* __restrict__ destinationValues,
1391 double* centerValues =
new double[unknowns];
1392 int numberOfDerivatives = (Dimensions == 2) ? 5 : 9;
1394 dfor(volume, numberOfDoFsPerAxisInSourcePatch + 2) {
1396 sourceVolume = volume
1398 int outsidePatchAlongCoordinateAxis = 0;
1399 for (
int d = 0; d < Dimensions; d++) {
1400 if (sourceVolume(d) < haloSourcePatch || sourceVolume(d) >= numberOfDoFsPerAxisInSourcePatch + haloSourcePatch) {
1401 outsidePatchAlongCoordinateAxis++;
1406 for (
int d = 0; d < Dimensions; d++) {
1407 if (sourceVolume(d) == 0)
1408 stencilOffset(d) = 1;
1409 if (sourceVolume(d) == numberOfDoFsPerAxisInSourcePatch + 2 * haloSourcePatch - 1)
1412 for (
int d1 = 0; d1 < Dimensions; d1++) {
1413 for (
int d2 = d1 + 1; d2 < Dimensions; d2++) {
1414 if (sourceVolume(d1) == haloSourcePatch and sourceVolume(d2) == haloSourcePatch) {
1415 stencilOffset(d1) = 1;
1416 stencilOffset(d2) = 1;
1418 if (sourceVolume(d1) == haloSourcePatch and sourceVolume(d2) == haloSourcePatch + numberOfDoFsPerAxisInSourcePatch - 1) {
1419 stencilOffset(d1) = 1;
1420 stencilOffset(d2) = -1;
1422 if (sourceVolume(d1) == haloSourcePatch + numberOfDoFsPerAxisInSourcePatch - 1 and sourceVolume(d2) == haloSourcePatch) {
1423 stencilOffset(d1) = -1;
1424 stencilOffset(d2) = 1;
1426 if (sourceVolume(d1) == haloSourcePatch + numberOfDoFsPerAxisInSourcePatch - 1 and sourceVolume(d2) == haloSourcePatch + numberOfDoFsPerAxisInSourcePatch - 1) {
1427 stencilOffset(d1) = -1;
1428 stencilOffset(d2) = -1;
1433 if (outsidePatchAlongCoordinateAxis <= 1) {
1434 int stencilSize = 0;
1439 !(offset(0) + stencilOffset(0) != 1
1440 and offset(1) + stencilOffset(1) != 1
1441 and offset(2) + stencilOffset(2) != 1)
1442#elif Dimensions == 2
1443 !(offset(0) + stencilOffset(0) != 1
1444 and offset(1) + stencilOffset(1) != 1)
1447 stencil[stencilSize] = stencilOffset + offset
1450 sourceVolume + offset + stencilOffset
1452 numberOfDoFsPerAxisInSourcePatch + 2 * haloSourcePatch
1460 numberOfDoFsPerAxisInSourcePatch + 2 * haloSourcePatch
1462 for (
int unknown = 0; unknown < unknowns; unknown++) {
1463 centerValues[unknown] = sourceValues[centerIndex * unknowns + unknown];
1467 for (
int k = 0; k < stencilSize; k++) {
1468 for (
int unknown = 0; unknown < unknowns; unknown++) {
1472 ) = sourceValues[indices[k] * unknowns + unknown]
1473 - centerValues[unknown];
1477 for (
int row = 0; row < stencilSize; row++) {
1480 for (
int a = 0;
a < Dimensions;
a++) {
1481 A(row, column) = cell(
a);
1484 for (
int a = 0;
a < Dimensions;
a++) {
1485 for (
int b =
a; b < Dimensions; b++) {
1486 A(row, column) = 0.5 * cell(
a) * cell(b);
1519 ) * numberOfDoFsPerAxisInDestinationPatch
1520 / numberOfDoFsPerAxisInSourcePatch
1525 ) * numberOfDoFsPerAxisInDestinationPatch
1526 / numberOfDoFsPerAxisInSourcePatch
1528 for (
int d = 0; d < Dimensions; d++) {
1529 destinationCorner1(d) = std::max(0, destinationCorner1(d));
1530 destinationCorner2(d) = std::min(
1531 numberOfDoFsPerAxisInDestinationPatch + 2 * haloDestinationPatch,
1532 destinationCorner2(d)
1537 destinationSpan = destinationCorner2 - destinationCorner1;
1538 int destinationDimensionsProduct = 1;
1539 for (
int d = 0; d < Dimensions; d++)
1540 destinationDimensionsProduct *= destinationSpan(d);
1544 = (1.0 / numberOfDoFsPerAxisInDestinationPatch)
1547 = (1.0 / numberOfDoFsPerAxisInSourcePatch)
1550 cornerDisplacement = (normalisedCornerPosition
1551 - normalisedSourcePosition)
1552 * (
double)numberOfDoFsPerAxisInSourcePatch;
1554 double* matrixData =
new double
1555 [destinationDimensionsProduct * numberOfDerivatives];
1558 dfor(localDestinationVolume, destinationSpan) {
1560 displacement = cornerDisplacement
1561 + ((
double)numberOfDoFsPerAxisInSourcePatch
1562 / numberOfDoFsPerAxisInDestinationPatch)
1564 double>(localDestinationVolume);
1566 for (
int a = 0;
a < Dimensions;
a++) {
1567 matrixData[writeIndex] = displacement(
a);
1570 for (
int a = 0;
a < Dimensions;
a++) {
1571 for (
int b =
a; b < Dimensions; b++) {
1572 matrixData[writeIndex] = 0.5 * displacement(
a) * displacement(b);
1579 destinationDimensionsProduct,
1580 numberOfDerivatives,
1585 int destinationVolumeNumber = 0;
1586 dfor(localDestinationVolume, destinationSpan) {
1588 destinationVolume = destinationCorner1 + localDestinationVolume;
1591 numberOfDoFsPerAxisInDestinationPatch + 2 * haloDestinationPatch
1593 for (
int unknown = 0; unknown < unknowns; unknown++) {
1594 destinationValues[destinationIndex * unknowns + unknown]
1595 = centerValues[unknown]
1596 + destinationValuesDelta(destinationVolumeNumber, unknown);
1598 destinationVolumeNumber++;
1602 delete[] centerValues;
1607 int numberOfDoFsPerAxisInSourcePatch,
1608 int numberOfDoFsPerAxisInDestinationPatch,
1609 int haloSourcePatch,
1610 int haloDestinationPatch,
1612 const double* __restrict__ sourceValues,
1613 double* __restrict__ destinationValues,
1617 numberOfDoFsPerAxisInDestinationPatch > numberOfDoFsPerAxisInSourcePatch
1620 simtDforWithSchedulerInstructions(
1622 numberOfDoFsPerAxisInDestinationPatch + 2 * haloDestinationPatch,
1624 )
const int baseIndexDestination
1627 numberOfDoFsPerAxisInDestinationPatch + 2 * haloDestinationPatch
1630 for (
int unknown = 0; unknown < unknowns; unknown++) {
1631 destinationValues[baseIndexDestination + unknown] = 0.0;
1640 int numberOfDoFsPerAxisInPatch,
1642 const double* __restrict__ coarseGridCellValues,
1643 double* __restrict__ fineGridCellValues
1646 "interpolateCell_AoS_linear_with_linear_extrapolation_and_linear_normal_interpolation(...)",
1648 numberOfDoFsPerAxisInPatch,
1652 internal::interpolateCell_AoS_linear(
1653 marker.getRelativePositionWithinFatherCell(),
1654 numberOfDoFsPerAxisInPatch,
1656 coarseGridCellValues,
1662 "interpolateCell_AoS_linear_with_linear_extrapolation_and_linear_normal_interpolation(...)"
1668 int numberOfDoFsPerAxisInPatch,
1670 const double* __restrict__ coarseGridCellValues,
1671 double* __restrict__ fineGridCellValues,
1672 bool extrapolateLinearly
1674 static internal::CellInterpolationMap cellInterpolationMap;
1675 internal::CellInterpolationOperatorKey key(numberOfDoFsPerAxisInPatch);
1678 if (cellInterpolationMap.count(key) == 0) {
1679 cellInterpolationMap[key] = internal::createLinearInterpolationMatrix(
1680 numberOfDoFsPerAxisInPatch,
1688 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch;
1690 const int patchSize = numberOfDoFsPerAxisInPatch * numberOfDoFsPerAxisInPatch
1691 * numberOfDoFsPerAxisInPatch;
1696 coarseGridCellValues,
1699 serialiseMarkerIn3x3PatchAssembly(
1700 relativePositionWithinFatherCell,
1701 numberOfDoFsPerAxisInPatch
1708 int numberOfDoFsPerAxisInPatch,
1711 const double* __restrict__ coarseGridFaceValues,
1712 double* __restrict__ fineGridFaceValues
1714 const int normal =
marker.getSelectedFaceNumber() % Dimensions;
1715 const int i = (normal + 1) % Dimensions;
1717 const int j = (normal + 2) % Dimensions;
1722 ) =
marker.getRelativePositionWithinFatherCell()(
i)
1723 * numberOfDoFsPerAxisInPatch / 3;
1726 ) =
marker.getRelativePositionWithinFatherCell()(
j)
1727 * numberOfDoFsPerAxisInPatch / 3;
1732 ) = ((
marker.getRelativePositionWithinFatherCell()(
i) + 1
1733 ) * numberOfDoFsPerAxisInPatch
1738 ) = ((
marker.getRelativePositionWithinFatherCell()(
j) + 1
1739 ) * numberOfDoFsPerAxisInPatch
1746 ) = (
marker.getRelativePositionWithinFatherCell()(
i)
1747 * numberOfDoFsPerAxisInPatch)
1751 ) = (
marker.getRelativePositionWithinFatherCell()(
j)
1752 * numberOfDoFsPerAxisInPatch)
1757 faceDimensions(normal) = (
overlap - 1) / 3 + 1;
1761 double* centerValues =
new double[
unknowns];
1763 dfor(kCoarse, faceDimensions) {
1766 ) = (
marker.getSelectedFaceNumber() < Dimensions)
1767 ? overlap - kCoarse(normal) - 1
1772 stencilOffset(i) = 1;
1773 if (
center(i) == numberOfDoFsPerAxisInPatch - 1)
1774 stencilOffset(i) = -1;
1777 stencilOffset(j) = 1;
1778 if (
center(j) == numberOfDoFsPerAxisInPatch - 1)
1779 stencilOffset(j) = -1;
1782 int stencilSize = 0;
1787 !(
offset(0) + stencilOffset(0) != 1
1788 and
offset(1) + stencilOffset(1) != 1
1789 and
offset(2) + stencilOffset(2) != 1)
1790#elif Dimensions == 2
1791 !(
offset(0) + stencilOffset(0) != 1
1792 and
offset(1) + stencilOffset(1) != 1)
1798 center + offset + stencilOffset
1800 numberOfDoFsPerAxisInPatch,
1810 numberOfDoFsPerAxisInPatch,
1814 for (
int unknown = 0; unknown <
unknowns; unknown++) {
1815 centerValues[unknown] = coarseGridFaceValues[
index *
unknowns + unknown];
1819 for (
int k = 0;
k < stencilSize;
k++) {
1820 for (
int unknown = 0; unknown <
unknowns; unknown++) {
1824 ) = coarseGridFaceValues[indices[
k] *
unknowns + unknown]
1825 - centerValues[unknown];
1829 int numberOfDerivatives = (Dimensions == 2) ? 5 : 9;
1831 for (
int row = 0;
row < stencilSize;
row++) {
1834 for (
int a = 0;
a < Dimensions;
a++) {
1835 A(row, column) = cell(
a);
1838 for (
int a = 0;
a < Dimensions;
a++) {
1839 for (
int b =
a;
b < Dimensions;
b++) {
1840 A(row, column) = 0.5 * cell(
a) * cell(b);
1847 if (A.rows() >= A.cols()){
1874 if (kCoarse(i) == 0)
1876 ) = (
marker.getRelativePositionWithinFatherCell()(
i)
1877 * numberOfDoFsPerAxisInPatch)
1880 if (kCoarse(j) == 0)
1882 ) = (
marker.getRelativePositionWithinFatherCell()(
j)
1883 * numberOfDoFsPerAxisInPatch)
1887 int modulus = (
marker.getRelativePositionWithinFatherCell()(
i) + 1)
1888 * numberOfDoFsPerAxisInPatch;
1889 if (modulus % 3 != 0)
1890 modulus = modulus % 3;
1893 if (kCoarse(i) == faceDimensions(i) - 1)
1894 fineEnd(i) = modulus;
1897 modulus = (
marker.getRelativePositionWithinFatherCell()(
j) + 1)
1898 * numberOfDoFsPerAxisInPatch;
1899 if (modulus % 3 != 0)
1900 modulus = modulus % 3;
1903 if (kCoarse(j) == faceDimensions(j) - 1)
1904 fineEnd(j) = modulus;
1908 fineDimensions(normal) = std::min(overlap - kCoarse(normal) * 3, 3);
1909 if (fineDimensions(normal) % 3 != 0)
1910 fineDimensions(normal) = fineDimensions(normal) % 3;
1912 fineDimensions(normal) = 3;
1914 int fineDimensionsProduct = fineDimensions(normal) * fineDimensions(i)
1915 * fineDimensions(j);
1916#elif Dimensions == 2
1917 int fineDimensionsProduct = fineDimensions(normal) * fineDimensions(i);
1920 fineMatrix(fineDimensionsProduct, numberOfDerivatives);
1923 dfor(kFine, fineDimensions) {
1927 for (
int a = 0;
a < Dimensions;
a++) {
1928 fineMatrix(row, column) = (1.0 / 3.0) * cell(
a);
1931 for (
int a = 0;
a < Dimensions;
a++) {
1932 for (
int b =
a;
b < Dimensions;
b++) {
1933 fineMatrix(row, column) = (1.0 / 18.0) * cell(
a) * cell(b);
1941 int fineCellNumber = 0;
1943 fineCorner = kCoarse * 3 + fineStart - fineDataStart;
1945 ) = (
marker.getSelectedFaceNumber() < Dimensions)
1946 ? (kCoarse(normal) * 3)
1947 :
overlap + (kCoarse(normal) * 3);
1949 dfor(kFine, fineDimensions) {
1953 numberOfDoFsPerAxisInPatch,
1958 for (
int unknown = 0; unknown <
unknowns; unknown++) {
1960 = centerValues[unknown] + fineValues(fineCellNumber, unknown);
1966 delete[] centerValues;
1972 int numberOfDoFsPerAxisInPatch,
1975 const double* __restrict__ coarseGridFaceValues,
1976 double* __restrict__ fineGridFaceValues
1978 const int normal =
marker.getSelectedFaceNumber() % Dimensions;
1979 const int i = (normal + 1) % Dimensions;
1981 const int j = (normal + 2) % Dimensions;
1986 ) =
marker.getRelativePositionWithinFatherCell()(
i)
1987 * numberOfDoFsPerAxisInPatch / 3;
1990 ) =
marker.getRelativePositionWithinFatherCell()(
j)
1991 * numberOfDoFsPerAxisInPatch / 3;
1996 ) = ((
marker.getRelativePositionWithinFatherCell()(
i) + 1
1997 ) * numberOfDoFsPerAxisInPatch
2002 ) = ((
marker.getRelativePositionWithinFatherCell()(
j) + 1
2003 ) * numberOfDoFsPerAxisInPatch
2010 ) = (
marker.getRelativePositionWithinFatherCell()(
i)
2011 * numberOfDoFsPerAxisInPatch)
2015 ) = (
marker.getRelativePositionWithinFatherCell()(
j)
2016 * numberOfDoFsPerAxisInPatch)
2021 faceDimensions(normal) = (
overlap - 1) / 3 + 1;
2023 double* centerValues =
new double[
unknowns];
2028 dfor(kCoarse, faceDimensions) {
2031 ) = (
marker.getSelectedFaceNumber() < Dimensions)
2032 ? overlap - kCoarse(normal) - 1
2037 stencilOffset(i) = 1;
2038 if (
center(i) == numberOfDoFsPerAxisInPatch - 1)
2039 stencilOffset(i) = -1;
2042 stencilOffset(j) = 1;
2043 if (
center(j) == numberOfDoFsPerAxisInPatch - 1)
2044 stencilOffset(j) = -1;
2047 int stencilSize = 0;
2053 center + offset + stencilOffset
2055 numberOfDoFsPerAxisInPatch,
2063 for (
int axis = 0;
axis < Dimensions;
axis++) {
2069 center + stencilOffset + offset,
2070 numberOfDoFsPerAxisInPatch,
2076 if (
center(axis) < numberOfDoFsPerAxisInPatch - 2) {
2081 center + stencilOffset + offset,
2082 numberOfDoFsPerAxisInPatch,
2092 numberOfDoFsPerAxisInPatch,
2096 for (
int unknown = 0; unknown <
unknowns; unknown++) {
2097 centerValues[unknown] = coarseGridFaceValues[
index *
unknowns + unknown];
2100 for (
int k = 0;
k < stencilSize;
k++) {
2101 for (
int unknown = 0; unknown <
unknowns; unknown++) {
2105 ) = coarseGridFaceValues[indices[
k] *
unknowns + unknown]
2106 - centerValues[unknown];
2110 int numberOfDerivatives = (Dimensions == 2) ? 9 : 19;
2113 for (
int row = 0;
row < stencilSize;
row++) {
2116 for (
int a = 0;
a < Dimensions;
a++) {
2117 A(row, column) = cell(
a);
2120 for (
int a = 0;
a < Dimensions;
a++) {
2121 for (
int b =
a;
b < Dimensions;
b++) {
2122 A(row, column) = 0.5 * cell(
a) * cell(b);
2126 for (
int a = 0;
a < Dimensions;
a++) {
2127 for (
int b =
a;
b < Dimensions;
b++) {
2128 for (
int c = b;
c < Dimensions;
c++) {
2129 A(row, column) = (1.0 / 6.0) * cell(
a) * cell(b) * cell(c);
2137 if (A.rows() >= A.cols()){
2163 if (kCoarse(i) == 0)
2165 ) = (
marker.getRelativePositionWithinFatherCell()(
i)
2166 * numberOfDoFsPerAxisInPatch)
2169 if (kCoarse(j) == 0)
2171 ) = (
marker.getRelativePositionWithinFatherCell()(
j)
2172 * numberOfDoFsPerAxisInPatch)
2176 int modulus = (
marker.getRelativePositionWithinFatherCell()(
i) + 1)
2177 * numberOfDoFsPerAxisInPatch;
2178 if (modulus % 3 != 0)
2179 modulus = modulus % 3;
2182 if (kCoarse(i) == faceDimensions(i) - 1)
2183 fineEnd(i) = modulus;
2186 modulus = (
marker.getRelativePositionWithinFatherCell()(
j) + 1)
2187 * numberOfDoFsPerAxisInPatch;
2188 if (modulus % 3 != 0)
2189 modulus = modulus % 3;
2192 if (kCoarse(j) == faceDimensions(j) - 1)
2193 fineEnd(j) = modulus;
2197 fineDimensions(normal) = std::min(overlap - kCoarse(normal) * 3, 3);
2198 if (fineDimensions(normal) % 3 != 0)
2199 fineDimensions(normal) = fineDimensions(normal) % 3;
2201 fineDimensions(normal) = 3;
2204 int fineDimensionsProduct = fineDimensions(normal) * fineDimensions(i)
2205 * fineDimensions(j);
2206#elif Dimensions == 2
2207 int fineDimensionsProduct = fineDimensions(normal) * fineDimensions(i);
2211 fineMatrix(fineDimensionsProduct, numberOfDerivatives);
2214 dfor(kFine, fineDimensions) {
2218 for (
int a = 0;
a < Dimensions;
a++) {
2219 fineMatrix(row, column) = (1.0 / 3.0) * cell(
a);
2222 for (
int a = 0;
a < Dimensions;
a++) {
2223 for (
int b =
a;
b < Dimensions;
b++) {
2224 fineMatrix(row, column) = (1.0 / 18.0) * cell(
a) * cell(b);
2228 for (
int a = 0;
a < Dimensions;
a++) {
2229 for (
int b =
a;
b < Dimensions;
b++) {
2230 for (
int c = b;
c < Dimensions;
c++) {
2234 ) = (1.0 / 162.0) * cell(
a) * cell(b) * cell(c);
2243 int fineCellNumber = 0;
2245 fineCorner = kCoarse * 3 + fineStart - fineDataStart;
2247 ) = (
marker.getSelectedFaceNumber() < Dimensions)
2248 ? (kCoarse(normal) * 3)
2249 :
overlap + (kCoarse(normal) * 3);
2251 dfor(kFine, fineDimensions) {
2255 numberOfDoFsPerAxisInPatch,
2260 for (
int unknown = 0; unknown <
unknowns; unknown++) {
2262 = centerValues[unknown] + fineValues(fineCellNumber, unknown);
2268 delete[] centerValues;
2274 int numberOfDoFsPerAxisInPatch,
2277 const double* __restrict__ interpolationData,
2278 const int* __restrict__ columnIndices,
2279 const int* __restrict__ rowIndices,
2281 int rowIndicesStart,
2282 const double* __restrict__ coarseGridFaceValues,
2283 double* __restrict__ fineGridFaceValues
2286 numberOfDoFsPerAxisInPatch
2289 numberOfDoFsPerAxisInPatch
2292 const int normal = marker.getSelectedFaceNumber() % Dimensions;
2293 const int matrixColumns = 2 * overlap
2295 pow(numberOfDoFsPerAxisInPatch, Dimensions - 1);
2296 const int matrixRows = overlap
2297 * std::pow(numberOfDoFsPerAxisInPatch, Dimensions - 1);
2299 fineFaceDimensions(normal) = overlap;
2300 coarseFaceDimensions(normal) = 2 * overlap;
2302 double* rearrangedCoarseData =
new double[matrixColumns * unknowns];
2304 dfor(kCoarse, coarseFaceDimensions) {
2307 numberOfDoFsPerAxisInPatch,
2311 int newIndex = (marker.getSelectedFaceNumber() >= Dimensions)
2313 : 2 * overlap - kCoarse(normal) - 1;
2314 int base = overlap * 2;
2315 for (
int d = 1; d < Dimensions; d++) {
2316 newIndex += kCoarse((normal + d) % Dimensions) * base;
2317 base *= numberOfDoFsPerAxisInPatch;
2319 for (
int unknown = 0; unknown < unknowns; unknown++) {
2320 rearrangedCoarseData[newIndex * unknowns + unknown] = coarseGridFaceValues
2321 [currentIndex * unknowns + unknown];
2325 dfor(kFine, fineFaceDimensions) {
2326 auto fineCoords = kFine;
2327 fineCoords(normal) = (marker.getSelectedFaceNumber() < Dimensions)
2328 ? overlap - kFine(normal) - 1
2329 : overlap + kFine(normal);
2333 numberOfDoFsPerAxisInPatch,
2338 int row = kFine(normal);
2340 for (
int d = 1; d < Dimensions; d++) {
2341 row += kFine((normal + d) % Dimensions) * base;
2342 base *= numberOfDoFsPerAxisInPatch;
2345 for (
int unknown = 0; unknown < unknowns; unknown++) {
2346 fineGridFaceValues[fineIndex * unknowns + unknown] = 0.0;
2349 int columnStart = rowIndices[rowIndicesStart + row];
2350 int columnEnd = rowIndices[rowIndicesStart + row + 1];
2352 for (
int column = columnStart; column < columnEnd; column++) {
2353 for (
int unknown = 0; unknown < unknowns; unknown++) {
2354 fineGridFaceValues[fineIndex * unknowns + unknown]
2355 += interpolationData[dataStart + column]
2356 * rearrangedCoarseData
2357 [(columnIndices[dataStart + column]) * unknowns + unknown];
2362 delete[] rearrangedCoarseData;
2367 int numberOfDoFsPerAxisInPatch,
2370 const double* __restrict__ normalInterpolationMatrix1d,
2371 const double* __restrict__ tangentialInterpolationMatrix1d,
2372 const double* __restrict__ coarseGridFaceValues,
2373 double* __restrict__ fineGridFaceValues
2376 "interpolateHaloLayer_AoS_tensor_product(...)",
2378 numberOfDoFsPerAxisInPatch,
2382 const int normal = marker.getSelectedFaceNumber() % Dimensions;
2384 dfore(kFine, numberOfDoFsPerAxisInPatch, normal, 0) {
2385 for (
int iFine = 0; iFine < overlap; iFine++) {
2388 ) = (marker.getSelectedFaceNumber() < Dimensions)
2390 : 2 * overlap - iFine - 1;
2394 numberOfDoFsPerAxisInPatch,
2400 "interpolateHaloLayer_AoS_tensor_product(...)",
2401 "clear dof " << dest
2403 for (
int unknown = 0; unknown < unknowns; unknown++) {
2404 fineGridFaceValues[destLinearised * unknowns + unknown] = 0.0;
2407 dfore(kCoarse, numberOfDoFsPerAxisInPatch, normal, 0) {
2408 for (
int iCoarse = 0; iCoarse < 2 * overlap; iCoarse++) {
2411 ) = (marker.getSelectedFaceNumber() < Dimensions)
2413 : 2 * overlap - iCoarse - 1;
2416 numberOfDoFsPerAxisInPatch,
2421 double weight = 1.0;
2422 for (
int d = 0; d < Dimensions; d++) {
2429 int index = col + row * 2 * overlap;
2431 "interpolateHaloLayer_AoS_tensor_product(...)",
2432 "(" << row <<
"," << col <<
")=" << index
2433 <<
" (normal contribution)"
2435 weight *= normalInterpolationMatrix1d[index];
2440 + marker.getRelativePositionWithinFatherCell()(d
2441 ) * numberOfDoFsPerAxisInPatch;
2444 int index = col + row * numberOfDoFsPerAxisInPatch;
2446 "interpolateHaloLayer_AoS_tensor_product(...)",
2447 "(" << row <<
"," << col <<
")=" << index
2448 <<
" (tangential contribution)"
2450 weight *= tangentialInterpolationMatrix1d[index];
2456 "interpolateHaloLayer_AoS_tensor_product(...)",
2457 "add dof " << src <<
" to " << dest <<
" with weight " << weight
2460 for (
int unknown = 0; unknown < unknowns; unknown++) {
2461 fineGridFaceValues[destLinearised * unknowns + unknown]
2463 * coarseGridFaceValues[srcLinearised * unknowns + unknown];
2470 logTraceOut(
"interpolateHaloLayer_AoS_tensor_product(...)");
2475 [[maybe_unused]]
int numberOfDoFsPerAxisInPatch,
2476 [[maybe_unused]]
int overlap,
2477 [[maybe_unused]]
int unknowns,
2478 [[maybe_unused]]
const double* __restrict__ normalInterpolationMatrix1d,
2479 [[maybe_unused]]
const double* __restrict__ tangentialInterpolationMatrix1d,
2480 [[maybe_unused]]
const double* __restrict__ coarseGridCellValues,
2481 [[maybe_unused]]
const double* __restrict__ coarseGridFaceValues,
2482 [[maybe_unused]]
double* __restrict__ fineGridFaceValues
2489 [[maybe_unused]]
int numberOfDoFsPerAxisInPatch,
2490 [[maybe_unused]]
int overlap,
2491 [[maybe_unused]]
int unknowns,
2492 [[maybe_unused]]
const double* __restrict__ interpolationData,
2493 [[maybe_unused]]
const int* __restrict__ columnIndices,
2494 [[maybe_unused]]
const int* __restrict__ rowIndices,
2495 [[maybe_unused]]
const double* __restrict__ coarseGridCellValues,
2496 [[maybe_unused]]
const double* __restrict__ coarseGridFaceValues,
2497 [[maybe_unused]]
double* __restrict__ fineGridFaceValues
2504 [[maybe_unused]]
int numberOfDoFsPerAxisInPatch,
2505 [[maybe_unused]]
int overlap,
2506 [[maybe_unused]]
int unknowns,
2507 [[maybe_unused]]
const double* __restrict__ coarseGridCellValues,
2508 [[maybe_unused]]
const double* __restrict__ coarseGridFaceValues,
2509 [[maybe_unused]]
double* __restrict__ fineGridFaceValues
2516 [[maybe_unused]]
int numberOfDoFsPerAxisInPatch,
2517 [[maybe_unused]]
int overlap,
2518 [[maybe_unused]]
int unknowns,
2519 [[maybe_unused]]
const double* __restrict__ coarseGridCellValues,
2520 [[maybe_unused]]
const double* __restrict__ coarseGridFaceValues,
2521 [[maybe_unused]]
double* __restrict__ fineGridFaceValues
2528 [[maybe_unused]]
int numberOfDoFsPerAxisInPatch,
2529 [[maybe_unused]]
int unknowns,
2530 [[maybe_unused]]
const double* __restrict__ interpolationMatrix1d,
2531 [[maybe_unused]]
const double* __restrict__ coarseGridCellValues,
2532 [[maybe_unused]]
double* __restrict__ fineGridCellValues
2539 [[maybe_unused]]
int numberOfDoFsPerAxisInPatch,
2540 [[maybe_unused]]
int unknowns,
2541 [[maybe_unused]]
const double* __restrict__ interpolationData,
2542 [[maybe_unused]]
const int* __restrict__ columnIndices,
2543 [[maybe_unused]]
const int* __restrict__ rowIndices,
2544 [[maybe_unused]]
const double* __restrict__ coarseGridCellValues,
2545 [[maybe_unused]]
double* __restrict__ fineGridCellValues
2552 [[maybe_unused]]
int numberOfDoFsPerAxisInPatch,
2553 [[maybe_unused]]
int unknowns,
2554 [[maybe_unused]]
const double* __restrict__ coarseGridCellValues,
2555 [[maybe_unused]]
double* __restrict__ fineGridCellValues
2562 [[maybe_unused]]
int numberOfDoFsPerAxisInPatch,
2563 [[maybe_unused]]
int unknowns,
2564 [[maybe_unused]]
const double* __restrict__ coarseGridCellValues,
2565 [[maybe_unused]]
double* __restrict__ fineGridCellValues
#define assertion4(expr, param0, param1, param2, param3)
#define assertionEquals1(lhs, rhs, a)
#define assertionEquals(lhs, rhs)
#define logDebug(methodName, logMacroMessageStream)
#define logTraceOut(methodName)
#define logTraceInWith4Arguments(methodName, argument0, argument1, argument2, argument3)
#define logTraceInWith3Arguments(methodName, argument0, argument1, argument2)
#define logTraceInWith1Argument(methodName, argument0)
#define dfor3(counter)
Shortcut For dfor(counter,3)
#define dfore(counter, max, dim, value)
This is an exclusive d-dimensional for loop.
#define dfor(counter, max)
d-dimensional Loop
#define enddforx
I prefer to use this macro for dforx instead of a closing bracket as many syntax parser fail otherwis...
tarch::logging::Log _log("::")
My standard matrix is a matrix where the size is fixed at compile time.
void batchedMultiplyAoS(double *__restrict__ result, const double *__restrict__ x, int batchCount, int resultSize, int firstRow)
This operation assumes that x holds a whole batch of vectors in AoS format.
void multiplyBySmallMatrix(double *result, const DynamicMatrix &matrix) const
void replicateRows(int blockSize, int numberOfReplications, int shiftAfterEveryReplication, bool extendColumnsToAccommodateShifts)
Split the matrix into blocks of rows of size blockSize.
std::string toString(bool addLineBreaks=false) const
Create a lock around a boolean semaphore region.
void free()
Free the lock.
const float const float const float struct part *restrict struct part *restrict const float a
LoopPlacement
Guide loop-level parallelism.
CPUGPUMethod int dLinearised(const tarch::la::Vector< Dimensions, int > &counter, int max)
Map d-dimensional vector onto integer index.
My collection of tiny vector operations.
DynamicMatrix transpose(const DynamicMatrix &matrix)
bool greaterEquals(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
tarch::la::SmartPointerVector< Size, NewScalarType > convertScalar(const tarch::la::SmartPointerVector< Size, Scalar > &SmartPointerVector)
DynamicMatrix invertUpperTriangular(const DynamicMatrix &R)
void modifiedGramSchmidt(Matrix< Rows, Cols, Scalar > A, Matrix< Rows, Cols, Scalar > &Q, Matrix< Cols, Cols, Scalar > &R)
Produces an economy-size QR decomposition of a matrix A, A is changed.
bool smallerEquals(double lhs, double rhs, double tolerance=NUMERICAL_ZERO_DIFFERENCE)
Matrix< Rows, Cols, Scalar > multiplyComponents(const Matrix< Rows, X, Scalar > &lhs, const Matrix< X, Cols, Scalar > &rhs)
Vector< Cols, Scalar > row(const Matrix< Rows, Cols, Scalar > &matrix, int whichRow)
Extract row from matrix.
void freeMemory(void *data, MemoryLocation location, int device=accelerator::Device::HostDevice)
Free memory.
@ Heap
Create data on the heap of the local device.
Provide information about selected face.