MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
StructuredInterpolation< nDim > Class Template Reference

#include <fvstructuredinterpolation.h>

Inheritance diagram for StructuredInterpolation< nDim >:
[legend]
Collaboration diagram for StructuredInterpolation< nDim >:
[legend]

Public Member Functions

 StructuredInterpolation (const MPI_Comm structuredCommunicator)
 Constructor for property given donor. More...
 
 StructuredInterpolation (MInt *noDonorCells, MFloat **donorCoordinates, MFloat **donorVariables, const MPI_Comm structuredCommunicator)
 Constructor for manually given donor. More...
 
 StructuredInterpolation (MInt *noDonorCellsDir, MFloat **donorCoordinates, const MPI_Comm structuredCommunicator)
 
 ~StructuredInterpolation ()
 
void interpolateAtPoint (MFloat *intPoint)
 interpolates variables at point For a given 3D coordinate the method interpolates from the donor grid More...
 
void prepareInterpolationField (MInt *noReceiverCells, MFloat **receiverCoordinates)
 Prepares interpolation for field For a given 3D coordinate field the method computes the transformed Points and stores them to perform interpolations later. More...
 
void interpolateField (MString, MFloat *)
 interpolates a field interpolates a given varName and varF More...
 
void loadDonorGrid ()
 Loads a grid file. More...
 
void loadDonorVariable (MString varName)
 Loads a Q file. More...
 
void prepareInterpolation (MInt, MFloat **, MInt *)
 Prepares interpolation neighbours and coefficients For a given number of points the methods computes the interpolation partners and coefficients for later use use together with interpolateVariables() More...
 
void interpolateVariables (MFloat **)
 
MFloat getInterpolatedVariable (MInt, MInt)
 Trilinear interpolation for single point. More...
 
void prepareZonalInterpolation (MInt, MFloat **, MInt *, MBool)
 computes the interpolation coefficients Interpolates all variables with precomputed interpolation coefficients More...
 
MFloat interpolateVariableZonal (MFloat *, MInt)
 
MFloat getInterpolatedVariableZonal (MFloat *, MInt)
 

Protected Member Functions

void buildDonorTree ()
 Builds a kd-tree Creates a kd-tree from the predefined grid-data in m_donorCoordinates. More...
 
void crossProduct (MFloat result[3], MFloat vec1[3], MFloat vec2[3])
 
MFloat scalarProduct (MFloat vec1[3], MFloat vec2[3])
 
MInt getCellIdfromCell (MInt origin, MInt incI, MInt incJ, MInt incK, MInt solverId)
 
MBool approx (const MFloat &, const MFloat &, const MFloat)
 
MInt getBlockId (MInt cellId)
 
void trilinearInterpolation (MFloat *, MInt, MInt, MFloat *, MInt)
 
void trilinearInterpolation (MFloat *, MInt, MFloat *, MInt)
 
void computeInterpolationCoefficients (MFloat *, MInt)
 Computes trilinear interpolation coefficients. More...
 
void transformPoint (MInt hexOrigin, MFloat intPoint[3], MFloat transformedPoint[3])
 Transforms point from physical to computational space. More...
 
MInt findSurroundingHexahedron (MFloat intPoint[3], MInt centerCellId, MInt stencil)
 Finds surrounding hexahedron for point For a given cellId it finds out which of the 8 eight surrounding hexahedrons contains intPoint. If point is inside any of the 6 possible tetraeders inside the hexahedron it is inside the hexahedron, the origin cellId is returned then. More...
 
void nearestNeighbourInterpolation (MInt, MInt, MFloat *)
 Nearest neighbour interpolation. More...
 
void nearestNeighbourInterpolation (MInt, MFloat *)
 
MInt cellIndex (MInt i, MInt j, MInt k, MInt solverId)
 
MInt ic (MInt, MInt, MInt)
 
void computeCellCentreCoordinates (MInt *, MFloatScratchSpace &, MInt, MInt)
 Computes cell centered coordinates. More...
 

Protected Attributes

MInt ** m_noDonorCellsDir = nullptr
 
MInt ** m_noDonorPointsDir = nullptr
 
MIntm_noDonorCells = nullptr
 
MIntm_noDonorPoints = nullptr
 
MFloat ** m_donorCoordinates = nullptr
 
MFloat ** m_donorVariables = nullptr
 
MFloatm_donorVar = nullptr
 
MInt m_noDonorDims
 
MInt m_totalNoDonorCells
 
MIntm_donorBlockOffsets = nullptr
 
MInt m_noBlocks
 
const MPI_Comm m_StructuredComm
 
MInt m_domainId
 
MInt m_noDonorVariables
 
MBool m_donorIsCellCentered
 
MBool m_isFieldInterpolation
 
MFloat m_eps
 
MIntm_donorOriginId = nullptr
 
MFloat ** m_interpolationCoefficients = nullptr
 
MFloatm_donorDistance = nullptr
 
MFloatm_globalDonorDistanceMin = nullptr
 
MBool m_hasInterpolationPartnerDomain
 
MIntm_hasInterpolationPartnersZonal = nullptr
 
MIntm_hasInterpolationPartnersZonalGlobal = nullptr
 
MFloat ** m_transformedReceiverPoints = nullptr
 
MFloat ** m_receiverVariables = nullptr
 
MBoolm_hasInterpolationPartners = nullptr
 
MInt m_noReceiverCells
 
MInt m_currentReceiverId
 
std::vector< Point< 3 > > m_donorPoints
 
KDtree< 3 > * m_donorTree
 

Static Protected Attributes

static const MInt xsd = 0
 
static const MInt ysd = 1
 
static const MInt zsd = 2
 
static constexpr MInt m_pyramidPoints [72]
 

Detailed Description

template<MInt nDim>
class StructuredInterpolation< nDim >

Definition at line 16 of file fvstructuredinterpolation.h.

Constructor & Destructor Documentation

◆ StructuredInterpolation() [1/3]

template<MInt nDim>
StructuredInterpolation< nDim >::StructuredInterpolation ( const MPI_Comm  structuredCommunicator)

The constructor for when the grid and the Q file are specified in the property file.

Author
Marian Albers, Nov 2015

Definition at line 28 of file fvstructuredinterpolation.cpp.

29 : m_StructuredComm(structuredCommunicator),
32 m_eps(std::numeric_limits<MFloat>::epsilon()) {
33 MPI_Comm_rank(m_StructuredComm, &m_domainId);
34
37}
void loadDonorGrid()
Loads a grid file.
void buildDonorTree()
Builds a kd-tree Creates a kd-tree from the predefined grid-data in m_donorCoordinates.

◆ StructuredInterpolation() [2/3]

template<MInt nDim>
StructuredInterpolation< nDim >::StructuredInterpolation ( MInt noDonorCellsDir,
MFloat **  donorCoordinates,
MFloat **  donorVariables,
const MPI_Comm  structuredCommunicator 
)

The constructor when the grid and the variable field are handed over manually, donorCoordinates are the coordinates at which the donorVariables are located, both have the amount of cells given by noDonorCells

Author
Marian Albers, Nov 2015

Definition at line 60 of file fvstructuredinterpolation.cpp.

64 : m_donorCoordinates(donorCoordinates),
65 m_donorVariables(donorVariables),
66 m_noBlocks(1),
67 m_StructuredComm(structuredCommunicator),
71 m_eps(std::numeric_limits<MFloat>::epsilon()) {
72 MPI_Comm_rank(m_StructuredComm, &m_domainId);
73 mAlloc(m_noDonorCellsDir, m_noBlocks, nDim, AT_, 0, "m_noDonorCellsDir");
74 mAlloc(m_donorBlockOffsets, m_noBlocks, AT_, 0, "m_donorBlockOffset");
75
77 for(MInt dim = 0; dim < nDim; dim++) {
78 m_noDonorCellsDir[0][dim] = noDonorCellsDir[dim];
79 m_totalNoDonorCells *= noDonorCellsDir[dim];
80 }
81
83}
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
Definition: alloc.h:173
int32_t MInt
Definition: maiatypes.h:62

◆ StructuredInterpolation() [3/3]

template<MInt nDim>
StructuredInterpolation< nDim >::StructuredInterpolation ( MInt noDonorCellsDir,
MFloat **  donorCoordinates,
const MPI_Comm  structuredCommunicator 
)

Definition at line 86 of file fvstructuredinterpolation.cpp.

89 : m_donorCoordinates(donorCoordinates),
90 m_noBlocks(1),
91 m_StructuredComm(structuredCommunicator),
95 m_eps(std::numeric_limits<MFloat>::epsilon()) {
96 MPI_Comm_rank(m_StructuredComm, &m_domainId);
97 mAlloc(m_noDonorCellsDir, m_noBlocks, nDim, AT_, 0, "m_noDonorCellsDir");
98 mAlloc(m_donorBlockOffsets, m_noBlocks, AT_, 0, "m_donorBlockOffset");
99
101 for(MInt dim = 0; dim < nDim; dim++) {
102 m_noDonorCellsDir[0][dim] = noDonorCellsDir[dim];
103 m_totalNoDonorCells *= noDonorCellsDir[dim];
104 }
105
107}

◆ ~StructuredInterpolation()

Definition at line 111 of file fvstructuredinterpolation.cpp.

111 {
120 } else {
127 }
128
129 delete m_donorTree;
130}
MBool mDeallocate(T *&a)
deallocates the memory previously allocated for element 'a'
Definition: alloc.h:544

Member Function Documentation

◆ approx()

template<MInt nDim>
MBool StructuredInterpolation< nDim >::approx ( const MFloat a,
const MFloat b,
const MFloat  eps 
)
inlineprotected

Definition at line 1311 of file fvstructuredinterpolation.cpp.

1311 {
1312 return abs(a - b) < eps;
1313}
Definition: contexttypes.h:19

◆ buildDonorTree()

template<MInt nDim>
void StructuredInterpolation< nDim >::buildDonorTree
protected
Author
Marian Albers, Nov 2015

Definition at line 140 of file fvstructuredinterpolation.cpp.

140 {
141 m_log << "Building up kd-tree..." << endl;
142
143 // cout << "totalNoCells: " << m_totalNoDonorCells << endl;
144
145 // first create kd tree from whole grid
146 for(MInt globalId = 0; globalId < m_totalNoDonorCells; globalId++) {
147 Point<3> a(m_donorCoordinates[0][globalId], m_donorCoordinates[1][globalId], m_donorCoordinates[2][globalId],
148 globalId);
149 m_donorPoints.push_back(a);
150 }
151
152 m_log << "Created points for kd-tree" << endl;
153
154 // build up the tree and fill it
156
157 m_log << "Building up kd-tree... FINISHED!" << endl;
158}
std::vector< Point< 3 > > m_donorPoints
InfoOutFile m_log
Definition: kdtree.h:73
Definition: pointbox.h:20

◆ cellIndex()

template<MInt nDim>
MInt StructuredInterpolation< nDim >::cellIndex ( MInt  i,
MInt  j,
MInt  k,
MInt  solverId 
)
inlineprotected

Definition at line 1283 of file fvstructuredinterpolation.cpp.

1283 {
1284 const MInt offset = m_donorBlockOffsets[blockId];
1285 return offset + i + (j + k * m_noDonorCellsDir[blockId][1]) * m_noDonorCellsDir[blockId][2];
1286}

◆ computeCellCentreCoordinates()

template<MInt nDim>
void StructuredInterpolation< nDim >::computeCellCentreCoordinates ( MInt noPoints,
MFloatScratchSpace coordinates,
MInt  dim,
MInt  blockId 
)
protected

Computes the cell-centered donorCoordinates from node-centered grid

Author
Marian Albers, Nov 2015

Definition at line 1212 of file fvstructuredinterpolation.cpp.

1215 {
1216 // function to compute the coordinates at cell centre
1217 // do it over I, J, K loop but change to one array
1218
1219 for(MInt k = 0; k < m_noDonorCellsDir[blockId][0]; k++) {
1220 for(MInt j = 0; j < m_noDonorCellsDir[blockId][1]; j++) {
1221 for(MInt i = 0; i < m_noDonorCellsDir[blockId][2]; i++) {
1222 MInt pointId = i + (j + k * noPoints[1]) * noPoints[2];
1223 MInt IJK = pointId;
1224 MInt IP1JK = pointId + 1;
1225 MInt IJP1K = pointId + noPoints[2];
1226 MInt IP1JP1K = IJP1K + 1;
1227 MInt IJKP1 = pointId + noPoints[2] * noPoints[1];
1228 MInt IP1JKP1 = IJKP1 + 1;
1229 MInt IJP1KP1 = pointId + noPoints[2] + noPoints[2] * noPoints[1];
1230 MInt IP1JP1KP1 = IJP1KP1 + 1;
1231 MInt cellId = cellIndex(i, j, k, blockId);
1232
1233 // average the coordinates for cell centre data
1235 F1B8
1236 * (coordinates[IJK] + coordinates[IP1JK] + coordinates[IJP1K] + coordinates[IP1JP1K] + coordinates[IJKP1]
1237 + coordinates[IP1JKP1] + coordinates[IJP1KP1] + coordinates[IP1JP1KP1]);
1238 }
1239 }
1240 }
1241}
MInt cellIndex(MInt i, MInt j, MInt k, MInt solverId)
void const MInt cellId
Definition: collector.h:239

◆ computeInterpolationCoefficients()

template<MInt nDim>
void StructuredInterpolation< nDim >::computeInterpolationCoefficients ( MFloat ,
MInt   
)
inlineprotected
Author
Marian Albers, Jan 2016

Definition at line 787 of file fvstructuredinterpolation.cpp.

787 {
788 m_interpolationCoefficients[receiverId][0] = dx[0] * dx[1] * dx[2];
789 m_interpolationCoefficients[receiverId][1] = (F1 - dx[0]) * dx[1] * dx[2];
790 m_interpolationCoefficients[receiverId][2] = dx[0] * (F1 - dx[1]) * dx[2];
791 m_interpolationCoefficients[receiverId][3] = dx[0] * dx[1] * (F1 - dx[2]);
792 m_interpolationCoefficients[receiverId][4] = (F1 - dx[0]) * (F1 - dx[1]) * dx[2];
793 m_interpolationCoefficients[receiverId][5] = (F1 - dx[0]) * dx[1] * (F1 - dx[2]);
794 m_interpolationCoefficients[receiverId][6] = dx[0] * (F1 - dx[1]) * (F1 - dx[2]);
795 m_interpolationCoefficients[receiverId][7] = (F1 - dx[0]) * (F1 - dx[1]) * (F1 - dx[2]);
796}

◆ crossProduct()

template<MInt nDim>
void StructuredInterpolation< nDim >::crossProduct ( MFloat  result[3],
MFloat  vec1[3],
MFloat  vec2[3] 
)
inlineprotected

Definition at line 1264 of file fvstructuredinterpolation.cpp.

1264 {
1265 result[xsd] = vec1[ysd] * vec2[zsd] - vec1[zsd] * vec2[ysd];
1266 result[ysd] = vec1[zsd] * vec2[xsd] - vec1[xsd] * vec2[zsd];
1267 result[zsd] = vec1[xsd] * vec2[ysd] - vec1[ysd] * vec2[xsd];
1268}

◆ findSurroundingHexahedron()

template<MInt nDim>
MInt StructuredInterpolation< nDim >::findSurroundingHexahedron ( MFloat  intPoint[3],
MInt  centerCellId,
MInt  stencil 
)
inlineprotected
Author
Marian Albers, Nov 2015

Definition at line 522 of file fvstructuredinterpolation.cpp.

523 {
524 MFloat v1[3] = {F0, F0, F0};
525 MFloat v2[3] = {F0, F0, F0};
526 MFloat v3[3] = {F0, F0, F0};
527 MFloat vp[3] = {F0, F0, F0};
528 MFloat vn[3] = {F0, F0, F0};
529
530 MBool isInside = false;
531
532 for(MInt i = -stencil; i < stencil; i++) {
533 for(MInt j = -stencil; j < stencil; j++) {
534 for(MInt k = -stencil; k < stencil; k++) {
535 // find out current blockId
536 const MInt currentBlockId = getBlockId(centerCellId);
537 const MInt currentOffset = m_donorBlockOffsets[currentBlockId];
538 const MInt IJK = getCellIdfromCell(centerCellId, i, j, k, currentBlockId);
539
540 // compute i,j,k from cellId, but use local cellIds
541 MInt noLocalCellsDir[3] = {m_noDonorCellsDir[currentBlockId][0] - currentOffset,
542 m_noDonorCellsDir[currentBlockId][1] - currentOffset,
543 m_noDonorCellsDir[currentBlockId][2] - currentOffset};
544 MInt trueI = (IJK % (noLocalCellsDir[2] * noLocalCellsDir[1])) % noLocalCellsDir[2];
545 MInt trueJ = ((IJK - trueI) / noLocalCellsDir[2]) % noLocalCellsDir[1];
546 MInt trueK = ((IJK - trueI) / noLocalCellsDir[2] - trueJ) / noLocalCellsDir[1];
547
548 // check if inside regular grid
549 if(trueI < 0 || trueI >= noLocalCellsDir[2] - 1 || trueJ < 0 || trueJ >= noLocalCellsDir[1] - 1 || trueK < 0
550 || trueK >= noLocalCellsDir[0] - 1) {
551 continue;
552 }
553
554 // now loop over all 6 possible tetragonal pyramids
555 for(MInt tetra = 0; tetra < 6; tetra++) {
556 // and now loop over all 4 sides of the pyramid
557 isInside = true;
558 for(MInt side = 0; side < 4; side++) {
559 MInt ixp = (side + 1) % 4;
560 MInt ixp2 = (ixp + 1) % 4;
561 MInt ixp3 = (ixp2 + 1) % 4;
562
563 // compute vectors
564 for(MInt dim = 0; dim < nDim; dim++) {
565 v1[dim] = m_donorCoordinates[dim][getCellIdfromCell(IJK, ic(tetra, side, 0), ic(tetra, side, 1),
566 ic(tetra, side, 2), currentBlockId)]
567 - m_donorCoordinates[dim][getCellIdfromCell(IJK, ic(tetra, ixp, 0), ic(tetra, ixp, 1),
568 ic(tetra, ixp, 2), currentBlockId)];
569 v2[dim] = m_donorCoordinates[dim][getCellIdfromCell(IJK, ic(tetra, ixp2, 0), ic(tetra, ixp2, 1),
570 ic(tetra, ixp2, 2), currentBlockId)]
571 - m_donorCoordinates[dim][getCellIdfromCell(IJK, ic(tetra, ixp, 0), ic(tetra, ixp, 1),
572 ic(tetra, ixp, 2), currentBlockId)];
573 v3[dim] = m_donorCoordinates[dim][getCellIdfromCell(IJK, ic(tetra, ixp3, 0), ic(tetra, ixp3, 1),
574 ic(tetra, ixp3, 2), currentBlockId)]
575 - m_donorCoordinates[dim][getCellIdfromCell(IJK, ic(tetra, ixp, 0), ic(tetra, ixp, 1),
576 ic(tetra, ixp, 2), currentBlockId)];
577 vp[dim] = intPoint[dim]
578 - m_donorCoordinates[dim][getCellIdfromCell(IJK, ic(tetra, ixp, 0), ic(tetra, ixp, 1),
579 ic(tetra, ixp, 2), currentBlockId)];
580 }
581
582 // compute perpendicular vector vn
583 crossProduct(vn, v1, v2);
584
585 // check direction of normal vector and correct if necessary
586 if(scalarProduct(v3, vn) > m_eps) {
587 // invert direction of vn
588 for(MInt dim = 0; dim < nDim; dim++) {
589 vn[dim] = -vn[dim];
590 }
591 }
592
593 // check scalar product, if vp*vn > 0 then point is outside of this pyramid
594 if(scalarProduct(vp, vn) > m_eps) {
595 // not inside pyramid
596 isInside = false;
597 break;
598 }
599 }
600
601 // point is inside the current tetra and
602 // thus inside the current hexahedron
603 if(isInside) {
604 return IJK;
605 }
606 }
607 }
608 }
609 }
610
611 // surprisingly the point isn't inside any of the 8 hexahedrons, return invalid cellId
612 return -1;
613}
void crossProduct(MFloat result[3], MFloat vec1[3], MFloat vec2[3])
MFloat scalarProduct(MFloat vec1[3], MFloat vec2[3])
MInt getCellIdfromCell(MInt origin, MInt incI, MInt incJ, MInt incK, MInt solverId)
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58

◆ getBlockId()

template<MInt nDim>
MInt StructuredInterpolation< nDim >::getBlockId ( MInt  cellId)
inlineprotected

Definition at line 1296 of file fvstructuredinterpolation.cpp.

1296 {
1297 MInt currentBlockId = 0;
1298 if(m_noBlocks > 1) {
1299 for(MInt blockId = 0; blockId < m_noBlocks; blockId++) {
1300 if(cellId < m_donorBlockOffsets[blockId + 1]) {
1301 currentBlockId = blockId;
1302 break;
1303 }
1304 }
1305 }
1306
1307 return currentBlockId;
1308}

◆ getCellIdfromCell()

template<MInt nDim>
MInt StructuredInterpolation< nDim >::getCellIdfromCell ( MInt  origin,
MInt  incI,
MInt  incJ,
MInt  incK,
MInt  solverId 
)
inlineprotected

Definition at line 1276 of file fvstructuredinterpolation.cpp.

1277 {
1278 return origin + incI + incJ * m_noDonorCellsDir[blockId][2]
1279 + incK * m_noDonorCellsDir[blockId][2] * m_noDonorCellsDir[blockId][1];
1280}

◆ getInterpolatedVariable()

template<MInt nDim>
MFloat StructuredInterpolation< nDim >::getInterpolatedVariable ( MInt  receiverId,
MInt  var 
)

Performs trilinear interpolation from previously computed interpolation coefficients (see computeInterpolationCoefficients)

Author
Marian Albers, Jan 2016

Definition at line 807 of file fvstructuredinterpolation.cpp.

807 {
808 const MInt donorOrigin = m_donorOriginId[receiverId];
809 const MInt currentBlockId = getBlockId(donorOrigin);
810 const MFloat interpolatedVar = m_interpolationCoefficients[receiverId][0]
811 * m_donorVariables[var][getCellIdfromCell(donorOrigin, 1, 1, 1, currentBlockId)]
812 + m_interpolationCoefficients[receiverId][1]
813 * m_donorVariables[var][getCellIdfromCell(donorOrigin, 0, 1, 1, currentBlockId)]
814 + m_interpolationCoefficients[receiverId][2]
815 * m_donorVariables[var][getCellIdfromCell(donorOrigin, 1, 0, 1, currentBlockId)]
816 + m_interpolationCoefficients[receiverId][3]
817 * m_donorVariables[var][getCellIdfromCell(donorOrigin, 1, 1, 0, currentBlockId)]
818 + m_interpolationCoefficients[receiverId][4]
819 * m_donorVariables[var][getCellIdfromCell(donorOrigin, 0, 0, 1, currentBlockId)]
820 + m_interpolationCoefficients[receiverId][5]
821 * m_donorVariables[var][getCellIdfromCell(donorOrigin, 0, 1, 0, currentBlockId)]
822 + m_interpolationCoefficients[receiverId][6]
823 * m_donorVariables[var][getCellIdfromCell(donorOrigin, 1, 0, 0, currentBlockId)]
824 + m_interpolationCoefficients[receiverId][7]
825 * m_donorVariables[var][getCellIdfromCell(donorOrigin, 0, 0, 0, currentBlockId)];
826
827 return interpolatedVar;
828}

◆ getInterpolatedVariableZonal()

template<MInt nDim>
MFloat StructuredInterpolation< nDim >::getInterpolatedVariableZonal ( MFloat donorVars,
MInt  receiverId 
)

Definition at line 831 of file fvstructuredinterpolation.cpp.

831 {
832 const MInt donorOrigin = m_donorOriginId[receiverId];
833 const MInt currentBlockId = getBlockId(donorOrigin);
834 const MFloat interpolatedVar =
835 m_interpolationCoefficients[receiverId][0] * donorVars[getCellIdfromCell(donorOrigin, 1, 1, 1, currentBlockId)]
836 + m_interpolationCoefficients[receiverId][1] * donorVars[getCellIdfromCell(donorOrigin, 0, 1, 1, currentBlockId)]
837 + m_interpolationCoefficients[receiverId][2] * donorVars[getCellIdfromCell(donorOrigin, 1, 0, 1, currentBlockId)]
838 + m_interpolationCoefficients[receiverId][3] * donorVars[getCellIdfromCell(donorOrigin, 1, 1, 0, currentBlockId)]
839 + m_interpolationCoefficients[receiverId][4] * donorVars[getCellIdfromCell(donorOrigin, 0, 0, 1, currentBlockId)]
840 + m_interpolationCoefficients[receiverId][5] * donorVars[getCellIdfromCell(donorOrigin, 0, 1, 0, currentBlockId)]
841 + m_interpolationCoefficients[receiverId][6] * donorVars[getCellIdfromCell(donorOrigin, 1, 0, 0, currentBlockId)]
842 + m_interpolationCoefficients[receiverId][7] * donorVars[getCellIdfromCell(donorOrigin, 0, 0, 0, currentBlockId)];
843
844 return interpolatedVar;
845}

◆ ic()

template<MInt nDim>
MInt StructuredInterpolation< nDim >::ic ( MInt  tetra,
MInt  side,
MInt  dim 
)
inlineprotected

Definition at line 1291 of file fvstructuredinterpolation.cpp.

1291 {
1292 return m_pyramidPoints[dim + side * 3 + tetra * 3 * 4];
1293}
static constexpr MInt m_pyramidPoints[72]

◆ interpolateAtPoint()

template<MInt nDim>
void StructuredInterpolation< nDim >::interpolateAtPoint ( MFloat intPoint)
Author
Marian Albers, Nov 2015

Definition at line 167 of file fvstructuredinterpolation.cpp.

167 {
168 // now go through own, fine cells and look for closest partner neighbour
169 MFloat distance = 0;
170 Point<3> pt(intPoint[0], intPoint[1], intPoint[2]);
171 cout << "Finding nearest point..." << endl;
172 // find point on the grid that is closest to intPoint
173 MInt centerCellId = m_donorTree->nearest(pt, distance);
174 cout << "Finding nearest point... FINISHED! Point"
175 << " x: " << m_donorCoordinates[0][centerCellId] << " y: " << m_donorCoordinates[1][centerCellId]
176 << " z: " << m_donorCoordinates[2][centerCellId] << endl;
177 cout << "Finding surrounding hexahedron..." << endl;
178 // now eight hexahedron could be candidates for a new home for intPoint,
179 // all around centerCellId
180 MInt hexahedronOriginId = findSurroundingHexahedron(intPoint, centerCellId, 1);
181 MFloat interpolatedVariables[5];
182
183 if(hexahedronOriginId != -1) {
184 MFloat transformedPoint[3];
185 // now hexahedronOriginId is the id of the hexahedron in which intPoint is immersed
186 transformPoint(hexahedronOriginId, intPoint, transformedPoint);
187 MInt currentBlockId = getBlockId(hexahedronOriginId);
188 // interpolate variables at transformed coordinate
189 trilinearInterpolation(transformedPoint, hexahedronOriginId, interpolatedVariables, currentBlockId);
190 } else {
191 // fallback to nearest neighbour interpolation
192 nearestNeighbourInterpolation(centerCellId, interpolatedVariables);
193 }
194}
void trilinearInterpolation(MFloat *, MInt, MInt, MFloat *, MInt)
void nearestNeighbourInterpolation(MInt, MInt, MFloat *)
Nearest neighbour interpolation.
void transformPoint(MInt hexOrigin, MFloat intPoint[3], MFloat transformedPoint[3])
Transforms point from physical to computational space.
MInt findSurroundingHexahedron(MFloat intPoint[3], MInt centerCellId, MInt stencil)
Finds surrounding hexahedron for point For a given cellId it finds out which of the 8 eight surroundi...
MFloat distance(const MFloat *a, const MFloat *b)
Definition: maiamath.h:249
MInt nearest(Point< DIM > pt, MFloat &dist)
Definition: kdtree.h:199

◆ interpolateField()

template<MInt nDim>
void StructuredInterpolation< nDim >::interpolateField ( MString  varName,
MFloat receiverVar 
)
Author
Marian Albers, Nov 2015

Definition at line 204 of file fvstructuredinterpolation.cpp.

204 {
205 // first load the current variable
206 loadDonorVariable(varName);
207 for(MInt cellId = 0; cellId < m_noReceiverCells; cellId++) {
208 if(cellId % 50000 == 0 && m_domainId == 0) {
209 cout << "Variable " << varName
210 << " interpolation progress: " << (MInt)((MFloat)cellId / ((MFloat)m_noReceiverCells) * 100.0) << " percent"
211 << endl;
212 }
213
214 if(m_hasInterpolationPartners[cellId]) {
217
218 // interpolate variables at transformed coordinate
219 MInt currentBlockId = getBlockId(m_donorOriginId[cellId]);
220 trilinearInterpolation(transformedPoint, m_donorOriginId[cellId], cellId, receiverVar, currentBlockId);
221 } else {
222 // fallback to nearest neighbour interpolation
223 nearestNeighbourInterpolation(m_donorOriginId[cellId], cellId, receiverVar);
224 }
225 }
226}
void loadDonorVariable(MString varName)
Loads a Q file.

◆ interpolateVariables()

template<MInt nDim>
void StructuredInterpolation< nDim >::interpolateVariables ( MFloat **  interpolatedVariables)

Definition at line 497 of file fvstructuredinterpolation.cpp.

497 {
498 for(MInt receiverId = 0; receiverId < m_noReceiverCells; receiverId++) {
499 if(m_hasInterpolationPartners[receiverId]) {
500 for(MInt var = 0; var < m_noDonorVariables; var++) {
501 interpolatedVariables[var][receiverId] = getInterpolatedVariable(receiverId, var);
502 }
503 } else {
504 for(MInt var = 0; var < m_noDonorVariables; var++) {
505 interpolatedVariables[var][receiverId] = m_donorVariables[var][m_donorOriginId[receiverId]];
506 }
507 }
508 }
509}
MFloat getInterpolatedVariable(MInt, MInt)
Trilinear interpolation for single point.

◆ interpolateVariableZonal()

template<MInt nDim>
MFloat StructuredInterpolation< nDim >::interpolateVariableZonal ( MFloat donorVars,
MInt  cellIdBC 
)

Definition at line 483 of file fvstructuredinterpolation.cpp.

483 {
484 MFloat interpolatedVariable = 0.0;
485
486 if(m_hasInterpolationPartnersZonalGlobal[cellIdBC] > 0) {
487 interpolatedVariable = getInterpolatedVariableZonal(donorVars, cellIdBC);
488 } else if(m_hasInterpolationPartnersZonalGlobal[cellIdBC] == 0) {
489 interpolatedVariable = donorVars[m_donorOriginId[cellIdBC]];
490 }
491
492 return interpolatedVariable;
493}
MFloat getInterpolatedVariableZonal(MFloat *, MInt)

◆ loadDonorGrid()

template<MInt nDim>
void StructuredInterpolation< nDim >::loadDonorGrid

Loads the grid file given in the property file. No domain decompositioning, all domains read whole grid file as it is necessary for neighbour search.

Author
Marian Albers
Date
Nov 2015

Definition at line 866 of file fvstructuredinterpolation.cpp.

◆ loadDonorVariable()

template<MInt nDim>
void StructuredInterpolation< nDim >::loadDonorVariable ( MString  varName)

loads a given variable (with varName) from donorFile

Author
Marian Albers, Nov 2015

Definition at line 1130 of file fvstructuredinterpolation.cpp.

◆ nearestNeighbourInterpolation() [1/2]

template<MInt nDim>
void StructuredInterpolation< nDim >::nearestNeighbourInterpolation ( MInt  donorId,
MFloat receiverVariables 
)
inlineprotected

Definition at line 1257 of file fvstructuredinterpolation.cpp.

1257 {
1258 for(MInt var = 0; var < m_noDonorVariables; var++) {
1259 receiverVariables[var] = m_donorVariables[var][donorId];
1260 }
1261}

◆ nearestNeighbourInterpolation() [2/2]

template<MInt nDim>
void StructuredInterpolation< nDim >::nearestNeighbourInterpolation ( MInt  donorId,
MInt  receiverId,
MFloat receiverVar 
)
inlineprotected

Fallback routine for when no trilinear interpolation is possible. Takes values from nearest neighbour.

Author
Marian Albers, Nov 2015

Definition at line 1251 of file fvstructuredinterpolation.cpp.

1252 {
1253 receiverVar[receiverId] = m_donorVar[donorId];
1254}

◆ prepareInterpolation()

template<MInt nDim>
void StructuredInterpolation< nDim >::prepareInterpolation ( MInt  noReceiverCells,
MFloat **  receiverCellCoordinates,
MInt interpolationPartner 
)
Author
Marian Albers, Jan 2015

Definition at line 317 of file fvstructuredinterpolation.cpp.

318 {
320 MInt noTrilinear = 0;
321 MInt noFallback = 0;
322 m_noReceiverCells = noReceiverCells;
323
324 if(noReceiverCells > 0) {
325 mAlloc(m_donorOriginId, m_noReceiverCells, AT_, "m_donorOriginId");
326 mAlloc(m_interpolationCoefficients, m_noReceiverCells, 8, AT_, "m_interpolationCoefficients");
327 mAlloc(m_hasInterpolationPartners, m_noReceiverCells, AT_, "m_hasInterpolationPartners");
328
329 for(MInt receiverId = 0; receiverId < m_noReceiverCells; receiverId++) {
330 if(m_domainId == 0 && receiverId % 10000 == 0) {
331 cout << "receiver no: " << receiverId << endl;
332 }
333 // now go through own, fine cells and look for closest partner neighbour
334 MFloat intPoint[3] = {receiverCellCoordinates[0][receiverId], receiverCellCoordinates[1][receiverId],
335 receiverCellCoordinates[2][receiverId]};
336 Point<3> pt(intPoint[0], intPoint[1], intPoint[2]);
337 MFloat dist = 0;
338 MInt closestCellId = m_donorTree->nearest(pt, dist);
339
340 // now eight hexahedron could be candidates for a new home for intPoint,
341 // all around closestCellId
342 // MInt hexahedronOriginId = findSurroundingHexahedron(intPoint, closestCellId, 1);
343 MInt hexahedronOriginId = -1;
344 const MInt maxNghbrRadius = 8;
345 for(MInt nghbrRadius = 1; nghbrRadius < maxNghbrRadius; nghbrRadius++) {
346 hexahedronOriginId = findSurroundingHexahedron(intPoint, closestCellId, nghbrRadius);
347 if(hexahedronOriginId != -1) {
348 break;
349 }
350 }
351
352 if(hexahedronOriginId != -1) {
353 m_hasInterpolationPartners[receiverId] = true;
354 m_donorOriginId[receiverId] = hexahedronOriginId;
355 MFloat transformedPoint[3];
356 // now hexahedronOriginId is the id of the hexahedron in which intPoint is immersed
357 transformPoint(hexahedronOriginId, intPoint, transformedPoint);
358 // interpolate variables at transformed coordinate
359 computeInterpolationCoefficients(transformedPoint, receiverId);
360 noTrilinear++;
361 } else {
362 // fallback to nearest neighbour interpolation
363 m_hasInterpolationPartners[receiverId] = false;
364 m_donorOriginId[receiverId] = closestCellId;
365
366 cout << "Fallback x: " << intPoint[0] << " y: " << intPoint[1] << " z: " << intPoint[2] << endl;
367 noFallback++;
368 }
369 interpolationPartner[receiverId] = m_hasInterpolationPartners[receiverId];
370 }
371 }
372
373 cout << "trilinar: " << noTrilinear << " fallback: " << noFallback << " noReceiverCells: " << noReceiverCells << endl;
374
375 MInt noLocal[3] = {noTrilinear, noFallback, noReceiverCells};
376 MInt noGlobal[3] = {0, 0, 0};
377 MPI_Allreduce(noLocal, noGlobal, 3, MPI_INT, MPI_SUM, m_StructuredComm, AT_, "noLocal", "noGlobal");
378 if(m_domainId == 0) {
379 cout << "Trilinear: " << noGlobal[0] << " (" << 100.0 * ((MFloat)noGlobal[0]) / ((MFloat)noGlobal[2]) << "%)"
380 << "Fallback: " << noGlobal[1] << " (" << 100.0 * ((MFloat)noGlobal[1]) / ((MFloat)noGlobal[2]) << "%)"
381 << endl;
382 }
383}
void computeInterpolationCoefficients(MFloat *, MInt)
Computes trilinear interpolation coefficients.
int MPI_Allreduce(const void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm, const MString &name, const MString &sndvarname, const MString &rcvvarname)
same as MPI_Allreduce
MFloat dist(const Point< DIM > &p, const Point< DIM > &q)
Definition: pointbox.h:54

◆ prepareInterpolationField()

template<MInt nDim>
void StructuredInterpolation< nDim >::prepareInterpolationField ( MInt noReceiverCells,
MFloat **  receiverCoordinates 
)
Author
Marian Albers, Nov 2015

Definition at line 244 of file fvstructuredinterpolation.cpp.

244 {
246 m_noReceiverCells = noReceiverCells[0] * noReceiverCells[1] * noReceiverCells[2];
247 MInt noTrilinear = 0;
248 MInt noFallback = 0;
249 mAlloc(m_donorOriginId, m_noReceiverCells, AT_, -1, "m_donorOriginId");
250 mAlloc(m_transformedReceiverPoints, nDim, m_noReceiverCells, AT_, F0, "m_interpolationCoefficients");
251 mAlloc(m_hasInterpolationPartners, m_noReceiverCells, AT_, "m_hasInterpolationPartners");
252 mAlloc(m_donorVar, m_totalNoDonorCells, "m_donorVariables", F0, AT_);
253
254 for(MInt cellId = 0; cellId < m_noReceiverCells; cellId++) {
255 if(cellId % 50000 == 0) {
256 cout << "Interpolation progress: " << (MInt)((MFloat)cellId / ((MFloat)m_noReceiverCells) * 100.0) << " percent"
257 << endl;
258 }
260 MFloat intPoint[3] = {receiverCoordinates[0][cellId], receiverCoordinates[1][cellId],
261 receiverCoordinates[2][cellId]};
262 // now go through own, fine cells and look for closest partner neighbour
263 MFloat distance = 0;
264 Point<3> pt(intPoint[0], intPoint[1], intPoint[2]);
265 // find point on the grid that is closest to intPoint
266 MInt centerCellId = m_donorTree->nearest(pt, distance);
267
268 // now eight hexahedron could be candidates for a new home for intPoint,
269 // all around centerCellId
270 MInt hexahedronOriginId = -1;
271 const MInt maxNghbrRadius = 4;
272 for(MInt nghbrRadius = 1; nghbrRadius < maxNghbrRadius; nghbrRadius++) {
273 hexahedronOriginId = findSurroundingHexahedron(intPoint, centerCellId, nghbrRadius);
274 if(hexahedronOriginId != -1) {
275 break;
276 }
277 }
278
279 if(hexahedronOriginId != -1) {
280 MFloat transformedPoint[3] = {F0, F0, F0};
281 // now hexahedronOriginId is the id of the hexahedron in which intPoint is immersed
282 transformPoint(hexahedronOriginId, intPoint, transformedPoint);
283 // interpolate variables at transformed coordinate
284
285 for(MInt dim = 0; dim < nDim; dim++) {
286 m_transformedReceiverPoints[dim][cellId] = transformedPoint[dim];
287 }
288 m_donorOriginId[cellId] = hexahedronOriginId;
290 noTrilinear++;
291 } else {
292 // fallback to nearest neighbour interpolation
294 m_donorOriginId[cellId] = centerCellId;
295 noFallback++;
296 }
297 }
298
299 MInt noLocal[3] = {noTrilinear, noFallback, m_noReceiverCells};
300 MInt noGlobal[3] = {0, 0, 0};
301 MPI_Allreduce(noLocal, noGlobal, 3, MPI_INT, MPI_SUM, m_StructuredComm, AT_, "noLocal", "noGlobal");
302 if(m_domainId == 0) {
303 cout << "Trilinear: " << noGlobal[0] << " (" << 100.0 * ((MFloat)noGlobal[0]) / ((MFloat)noGlobal[2]) << "%) "
304 << "Fallback: " << noGlobal[1] << " (" << 100.0 * ((MFloat)noGlobal[1]) / ((MFloat)noGlobal[2]) << "%)"
305 << endl;
306 }
307}

◆ prepareZonalInterpolation()

template<MInt nDim>
void StructuredInterpolation< nDim >::prepareZonalInterpolation ( MInt  noReceiverCells,
MFloat **  receiverCellCoordinates,
MInt interpolationPartner,
MBool  hasInterpolationPartnerDomain 
)
Author
Marian Albers, Jan 2015

Definition at line 392 of file fvstructuredinterpolation.cpp.

395 {
397 MInt noTrilinear = 0;
398 MInt noFallback = 0;
399 m_noReceiverCells = noReceiverCells;
400 m_hasInterpolationPartnerDomain = hasInterpolationPartnerDomain;
401
402 mAlloc(m_donorOriginId, m_noReceiverCells, AT_, "m_donorOriginId");
403 mAlloc(m_interpolationCoefficients, m_noReceiverCells, 8, AT_, "m_interpolationCoefficients");
404 mAlloc(m_hasInterpolationPartnersZonal, m_noReceiverCells, AT_, 0, "m_hasInterpolationPartnersZonal");
405 mAlloc(m_hasInterpolationPartnersZonalGlobal, m_noReceiverCells, AT_, 0, "m_hasInterpolationPartnersZonalGlobal");
406 mAlloc(m_donorDistance, m_noReceiverCells, AT_, "m_donorDistance");
407 mAlloc(m_globalDonorDistanceMin, m_noReceiverCells, AT_, F0, "m_globalDonorDistanceMin");
408
410 for(MInt receiverId = 0; receiverId < m_noReceiverCells; receiverId++) {
411 // if(m_domainId==0 && receiverId % 10000 == 0) {cout << "receiver no: " << receiverId << endl;}
412 // now go through own, fine cells and look for closest partner neighbour
413 MFloat intPoint[3] = {receiverCellCoordinates[0][receiverId], receiverCellCoordinates[1][receiverId],
414 receiverCellCoordinates[2][receiverId]};
415 Point<3> pt(intPoint[0], intPoint[1], intPoint[2]);
416 MFloat dist = 0;
417 MInt closestCellId;
418 closestCellId = m_donorTree->nearest(pt, dist);
419 // now eight hexahedron could be candidates for a new home for intPoint,
420 // all around closestCellId
421 // MInt hexahedronOriginId = findSurroundingHexahedron(intPoint, closestCellId, 1);
422 MInt hexahedronOriginId = -1;
423 const MInt maxNghbrRadius = 4;
424 for(MInt nghbrRadius = 1; nghbrRadius < maxNghbrRadius; nghbrRadius++) {
425 hexahedronOriginId = findSurroundingHexahedron(intPoint, closestCellId, nghbrRadius);
426 if(hexahedronOriginId != -1) {
427 break;
428 }
429 }
430 if(hexahedronOriginId != -1) {
431 m_hasInterpolationPartnersZonal[receiverId] = true;
432 m_donorOriginId[receiverId] = hexahedronOriginId;
433 MFloat transformedPoint[3];
434 // now hexahedronOriginId is the id of the hexahedron in which intPoint is immersed
435 transformPoint(hexahedronOriginId, intPoint, transformedPoint);
436 // interpolate variables at transformed coordinate
437 computeInterpolationCoefficients(transformedPoint, receiverId);
438 noTrilinear++;
439 } else {
440 // fallback to nearest neighbour interpolation
441 m_hasInterpolationPartnersZonal[receiverId] = false;
442 m_donorOriginId[receiverId] = closestCellId;
443 m_donorDistance[receiverId] = dist;
444 noFallback++;
445 }
446 }
447 } else {
448 for(MInt receiverId = 0; receiverId < m_noReceiverCells; receiverId++) {
449 m_donorDistance[receiverId] =
450 1000; // avoid to pick interpolation cells in receiverDomain using MPI_Allreduce(MIN) below
451 m_hasInterpolationPartnersZonal[receiverId] = false;
452 }
453 }
454
456 MPI_SUM, m_StructuredComm, AT_, "m_hasInterpolationPartnersZonal",
457 "m_hasInterpolationPartnersZonalGlobal");
458
460 AT_, "m_donorDistance", "m_globalDonorDistanceMin");
461
463 for(MInt receiverId = 0; receiverId < m_noReceiverCells; receiverId++) {
464 if(m_hasInterpolationPartnersZonalGlobal[receiverId] == 0
465 && approx(m_donorDistance[receiverId], m_globalDonorDistanceMin[receiverId], m_eps)) {
466 m_hasInterpolationPartnersZonal[receiverId] = true;
467 }
468 }
469 }
470
471 for(MInt receiverId = 0; receiverId < m_noReceiverCells; receiverId++) {
472 interpolationPartner[receiverId] = m_hasInterpolationPartnersZonal[receiverId];
473 }
474
475
476 MInt noLocal[3] = {noTrilinear, noFallback, noReceiverCells};
477 MInt noGlobal[3] = {0, 0, 0};
478 MPI_Allreduce(noLocal, noGlobal, 3, MPI_INT, MPI_SUM, m_StructuredComm, AT_, "noLocal", "noGlobal");
479}
MBool approx(const MFloat &, const MFloat &, const MFloat)

◆ scalarProduct()

template<MInt nDim>
MFloat StructuredInterpolation< nDim >::scalarProduct ( MFloat  vec1[3],
MFloat  vec2[3] 
)
inlineprotected

Definition at line 1271 of file fvstructuredinterpolation.cpp.

1271 {
1272 return vec1[xsd] * vec2[xsd] + vec1[ysd] * vec2[ysd] + vec1[zsd] * vec2[zsd];
1273}

◆ transformPoint()

template<MInt nDim>
void StructuredInterpolation< nDim >::transformPoint ( MInt  hexOrigin,
MFloat  intPoint[3],
MFloat  transformedPoint[3] 
)
inlineprotected

Transforms a given point from physical space to computational space with help of the surrounding eight points (which define a hexahedron). Iterative solution with Newton to solve system of equations. Benek (1987) - Chimera - A grid-embedding technique

Author
Marian Albers, Nov 23, 2015

Definition at line 626 of file fvstructuredinterpolation.cpp.

627 {
628 MFloatScratchSpace a(3, 8, AT_, "a");
629 const MInt currentBlockId = getBlockId(hexOrigin);
630
631 for(MInt dim = 0; dim < nDim; dim++) {
632 a(dim, 0) = m_donorCoordinates[dim][hexOrigin];
633 a(dim, 1) = m_donorCoordinates[dim][getCellIdfromCell(hexOrigin, 1, 0, 0, currentBlockId)] - a(dim, 0);
634 a(dim, 2) = m_donorCoordinates[dim][getCellIdfromCell(hexOrigin, 0, 1, 0, currentBlockId)] - a(dim, 0);
635 a(dim, 3) = m_donorCoordinates[dim][getCellIdfromCell(hexOrigin, 0, 0, 1, currentBlockId)] - a(dim, 0);
636 a(dim, 4) = m_donorCoordinates[dim][getCellIdfromCell(hexOrigin, 1, 1, 0, currentBlockId)] - a(dim, 0) - a(dim, 1)
637 - a(dim, 2);
638 a(dim, 5) = m_donorCoordinates[dim][getCellIdfromCell(hexOrigin, 1, 0, 1, currentBlockId)] - a(dim, 0) - a(dim, 1)
639 - a(dim, 3);
640 a(dim, 6) = m_donorCoordinates[dim][getCellIdfromCell(hexOrigin, 0, 1, 1, currentBlockId)] - a(dim, 0) - a(dim, 2)
641 - a(dim, 3);
642 a(dim, 7) = m_donorCoordinates[dim][getCellIdfromCell(hexOrigin, 1, 1, 1, currentBlockId)] - a(dim, 0) - a(dim, 1)
643 - a(dim, 2) - a(dim, 3) - a(dim, 4) - a(dim, 5) - a(dim, 6) - a(dim, 7);
644 }
645
646 // set initial values 0.5
647 MFloatScratchSpace dxezdxyz(3, 3, AT_, "dxezdxyz");
648 MFloatScratchSpace rhs(3, AT_, "rhs");
649
650 MFloat xi = F1B2;
651 MFloat eta = F1B2;
652 MFloat zeta = F1B2;
653
654 MFloat xicor, etacor, zetacor;
655
656 MInt noIterations = 50;
657 for(MInt newton = 0; newton < noIterations; newton++) {
658 for(MInt dim = 0; dim < nDim; dim++) {
659 dxezdxyz(dim, 0) = a(dim, 1) + a(dim, 4) * eta + a(dim, 5) * zeta + a(dim, 7) * eta * zeta;
660 dxezdxyz(dim, 1) = a(dim, 2) + a(dim, 4) * xi + a(dim, 6) * zeta + a(dim, 7) * xi * zeta;
661 dxezdxyz(dim, 2) = a(dim, 3) + a(dim, 5) * xi + a(dim, 6) * eta + a(dim, 7) * xi * eta;
662
663 rhs[dim] = intPoint[dim]
664 - (a(dim, 0) + a(dim, 1) * xi + a(dim, 2) * eta + a(dim, 3) * zeta + a(dim, 4) * xi * eta
665 + a(dim, 5) * xi * zeta + a(dim, 6) * eta * zeta + a(dim, 7) * xi * eta * zeta);
666 }
667
668 MFloat jac = dxezdxyz(0, 0) * (dxezdxyz(1, 1) * dxezdxyz(2, 2) - dxezdxyz(1, 2) * dxezdxyz(2, 1))
669 + dxezdxyz(0, 1) * (dxezdxyz(1, 2) * dxezdxyz(2, 0) - dxezdxyz(1, 0) * dxezdxyz(2, 2))
670 + dxezdxyz(0, 2) * (dxezdxyz(1, 0) * dxezdxyz(2, 1) - dxezdxyz(1, 1) * dxezdxyz(2, 0));
671
672 if(fabs(jac) < m_eps) {
673 xicor = F0;
674 etacor = F0;
675 zetacor = F0;
676 } else {
677 xicor = (rhs[0] * (dxezdxyz(1, 1) * dxezdxyz(2, 2) - dxezdxyz(1, 2) * dxezdxyz(2, 1))
678 + dxezdxyz(0, 1) * (dxezdxyz(1, 2) * rhs[2] - rhs[1] * dxezdxyz(2, 2))
679 + dxezdxyz(0, 2) * (rhs[1] * dxezdxyz(2, 1) - dxezdxyz(1, 1) * rhs[2]))
680 / jac;
681 etacor = (dxezdxyz(0, 0) * (rhs[1] * dxezdxyz(2, 2) - dxezdxyz(1, 2) * rhs[2])
682 + rhs[0] * (dxezdxyz(1, 2) * dxezdxyz(2, 0) - dxezdxyz(1, 0) * dxezdxyz(2, 2))
683 + dxezdxyz(0, 2) * (dxezdxyz(1, 0) * rhs[2] - rhs[1] * dxezdxyz(2, 0)))
684 / jac;
685 zetacor = (dxezdxyz(0, 0) * (dxezdxyz(1, 1) * rhs[2] - rhs[1] * dxezdxyz(2, 1))
686 + dxezdxyz(0, 1) * (rhs[1] * dxezdxyz(2, 0) - dxezdxyz(1, 0) * rhs[2])
687 + rhs[0] * (dxezdxyz(1, 0) * dxezdxyz(2, 1) - dxezdxyz(1, 1) * dxezdxyz(2, 0)))
688 / jac;
689 }
690
691 xi = xi + xicor;
692 eta = eta + etacor;
693 zeta = zeta + zetacor;
694
695 MFloat sumcor = fabs(xicor) + fabs(etacor) + fabs(zetacor);
696
697 if(sumcor < m_eps) {
698 break;
699 }
700 }
701
702 xi = mMax(mMin(xi, F1), F0);
703 eta = mMax(mMin(eta, F1), F0);
704 zeta = mMax(mMin(zeta, F1), F0);
705
706 transformedPoint[0] = xi;
707 transformedPoint[1] = eta;
708 transformedPoint[2] = zeta;
709}
This class is a ScratchSpace.
Definition: scratch.h:758
constexpr T mMin(const T &x, const T &y)
Definition: functions.h:90
constexpr T mMax(const T &x, const T &y)
Definition: functions.h:94

◆ trilinearInterpolation() [1/2]

template<MInt nDim>
void StructuredInterpolation< nDim >::trilinearInterpolation ( MFloat ,
MInt  ,
MFloat ,
MInt   
)
inlineprotected

◆ trilinearInterpolation() [2/2]

template<MInt nDim>
void StructuredInterpolation< nDim >::trilinearInterpolation ( MFloat ,
MInt  ,
MInt  ,
MFloat ,
MInt   
)
inlineprotected

Member Data Documentation

◆ m_currentReceiverId

template<MInt nDim>
MInt StructuredInterpolation< nDim >::m_currentReceiverId
protected

Definition at line 90 of file fvstructuredinterpolation.h.

◆ m_domainId

template<MInt nDim>
MInt StructuredInterpolation< nDim >::m_domainId
protected

Definition at line 72 of file fvstructuredinterpolation.h.

◆ m_donorBlockOffsets

template<MInt nDim>
MInt* StructuredInterpolation< nDim >::m_donorBlockOffsets = nullptr
protected

Definition at line 68 of file fvstructuredinterpolation.h.

◆ m_donorCoordinates

template<MInt nDim>
MFloat** StructuredInterpolation< nDim >::m_donorCoordinates = nullptr
protected

Definition at line 63 of file fvstructuredinterpolation.h.

◆ m_donorDistance

template<MInt nDim>
MFloat* StructuredInterpolation< nDim >::m_donorDistance = nullptr
protected

Definition at line 80 of file fvstructuredinterpolation.h.

◆ m_donorIsCellCentered

template<MInt nDim>
MBool StructuredInterpolation< nDim >::m_donorIsCellCentered
protected

Definition at line 74 of file fvstructuredinterpolation.h.

◆ m_donorOriginId

template<MInt nDim>
MInt* StructuredInterpolation< nDim >::m_donorOriginId = nullptr
protected

Definition at line 78 of file fvstructuredinterpolation.h.

◆ m_donorPoints

template<MInt nDim>
std::vector<Point<3> > StructuredInterpolation< nDim >::m_donorPoints
protected

Definition at line 92 of file fvstructuredinterpolation.h.

◆ m_donorTree

template<MInt nDim>
KDtree<3>* StructuredInterpolation< nDim >::m_donorTree
protected

Definition at line 93 of file fvstructuredinterpolation.h.

◆ m_donorVar

template<MInt nDim>
MFloat* StructuredInterpolation< nDim >::m_donorVar = nullptr
protected

Definition at line 65 of file fvstructuredinterpolation.h.

◆ m_donorVariables

template<MInt nDim>
MFloat** StructuredInterpolation< nDim >::m_donorVariables = nullptr
protected

Definition at line 64 of file fvstructuredinterpolation.h.

◆ m_eps

template<MInt nDim>
MFloat StructuredInterpolation< nDim >::m_eps
protected

Definition at line 76 of file fvstructuredinterpolation.h.

◆ m_globalDonorDistanceMin

template<MInt nDim>
MFloat* StructuredInterpolation< nDim >::m_globalDonorDistanceMin = nullptr
protected

Definition at line 81 of file fvstructuredinterpolation.h.

◆ m_hasInterpolationPartnerDomain

template<MInt nDim>
MBool StructuredInterpolation< nDim >::m_hasInterpolationPartnerDomain
protected

Definition at line 82 of file fvstructuredinterpolation.h.

◆ m_hasInterpolationPartners

template<MInt nDim>
MBool* StructuredInterpolation< nDim >::m_hasInterpolationPartners = nullptr
protected

Definition at line 88 of file fvstructuredinterpolation.h.

◆ m_hasInterpolationPartnersZonal

template<MInt nDim>
MInt* StructuredInterpolation< nDim >::m_hasInterpolationPartnersZonal = nullptr
protected

Definition at line 83 of file fvstructuredinterpolation.h.

◆ m_hasInterpolationPartnersZonalGlobal

template<MInt nDim>
MInt* StructuredInterpolation< nDim >::m_hasInterpolationPartnersZonalGlobal = nullptr
protected

Definition at line 84 of file fvstructuredinterpolation.h.

◆ m_interpolationCoefficients

template<MInt nDim>
MFloat** StructuredInterpolation< nDim >::m_interpolationCoefficients = nullptr
protected

Definition at line 79 of file fvstructuredinterpolation.h.

◆ m_isFieldInterpolation

template<MInt nDim>
MBool StructuredInterpolation< nDim >::m_isFieldInterpolation
protected

Definition at line 75 of file fvstructuredinterpolation.h.

◆ m_noBlocks

template<MInt nDim>
MInt StructuredInterpolation< nDim >::m_noBlocks
protected

Definition at line 69 of file fvstructuredinterpolation.h.

◆ m_noDonorCells

template<MInt nDim>
MInt* StructuredInterpolation< nDim >::m_noDonorCells = nullptr
protected

Definition at line 61 of file fvstructuredinterpolation.h.

◆ m_noDonorCellsDir

template<MInt nDim>
MInt** StructuredInterpolation< nDim >::m_noDonorCellsDir = nullptr
protected

Definition at line 59 of file fvstructuredinterpolation.h.

◆ m_noDonorDims

template<MInt nDim>
MInt StructuredInterpolation< nDim >::m_noDonorDims
protected

Definition at line 66 of file fvstructuredinterpolation.h.

◆ m_noDonorPoints

template<MInt nDim>
MInt* StructuredInterpolation< nDim >::m_noDonorPoints = nullptr
protected

Definition at line 62 of file fvstructuredinterpolation.h.

◆ m_noDonorPointsDir

template<MInt nDim>
MInt** StructuredInterpolation< nDim >::m_noDonorPointsDir = nullptr
protected

Definition at line 60 of file fvstructuredinterpolation.h.

◆ m_noDonorVariables

template<MInt nDim>
MInt StructuredInterpolation< nDim >::m_noDonorVariables
protected

Definition at line 73 of file fvstructuredinterpolation.h.

◆ m_noReceiverCells

template<MInt nDim>
MInt StructuredInterpolation< nDim >::m_noReceiverCells
protected

Definition at line 89 of file fvstructuredinterpolation.h.

◆ m_pyramidPoints

template<MInt nDim>
constexpr MInt StructuredInterpolation< nDim >::m_pyramidPoints
staticconstexprprotected
Initial value:
= {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0,
1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1,
1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0}

Definition at line 98 of file fvstructuredinterpolation.h.

◆ m_receiverVariables

template<MInt nDim>
MFloat** StructuredInterpolation< nDim >::m_receiverVariables = nullptr
protected

Definition at line 87 of file fvstructuredinterpolation.h.

◆ m_StructuredComm

template<MInt nDim>
const MPI_Comm StructuredInterpolation< nDim >::m_StructuredComm
protected

Definition at line 71 of file fvstructuredinterpolation.h.

◆ m_totalNoDonorCells

template<MInt nDim>
MInt StructuredInterpolation< nDim >::m_totalNoDonorCells
protected

Definition at line 67 of file fvstructuredinterpolation.h.

◆ m_transformedReceiverPoints

template<MInt nDim>
MFloat** StructuredInterpolation< nDim >::m_transformedReceiverPoints = nullptr
protected

Definition at line 86 of file fvstructuredinterpolation.h.

◆ xsd

template<MInt nDim>
const MInt StructuredInterpolation< nDim >::xsd = 0
staticprotected

Definition at line 55 of file fvstructuredinterpolation.h.

◆ ysd

template<MInt nDim>
const MInt StructuredInterpolation< nDim >::ysd = 1
staticprotected

Definition at line 56 of file fvstructuredinterpolation.h.

◆ zsd

template<MInt nDim>
const MInt StructuredInterpolation< nDim >::zsd = 2
staticprotected

Definition at line 57 of file fvstructuredinterpolation.h.


The documentation for this class was generated from the following files: