29 : m_solverId(solverId_), m_mpiComm(comm) {
30 MPI_Comm_rank(mpiComm(), &m_domainId);
31 MPI_Comm_size(mpiComm(), &m_noDomains);
41 m_gridInputFileName = Context::getSolverProperty<MString>(
"gridInputFileName", m_solverId, AT_);
42 m_noGhostLayers = Context::getSolverProperty<MInt>(
"noGhostLayers", m_solverId, AT_);
44 mAlloc(m_nPoints, nDim,
"m_nPoints", -1, AT_);
45 mAlloc(m_nActivePoints, nDim,
"m_nActivePoints", -1, AT_);
46 mAlloc(m_nCells, nDim,
"m_nCells", -1, AT_);
47 mAlloc(m_nActiveCells, nDim,
"m_nActiveCells", -1, AT_);
48 mAlloc(m_nOffsetCells, nDim,
"m_nOffsetCells", -1, AT_);
49 mAlloc(m_nOffsetPoints, nDim,
"m_nOffsetPoints", -1, AT_);
50 mAlloc(m_nBlockCells, nDim,
"m_nBlockCells", -1, AT_);
52 mAlloc(m_periodicDisplacements, nDim * nDim,
"m_periodicDisplacement", F0, AT_);
59 mAlloc(m_singularity, 30,
"m_singularity", AT_);
70 cout <<
"Doing block decomposition..." << endl;
85 m_readDecompositionFromFile =
false;
86 m_readDecompositionFromFile =
87 Context::getSolverProperty<MBool>(
"readPartitionFromFile", m_solverId, AT_, &m_readDecompositionFromFile);
91 MInt noBlocksType = pio.getAttributeType(
"noBlocks",
"");
92 if(noBlocksType == 1) {
93 pio.getAttribute<
MInt>(&m_noBlocks,
"noBlocks",
"");
94 }
else if(noBlocksType == 0) {
95 MFloat noBlocksFloat = -1.0;
96 pio.getAttribute<
MFloat>(&noBlocksFloat,
"noBlocks",
"");
97 m_noBlocks = (
MInt)noBlocksFloat;
100 pio.getAttribute(&m_uID,
"UID",
"");
102 m_partition = make_unique<StructuredDecomposition<nDim>>(m_noBlocks, m_gridInputFileName, m_mpiComm, m_noDomains);
105 m_log <<
"reading repartition from file ....." << endl;
106 MBool success = m_partition->readFromFile();
108 m_log <<
"..... Reading from partition file FAILED --> new decomposition activated" << endl;
109 m_partition->decompose();
111 m_log <<
"..... Reading in successful" << endl;
113 m_partition->decompose();
117 for(
MInt i = 0; i < m_noBlocks; i++) {
119 for(
MInt dim = 0; dim < nDim; dim++) {
120 temp *= getBlockNoCells(i, dim);
122 if(temp != 1) m_totalNoCells += temp;
124 if(m_domainId == 0) {
125 cout <<
"Doing block decomposition... SUCCESSFUL!" << endl;
135 m_blockId = getMyBlockId();
136 for(
MInt i = 0; i < nDim; i++) {
137 m_nOffsetCells[i] = getMyOffset(i);
138 if(getMyOffset(i) > 0) {
139 m_nOffsetPoints[i] = getMyOffset(i) + 1;
141 m_nOffsetPoints[i] = 0;
143 m_nActivePoints[i] = getMyActivePoints(i);
144 m_nPoints[i] = m_nActivePoints[i] + 2 * m_noGhostLayers;
146 m_nActiveCells[i] = m_nActivePoints[i] - 1;
147 m_nCells[i] = m_nPoints[i] - 1;
148 m_noPoints *= m_nPoints[i];
149 m_noActiveCells *= m_nActiveCells[i];
150 m_noCells *= m_nCells[i];
153 mAlloc(m_cells->coordinates, nDim, m_noCells,
"m_cells->coordinates", AT_);
154 mAlloc(m_coordinates, nDim, m_noPoints,
"m_coordinates", -1.01010101, AT_);
170 m_movingGrid =
false;
172 m_movingGrid = Context::getSolverProperty<MBool>(
"movingGrid", m_solverId, AT_, &m_movingGrid);
176 mAlloc(m_velocity, nDim, m_noPoints,
"m_velocity", F0, AT_);
177 mAlloc(m_acceleration, nDim, m_noPoints,
"m_acceleration", F0, AT_);
178 mAlloc(m_oldCoordinates, nDim, m_noPoints,
"m_mgOldCoordinates", F0, AT_);
179 mAlloc(m_initCoordinates, nDim, m_noPoints,
"m_mgInitCoordinates", F0, AT_);
188 mAlloc(m_cells->cornerJac, m_noCells,
"m_cells->cornerJac", 123.123, AT_);
189 mAlloc(m_cells->cellJac, m_noCells,
"m_cells->cellJac", 123.123, AT_);
190 mAlloc(m_cells->oldCellJac, m_noCells,
"m_cells->oldCellJac", 123.123, AT_);
191 IF_CONSTEXPR(nDim == 2)
mAlloc(m_cells->surfJac, m_noCells * 2,
"m_cells->surfJac", AT_);
192 mAlloc(m_cells->cellMetrics, nDim * nDim, m_noCells,
"cellMetrics", 123.123, AT_);
193 mAlloc(m_cells->cornerMetrics, nDim * nDim, m_noCells,
"cornerMetrics", 123.123, AT_);
194 mAlloc(m_cells->surfaceMetrics, nDim * nDim, m_noCells,
"surfaceMetrics", 123.123, AT_);
197 IF_CONSTEXPR(nDim == 2) {
198 if(m_hasSingularity) {
200 for(
MInt i = 0; i < m_hasSingularity; ++i) {
202 if(m_singularity[i].BC == -6000) {
203 for(
MInt j = 0; j < nDim; j++) {
204 const MInt len = m_singularity[i].end[j] - m_singularity[i].start[j];
205 ASSERT(len == 1,
"");
211 const MInt no_metrics = 4;
213 mAlloc(m_cells->surfaceMetricsSingularity, no_metrics, no_cells,
"surfaceMetrics", 123.123, AT_);
229 dummy1 << m_blockId <<
"/";
230 sBlockName += dummy1.str();
232 MString varNames[] = {
"x",
"y",
"z"};
233 ParallelIo::size_type offset[3];
234 ParallelIo::size_type size[3];
235 for(
MInt i = 0; i < nDim; ++i) {
236 offset[i] = m_nOffsetCells[i];
237 size[i] = m_nActivePoints[i];
240 for(
MInt dim = 0; dim < nDim; dim++) {
241 pio.
readArray(m_coordinates[dim], sBlockName, varNames[dim], nDim, offset, size);
258 m_log <<
"writing the partitionedGrid.hdf5 File" << endl;
259 cout <<
"writing the partitionedGrid.hdf5 File" << endl;
260 const char* fileName =
"partitionedGrid.hdf5";
262 MInt noDomains_ = noDomains();
264 MString gridVarNames[3] = {
"x",
"y",
"z"};
265 for(
MInt i = 0; i < noDomains(); i++) {
267 ParallelIo::size_type noPoints[nDim] = {};
268 for(
MInt j = 0; j < nDim; j++) {
269 noPoints[j] = getActivePoints(i, j) + 2 * m_noGhostLayers;
274 MString partitionPathStr =
"block";
275 partitionPathStr += path.str();
276 const char* partitionPath = partitionPathStr.c_str();
277 for(
MInt dim = 0; dim < nDim; ++dim) {
283 ParallelIo::size_type offset[3] = {0, 0, 0};
284 ParallelIo::size_type size[3] = {m_nPoints[0], m_nPoints[1], m_nPoints[2]};
287 MString partitionPathStr =
"block";
288 partitionPathStr += path.str();
289 for(
MInt dim = 0; dim < nDim; ++dim) {
290 pio.
writeArray(&m_coordinates[dim][0], partitionPathStr, gridVarNames[dim], nDim, offset, size);
301 constexpr MInt nDim = 2;
303 std::array<MInt, nDim> begin{0, 0};
304 std::array<MInt, nDim> end{m_nActivePoints[1], m_nActivePoints[0]};
307 maia::parallelFor<true, nDim>(begin, end, [=](
const MInt& i,
const MInt& j) {
308 const MInt i_org = end[0] - 1 - i;
309 const MInt j_org = end[1] - 1 - j;
310 const MInt i_new = i_org + m_noGhostLayers;
311 const MInt j_new = j_org + m_noGhostLayers;
312 const MInt pointId_org = i_org + (j_org * m_nActivePoints[1]);
313 const MInt pointId_new = i_new + (j_new * m_nPoints[1]);
314 for(
MInt dim = 0; dim < nDim; ++dim) {
315 m_coordinates[dim][pointId_new] = m_coordinates[dim][pointId_org];
316 m_coordinates[dim][pointId_org] = -1000.0;
328 constexpr MInt nDim = 3;
330 std::array<MInt, nDim> begin{0, 0};
331 std::array<MInt, nDim> end{m_nActivePoints[2], m_nActivePoints[1], m_nActivePoints[0]};
334 maia::parallelFor<true, nDim>(begin, end, [=](
const MInt& i,
const MInt& j,
const MInt& k) {
335 const MInt i_org = end[0] - 1 - i;
336 const MInt j_org = end[1] - 1 - j;
337 const MInt k_org = end[2] - 1 - k;
338 const MInt i_new = i_org + m_noGhostLayers;
339 const MInt j_new = j_org + m_noGhostLayers;
340 const MInt k_new = k_org + m_noGhostLayers;
342 const MInt pointId_org = i_org + (j_org + k_org * m_nActivePoints[1]) * m_nActivePoints[2];
343 const MInt pointId_new = i_new + (j_new + k_new * m_nPoints[1]) * m_nPoints[2];
345 for(
MInt dim = 0; dim < nDim; ++dim) {
346 m_coordinates[dim][pointId_new] = m_coordinates[dim][pointId_org];
347 m_coordinates[dim][pointId_org] = F0;
360 stringstream fileName;
361 fileName << solutionOutput <<
"grid" <<
globalTimeStep << outputFormat;
367 MString gridTypeName =
"structured";
372 ParallelIo::size_type allPoints[3]{-1, -1, -1};
373 for(
MInt i = 0; i < m_noBlocks; ++i) {
374 for(
MInt j = 0; j < nDim; ++j) {
375 allPoints[j] = getBlockNoPoints(i, j);
377 MString blockPathStr =
"block" + std::to_string(i);
383 MString blockPathStr =
"block" + std::to_string(m_blockId);
384 ParallelIo::size_type offset[nDim]{};
385 ParallelIo::size_type size[nDim]{};
386 ParallelIo::size_type ghostArray[nDim]{};
387 for(
MInt dim = 0; dim < nDim; ++dim) {
388 offset[dim] = m_nOffsetCells[dim];
389 size[dim] = m_nActivePoints[dim];
390 ghostArray[dim] = m_noGhostLayers;
393 pio.
writeArray(&m_coordinates[0][0], blockPathStr,
"x", nDim, offset, size, ghostArray);
394 pio.
writeArray(&m_coordinates[1][0], blockPathStr,
"y", nDim, offset, size, ghostArray);
395 IF_CONSTEXPR(nDim == 3) { pio.
writeArray(&m_coordinates[2][0], blockPathStr,
"z", nDim, offset, size, ghostArray); }
412 std::vector<MPI_Request> sndRequests;
413 std::vector<MPI_Request> rcvRequests;
414 std::vector<MPI_Status> sndStatus;
415 std::vector<MPI_Status> rcvStatus;
416 sndRequests.reserve(sndComm.size());
417 rcvRequests.reserve(rcvComm.size());
419 gatherPoints(sndComm, commType);
420 sendPoints(sndComm, commType, sndRequests);
421 receivePoints(rcvComm, commType, rcvRequests);
423 sndStatus.resize(sndRequests.size());
424 MPI_Waitall(sndRequests.size(), &sndRequests[0], &sndStatus[0], AT_);
426 rcvStatus.resize(rcvRequests.size());
427 MPI_Waitall(rcvRequests.size(), &rcvRequests[0], &rcvStatus[0], AT_);
429 scatterPoints(rcvComm, commType);
446 for(
auto& snd : sndComm) {
447 if(commType != snd->commType)
continue;
450 MFloat** coordinates = m_coordinates;
451 std::array<MInt, nDim> INC{};
452 for(
MInt dim = 0; dim < nDim; ++dim) {
453 INC[dim] = m_nPoints[dim];
458 coordinates = m_cells->coordinates;
461 for(
MInt dim = 0; dim < nDim; ++dim) {
462 INC[dim] = m_nCells[dim];
466 MBool isPeriodic =
false;
471 std::array<MInt, nDim> begin{};
472 std::array<MInt, nDim> end{};
473 std::array<MInt, nDim> size{};
475 for(
MInt dim = 0; dim < nDim; ++dim) {
476 begin[dim] = snd->startInfoPoints[dim];
477 end[dim] = snd->endInfoPoints[dim] + plusOne;
478 size[dim] = end[dim] - begin[dim];
480 const MInt totalSize = std::accumulate(size.begin(), size.end(), 1, std::multiplies<double>());
483 const MInt bcId = snd->bcId;
484 auto* pointBuffer = snd->pointBuffer.get();
485 if constexpr(nDim == 3) {
486 for(
MInt dim = 0; dim < nDim; dim++) {
487 maia::parallelFor<true, nDim>(begin, end, [=](
const MInt& i,
const MInt& j,
const MInt& k) {
488 const MInt pointId = i + (j + k * INC[1]) * INC[2];
489 const MInt bufferId =
490 totalSize * dim + (i - begin[0]) + ((j - begin[1]) + (k - begin[2]) * size[1]) * size[0];
493 MFloat tmppoint = coordinates[dim][pointId];
494 periodicPointsChange(tmppoint, bcId, dim);
495 pointBuffer[bufferId] = tmppoint;
497 pointBuffer[bufferId] = coordinates[dim][pointId];
501 }
else if constexpr(nDim == 2) {
502 for(
MInt dim = 0; dim < nDim; dim++) {
503 maia::parallelFor<true, nDim>(begin, end, [=](
const MInt& i,
const MInt& j) {
504 const MInt pointId = i + j * INC[1];
505 const MInt bufferId = totalSize * dim + (i - begin[0]) + (j - begin[1]) * size[0];
508 MFloat tmppoint = coordinates[dim][pointId];
509 periodicPointsChange(tmppoint, bcId, dim);
510 pointBuffer[bufferId] = tmppoint;
512 pointBuffer[bufferId] = coordinates[dim][pointId];
545 const MInt displacementId = (
MFloat)(type - 4400 + 1) / 2.0 - 1;
546 pt = pt - m_periodicDisplacements[dim * nDim + displacementId];
553 const MInt displacementId = (
MFloat)(type - 4400 + 1) / 2.0 - 1;
554 pt = pt + m_periodicDisplacements[dim * nDim + displacementId];
559#ifndef WAR_NVHPC_PSTL
560 std::cout <<
"ERROR!!! periodic type is wrong!!! in BC call BC: " << type << endl;
578 std::vector<MPI_Request>& sndRequests) {
580 for(
auto& snd : sndComm) {
581 if(commType != snd->commType)
continue;
582 MPI_Request request{};
583 const MInt tag = m_domainId + (snd->tagHelper) * m_noDomains;
585 snd->pointBufferSize,
593 sndRequests.push_back(request);
594 if(err) cout <<
"rank" << m_domainId <<
"sending throws errors" << endl;
610 std::vector<MPI_Request>& rcvRequests) {
612 for(
auto& rcv : rcvComm) {
613 if(commType != rcv->commType)
continue;
614 MPI_Request request{};
615 const MInt tag = rcv->nghbrId + (rcv->tagHelper) * m_noDomains;
617 rcv->pointBufferSize,
625 rcvRequests.push_back(request);
626 if(err) cout <<
"rank" << m_domainId <<
" receiving throws errors" << endl;
646 for(
auto& rcv : rcvComm) {
647 if(commType != rcv->commType)
continue;
649 MFloat** coordinates = m_coordinates;
650 std::array<MInt, nDim> INC{};
653 for(
MInt dim = 0; dim < nDim; ++dim) {
654 INC[dim] = m_nPoints[dim];
658 coordinates = m_cells->coordinates;
660 for(
MInt dim = 0; dim < nDim; ++dim) {
661 INC[dim] = m_nCells[dim];
665 std::array<MInt, nDim> begin{};
666 std::array<MInt, nDim> end{};
667 std::array<MInt, nDim> size{};
669 for(
MInt dim = 0; dim < nDim; ++dim) {
670 begin[dim] = rcv->startInfoPoints[dim];
671 end[dim] = rcv->endInfoPoints[dim] + plusOne;
672 size[dim] = end[dim] - begin[dim];
674 const MInt totalSize = std::accumulate(size.begin(), size.end(), 1, std::multiplies<double>());
676 std::array<MInt, nDim> stepBuffer{};
677 std::array<MInt, nDim> startBuffer{};
678 std::array<MInt, nDim> endBuffer{};
679 std::array<MInt, nDim> sizeBuffer{};
681 for(
MInt j = 0; j < nDim; j++) {
682 stepBuffer[rcv->orderInfo[j]] = rcv->stepInfo[j];
685 for(
MInt j = 0; j < nDim; j++) {
686 endBuffer[j] = size[j] - 1;
687 sizeBuffer[rcv->orderInfo[j]] = size[j];
688 if(stepBuffer[j] < 0) {
689 std::swap(startBuffer[j], endBuffer[j]);
694 auto* pointBuffer = rcv->pointBuffer.get();
695 auto* orderInfo = rcv->orderInfo.data();
696 auto* startInfoCells = rcv->startInfoCells.data();
697 if constexpr(nDim == 3) {
698 for(
MInt dim = 0; dim < nDim; dim++) {
699 maia::parallelFor<true, nDim>(begin, end, [=](
const MInt& i,
const MInt& j,
const MInt& k) {
700 std::array<MInt, nDim> start{};
701 start[orderInfo[0]] = startBuffer[0] + (i - startInfoCells[0]) * stepBuffer[0];
702 start[orderInfo[1]] = startBuffer[1] + (j - startInfoCells[1]) * stepBuffer[1];
703 start[orderInfo[2]] = startBuffer[2] + (k - startInfoCells[2]) * stepBuffer[2];
705 const MInt bufferId = dim * totalSize + start[0] + (start[1] + start[2] * sizeBuffer[1]) * sizeBuffer[0];
706 const MInt pointId = i + (j + k * INC[1]) * INC[2];
708 coordinates[dim][pointId] = pointBuffer[bufferId];
711 }
else if constexpr(nDim == 2) {
712 for(
MInt dim = 0; dim < nDim; dim++) {
713 maia::parallelFor<true, nDim>(begin, end, [=](
const MInt& i,
const MInt& j) {
714 std::array<MInt, nDim> start{};
715 start[orderInfo[0]] = startBuffer[0] + (i - startInfoCells[0]) * stepBuffer[0];
716 start[orderInfo[1]] = startBuffer[1] + (j - startInfoCells[1]) * stepBuffer[1];
718 const MInt bufferId = dim * totalSize + start[0] + start[1] * sizeBuffer[0];
719 const MInt pointId = i + j * INC[1];
721 coordinates[dim][pointId] = pointBuffer[bufferId];
734 m_cells = structuredCell;
746 constexpr MInt nDim = 2;
748 maia::parallelFor<true, nDim>(cellBegin(0), cellEnd(0), [=](
const MInt& i,
const MInt& j) {
749 const MInt IJ = getPointIdFromCell(i, j);
750 const MInt IP1J = getPointIdFromPoint(IJ, 1, 0);
751 const MInt IJP1 = getPointIdFromPoint(IJ, 0, 1);
752 const MInt IP1JP1 = getPointIdFromPoint(IJ, 1, 1);
753 const MInt cellId = cellIndex(i, j);
755 for(
MInt dim = 0; dim < nDim; dim++) {
757 m_cells->coordinates[dim][cellId] =
759 * (m_coordinates[dim][IJ] + m_coordinates[dim][IP1J] + m_coordinates[dim][IJP1] + m_coordinates[dim][IP1JP1]);
769 constexpr MInt nDim = 3;
771 maia::parallelFor<true, nDim>(cellBegin(0), cellEnd(0), [=](
const MInt& i,
const MInt& j,
const MInt& k) {
772 const MInt pointId = i + (j + k * m_nPoints[1]) * m_nPoints[2];
773 const MInt IJK = pointId;
774 const MInt IP1JK = pointId + 1;
775 const MInt IJP1K = pointId + m_nPoints[2];
776 const MInt IP1JP1K = IJP1K + 1;
777 const MInt IJKP1 = pointId + m_nPoints[2] * m_nPoints[1];
778 const MInt IP1JKP1 = IJKP1 + 1;
779 const MInt IJP1KP1 = pointId + m_nPoints[2] + m_nPoints[2] * m_nPoints[1];
780 const MInt IP1JP1KP1 = IJP1KP1 + 1;
781 const MInt cellId = i + (j + k * m_nCells[1]) * m_nCells[2];
784 for(
MInt dim = 0; dim < nDim; dim++) {
785 m_cells->coordinates[dim][cellId] =
787 * (m_coordinates[dim][IJK] + m_coordinates[dim][IP1JK] + m_coordinates[dim][IJP1K]
788 + m_coordinates[dim][IP1JP1K] + m_coordinates[dim][IJKP1] + m_coordinates[dim][IP1JKP1]
789 + m_coordinates[dim][IJP1KP1] + m_coordinates[dim][IP1JP1KP1]);
800 computeSurfaceMetrics();
801 computeCornerMetrics();
802 computeCellMetrics();
803 IF_CONSTEXPR(nDim == 2) {
804 if(m_hasSingularity) computeSurfaceMetricsSingularity();
814 computeCornerJacobian();
815 computeCellJacobian();
816 IF_CONSTEXPR(nDim == 2) computeSurfaceJacobian();
826 constexpr MInt nDim = 2;
828 maia::parallelFor<true, nDim>(
829 cellBegin(m_noGhostLayers - 1), cellEnd(m_noGhostLayers), [=](
const MInt& i,
const MInt& j) {
830 const MInt cellId = cellIndex(i, j);
832 m_cells->cornerMetrics[xsd * 2 + xsd][cellId] * m_cells->cornerMetrics[ysd * 2 + ysd][cellId]
833 - m_cells->cornerMetrics[ysd * 2 + xsd][cellId] * m_cells->cornerMetrics[xsd * 2 + ysd][cellId];
838 m_cells->cornerJac[cellId] = cornerJac;
849 constexpr MInt nDim = 3;
850 maia::parallelFor<true, nDim>(
851 cellBegin(m_noGhostLayers - 1), cellEnd(m_noGhostLayers), [=](
const MInt& i,
const MInt& j,
const MInt& k) {
852 const MInt cellId = cellIndex(i, j, k);
855 m_cells->cornerMetrics[xsd * nDim + xsd][cellId]
856 * (m_cells->cornerMetrics[ysd * nDim + ysd][cellId] * m_cells->cornerMetrics[zsd * nDim + zsd][cellId]
857 - m_cells->cornerMetrics[ysd * nDim + zsd][cellId]
858 * m_cells->cornerMetrics[zsd * nDim + ysd][cellId])
859 - m_cells->cornerMetrics[ysd * nDim + xsd][cellId]
860 * (m_cells->cornerMetrics[xsd * nDim + ysd][cellId] * m_cells->cornerMetrics[zsd * nDim + zsd][cellId]
861 - m_cells->cornerMetrics[xsd * nDim + zsd][cellId]
862 * m_cells->cornerMetrics[zsd * nDim + ysd][cellId])
863 + m_cells->cornerMetrics[zsd * nDim + xsd][cellId]
864 * (m_cells->cornerMetrics[xsd * nDim + ysd][cellId] * m_cells->cornerMetrics[ysd * nDim + zsd][cellId]
865 - m_cells->cornerMetrics[xsd * nDim + zsd][cellId]
866 * m_cells->cornerMetrics[ysd * nDim + ysd][cellId]);
871 this->m_cells->cornerJac[cellId] = sqrt(invJac);
882 constexpr MInt nDim = 3;
884 MFloat** __restrict coords = m_coordinates;
886 constexpr MFloat fsqrttwo = F1 / SQRT2;
888 constexpr MInt noSubJ = 8;
895 maia::parallelFor<true, nDim>(
896 cellBegin(m_noGhostLayers), cellEnd(m_noGhostLayers), [=](
const MInt& i,
const MInt& j,
const MInt& k) {
932 const MInt cellId = cellIndex(i, j, k);
933 const MInt centCellId = cellIndex(i + 1, j + 1, k + 1);
934 const MInt tmpId = getPointIdFromCell(i, j, k);
936 const MInt ijk = getPointIdFromPoint(tmpId, 1, 1, 1);
937 const MInt ijpk = getPointIdFromPoint(ijk, 0, 1, 0);
938 const MInt ijkp = getPointIdFromPoint(ijk, 0, 0, 1);
939 const MInt ijpkp = getPointIdFromPoint(ijk, 0, 1, 1);
940 const MInt ipjk = getPointIdFromPoint(ijk, 1, 0, 0);
941 const MInt ipjpk = getPointIdFromPoint(ijk, 1, 1, 0);
942 const MInt ipjkp = getPointIdFromPoint(ijk, 1, 0, 1);
943 const MInt ipjpkp = getPointIdFromPoint(ijk, 1, 1, 1);
945 for(
MInt isd = xsd; isd < nDim; isd++) {
947 S1[isd] = F1B4 * (coords[isd][ijpkp] + coords[isd][ijk] + coords[isd][ijkp] + coords[isd][ijpk]);
949 S2[isd] = F1B4 * (coords[isd][ipjk] + coords[isd][ijk] + coords[isd][ipjkp] + coords[isd][ijkp]);
951 S3[isd] = F1B4 * (coords[isd][ipjk] + coords[isd][ijk] + coords[isd][ipjpk] + coords[isd][ijpk]);
953 S1P[isd] = F1B4 * (coords[isd][ipjpkp] + coords[isd][ipjk] + coords[isd][ipjkp] + coords[isd][ipjpk]);
955 S2P[isd] = F1B4 * (coords[isd][ipjpk] + coords[isd][ijpk] + coords[isd][ipjpkp] + coords[isd][ijpkp]);
957 S3P[isd] = F1B4 * (coords[isd][ipjkp] + coords[isd][ijkp] + coords[isd][ipjpkp] + coords[isd][ijpkp]);
965 for(
MInt isd = xsd; isd < nDim; isd++) {
967 CP1[isd] = F1B2 * (coords[isd][ipjk] + coords[isd][ijk]);
968 CP2[isd] = F1B2 * (coords[isd][ijpk] + coords[isd][ijk]);
969 CP3[isd] = F1B2 * (coords[isd][ijkp] + coords[isd][ijk]);
972 tmpX1[isd] = (CP2[isd] - CP3[isd]) * fsqrttwo;
973 tmpX2[isd] = (S1[isd] - coords[isd][ijk]) * fsqrttwo;
975 tmpX3[isd] = (CP3[isd] - CP1[isd]) * fsqrttwo;
976 tmpX4[isd] = (S2[isd] - coords[isd][ijk]) * fsqrttwo;
978 tmpX5[isd] = (S3[isd] - coords[isd][ijk]) * fsqrttwo;
979 tmpX6[isd] = (CP2[isd] - CP1[isd]) * fsqrttwo;
982 this->crossProduct(DX1, tmpX1, tmpX2);
983 this->crossProduct(DX2, tmpX3, tmpX4);
984 this->crossProduct(DX3, tmpX5, tmpX6);
986 subJ[noSubJ * cellId + 0] = F0;
987 for(
MInt isd = xsd; isd < nDim; isd++) {
988 subJ[noSubJ * cellId + 0] +=
989 (m_cells->coordinates[isd][centCellId] - coords[isd][ijk]) * (DX1[isd] + DX2[isd] + DX3[isd]);
996 for(
MInt isd = xsd; isd < nDim; isd++) {
997 CP4[isd] = F1B2 * (coords[isd][ipjk] + coords[isd][ipjpk]);
998 CP5[isd] = F1B2 * (coords[isd][ipjk] + coords[isd][ipjkp]);
1000 tmpX1[isd] = (S3[isd] - S2[isd]) * fsqrttwo;
1001 tmpX2[isd] = (m_cells->coordinates[isd][centCellId] - CP1[isd]) * fsqrttwo;
1003 tmpX3[isd] = (S2[isd] - coords[isd][ipjk]) * fsqrttwo;
1004 tmpX4[isd] = (CP5[isd] - CP1[isd]) * fsqrttwo;
1006 tmpX5[isd] = (CP4[isd] - CP1[isd]) * fsqrttwo;
1007 tmpX6[isd] = (S3[isd] - coords[isd][ipjk]) * fsqrttwo;
1010 this->crossProduct(DX1, tmpX1, tmpX2);
1011 this->crossProduct(DX2, tmpX3, tmpX4);
1012 this->crossProduct(DX3, tmpX5, tmpX6);
1014 subJ[noSubJ * cellId + 1] = F0;
1015 for(
MInt isd = xsd; isd < nDim; isd++) {
1016 subJ[noSubJ * cellId + 1] += (S1P[isd] - CP1[isd]) * (DX1[isd] + DX2[isd] + DX3[isd]);
1023 for(
MInt isd = xsd; isd < nDim; isd++) {
1024 CP6[isd] = F1B2 * (coords[isd][ipjpk] + coords[isd][ijpk]);
1025 CP7[isd] = F1B2 * (coords[isd][ijpkp] + coords[isd][ijpk]);
1027 tmpX1[isd] = (coords[isd][ijpk] - S1[isd]) * fsqrttwo;
1028 tmpX2[isd] = (CP7[isd] - CP2[isd]) * fsqrttwo;
1030 tmpX3[isd] = (S1[isd] - S3[isd]) * fsqrttwo;
1031 tmpX4[isd] = (m_cells->coordinates[isd][centCellId] - CP2[isd]) * fsqrttwo;
1033 tmpX5[isd] = (CP6[isd] - CP2[isd]) * fsqrttwo;
1034 tmpX6[isd] = (coords[isd][ijpk] - S3[isd]) * fsqrttwo;
1037 this->crossProduct(DX1, tmpX1, tmpX2);
1038 this->crossProduct(DX2, tmpX3, tmpX4);
1039 this->crossProduct(DX3, tmpX5, tmpX6);
1041 subJ[noSubJ * cellId + 2] = F0;
1042 for(
MInt isd = xsd; isd < nDim; isd++) {
1043 subJ[noSubJ * cellId + 2] += (S2P[isd] - CP2[isd]) * (DX1[isd] + DX2[isd] + DX3[isd]);
1050 for(
MInt isd = xsd; isd < nDim; isd++) {
1051 CP8[isd] = F1B2 * (coords[isd][ipjpkp] + coords[isd][ipjpk]);
1053 tmpX1[isd] = (CP6[isd] - m_cells->coordinates[isd][centCellId]) * fsqrttwo;
1054 tmpX2[isd] = (S2P[isd] - S3[isd]) * fsqrttwo;
1056 tmpX3[isd] = (m_cells->coordinates[isd][centCellId] - CP4[isd]) * fsqrttwo;
1057 tmpX4[isd] = (S1P[isd] - S3[isd]) * fsqrttwo;
1059 tmpX5[isd] = (coords[isd][ipjpk] - S3[isd]) * fsqrttwo;
1060 tmpX6[isd] = (CP6[isd] - CP4[isd]) * fsqrttwo;
1063 this->crossProduct(DX1, tmpX1, tmpX2);
1064 this->crossProduct(DX2, tmpX3, tmpX4);
1065 this->crossProduct(DX3, tmpX5, tmpX6);
1067 subJ[noSubJ * cellId + 3] = F0;
1068 for(
MInt isd = xsd; isd < nDim; isd++) {
1069 subJ[noSubJ * cellId + 3] += (CP8[isd] - S3[isd]) * (DX1[isd] + DX2[isd] + DX3[isd]);
1076 for(
MInt isd = xsd; isd < nDim; isd++) {
1077 CP9[isd] = F1B2 * (coords[isd][ipjkp] + coords[isd][ijkp]);
1078 CP10[isd] = F1B2 * (coords[isd][ijpkp] + coords[isd][ijkp]);
1080 tmpX1[isd] = (S1[isd] - coords[isd][ijkp]) * fsqrttwo;
1081 tmpX2[isd] = (CP10[isd] - CP3[isd]) * fsqrttwo;
1083 tmpX3[isd] = (coords[isd][ijkp] - S2[isd]) * fsqrttwo;
1084 tmpX4[isd] = (CP9[isd] - CP3[isd]) * fsqrttwo;
1086 tmpX5[isd] = (m_cells->coordinates[isd][centCellId] - CP3[isd]) * fsqrttwo;
1087 tmpX6[isd] = (S1[isd] - S2[isd]) * fsqrttwo;
1090 this->crossProduct(DX1, tmpX1, tmpX2);
1091 this->crossProduct(DX2, tmpX3, tmpX4);
1092 this->crossProduct(DX3, tmpX5, tmpX6);
1094 subJ[noSubJ * cellId + 4] = F0;
1095 for(
MInt isd = xsd; isd < nDim; isd++) {
1096 subJ[noSubJ * cellId + 4] += (S3P[isd] - CP3[isd]) * (DX1[isd] + DX2[isd] + DX3[isd]);
1103 for(
MInt isd = xsd; isd < nDim; isd++) {
1104 CP11[isd] = F1B2 * (coords[isd][ipjkp] + coords[isd][ipjpkp]);
1106 tmpX1[isd] = (m_cells->coordinates[isd][centCellId] - CP9[isd]) * fsqrttwo;
1107 tmpX2[isd] = (S3P[isd] - S2[isd]) * fsqrttwo;
1109 tmpX3[isd] = (CP9[isd] - CP5[isd]) * fsqrttwo;
1110 tmpX4[isd] = (coords[isd][ipjkp] - S2[isd]) * fsqrttwo;
1112 tmpX5[isd] = (S1P[isd] - S2[isd]) * fsqrttwo;
1113 tmpX6[isd] = (m_cells->coordinates[isd][centCellId] - CP5[isd]) * fsqrttwo;
1116 this->crossProduct(DX1, tmpX1, tmpX2);
1117 this->crossProduct(DX2, tmpX3, tmpX4);
1118 this->crossProduct(DX3, tmpX5, tmpX6);
1120 subJ[noSubJ * cellId + 5] = F0;
1121 for(
MInt isd = xsd; isd < nDim; isd++) {
1122 subJ[noSubJ * cellId + 5] += (CP11[isd] - S2[isd]) * (DX1[isd] + DX2[isd] + DX3[isd]);
1129 for(
MInt isd = xsd; isd < nDim; isd++) {
1130 CP12[isd] = F1B2 * (coords[isd][ipjpkp] + coords[isd][ijpkp]);
1132 tmpX1[isd] = (CP7[isd] - CP10[isd]) * fsqrttwo;
1133 tmpX2[isd] = (coords[isd][ijpkp] - S1[isd]) * fsqrttwo;
1135 tmpX3[isd] = (CP10[isd] - m_cells->coordinates[isd][centCellId]) * fsqrttwo;
1136 tmpX4[isd] = (S3P[isd] - S1[isd]) * fsqrttwo;
1138 tmpX5[isd] = (S2P[isd] - S1[isd]) * fsqrttwo;
1139 tmpX6[isd] = (CP7[isd] - m_cells->coordinates[isd][centCellId]) * fsqrttwo;
1142 this->crossProduct(DX1, tmpX1, tmpX2);
1143 this->crossProduct(DX2, tmpX3, tmpX4);
1144 this->crossProduct(DX3, tmpX5, tmpX6);
1146 subJ[noSubJ * cellId + 6] = F0;
1147 for(
MInt isd = xsd; isd < nDim; isd++) {
1148 subJ[noSubJ * cellId + 6] += (CP12[isd] - S1[isd]) * (DX1[isd] + DX2[isd] + DX3[isd]);
1155 for(
MInt isd = xsd; isd < nDim; isd++) {
1156 tmpX1[isd] = (S2P[isd] - S3P[isd]) * fsqrttwo;
1157 tmpX2[isd] = (CP12[isd] - m_cells->coordinates[isd][centCellId]) * fsqrttwo;
1159 tmpX3[isd] = (S3P[isd] - S1P[isd]) * fsqrttwo;
1160 tmpX4[isd] = (CP11[isd] - m_cells->coordinates[isd][centCellId]) * fsqrttwo;
1162 tmpX5[isd] = (CP8[isd] - m_cells->coordinates[isd][centCellId]) * fsqrttwo;
1163 tmpX6[isd] = (S2P[isd] - S1P[isd]) * fsqrttwo;
1166 this->crossProduct(DX1, tmpX1, tmpX2);
1167 this->crossProduct(DX2, tmpX3, tmpX4);
1168 this->crossProduct(DX3, tmpX5, tmpX6);
1170 subJ[noSubJ * cellId + 7] = F0;
1171 for(
MInt isd = xsd; isd < nDim; isd++) {
1172 subJ[noSubJ * cellId + 7] +=
1173 (coords[isd][ipjpkp] - m_cells->coordinates[isd][centCellId]) * (DX1[isd] + DX2[isd] + DX3[isd]);
1182 maia::parallelFor<true>(0, m_noCells, [=](
const MInt& cellId) {
1183 for(
MInt j = 0; j < 8; j++) {
1184 subJtmp[noSubJ * cellId + j] = subJ[noSubJ * cellId + j];
1189 maia::parallelFor<true, nDim>(cellBegin(m_noGhostLayers), cellEnd(m_noGhostLayers),
1191 const MInt cellId = cellIndex(i, j, k);
1193 subJ[noSubJ * cellId + 0] = subJ[noSubJ * cellIndex(i - 1, j - 1, k - 1) + 7];
1194 subJ[noSubJ * cellId + 1] = subJ[noSubJ * cellIndex(i, j - 1, k - 1) + 6];
1195 subJ[noSubJ * cellId + 2] = subJ[noSubJ * cellIndex(i - 1, j, k - 1) + 5];
1196 subJ[noSubJ * cellId + 3] = subJ[noSubJ * cellIndex(i, j, k - 1) + 4];
1199 maia::parallelFor<true, nDim>(cellBegin(m_noGhostLayers - 1), cellEnd(m_noGhostLayers),
1201 const MInt cellId = cellIndex(i, j, k);
1202 subJ[noSubJ * cellId + 4] = subJtmp[noSubJ * cellIndex(i - 1, j - 1, k) + 3];
1203 subJ[noSubJ * cellId + 5] = subJtmp[noSubJ * cellIndex(i, j - 1, k) + 2];
1204 subJ[noSubJ * cellId + 6] = subJtmp[noSubJ * cellIndex(i - 1, j, k) + 1];
1205 subJ[noSubJ * cellId + 7] = subJtmp[noSubJ * cellId + 0];
1209 maia::parallelFor<true, nDim>(cellBegin(m_noGhostLayers - 1), cellEnd(m_noGhostLayers),
1211 const MInt cellId = cellIndex(i, j, k);
1213 m_cells->cornerJac[cellId] = F0;
1214 for(
MInt jacId = 0; jacId < 8; jacId++) {
1215 m_cells->cornerJac[cellId] += subJ[noSubJ * cellId + jacId];
1218 m_cells->cornerJac[cellId] = F1B3 * m_cells->cornerJac[cellId];
1228 constexpr MInt nDim = 2;
1232 MFloat** __restrict coords = m_coordinates;
1235 subJtmp.
fill(5678.9);
1237 for(
MInt j = m_noGhostLayers - 2; j < this->m_nCells[0] - m_noGhostLayers; ++j) {
1238 for(
MInt i = m_noGhostLayers - 2; i < this->m_nCells[1] - m_noGhostLayers; ++i) {
1239 const MInt cellId = cellIndex(i, j);
1240 const MInt centCellId = cellIndex(i + 1, j + 1);
1241 const MInt tmpId = getPointIdFromCell(i, j);
1243 const MInt ij = getPointIdFromPoint(tmpId, 1, 1);
1244 const MInt ipj = getPointIdFromPoint(ij, 1, 0);
1245 const MInt ijp = getPointIdFromPoint(ij, 0, 1);
1246 const MInt ipjp = getPointIdFromPoint(ij, 1, 1);
1255 for(
MInt isd = xsd; isd < nDim; isd++) {
1256 S1[isd] = F1B2 * (coords[isd][ijp] + coords[isd][ij]);
1257 S2[isd] = F1B2 * (coords[isd][ipj] + coords[isd][ij]);
1258 S1P[isd] = F1B2 * (coords[isd][ipjp] + coords[isd][ipj]);
1259 S2P[isd] = F1B2 * (coords[isd][ipjp] + coords[isd][ijp]);
1271 for(
MInt isd = xsd; isd < nDim; isd++) {
1275 tmpX1[isd] = (m_cells->coordinates[isd][centCellId] - coords[isd][ij]) / sqrt(2);
1276 tmpX2[isd] = (S1[isd] - S2[isd]) / sqrt(2);
1279 subJ(cellId, 0) = F0;
1280 subJ(cellId, 0) = crossProduct(tmpX1, tmpX2);
1286 for(
MInt isd = xsd; isd < nDim; isd++) {
1287 tmpX1[isd] = (S1P[isd] - S2[isd]) / sqrt(2);
1288 tmpX2[isd] = (m_cells->coordinates[isd][centCellId] - m_coordinates[isd][ipj]) / sqrt(2);
1291 subJ(cellId, 1) = F0;
1292 subJ(cellId, 1) = crossProduct(tmpX1, tmpX2);
1298 for(
MInt isd = xsd; isd < nDim; isd++) {
1299 tmpX1[isd] = (S2P[isd] - S1[isd]) / sqrt(2);
1300 tmpX2[isd] = (m_coordinates[isd][ijp] - m_cells->coordinates[isd][centCellId]) / sqrt(2);
1303 subJ(cellId, 2) = F0;
1304 subJ(cellId, 2) = crossProduct(tmpX1, tmpX2);
1310 for(
MInt isd = xsd; isd < nDim; isd++) {
1311 tmpX1[isd] = (m_coordinates[isd][ipjp] - m_cells->coordinates[isd][centCellId]) / sqrt(2);
1312 tmpX2[isd] = (S2P[isd] - S1P[isd]) / sqrt(2);
1315 subJ(cellId, 3) = F0;
1316 subJ(cellId, 3) = crossProduct(tmpX1, tmpX2);
1326 for(
MInt i = 0; i < m_noCells; i++) {
1327 for(
MInt j = 0; j < 4; j++) {
1328 subJtmp(i, j) = subJ(i, j);
1334 for(
MInt j = m_noGhostLayers - 1; j < this->m_nCells[0] - m_noGhostLayers; j++) {
1335 for(
MInt i = m_noGhostLayers - 1; i < this->m_nCells[1] - m_noGhostLayers; i++) {
1336 MInt cellId = cellIndex(i, j);
1338 subJ(cellId, 0) = subJtmp(cellIndex(i - 1, j - 1), 3);
1339 subJ(cellId, 1) = subJtmp(cellIndex(i, j - 1), 2);
1340 subJ(cellId, 2) = subJtmp(cellIndex(i - 1, j), 1);
1341 subJ(cellId, 3) = subJtmp(cellIndex(i, j), 0);
1347 for(
MInt j = m_noGhostLayers - 1; j < this->m_nCells[0] - m_noGhostLayers; j++) {
1348 for(
MInt i = m_noGhostLayers - 1; i < this->m_nCells[1] - m_noGhostLayers; i++) {
1349 MInt cellId = cellIndex(i, j);
1351 m_cells->cornerJac[cellId] = F0;
1352 for(
MInt jacId = 0; jacId < 4; jacId++) {
1353 m_cells->cornerJac[cellId] += subJ(cellId, jacId);
1357 m_cells->cornerJac[cellId] = m_cells->cornerJac[cellId];
1368 constexpr MInt nDim = 3;
1369 MFloat** __restrict coords = m_coordinates;
1371 maia::parallelFor<true, nDim>(
1372 cellBegin(m_noGhostLayers - 1), cellEnd(1), [=](
const MInt& i,
const MInt& j,
const MInt& k) {
1373 const MInt cellId = cellIndex(i, j, k);
1375 const MInt ijk = getPointIdFromCell(i, j, k);
1376 const MInt ijpk = getPointIdFromPoint(ijk, 0, 1, 0);
1377 const MInt ijkp = getPointIdFromPoint(ijk, 0, 0, 1);
1378 const MInt ijpkp = getPointIdFromPoint(ijk, 0, 1, 1);
1379 const MInt ipjk = getPointIdFromPoint(ijk, 1, 0, 0);
1380 const MInt ipjpk = getPointIdFromPoint(ijk, 1, 1, 0);
1381 const MInt ipjkp = getPointIdFromPoint(ijk, 1, 0, 1);
1382 const MInt ipjpkp = getPointIdFromPoint(ijk, 1, 1, 1);
1384 MFloat DX1[3] = {F0, F0, F0};
1385 MFloat DX2[3] = {F0, F0, F0};
1386 MFloat DX3[3] = {F0, F0, F0};
1388 MFloat tmpX1[3] = {F0, F0, F0};
1389 MFloat tmpX2[3] = {F0, F0, F0};
1390 MFloat tmpX3[3] = {F0, F0, F0};
1391 MFloat tmpX4[3] = {F0, F0, F0};
1392 MFloat tmpX5[3] = {F0, F0, F0};
1393 MFloat tmpX6[3] = {F0, F0, F0};
1395 for(
MInt isd = xsd; isd < nDim; isd++) {
1397 tmpX1[isd] = (coords[isd][ijpk] - coords[isd][ijkp]);
1398 tmpX2[isd] = (coords[isd][ijpkp] - coords[isd][ijk]);
1400 tmpX3[isd] = (coords[isd][ijkp] - coords[isd][ipjk]);
1401 tmpX4[isd] = (coords[isd][ipjkp] - coords[isd][ijk]);
1403 tmpX5[isd] = (coords[isd][ipjpk] - coords[isd][ijk]);
1404 tmpX6[isd] = (coords[isd][ijpk] - coords[isd][ipjk]);
1407 this->crossProduct(DX1, tmpX1, tmpX2);
1408 this->crossProduct(DX2, tmpX3, tmpX4);
1409 this->crossProduct(DX3, tmpX5, tmpX6);
1412 for(
MInt isd = xsd; isd < nDim; isd++) {
1413 jac += (coords[isd][ipjpkp] - coords[isd][ijk]) * F1B2 * (DX1[isd] + DX2[isd] + DX3[isd]);
1417 m_cells->cellJac[cellId] = F1B3 * fabs(jac);
1427 constexpr MInt nDim = 2;
1428 const MFloat*
const*
const RESTRICT coords = m_coordinates;
1430 maia::parallelFor<true, nDim>(cellBegin(m_noGhostLayers - 1), cellEnd(1), [=](
const MInt& i,
const MInt& j) {
1431 const MInt cellId = cellIndex(i, j);
1432 const MInt IJ = getPointIdFromCell(i, j);
1433 const MInt IPJ = getPointIdFromPoint(IJ, 1, 0);
1434 const MInt IJP = getPointIdFromPoint(IJ, 0, 1);
1435 const MInt IPJP = getPointIdFromPoint(IJ, 1, 1);
1437 MFloat diag1[2] = {F0, F0};
1438 MFloat diag2[2] = {F0, F0};
1440 for(
MInt isd = xsd; isd < nDim; isd++) {
1441 diag1[isd] = (coords[isd][IPJP] - coords[isd][IJ]);
1442 diag2[isd] = (coords[isd][IJP] - coords[isd][IPJ]);
1445 const MFloat area = F1B2 * this->crossProduct(diag1, diag2);
1447 m_cells->cellJac[cellId] = area;
1461 constexpr MInt nDim = 2;
1462 maia::parallelFor<true, nDim>(cellBegin(0), cellEnd(1), [=](
const MInt& i,
const MInt& j) {
1463 const MInt IJ = cellIndex(i, j);
1464 const MInt IPJ = cellIndex(i + 1, j);
1465 const MInt IJP = cellIndex(i, j + 1);
1466 const MInt ipjp = getPointIdFromPoint(getPointIdFromCell(i, j), 1, 1);
1467 const MInt ipj = getPointIdFromPoint(getPointIdFromCell(i, j), 1, 0);
1468 const MInt ijp = getPointIdFromPoint(getPointIdFromCell(i, j), 0, 1);
1473 for(
MInt dim = 0; dim < nDim; ++dim) {
1475 DcoordDxi[dim] = m_cells->coordinates[dim][IPJ] - m_cells->coordinates[dim][IJ];
1478 DcoordDeta[dim] = m_coordinates[dim][ipjp] - m_coordinates[dim][ipj];
1481 this->m_cells->surfJac[IJ] = DcoordDeta[1] * DcoordDxi[0] - DcoordDxi[1] * DcoordDeta[0];
1483 for(
MInt dim = 0; dim < nDim; ++dim) {
1485 DcoordDxi[dim] = m_coordinates[dim][ipjp] - m_coordinates[dim][ijp];
1488 DcoordDeta[dim] = m_cells->coordinates[dim][IJP] - m_cells->coordinates[dim][IJ];
1491 this->m_cells->surfJac[m_noCells + IJ] = DcoordDeta[1] * DcoordDxi[0] - DcoordDxi[1] * DcoordDeta[0];
1503 mTerm(1, AT_,
"Not implemented for 3D");
1512 constexpr MInt nDim = 2;
1513 maia::parallelFor<true, nDim>(cellBegin(m_noGhostLayers - 1), cellEnd(1), [=](
const MInt& i,
const MInt& j) {
1514 const MInt cellId = cellIndex(i, j);
1519 for(
MInt isd = xsd; isd < nDim; isd++) {
1521 (m_cells->coordinates[isd][cellIndex(i + 1, j)] - m_cells->coordinates[isd][cellIndex(i - 1, j)]) * F1B2;
1524 (m_cells->coordinates[isd][cellIndex(i, j + 1)] - m_cells->coordinates[isd][cellIndex(i, j - 1)]) * F1B2;
1527 m_cells->cellMetrics[0][cellId] = DcoordDeta[1];
1528 m_cells->cellMetrics[1][cellId] = -DcoordDeta[0];
1529 m_cells->cellMetrics[2][cellId] = -DcoordDxi[1];
1530 m_cells->cellMetrics[3][cellId] = DcoordDxi[0];
1540 constexpr MInt nDim = 3;
1541 const MFloat*
const*
const RESTRICT coords = m_cells->coordinates;
1543 maia::parallelFor<true, nDim>(
1544 cellBegin(m_noGhostLayers - 1), cellEnd(1), [=](
const MInt& i,
const MInt& j,
const MInt& k) {
1545 const MInt cellId = cellIndex(i, j, k);
1553 for(
MInt isd = xsd; isd < nDim; isd++) {
1554 DcoordDxi[isd] = (coords[isd][cellIndex(i + 1, j, k)] - coords[isd][cellIndex(i - 1, j, k)]) * F1B2;
1556 DcoordDeta[isd] = (coords[isd][cellIndex(i, j + 1, k)] - coords[isd][cellIndex(i, j - 1, k)]) * F1B2;
1558 DcoordDzeta[isd] = (coords[isd][cellIndex(i, j, k + 1)] - coords[isd][cellIndex(i, j, k - 1)]) * F1B2;
1564 this->crossProduct(metricTmp, DcoordDeta, DcoordDzeta);
1565 for(
MInt isd = xsd; isd < nDim; isd++) {
1566 m_cells->cellMetrics[xsd * nDim + isd][cellId] = metricTmp[isd];
1569 this->crossProduct(metricTmp, DcoordDzeta, DcoordDxi);
1570 for(
MInt isd = xsd; isd < nDim; isd++) {
1571 m_cells->cellMetrics[ysd * nDim + isd][cellId] = metricTmp[isd];
1574 this->crossProduct(metricTmp, DcoordDxi, DcoordDeta);
1575 for(
MInt isd = xsd; isd < nDim; isd++) {
1576 m_cells->cellMetrics[zsd * nDim + isd][cellId] = metricTmp[isd];
1587 constexpr MInt nDim = 3;
1588 const MFloat*
const*
const RESTRICT coords = m_coordinates;
1590 maia::parallelFor<true, nDim>(cellBegin(0), cellEnd(0), [=](
const MInt& i,
const MInt& j,
const MInt& k) {
1592 const MInt cellId = cellIndex(i, j, k);
1594 const MInt ijk = getPointIdFromCell(i, j, k);
1595 const MInt ipjk = getPointIdFromPoint(ijk, 1, 0, 0);
1596 const MInt ipjpk = getPointIdFromPoint(ijk, 1, 1, 0);
1597 const MInt ipjkp = getPointIdFromPoint(ijk, 1, 0, 1);
1598 const MInt ipjpkp = getPointIdFromPoint(ijk, 1, 1, 1);
1599 const MInt ijpk = getPointIdFromPoint(ijk, 0, 1, 0);
1600 const MInt ijpkp = getPointIdFromPoint(ijk, 0, 1, 1);
1601 const MInt ijkp = getPointIdFromPoint(ijk, 0, 0, 1);
1604 MFloat DcoordDxi[3] = {F0, F0, F0};
1605 MFloat DcoordDeta[3] = {F0, F0, F0};
1606 MFloat DcoordDzeta[3] = {F0, F0, F0};
1608 MFloat metricTmp[3] = {F0, F0, F0};
1614 for(
MInt isd = xsd; isd < nDim; isd++) {
1615 DcoordDeta[isd] = ((coords[isd][ipjpkp] + coords[isd][ipjpk]) - (coords[isd][ipjkp] + coords[isd][ipjk])) * F1B2;
1616 DcoordDzeta[isd] = ((coords[isd][ipjpkp] + coords[isd][ipjkp]) - (coords[isd][ipjpk] + coords[isd][ipjk])) * F1B2;
1620 crossProduct(metricTmp, DcoordDeta, DcoordDzeta);
1622 for(
MInt isd = xsd; isd < nDim; isd++) {
1623 m_cells->surfaceMetrics[xsd * nDim + isd][cellId] = metricTmp[isd];
1630 for(
MInt isd = xsd; isd < nDim; isd++) {
1631 DcoordDxi[isd] = ((coords[isd][ipjpkp] + coords[isd][ipjpk]) - (coords[isd][ijpkp] + coords[isd][ijpk])) * F1B2;
1633 DcoordDzeta[isd] = ((coords[isd][ijpkp] + coords[isd][ipjpkp]) - (coords[isd][ipjpk] + coords[isd][ijpk])) * F1B2;
1637 crossProduct(metricTmp, DcoordDzeta, DcoordDxi);
1639 for(
MInt isd = xsd; isd < nDim; isd++) {
1640 m_cells->surfaceMetrics[ysd * nDim + isd][cellId] = metricTmp[isd];
1647 for(
MInt isd = xsd; isd < nDim; isd++) {
1648 DcoordDxi[isd] = ((coords[isd][ipjpkp] + coords[isd][ipjkp]) - (coords[isd][ijpkp] + coords[isd][ijkp])) * F1B2;
1650 DcoordDeta[isd] = ((coords[isd][ipjpkp] + coords[isd][ijpkp]) - (coords[isd][ipjkp] + coords[isd][ijkp])) * F1B2;
1654 crossProduct(metricTmp, DcoordDxi, DcoordDeta);
1656 for(
MInt isd = xsd; isd < nDim; isd++) {
1657 m_cells->surfaceMetrics[zsd * nDim + isd][cellId] = metricTmp[isd];
1668 constexpr MInt nDim = 2;
1669 maia::parallelFor<true, nDim>(cellBegin(0), cellEnd(1), [=](
const MInt& i,
const MInt& j) {
1671 const MInt cellId = this->cellIndex(i, j);
1673 const MInt IJ = getPointIdFromCell(i, j);
1674 const MInt IPJ = getPointIdFromPoint(IJ, 1, 0);
1675 const MInt IPJP = getPointIdFromPoint(IJ, 1, 1);
1676 const MInt IJP = getPointIdFromPoint(IJ, 0, 1);
1682 for(
MInt isd = xsd; isd < nDim; ++isd) {
1683 DcoordDxi[isd] = m_coordinates[isd][IPJP] - m_coordinates[isd][IPJ];
1687 m_cells->surfaceMetrics[0][cellId] = DcoordDxi[1];
1688 m_cells->surfaceMetrics[1][cellId] = -DcoordDxi[0];
1692 for(
MInt isd = xsd; isd < nDim; ++isd) {
1693 DcoordDxi[isd] = m_coordinates[isd][IPJP] - m_coordinates[isd][IJP];
1696 m_cells->surfaceMetrics[2][cellId] = -DcoordDxi[1];
1697 m_cells->surfaceMetrics[3][cellId] = DcoordDxi[0];
1709 IF_CONSTEXPR(nDim == 3) TERMM(1,
"Not implemented in 3D!");
1711 for(
MInt i = 0; i < m_hasSingularity; ++i) {
1713 if(m_singularity[i].BC == -6000) {
1715 for(
MInt j = 0; j < nDim; j++) {
1716 ASSERT(m_singularity[i].end[j] - m_singularity[i].start[j] == 1,
"");
1719 for(
MInt jj = m_singularity[i].start[1]; jj < m_singularity[i].end[1]; ++jj) {
1720 for(
MInt ii = m_singularity[i].start[0]; ii < m_singularity[i].end[0]; ++ii) {
1722 const MInt IJ = cellIndex(ii, jj);
1724 const MInt sign_xi = 2 * m_singularity[i].Viscous[0] + 1;
1725 const MInt sign_eta = 2 * m_singularity[i].Viscous[1] + 1;
1727 const MInt IPMJ = getCellIdFromCell(IJ, sign_xi, 0);
1728 const MInt IJPM = getCellIdFromCell(IJ, 0, sign_eta);
1734 for(
MInt isd = xsd; isd < nDim; ++isd) {
1735 DcoordD[isd] = sign_xi * (m_cells->coordinates[isd][IPMJ] - m_cells->coordinates[isd][IJ]);
1739 m_cells->surfaceMetricsSingularity[2][i] = -DcoordD[1];
1740 m_cells->surfaceMetricsSingularity[3][i] = DcoordD[0];
1744 for(
MInt isd = xsd; isd < nDim; ++isd) {
1745 DcoordD[isd] = sign_eta * (m_cells->coordinates[isd][IJPM] - m_cells->coordinates[isd][IJ]);
1748 m_cells->surfaceMetricsSingularity[0][i] = DcoordD[1];
1749 m_cells->surfaceMetricsSingularity[1][i] = -DcoordD[0];
1771 constexpr MInt nDim = 3;
1773 const MFloat*
const*
const RESTRICT coords = m_coordinates;
1775 for(
MInt k = m_noGhostLayers - 1; k < this->m_nCells[0] - m_noGhostLayers; k++) {
1776 for(
MInt j = m_noGhostLayers - 1; j < this->m_nCells[1] - m_noGhostLayers; j++) {
1777 for(
MInt i = m_noGhostLayers - 1; i < this->m_nCells[2] - m_noGhostLayers; i++) {
1779 MInt cellId = this->cellIndex(i, j, k);
1782 MFloat DcoordDxi[3] = {F0, F0, F0};
1783 MFloat DcoordDeta[3] = {F0, F0, F0};
1784 MFloat DcoordDzeta[3] = {F0, F0, F0};
1788 for(
MInt isd = xsd; isd < nDim; isd++) {
1790 DcoordDxi[isd] = F1B2
1791 * (coords[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k), 1, 1, 1)]
1792 - coords[isd][getPointIdFromPoint(getPointIdFromCell(i - 1, j, k), 1, 1, 1)]);
1795 DcoordDeta[isd] = F1B2
1796 * (coords[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k), 1, 1, 1)]
1797 - coords[isd][getPointIdFromPoint(getPointIdFromCell(i, j - 1, k), 1, 1, 1)]);
1800 DcoordDzeta[isd] = F1B2
1801 * (coords[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k + 1), 1, 1, 1)]
1802 - coords[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k - 1), 1, 1, 1)]);
1808 this->crossProduct(metricTmp, DcoordDeta, DcoordDzeta);
1809 for(
MInt isd = xsd; isd < nDim; isd++) {
1810 m_cells->cornerMetrics[xsd * nDim + isd][cellId] = metricTmp[isd];
1813 this->crossProduct(metricTmp, DcoordDzeta, DcoordDxi);
1814 for(
MInt isd = xsd; isd < nDim; isd++) {
1815 m_cells->cornerMetrics[ysd * nDim + isd][cellId] = metricTmp[isd];
1818 this->crossProduct(metricTmp, DcoordDxi, DcoordDeta);
1819 for(
MInt isd = xsd; isd < nDim; isd++) {
1820 m_cells->cornerMetrics[zsd * nDim + isd][cellId] = metricTmp[isd];
1833 constexpr MInt nDim = 2;
1834 for(
MInt j = m_noGhostLayers - 1; j < m_nCells[0] - m_noGhostLayers; ++j) {
1835 for(
MInt i = m_noGhostLayers - 1; i < m_nCells[1] - m_noGhostLayers; ++i) {
1837 const MInt cellId = cellIndex(i, j);
1843 for(
MInt isd = xsd; isd < nDim; ++isd) {
1848 DcoordDxi[isd] = F1B2
1849 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j), 1, 1)]
1850 - m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i - 1, j), 1, 1)]);
1853 DcoordDeta[isd] = F1B2
1854 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1), 1, 1)]
1855 - m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j - 1), 1, 1)]);
1857 m_cells->cornerMetrics[0][cellId] = DcoordDeta[1];
1858 m_cells->cornerMetrics[1][cellId] = -DcoordDeta[0];
1859 m_cells->cornerMetrics[2][cellId] = -DcoordDxi[1];
1860 m_cells->cornerMetrics[3][cellId] = DcoordDxi[0];
1871 computeCornerMetrics();
1880 m_log <<
"computing corner metrics ..." << endl;
1881 constexpr MInt nDim = 3;
1883 for(
MInt k = m_noGhostLayers - 1; k < this->m_nCells[0] - m_noGhostLayers; k++) {
1884 for(
MInt j = m_noGhostLayers - 1; j < this->m_nCells[1] - m_noGhostLayers; j++) {
1885 for(
MInt i = m_noGhostLayers - 1; i < this->m_nCells[2] - m_noGhostLayers; i++) {
1887 MInt cellId = this->cellIndex(i, j, k);
1903 for(
MInt isd = xsd; isd < nDim; isd++) {
1908 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k + 1), 1, 0, 0)]
1909 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k + 1), 1, 0, 1)]
1910 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k + 1), 1, 1, 0)]
1911 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k + 1), 1, 1, 1)]);
1915 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 1, 0, 0)]
1916 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 1, 0, 1)]
1917 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 1, 1, 0)]
1918 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 1, 1, 1)]);
1922 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k + 1), 1, 0, 0)]
1923 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k + 1), 1, 0, 1)]
1924 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k + 1), 1, 1, 0)]
1925 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k + 1), 1, 1, 1)]);
1928 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k), 1, 0, 0)]
1929 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k), 1, 0, 1)]
1930 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k), 1, 1, 0)]
1931 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k), 1, 1, 1)]);
1933 diag1[isd] = p1[isd] - p2[isd];
1934 diag2[isd] = p3[isd] - p4[isd];
1937 this->crossProduct(metricTmp, diag1, diag2);
1938 for(
MInt isd = xsd; isd < nDim; isd++) {
1939 m_cells->cornerMetrics[xsd * nDim + isd][cellId] = F1B2 * metricTmp[isd];
1947 for(
MInt isd = xsd; isd < nDim; isd++) {
1952 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k + 1), 0, 1, 0)]
1953 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k + 1), 1, 1, 0)]
1954 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k + 1), 0, 1, 1)]
1955 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k + 1), 1, 1, 1)]);
1959 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 0, 1, 0)]
1960 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 1, 1, 0)]
1961 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 0, 1, 1)]
1962 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 1, 1, 1)]);
1965 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k), 0, 1, 0)]
1966 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k), 1, 1, 0)]
1967 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k), 0, 1, 1)]
1968 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k), 1, 1, 1)]);
1971 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k + 1), 0, 1, 0)]
1972 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k + 1), 1, 1, 0)]
1973 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k + 1), 0, 1, 1)]
1974 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k + 1), 1, 1, 1)]);
1976 diag1[isd] = p1[isd] - p2[isd];
1977 diag2[isd] = p3[isd] - p4[isd];
1980 this->crossProduct(metricTmp, diag1, diag2);
1981 for(
MInt isd = xsd; isd < nDim; isd++) {
1982 m_cells->cornerMetrics[ysd * nDim + isd][cellId] = F1B2 * metricTmp[isd];
1989 for(
MInt isd = xsd; isd < nDim; isd++) {
1991 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j + 1, k), 1, 1, 1)]
1992 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j + 1, k), 0, 1, 1)]
1993 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j + 1, k), 1, 0, 1)]
1994 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j + 1, k), 0, 0, 1)]);
1998 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 1, 1, 1)]
1999 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 0, 1, 1)]
2000 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 1, 0, 1)]
2001 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j, k), 0, 0, 1)]);
2004 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k), 1, 1, 1)]
2005 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k), 0, 1, 1)]
2006 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k), 1, 0, 1)]
2007 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i, j + 1, k), 0, 0, 1)]);
2010 * (m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k), 1, 1, 1)]
2011 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k), 0, 1, 1)]
2012 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k), 1, 0, 1)]
2013 + m_coordinates[isd][getPointIdFromPoint(getPointIdFromCell(i + 1, j, k), 0, 0, 1)]);
2015 diag1[isd] = p1[isd] - p2[isd];
2016 diag2[isd] = p3[isd] - p4[isd];
2019 this->crossProduct(metricTmp, diag1, diag2);
2020 for(
MInt isd = xsd; isd < nDim; isd++) {
2021 m_cells->cornerMetrics[zsd * nDim + isd][cellId] = F1B2 * metricTmp[isd];
2041 const MFloat frk = F1 / (timeStep * RKalpha[RKStep]);
2042 constexpr MInt nDim = 3;
2044 const MInt IJK[3] = {m_nCells[2], m_nCells[1], m_nCells[0]};
2046 const MFloat*
const*
const RESTRICT coords = m_coordinates;
2047 const MFloat*
const*
const RESTRICT oldCoords = m_oldCoordinates;
2049 const MInt inc[12] = {getPointIdFromPoint(0, 1, 0, 0), getPointIdFromPoint(0, 1, 1, 0),
2050 getPointIdFromPoint(0, 1, 0, 1), getPointIdFromPoint(0, 1, 1, 1),
2052 getPointIdFromPoint(0, 0, 1, 0), getPointIdFromPoint(0, 0, 1, 1),
2053 getPointIdFromPoint(0, 1, 1, 0), getPointIdFromPoint(0, 1, 1, 1),
2055 getPointIdFromPoint(0, 0, 0, 1), getPointIdFromPoint(0, 1, 0, 1),
2056 getPointIdFromPoint(0, 0, 1, 1), getPointIdFromPoint(0, 1, 1, 1)};
2059 for(
MInt dim = 0; dim < nDim; ++dim) {
2060 for(
MInt k = 0; k < IJK[2]; ++k) {
2061 for(
MInt j = 0; j < IJK[1]; ++j) {
2062 for(
MInt i = 0; i < IJK[0]; ++i) {
2064 const MInt cellId = cellIndex(i, j, k);
2067 const MInt ijk = getPointIdFromCell(i, j, k);
2069 const MInt p0 = ijk + inc[dim * 4 + 0];
2070 const MInt p1 = ijk + inc[dim * 4 + 1];
2071 const MInt p2 = ijk + inc[dim * 4 + 2];
2072 const MInt p3 = ijk + inc[dim * 4 + 3];
2075 m_cells->dxt[dim][cellId] = F0;
2077 MFloat diag1[3] = {F0, F0, F0};
2078 MFloat diag2[3] = {F0, F0, F0};
2079 MFloat oldNormal[3] = {F0, F0, F0};
2080 MFloat newNormal1[3] = {F0, F0, F0};
2081 MFloat newNormal2[3] = {F0, F0, F0};
2085 for(
MInt isd = xsd; isd < nDim; isd++) {
2086 diag1[isd] = (oldCoords[isd][p3] - oldCoords[isd][p0]);
2087 diag2[isd] = (oldCoords[isd][p2] - oldCoords[isd][p1]);
2090 this->crossProduct(oldNormal, diag1, diag2);
2092 for(
MInt isd = xsd; isd < nDim; isd++) {
2093 diag1[isd] = (coords[isd][p2] - oldCoords[isd][p0]);
2094 diag2[isd] = (coords[isd][p0] - oldCoords[isd][p2]);
2097 this->crossProduct(newNormal1, diag1, diag2);
2099 for(
MInt isd = xsd; isd < nDim; isd++) {
2100 diag1[isd] = (coords[isd][p0] - oldCoords[isd][p1]);
2101 diag2[isd] = (coords[isd][p1] - oldCoords[isd][p0]);
2104 this->crossProduct(newNormal2, diag1, diag2);
2108 * ((coords[0][p3] - oldCoords[0][p0]) * (oldNormal[0] + newNormal1[0] + newNormal2[0]) * F1B2
2109 + (coords[1][p3] - oldCoords[1][p0]) * (oldNormal[1] + newNormal1[1] + newNormal2[1]) * F1B2
2110 + (coords[2][p3] - oldCoords[2][p0]) * (oldNormal[2] + newNormal1[2] + newNormal2[2]) * F1B2);
2112 m_cells->dxt[dim][cellId] = jac * frk;
2131 const MFloat frk = F1 / (timeStep * RKalpha[RKStep]);
2132 constexpr MInt nDim = 2;
2134 const MInt IJ[2] = {m_nCells[0], m_nCells[1]};
2136 const MFloat*
const*
const RESTRICT coords = m_coordinates;
2137 const MFloat*
const*
const RESTRICT oldCoords = m_oldCoordinates;
2139 const MInt inc[4] = {
2140 getPointIdFromPoint(0, 1, 1),
2141 getPointIdFromPoint(0, 1, 0),
2142 getPointIdFromPoint(0, 0, 1),
2143 getPointIdFromPoint(0, 1, 1),
2146 for(
MInt dim = 0; dim < nDim; ++dim) {
2147 for(
MInt j = 0; j < IJ[0]; ++j) {
2148 for(
MInt i = 0; i < IJ[1]; ++i) {
2150 const MInt cellId = cellIndex(i, j);
2153 const MInt ij = getPointIdFromCell(i, j);
2155 const MInt p0 = ij + inc[dim * 2 + 0];
2156 const MInt p1 = ij + inc[dim * 2 + 1];
2159 m_cells->dxt[dim][cellId] = F0;
2161 MFloat diag1[2] = {F0, F0};
2162 MFloat diag2[2] = {F0, F0};
2164 for(
MInt isd = xsd; isd < nDim; isd++) {
2165 diag1[isd] = (oldCoords[isd][p0] - coords[isd][p1]);
2166 diag2[isd] = (oldCoords[isd][p1] - coords[isd][p0]);
2169 const MFloat area = F1B2 * (diag1[0] * diag2[1] - diag1[1] * diag2[0]);
2171 m_cells->dxt[dim][cellId] = area * frk;
2183 constexpr MInt nDim = 3;
2184 for(
MInt k = 0; k < m_nPoints[0]; ++k) {
2185 for(
MInt j = 0; j < m_nPoints[1]; ++j) {
2186 for(
MInt i = 0; i < m_nPoints[2]; ++i) {
2187 const MInt pointId = pointIndex(i, j, k);
2188 for(
MInt isd = xsd; isd < nDim; ++isd) {
2189 m_oldCoordinates[isd][pointId] = m_coordinates[isd][pointId];
2202 constexpr MInt nDim = 2;
2203 for(
MInt j = 0; j < m_nPoints[0]; ++j) {
2204 for(
MInt i = 0; i < m_nPoints[1]; ++i) {
2205 const MInt pointId = pointIndex(i, j);
2206 for(
MInt isd = xsd; isd < nDim; ++isd) {
2207 m_oldCoordinates[isd][pointId] = m_coordinates[isd][pointId];
2220 MFloat*
const RESTRICT oldCellJac = ALIGNED_MF(m_cells->oldCellJac);
2221 const MFloat*
const RESTRICT cellJac = ALIGNED_MF(m_cells->cellJac);
2222 for(
MInt cellId = 0; cellId < m_noCells; cellId++) {
2223 oldCellJac[cellId] = cellJac[cellId];
2234 constexpr MInt nDim = 3;
2236 MInt pointId, FixPointId, MirrorPointId;
2238 for(
MInt k = m_noGhostLayers; k < (m_nPoints[0] - m_noGhostLayers); k++) {
2239 for(
MInt j = m_noGhostLayers; j < (m_nPoints[1] - m_noGhostLayers); j++) {
2240 for(
MInt i = 0; i < m_noGhostLayers; i++) {
2241 pointId = (m_noGhostLayers - 1 - i) + (j + k * m_nPoints[1]) * m_nPoints[2];
2243 (m_noGhostLayers - i) + (j + k * m_nPoints[1]) * m_nPoints[2];
2244 MirrorPointId = (m_noGhostLayers + 1 - i) + (j + k * m_nPoints[1]) * m_nPoints[2];
2245 for(
MInt dim = 0; dim < nDim; dim++) {
2246 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2250 pointId = (m_nPoints[2] - i - 1) + (j + k * m_nPoints[1]) * m_nPoints[2];
2251 FixPointId = (m_nPoints[2] - m_noGhostLayers - 1) + (j + k * m_nPoints[1]) * m_nPoints[2];
2252 MirrorPointId = (m_nPoints[2] - 1 - (2 * m_noGhostLayers - i)) + (j + k * m_nPoints[1]) * m_nPoints[2];
2253 for(
MInt dim = 0; dim < nDim; dim++) {
2254 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2262 for(
MInt k = m_noGhostLayers; k < (m_nPoints[0] - m_noGhostLayers); k++) {
2263 for(
MInt j = 0; j < m_noGhostLayers; j++) {
2264 for(
MInt i = m_noGhostLayers; i < (m_nPoints[2] - m_noGhostLayers); i++) {
2265 pointId = i + ((m_noGhostLayers - j - 1) + k * m_nPoints[1]) * m_nPoints[2];
2267 i + ((m_noGhostLayers - j) + k * m_nPoints[1]) * m_nPoints[2];
2268 MirrorPointId = i + ((m_noGhostLayers + 1 - j) + k * m_nPoints[1]) * m_nPoints[2];
2269 for(
MInt dim = 0; dim < nDim; dim++) {
2270 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2273 pointId = i + ((m_nPoints[1] - j - 1) + k * m_nPoints[1]) * m_nPoints[2];
2274 FixPointId = i + ((m_nPoints[1] - m_noGhostLayers - 1) + k * m_nPoints[1]) * m_nPoints[2];
2275 MirrorPointId = i + ((m_nPoints[1] - 1 - (2 * m_noGhostLayers - j)) + k * m_nPoints[1]) * m_nPoints[2];
2276 for(
MInt dim = 0; dim < nDim; dim++) {
2277 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2284 for(
MInt k = 0; k < m_noGhostLayers; k++) {
2285 for(
MInt j = 0; j < (m_nPoints[1] - m_noGhostLayers); j++) {
2286 for(
MInt i = m_noGhostLayers; i < (m_nPoints[2] - m_noGhostLayers); i++) {
2287 pointId = i + (j + (m_noGhostLayers - 1 - k) * m_nPoints[1]) * m_nPoints[2];
2289 i + (j + (m_noGhostLayers - k) * m_nPoints[1]) * m_nPoints[2];
2291 i + (j + (m_noGhostLayers + 1 - k) * m_nPoints[1]) * m_nPoints[2];
2292 for(
MInt dim = 0; dim < nDim; dim++) {
2293 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2298 pointId = i + (j + (m_nPoints[0] - k - 1) * m_nPoints[1]) * m_nPoints[2];
2299 FixPointId = i + (j + (m_nPoints[0] - m_noGhostLayers - 1) * m_nPoints[1]) * m_nPoints[2];
2300 MirrorPointId = i + (j + (m_nPoints[0] - 1 - (2 * m_noGhostLayers - k)) * m_nPoints[1]) * m_nPoints[2];
2301 for(
MInt dim = 0; dim < nDim; dim++) {
2302 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2314 for(
MInt k = 0; k < (m_nPoints[0]); k++) {
2315 for(
MInt j = 0; j < (m_nPoints[1]); j++) {
2316 for(
MInt i = 0; i < m_noGhostLayers; i++) {
2317 pointId = (m_noGhostLayers - 1 - i) + (j + k * m_nPoints[1]) * m_nPoints[2];
2319 (m_noGhostLayers - i) + (j + k * m_nPoints[1]) * m_nPoints[2];
2321 (m_noGhostLayers + 1 - i) + (j + k * m_nPoints[1]) * m_nPoints[2];
2322 for(
MInt dim = 0; dim < nDim; dim++) {
2323 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2327 pointId = (m_nPoints[2] - i - 1) + (j + k * m_nPoints[1]) * m_nPoints[2];
2328 FixPointId = (m_nPoints[2] - m_noGhostLayers - 1) + (j + k * m_nPoints[1]) * m_nPoints[2];
2329 MirrorPointId = (m_nPoints[2] - 1 - (2 * m_noGhostLayers - i)) + (j + k * m_nPoints[1]) * m_nPoints[2];
2330 for(
MInt dim = 0; dim < nDim; dim++) {
2331 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2337 for(
MInt k = 0; k < (m_nPoints[0]); k++) {
2338 for(
MInt j = 0; j < m_noGhostLayers; j++) {
2339 for(
MInt i = 0; i < (m_nPoints[2]); i++) {
2340 pointId = i + ((m_noGhostLayers - j - 1) + k * m_nPoints[1]) * m_nPoints[2];
2342 i + ((m_noGhostLayers - j) + k * m_nPoints[1]) * m_nPoints[2];
2343 MirrorPointId = i + ((m_noGhostLayers + 1 - j) + k * m_nPoints[1]) * m_nPoints[2];
2344 for(
MInt dim = 0; dim < nDim; dim++) {
2345 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2348 pointId = i + ((m_nPoints[1] - j - 1) + k * m_nPoints[1]) * m_nPoints[2];
2349 FixPointId = i + ((m_nPoints[1] - m_noGhostLayers - 1) + k * m_nPoints[1]) * m_nPoints[2];
2350 MirrorPointId = i + ((m_nPoints[1] - 1 - (2 * m_noGhostLayers - j)) + k * m_nPoints[1]) * m_nPoints[2];
2351 for(
MInt dim = 0; dim < nDim; dim++) {
2352 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2358 for(
MInt k = 0; k < m_noGhostLayers; k++) {
2359 for(
MInt j = 0; j < (m_nPoints[1]); j++) {
2360 for(
MInt i = 0; i < (m_nPoints[2]); i++) {
2361 pointId = i + (j + (m_noGhostLayers - 1 - k) * m_nPoints[1]) * m_nPoints[2];
2363 i + (j + (m_noGhostLayers - k) * m_nPoints[1]) * m_nPoints[2];
2364 MirrorPointId = i + (j + (m_noGhostLayers + 1 - k) * m_nPoints[1]) * m_nPoints[2];
2365 for(
MInt dim = 0; dim < nDim; dim++) {
2366 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2370 pointId = i + (j + (m_nPoints[0] - k - 1) * m_nPoints[1]) * m_nPoints[2];
2371 FixPointId = i + (j + (m_nPoints[0] - m_noGhostLayers - 1) * m_nPoints[1]) * m_nPoints[2];
2372 MirrorPointId = i + (j + (m_nPoints[0] - 1 - (2 * m_noGhostLayers - k)) * m_nPoints[1]) * m_nPoints[2];
2373 for(
MInt dim = 0; dim < nDim; dim++) {
2374 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2388 constexpr MInt nDim = 2;
2391 MInt pointId, FixPointId, MirrorPointId;
2393 for(
MInt j = m_noGhostLayers; j < (m_nPoints[0] - m_noGhostLayers); ++j) {
2394 for(
MInt i = 0; i < m_noGhostLayers; ++i) {
2395 pointId = (m_noGhostLayers - 1 - i) + (j * m_nPoints[1]);
2396 FixPointId = (m_noGhostLayers - i) + (j * m_nPoints[1]);
2397 MirrorPointId = (m_noGhostLayers + 1 - i) + (j * m_nPoints[1]);
2399 for(
MInt dim = 0; dim < nDim; ++dim) {
2400 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2404 pointId = (m_nPoints[1] - i - 1) + (j * m_nPoints[1]);
2405 FixPointId = (m_nPoints[1] - m_noGhostLayers - 1) + (j * m_nPoints[1]);
2406 MirrorPointId = (m_nPoints[1] - 1 - (2 * m_noGhostLayers - i)) + (j * m_nPoints[1]);
2407 for(
MInt dim = 0; dim < nDim; ++dim) {
2408 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2415 for(
MInt j = 0; j < m_noGhostLayers; ++j) {
2416 for(
MInt i = m_noGhostLayers; i < (m_nPoints[1] - m_noGhostLayers); ++i) {
2417 pointId = i + (m_noGhostLayers - j - 1) * m_nPoints[1];
2418 FixPointId = i + (m_noGhostLayers - j) * m_nPoints[1];
2419 MirrorPointId = i + (m_noGhostLayers + 1 - j) * m_nPoints[1];
2420 for(
MInt dim = 0; dim < nDim; ++dim) {
2421 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2425 pointId = i + (m_nPoints[0] - j - 1) * m_nPoints[1];
2426 FixPointId = i + (m_nPoints[0] - m_noGhostLayers - 1) * m_nPoints[1];
2427 MirrorPointId = i + (m_nPoints[0] - 1 - (2 * m_noGhostLayers - j)) * m_nPoints[1];
2428 for(
MInt dim = 0; dim < nDim; ++dim) {
2429 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2440 for(
MInt j = 0; j < (m_nPoints[0]); ++j) {
2441 for(
MInt i = 0; i < m_noGhostLayers; ++i) {
2442 pointId = (m_noGhostLayers - 1 - i) + (j * m_nPoints[1]);
2443 FixPointId = (m_noGhostLayers - i) + (j * m_nPoints[1]);
2444 MirrorPointId = (m_noGhostLayers + 1 - i) + (j * m_nPoints[1]);
2445 for(
MInt dim = 0; dim < nDim; ++dim) {
2446 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2450 pointId = (m_nPoints[1] - i - 1) + (j * m_nPoints[1]);
2451 FixPointId = (m_nPoints[1] - m_noGhostLayers - 1) + (j * m_nPoints[1]);
2452 MirrorPointId = (m_nPoints[1] - 1 - (2 * m_noGhostLayers - i)) + (j * m_nPoints[1]);
2453 for(
MInt dim = 0; dim < nDim; ++dim) {
2454 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2461 for(
MInt j = 0; j < m_noGhostLayers; ++j) {
2462 for(
MInt i = 0; i < (m_nPoints[1]); ++i) {
2463 pointId = i + (m_noGhostLayers - j - 1) * m_nPoints[1];
2464 FixPointId = i + (m_noGhostLayers - j) * m_nPoints[1];
2465 MirrorPointId = i + (m_noGhostLayers + 1 - j) * m_nPoints[1];
2466 for(
MInt dim = 0; dim < nDim; ++dim) {
2467 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
2471 pointId = i + (m_nPoints[0] - j - 1) * m_nPoints[1];
2472 FixPointId = i + (m_nPoints[0] - m_noGhostLayers - 1) * m_nPoints[1];
2473 MirrorPointId = i + (m_nPoints[0] - 1 - (2 * m_noGhostLayers - j)) * m_nPoints[1];
2474 for(
MInt dim = 0; dim < nDim; ++dim) {
2475 m_coordinates[dim][pointId] = (2 * m_coordinates[dim][FixPointId] - m_coordinates[dim][MirrorPointId]);
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
void defineArray(maiabd_type type, const MString &name, size_type totalCount)
Create a new array in the file.
void writeArray(const T *array, const MString &name, size_type memoryStride=-1, size_type diskStride=-1)
Write array data to file. [MPI]
void setAttribute(const T &value, const MString &name, const MString &datasetName="")
Set a file or dataset attribute. [MPI]
void readArray(T *array, const MString &name, size_type memoryStride=-1, size_type diskStride=-1)
Read array data from file. [MPI]
This class is a ScratchSpace.
void fill(T val)
fill the scratch with a given value
void gridDecomposition(MBool)
Create decomposition of the grid into partitions for MPI parallelization.
void computeCellJacobian()
void computeMetrics()
Computes all metrics by calling the functions for each type of metric computation (cell,...
void extrapolateGhostPointCoordinates()
void saveCellJacobian()
Copies the current state of the cell Jacobians to m_cells->oldCellJacobian.
void periodicPointsChange(MFloat &, const MInt, const MInt)
Displaces the points on periodic boundaries by the distance between the two periodic boundaries.
void exchangePoints(std::vector< std::unique_ptr< StructuredComm< nDim > > > &, std::vector< std::unique_ptr< StructuredComm< nDim > > > &, StructuredCommType)
Exchanges the boundary grid points between MPI partitions.
void writeGrid(MString, MString)
Writes the current grid (including deformations for moving grids) to a file.
void computeCornerMetrics()
void computeModCornerJacobian()
void computeCornerJacobian()
void computeCellMetrics()
~StructuredGrid()
Destructor of the structured grid class.
void readGrid()
Reads in the coordinates (x,y,z) from the grid file.
void computeJacobian()
Computes the Jacobians by calling the functions for each type of Jacobian computation (corner,...
void sendPoints(std::vector< std::unique_ptr< StructuredComm< nDim > > > &, StructuredCommType, std::vector< MPI_Request > &)
Send the coordinates between partitions to other partitions.
void computeDxt(MFloat, MFloat *, MInt)
void computeModCornerMetrics()
void computeSurfaceJacobian()
void setCellReference(StructuredCell *)
Sets the reference to the cell object.
void writePartitionedGrid()
Saves coordinates for partitioned grid with ghost points. Useful for debugging.
void computeSurfaceMetricsSingularity()
Computes the surface metrics for the cell surfaces at the surface centroids (2D) Special version for ...
void computeCellCenterCoordinates()
void scatterPoints(std::vector< std::unique_ptr< StructuredComm< nDim > > > &, StructuredCommType)
Distributes the exchanged points from the receiving buffers to the actual coordinates of the grid.
void gatherPoints(std::vector< std::unique_ptr< StructuredComm< nDim > > > &, StructuredCommType)
Gathers the coordinates of the points for all given sending maps and copies them to a sending buffer.
void prepareReadGrid()
Prepares the arrays containing the size of the grid (points/cells) before the grid coordinates are ac...
void allocateMetricsAndJacobians()
Allocates memory for the metrics and the Jacobians.
StructuredGrid(const MInt, const MPI_Comm)
Constructor for structured grids.
void receivePoints(std::vector< std::unique_ptr< StructuredComm< nDim > > > &, StructuredCommType, std::vector< MPI_Request > &)
Receives the coordinates between partitions to other partitions.
void computeSurfaceMetrics()
void mTerm(const MInt errorCode, const MString &location, const MString &message)
std::basic_string< char > MString
int MPI_Isend(const void *buf, int count, MPI_Datatype datatype, int dest, int tag, MPI_Comm comm, MPI_Request *request, const MString &name, const MString &varname)
same as MPI_Isend
int MPI_Irecv(void *buf, int count, MPI_Datatype datatype, int source, int tag, MPI_Comm comm, MPI_Request *request, const MString &name, const MString &varname)
same as MPI_Irecv
int MPI_Waitall(int count, MPI_Request *request, MPI_Status *status, const MString &name)
same as MPI_Waitall