29 : m_StructuredComm(structuredCommunicator),
30 m_donorIsCellCentered(true),
31 m_isFieldInterpolation(false),
32 m_eps(std::numeric_limits<
MFloat>::epsilon()) {
33 MPI_Comm_rank(m_StructuredComm, &m_domainId);
41 : m_StructuredComm(structuredCommunicator),
42 m_donorIsCellCentered(true),
43 m_isFieldInterpolation(false),
44 m_eps(std::numeric_limits<
MFloat>::epsilon()) {
45 MPI_Comm_rank(m_StructuredComm, &m_domainId);
46 TERMM(1,
"Activate HDF5 to use this function!");
63 const MPI_Comm structuredCommunicator)
64 : m_donorCoordinates(donorCoordinates),
65 m_donorVariables(donorVariables),
67 m_StructuredComm(structuredCommunicator),
68 m_noDonorVariables(5),
69 m_donorIsCellCentered(true),
70 m_isFieldInterpolation(false),
71 m_eps(std::numeric_limits<
MFloat>::epsilon()) {
77 for(
MInt dim = 0; dim < nDim; dim++) {
88 const MPI_Comm structuredCommunicator)
89 : m_donorCoordinates(donorCoordinates),
91 m_StructuredComm(structuredCommunicator),
92 m_noDonorVariables(5),
93 m_donorIsCellCentered(true),
94 m_isFieldInterpolation(false),
95 m_eps(std::numeric_limits<
MFloat>::epsilon()) {
101 for(
MInt dim = 0; dim < nDim; dim++) {
112 if(m_isFieldInterpolation) {
118 mDeallocate(m_hasInterpolationPartnersZonalGlobal);
125 mDeallocate(m_hasInterpolationPartnersZonalGlobal);
141 m_log <<
"Building up kd-tree..." << endl;
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],
149 m_donorPoints.push_back(
a);
152 m_log <<
"Created points for kd-tree" << endl;
155 m_donorTree =
new KDtree<3>(m_donorPoints);
157 m_log <<
"Building up kd-tree... FINISHED!" << endl;
170 Point<3> pt(intPoint[0], intPoint[1], intPoint[2]);
171 cout <<
"Finding nearest point..." << endl;
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;
180 MInt hexahedronOriginId = findSurroundingHexahedron(intPoint, centerCellId, 1);
181 MFloat interpolatedVariables[5];
183 if(hexahedronOriginId != -1) {
184 MFloat transformedPoint[3];
186 transformPoint(hexahedronOriginId, intPoint, transformedPoint);
187 MInt currentBlockId = getBlockId(hexahedronOriginId);
189 trilinearInterpolation(transformedPoint, hexahedronOriginId, interpolatedVariables, currentBlockId);
192 nearestNeighbourInterpolation(centerCellId, interpolatedVariables);
202#if defined(WITH_HDF5)
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"
214 if(m_hasInterpolationPartners[cellId]) {
215 MFloat transformedPoint[3] = {m_transformedReceiverPoints[0][cellId], m_transformedReceiverPoints[1][cellId],
216 m_transformedReceiverPoints[2][cellId]};
219 MInt currentBlockId = getBlockId(m_donorOriginId[cellId]);
220 trilinearInterpolation(transformedPoint, m_donorOriginId[cellId], cellId, receiverVar, currentBlockId);
223 nearestNeighbourInterpolation(m_donorOriginId[cellId], cellId, receiverVar);
232 TERMM(1,
"Activate HDF5 to use this function!");
245 m_isFieldInterpolation =
true;
246 m_noReceiverCells = noReceiverCells[0] * noReceiverCells[1] * noReceiverCells[2];
247 MInt noTrilinear = 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_);
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"
259 m_currentReceiverId = cellId;
260 MFloat intPoint[3] = {receiverCoordinates[0][cellId], receiverCoordinates[1][cellId],
261 receiverCoordinates[2][cellId]};
264 Point<3> pt(intPoint[0], intPoint[1], intPoint[2]);
266 MInt centerCellId = m_donorTree->nearest(pt, distance);
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) {
279 if(hexahedronOriginId != -1) {
280 MFloat transformedPoint[3] = {F0, F0, F0};
282 transformPoint(hexahedronOriginId, intPoint, transformedPoint);
285 for(
MInt dim = 0; dim < nDim; dim++) {
286 m_transformedReceiverPoints[dim][cellId] = transformedPoint[dim];
288 m_donorOriginId[cellId] = hexahedronOriginId;
289 m_hasInterpolationPartners[cellId] =
true;
293 m_hasInterpolationPartners[cellId] =
false;
294 m_donorOriginId[cellId] = centerCellId;
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]) <<
"%)"
318 MInt* interpolationPartner) {
319 m_isFieldInterpolation =
false;
320 MInt noTrilinear = 0;
322 m_noReceiverCells = noReceiverCells;
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");
329 for(
MInt receiverId = 0; receiverId < m_noReceiverCells; receiverId++) {
330 if(m_domainId == 0 && receiverId % 10000 == 0) {
331 cout <<
"receiver no: " << receiverId << endl;
334 MFloat intPoint[3] = {receiverCellCoordinates[0][receiverId], receiverCellCoordinates[1][receiverId],
335 receiverCellCoordinates[2][receiverId]};
336 Point<3> pt(intPoint[0], intPoint[1], intPoint[2]);
338 MInt closestCellId = m_donorTree->nearest(pt,
dist);
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) {
352 if(hexahedronOriginId != -1) {
353 m_hasInterpolationPartners[receiverId] =
true;
354 m_donorOriginId[receiverId] = hexahedronOriginId;
355 MFloat transformedPoint[3];
357 transformPoint(hexahedronOriginId, intPoint, transformedPoint);
359 computeInterpolationCoefficients(transformedPoint, receiverId);
363 m_hasInterpolationPartners[receiverId] =
false;
364 m_donorOriginId[receiverId] = closestCellId;
366 cout <<
"Fallback x: " << intPoint[0] <<
" y: " << intPoint[1] <<
" z: " << intPoint[2] << endl;
369 interpolationPartner[receiverId] = m_hasInterpolationPartners[receiverId];
373 cout <<
"trilinar: " << noTrilinear <<
" fallback: " << noFallback <<
" noReceiverCells: " << noReceiverCells << endl;
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]) <<
"%)"
393 MFloat** receiverCellCoordinates,
394 MInt* interpolationPartner,
395 MBool hasInterpolationPartnerDomain) {
396 m_isFieldInterpolation =
false;
397 MInt noTrilinear = 0;
399 m_noReceiverCells = noReceiverCells;
400 m_hasInterpolationPartnerDomain = hasInterpolationPartnerDomain;
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");
409 if(m_hasInterpolationPartnerDomain ==
true) {
410 for(
MInt receiverId = 0; receiverId < m_noReceiverCells; receiverId++) {
413 MFloat intPoint[3] = {receiverCellCoordinates[0][receiverId], receiverCellCoordinates[1][receiverId],
414 receiverCellCoordinates[2][receiverId]};
415 Point<3> pt(intPoint[0], intPoint[1], intPoint[2]);
418 closestCellId = m_donorTree->nearest(pt,
dist);
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) {
430 if(hexahedronOriginId != -1) {
431 m_hasInterpolationPartnersZonal[receiverId] =
true;
432 m_donorOriginId[receiverId] = hexahedronOriginId;
433 MFloat transformedPoint[3];
435 transformPoint(hexahedronOriginId, intPoint, transformedPoint);
437 computeInterpolationCoefficients(transformedPoint, receiverId);
441 m_hasInterpolationPartnersZonal[receiverId] =
false;
442 m_donorOriginId[receiverId] = closestCellId;
443 m_donorDistance[receiverId] =
dist;
448 for(
MInt receiverId = 0; receiverId < m_noReceiverCells; receiverId++) {
449 m_donorDistance[receiverId] =
451 m_hasInterpolationPartnersZonal[receiverId] =
false;
455 MPI_Allreduce(m_hasInterpolationPartnersZonal, m_hasInterpolationPartnersZonalGlobal, m_noReceiverCells, MPI_INT,
456 MPI_SUM, m_StructuredComm, AT_,
"m_hasInterpolationPartnersZonal",
457 "m_hasInterpolationPartnersZonalGlobal");
459 MPI_Allreduce(m_donorDistance, m_globalDonorDistanceMin, m_noReceiverCells, MPI_DOUBLE, MPI_MIN, m_StructuredComm,
460 AT_,
"m_donorDistance",
"m_globalDonorDistanceMin");
462 if(m_hasInterpolationPartnerDomain ==
true) {
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;
471 for(
MInt receiverId = 0; receiverId < m_noReceiverCells; receiverId++) {
472 interpolationPartner[receiverId] = m_hasInterpolationPartnersZonal[receiverId];
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");
484 MFloat interpolatedVariable = 0.0;
486 if(m_hasInterpolationPartnersZonalGlobal[cellIdBC] > 0) {
487 interpolatedVariable = getInterpolatedVariableZonal(donorVars, cellIdBC);
488 }
else if(m_hasInterpolationPartnersZonalGlobal[cellIdBC] == 0) {
489 interpolatedVariable = donorVars[m_donorOriginId[cellIdBC]];
492 return interpolatedVariable;
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);
504 for(
MInt var = 0; var < m_noDonorVariables; var++) {
505 interpolatedVariables[var][receiverId] = m_donorVariables[var][m_donorOriginId[receiverId]];
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};
530 MBool isInside =
false;
532 for(
MInt i = -stencil; i < stencil; i++) {
533 for(
MInt j = -stencil; j < stencil; j++) {
534 for(
MInt k = -stencil; k < stencil; k++) {
536 const MInt currentBlockId = getBlockId(centerCellId);
537 const MInt currentOffset = m_donorBlockOffsets[currentBlockId];
538 const MInt IJK = getCellIdfromCell(centerCellId, i, j, k, currentBlockId);
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];
549 if(trueI < 0 || trueI >= noLocalCellsDir[2] - 1 || trueJ < 0 || trueJ >= noLocalCellsDir[1] - 1 || trueK < 0
550 || trueK >= noLocalCellsDir[0] - 1) {
555 for(
MInt tetra = 0; tetra < 6; tetra++) {
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;
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)];
583 crossProduct(vn, v1, v2);
586 if(scalarProduct(v3, vn) > m_eps) {
588 for(
MInt dim = 0; dim < nDim; dim++) {
594 if(scalarProduct(vp, vn) > m_eps) {
627 MFloat transformedPoint[3]) {
629 const MInt currentBlockId = getBlockId(hexOrigin);
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)
638 a(dim, 5) = m_donorCoordinates[dim][getCellIdfromCell(hexOrigin, 1, 0, 1, currentBlockId)] -
a(dim, 0) -
a(dim, 1)
640 a(dim, 6) = m_donorCoordinates[dim][getCellIdfromCell(hexOrigin, 0, 1, 1, currentBlockId)] -
a(dim, 0) -
a(dim, 2)
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);
654 MFloat xicor, etacor, zetacor;
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;
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);
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));
672 if(fabs(jac) < m_eps) {
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]))
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)))
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)))
693 zeta = zeta + zetacor;
695 MFloat sumcor = fabs(xicor) + fabs(etacor) + fabs(zetacor);
706 transformedPoint[0] = xi;
707 transformedPoint[1] = eta;
708 transformedPoint[2] = zeta;
724 v[0] = dx[0] * dx[1] * dx[2];
725 v[1] = (F1 - dx[0]) * dx[1] * dx[2];
726 v[2] = dx[0] * (F1 - dx[1]) * dx[2];
727 v[3] = dx[0] * dx[1] * (F1 - dx[2]);
728 v[4] = (F1 - dx[0]) * (F1 - dx[1]) * dx[2];
729 v[5] = (F1 - dx[0]) * dx[1] * (F1 - dx[2]);
730 v[6] = dx[0] * (F1 - dx[1]) * (F1 - dx[2]);
731 v[7] = (F1 - dx[0]) * (F1 - dx[1]) * (F1 - dx[2]);
734 receiverVar[receiverId] = v[0] * m_donorVar[getCellIdfromCell(hexOrigin, 1, 1, 1, currentBlockId)]
735 + v[1] * m_donorVar[getCellIdfromCell(hexOrigin, 0, 1, 1, currentBlockId)]
736 + v[2] * m_donorVar[getCellIdfromCell(hexOrigin, 1, 0, 1, currentBlockId)]
737 + v[3] * m_donorVar[getCellIdfromCell(hexOrigin, 1, 1, 0, currentBlockId)]
738 + v[4] * m_donorVar[getCellIdfromCell(hexOrigin, 0, 0, 1, currentBlockId)]
739 + v[5] * m_donorVar[getCellIdfromCell(hexOrigin, 0, 1, 0, currentBlockId)]
740 + v[6] * m_donorVar[getCellIdfromCell(hexOrigin, 1, 0, 0, currentBlockId)]
741 + v[7] * m_donorVar[getCellIdfromCell(hexOrigin, 0, 0, 0, currentBlockId)];
755 MFloat* receiverVariables,
756 MInt currentBlockId) {
759 v[0] = dx[0] * dx[1] * dx[2];
760 v[1] = (F1 - dx[0]) * dx[1] * dx[2];
761 v[2] = dx[0] * (F1 - dx[1]) * dx[2];
762 v[3] = dx[0] * dx[1] * (F1 - dx[2]);
763 v[4] = (F1 - dx[0]) * (F1 - dx[1]) * dx[2];
764 v[5] = (F1 - dx[0]) * dx[1] * (F1 - dx[2]);
765 v[6] = dx[0] * (F1 - dx[1]) * (F1 - dx[2]);
766 v[7] = (F1 - dx[0]) * (F1 - dx[1]) * (F1 - dx[2]);
769 for(
MInt var = 0; var < m_noDonorVariables; var++) {
770 receiverVariables[var] = v[0] * m_donorVariables[var][getCellIdfromCell(hexOrigin, 1, 1, 1, currentBlockId)]
771 + v[1] * m_donorVariables[var][getCellIdfromCell(hexOrigin, 0, 1, 1, currentBlockId)]
772 + v[2] * m_donorVariables[var][getCellIdfromCell(hexOrigin, 1, 0, 1, currentBlockId)]
773 + v[3] * m_donorVariables[var][getCellIdfromCell(hexOrigin, 1, 1, 0, currentBlockId)]
774 + v[4] * m_donorVariables[var][getCellIdfromCell(hexOrigin, 0, 0, 1, currentBlockId)]
775 + v[5] * m_donorVariables[var][getCellIdfromCell(hexOrigin, 0, 1, 0, currentBlockId)]
776 + v[6] * m_donorVariables[var][getCellIdfromCell(hexOrigin, 1, 0, 0, currentBlockId)]
777 + v[7] * m_donorVariables[var][getCellIdfromCell(hexOrigin, 0, 0, 0, currentBlockId)];
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]);
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)];
827 return interpolatedVar;
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)];
844 return interpolatedVar;
859#if defined(WITH_HDF5)
862 if(m_domainId == 0) {
863 cout <<
"Reading in donor grid file..." << endl;
878 MString donorGridName = Context::getSolverProperty<MString>(
"donorGridName", 0, AT_);
880 MFloat translation[3] = {F0, F0, F0};
881 MFloat scale[3] = {F1, F1, F1};
896 for(
MInt dim = 0; dim < nDim; dim++) {
897 translation[dim] = Context::getSolverProperty<MFloat>(
"donorTranslation", 0, AT_, &translation[dim], dim);
914 for(
MInt dim = 0; dim < nDim; dim++) {
915 scale[dim] = Context::getSolverProperty<MFloat>(
"donorScale", 0, AT_, &scale[dim], dim);
919 if(m_domainId == 0) {
920 cout <<
"Translating donorGrid by deltaX: " << translation[0] <<
" deltaY: " << translation[1]
921 <<
" deltaZ: " << translation[2] << endl;
922 cout <<
"Scaling donorGrid by scaleX: " << scale[0] <<
" scaleY: " << scale[1] <<
" scaleZ: " << scale[2] << endl;
930 dummy1 << blockId1 <<
"/";
931 sBlockName += dummy1.str();
932 m_noDonorDims = pio.getDatasetNoDims(
"x", sBlockName);
934 if(m_domainId == 0) {
935 cout <<
"Donor grid has " << m_noDonorDims <<
" dimensions" << endl;
939 MInt noBlocksType = pio.getAttributeType(
"noBlocks",
"");
940 if(noBlocksType == 1) {
941 pio.getAttribute(&m_noBlocks,
"noBlocks",
"");
942 }
else if(noBlocksType == 0) {
943 MFloat noBlocksFloat = -1.0;
944 pio.getAttribute<
MFloat>(&noBlocksFloat,
"noBlocks",
"");
945 m_noBlocks = (
MInt)noBlocksFloat;
948 mAlloc(m_noDonorCellsDir, m_noBlocks, nDim, AT_, 0,
"m_noDonorCellsDir");
949 mAlloc(m_noDonorPointsDir, m_noBlocks, nDim, AT_, 0,
"m_noDonorPointsDir");
950 mAlloc(m_noDonorPoints, m_noBlocks, AT_, 1,
"m_noDonorPoints");
951 mAlloc(m_noDonorCells, m_noBlocks, AT_, 1,
"m_noDonorCells");
952 m_totalNoDonorCells = 0;
953 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
954 MInt ijk_max[MAX_SPACE_DIMENSIONS] = {0};
955 stringstream blockName;
956 blockName <<
"/block" << blockId <<
"/";
957 MString blockNameStr = blockName.str();
958 std::vector<ParallelIo::size_type> tmp(nDim, 0);
959 pio.getArraySize(
"x", blockNameStr, &tmp[0]);
960 std::copy(tmp.begin(), tmp.end(), &ijk_max[0]);
962 for(
MInt j = 0; j < m_noDonorDims; j++) {
963 if(m_donorIsCellCentered ==
true) {
964 m_noDonorCellsDir[blockId][j] = ijk_max[j] - 1;
966 m_noDonorCellsDir[blockId][j] = ijk_max[j];
968 m_noDonorPointsDir[blockId][j] = ijk_max[j];
970 m_noDonorPoints[blockId] *= m_noDonorPointsDir[blockId][j];
972 m_noDonorCells[blockId] *= m_noDonorCellsDir[blockId][j];
974 if(m_domainId == 0) {
975 cout <<
"Donor solver " << blockId <<
" has " << m_noDonorCells[blockId] <<
" cells" << endl;
978 m_totalNoDonorCells += m_noDonorCells[blockId];
981 if(m_domainId == 0) {
982 cout <<
"totalNoDonorCells: " << m_totalNoDonorCells << endl;
985 if(m_noDonorDims == 2) {
986 m_totalNoDonorCells = 0;
987 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
988 m_noDonorPointsDir[blockId][2] = m_noDonorPointsDir[blockId][1];
989 m_noDonorPointsDir[blockId][1] = m_noDonorPointsDir[blockId][0];
990 m_noDonorPointsDir[blockId][0] = 3;
991 m_noDonorCellsDir[blockId][2] = m_noDonorCellsDir[blockId][1];
992 m_noDonorCellsDir[blockId][1] = m_noDonorCellsDir[blockId][0];
993 m_noDonorCellsDir[blockId][0] = 2;
994 m_noDonorCells[blockId] =
995 m_noDonorCellsDir[blockId][0] * m_noDonorCellsDir[blockId][1] * m_noDonorCellsDir[blockId][2];
996 m_noDonorPoints[blockId] =
997 m_noDonorPointsDir[blockId][0] * m_noDonorPointsDir[blockId][1] * m_noDonorPointsDir[blockId][2];
998 m_totalNoDonorCells += m_noDonorCells[blockId];
1002 mAlloc(m_donorBlockOffsets, m_noBlocks, AT_, 0,
"m_donorBlockOffset");
1003 if(m_noBlocks > 1) {
1004 for(
MInt blockId = 1; blockId < m_noBlocks; blockId++) {
1005 m_donorBlockOffsets[blockId] = m_donorBlockOffsets[blockId - 1] + m_noDonorCells[blockId - 1];
1009 mAlloc(m_donorCoordinates, nDim, m_totalNoDonorCells,
"m_donorGridCoordinates", AT_);
1010 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
1011 MInt offset = m_donorBlockOffsets[blockId];
1012 stringstream blockName;
1013 blockName <<
"/block" << blockId <<
"/";
1014 MString blockNameStr = blockName.str();
1016 if(m_noDonorDims == 3) {
1017 MFloatScratchSpace gridCoordinates(m_noDonorPoints[blockId], AT_,
"gridCoordinates");
1018 MString coordName[3] = {
"x",
"y",
"z"};
1019 ParallelIo::size_type ioSize[3] = {m_noDonorPointsDir[blockId][0], m_noDonorPointsDir[blockId][1],
1020 m_noDonorPointsDir[blockId][2]};
1021 ParallelIo::size_type ioOffset[3] = {0, 0, 0};
1022 ParallelIo::size_type ioDims = m_noDonorDims;
1023 for(
MInt dim = 0; dim < m_noDonorDims; dim++) {
1024 pio.readArray(&gridCoordinates[0], blockNameStr, coordName[dim], ioDims, ioOffset, ioSize);
1025 if(!m_donorIsCellCentered) {
1027 m_donorCoordinates[dim][offset +
cellId] = gridCoordinates[
cellId];
1030 computeCellCentreCoordinates(m_noDonorPointsDir[blockId], gridCoordinates, dim, blockId);
1033 m_donorCoordinates[dim][offset +
cellId] =
1034 translation[dim] + scale[dim] * m_donorCoordinates[dim][offset +
cellId];
1038 ParallelIo::size_type ioSize[2] = {m_noDonorPointsDir[blockId][1], m_noDonorPointsDir[blockId][2]};
1039 ParallelIo::size_type ioOffset[3] = {0, 0, 0};
1040 MFloatScratchSpace gridCoordinates(m_noDonorPoints[blockId], AT_,
"gridCoordinates");
1042 for(
MInt dim = 0; dim < nDim; dim++) {
1043 MString coordName[3] = {
"x",
"y",
"z"};
1045 pio.readArray(gridCoordinates.begin(), blockNameStr, coordName[dim], m_noDonorDims, ioOffset, ioSize);
1048 for(
MInt i = 0; i < m_noDonorPointsDir[blockId][2]; i++) {
1049 for(
MInt j = 0; j < m_noDonorPointsDir[blockId][1]; j++) {
1050 for(
MInt k = 1; k < m_noDonorPointsDir[blockId][0]; k++) {
1051 MInt pointId2D = i + j * m_noDonorPointsDir[blockId][2];
1052 MInt pointId = i + (j + k * m_noDonorPointsDir[blockId][1]) * m_noDonorPointsDir[blockId][2];
1053 gridCoordinates(pointId) = gridCoordinates(pointId2D);
1060 for(
MInt i = 0; i < m_noDonorPointsDir[blockId][2]; i++) {
1061 for(
MInt j = 0; j < m_noDonorPointsDir[blockId][1]; j++) {
1062 for(
MInt k = 0; k < m_noDonorPointsDir[blockId][0]; k++) {
1063 MInt pointId = i + (j + k * m_noDonorPointsDir[blockId][1]) * m_noDonorPointsDir[blockId][2];
1064 gridCoordinates(pointId) = (maxZ - minZ) / (m_noDonorPointsDir[blockId][0] - 1) * k;
1070 computeCellCentreCoordinates(m_noDonorPointsDir[blockId], gridCoordinates, dim, blockId);
1072 m_donorCoordinates[dim][
cellId] = translation[dim] + scale[dim] * m_donorCoordinates[dim][offset +
cellId];
1078 MBool write2D3DGrid =
false;
1080 const char* fileName =
"rescaledGrid.hdf5";
1082 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
1083 MInt offset = m_donorBlockOffsets[blockId];
1084 stringstream blockName;
1085 blockName <<
"/block" << blockId <<
"/";
1086 MString blockNameStr = blockName.str();
1088 ParallelIo::size_type ioSize[3] = {m_noDonorCellsDir[blockId][0], m_noDonorCellsDir[blockId][1],
1089 m_noDonorCellsDir[blockId][2]};
1093 ParallelIo::size_type ioOffset[3] = {0, 0, 0};
1095 if(m_domainId == 0) {
1096 rescaledGridFile.writeArray(&m_donorCoordinates[0][offset + 0], blockNameStr,
"x", nDim, ioOffset, ioSize);
1097 rescaledGridFile.writeArray(&m_donorCoordinates[1][offset + 0], blockNameStr,
"y", nDim, ioOffset, ioSize);
1098 rescaledGridFile.writeArray(&m_donorCoordinates[2][offset + 0], blockNameStr,
"z", nDim, ioOffset, ioSize);
1100 ParallelIo::size_type ioEmptySize[3] = {0, 0, 0};
1102 rescaledGridFile.writeArray(&empty, blockNameStr,
"x", nDim, ioOffset, ioEmptySize);
1103 rescaledGridFile.writeArray(&empty, blockNameStr,
"y", nDim, ioOffset, ioEmptySize);
1104 rescaledGridFile.writeArray(&empty, blockNameStr,
"z", nDim, ioOffset, ioEmptySize);
1108 if(m_domainId == 0) {
1109 cout <<
"Reading in donor grid file... FINISHED!" << endl;
1120#if defined(WITH_HDF5)
1123 stringstream donorFileName;
1125 if(m_domainId == 0) {
1126 cout <<
"Reading in " << varName <<
" from donor file..." << endl;
1142 MString donorFile = Context::getSolverProperty<MString>(
"donorVars", 0, AT_);
1147 for(
MInt blockId = 0; blockId < m_noBlocks; blockId++) {
1148 stringstream blockName;
1149 blockName <<
"/block" << blockId <<
"/";
1150 MString blockNameStr = blockName.str();
1152 MBool fieldExists = pio.hasDataset(varName, blockNameStr);
1154 if(m_domainId == 0) {
1155 cout <<
"Field " << varName <<
" exist, loading from donorFile. " << endl;
1157 MInt offset = m_donorBlockOffsets[blockId];
1158 ParallelIo::size_type ioSize[3] = {0, 0, 0};
1159 ParallelIo::size_type ioOffset[3] = {0, 0, 0};
1160 if(m_noDonorDims == 3) {
1161 ioSize[0] = m_noDonorCellsDir[blockId][0];
1162 ioSize[1] = m_noDonorCellsDir[blockId][1];
1163 ioSize[2] = m_noDonorCellsDir[blockId][2];
1165 ioSize[0] = m_noDonorCellsDir[blockId][1];
1166 ioSize[1] = m_noDonorCellsDir[blockId][2];
1169 pio.readArray(&m_donorVar[offset], blockNameStr, varName, m_noDonorDims, ioOffset, ioSize);
1172 if(m_noDonorDims == 2) {
1173 for(
MInt k = 1; k < m_noDonorCellsDir[blockId][0]; k++) {
1174 for(
MInt j = 0; j < m_noDonorCellsDir[blockId][1]; j++) {
1175 for(
MInt i = 0; i < m_noDonorCellsDir[blockId][2]; i++) {
1176 const MInt cellId = cellIndex(i, j, k, blockId);
1177 const MInt cellId2D = cellIndex(i, j, 0, blockId);
1178 m_donorVar[
cellId] = m_donorVar[cellId2D];
1184 if(m_domainId == 0) {
1185 cout <<
"Field " << varName <<
" doesn't exist, setting zero. " << endl;
1187 for(
MInt k = 0; k < m_noDonorCellsDir[blockId][0]; k++) {
1188 for(
MInt j = 0; j < m_noDonorCellsDir[blockId][1]; j++) {
1189 for(
MInt i = 0; i < m_noDonorCellsDir[blockId][2]; i++) {
1190 const MInt cellId = cellIndex(i, j, k, blockId);
1198 if(m_domainId == 0) {
1199 cout <<
"Reading in " << varName <<
" from donor file... FINISHED!" << endl;
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];
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);
1234 m_donorCoordinates[dim][cellId] =
1236 * (coordinates[IJK] + coordinates[IP1JK] + coordinates[IJP1K] + coordinates[IP1JP1K] + coordinates[IJKP1]
1237 + coordinates[IP1JKP1] + coordinates[IJP1KP1] + coordinates[IP1JP1KP1]);
1253 receiverVar[receiverId] = m_donorVar[donorId];
1258 for(
MInt var = 0; var < m_noDonorVariables; var++) {
1259 receiverVariables[var] = m_donorVariables[var][donorId];
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];
1272 return vec1[xsd] * vec2[xsd] + vec1[ysd] * vec2[ysd] + vec1[zsd] * vec2[zsd];
1278 return origin + incI + incJ * m_noDonorCellsDir[blockId][2]
1279 + incK * m_noDonorCellsDir[blockId][2] * m_noDonorCellsDir[blockId][1];
1284 const MInt offset = m_donorBlockOffsets[blockId];
1285 return offset + i + (j + k * m_noDonorCellsDir[blockId][1]) * m_noDonorCellsDir[blockId][2];
1292 return m_pyramidPoints[dim + side * 3 + tetra * 3 * 4];
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;
1307 return currentBlockId;
1312 return abs(
a -
b) < eps;
void mAlloc(T *&a, const MLong N, const MString &objectName, MString function)
allocates memory for one-dimensional array 'a' of size N
MBool mDeallocate(T *&a)
deallocates the memory previously allocated for element 'a'
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
This class is a ScratchSpace.
void loadDonorVariable(MString varName)
Loads a Q file.
void trilinearInterpolation(MFloat *, MInt, MInt, MFloat *, MInt)
void prepareInterpolationField(MInt *noReceiverCells, MFloat **receiverCoordinates)
Prepares interpolation for field For a given 3D coordinate field the method computes the transformed ...
void computeInterpolationCoefficients(MFloat *, MInt)
Computes trilinear interpolation coefficients.
MInt * m_donorBlockOffsets
void nearestNeighbourInterpolation(MInt, MInt, MFloat *)
Nearest neighbour interpolation.
MFloat getInterpolatedVariable(MInt, MInt)
Trilinear interpolation for single point.
~StructuredInterpolation()
MInt cellIndex(MInt i, MInt j, MInt k, MInt solverId)
MFloat interpolateVariableZonal(MFloat *, MInt)
MInt ic(MInt, MInt, MInt)
void prepareInterpolation(MInt, MFloat **, MInt *)
Prepares interpolation neighbours and coefficients For a given number of points the methods computes ...
void interpolateVariables(MFloat **)
MInt getBlockId(MInt cellId)
void transformPoint(MInt hexOrigin, MFloat intPoint[3], MFloat transformedPoint[3])
Transforms point from physical to computational space.
void loadDonorGrid()
Loads a grid file.
void crossProduct(MFloat result[3], MFloat vec1[3], MFloat vec2[3])
MInt ** m_noDonorCellsDir
void computeCellCentreCoordinates(MInt *, MFloatScratchSpace &, MInt, MInt)
Computes cell centered coordinates.
MBool approx(const MFloat &, const MFloat &, const MFloat)
StructuredInterpolation(const MPI_Comm structuredCommunicator)
Constructor for property given donor.
void interpolateField(MString, MFloat *)
interpolates a field interpolates a given varName and varF
void buildDonorTree()
Builds a kd-tree Creates a kd-tree from the predefined grid-data in m_donorCoordinates.
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...
void interpolateAtPoint(MFloat *intPoint)
interpolates variables at point For a given 3D coordinate the method interpolates from the donor grid
MFloat scalarProduct(MFloat vec1[3], MFloat vec2[3])
MFloat getInterpolatedVariableZonal(MFloat *, MInt)
const MPI_Comm m_StructuredComm
MInt getCellIdfromCell(MInt origin, MInt incI, MInt incJ, MInt incK, MInt solverId)
void prepareZonalInterpolation(MInt, MFloat **, MInt *, MBool)
computes the interpolation coefficients Interpolates all variables with precomputed interpolation coe...
MBool approx(const T &, const U &, const T)
constexpr T mMin(const T &x, const T &y)
constexpr T mMax(const T &x, const T &y)
std::basic_string< char > MString
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)