MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
fvstructuredinterpolation.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef STRUCTUREDINTERPOLATION_H
8#define STRUCTUREDINTERPOLATION_H
9
10#include <vector>
11#include "UTIL/kdtree.h"
12#include "UTIL/pointbox.h"
13#include "globals.h"
14
15template <MInt nDim>
17 public:
18 StructuredInterpolation(const MPI_Comm structuredCommunicator);
19 StructuredInterpolation(MInt* noDonorCells, MFloat** donorCoordinates, MFloat** donorVariables,
20 const MPI_Comm structuredCommunicator);
21 StructuredInterpolation(MInt* noDonorCellsDir, MFloat** donorCoordinates, const MPI_Comm structuredCommunicator);
23 void interpolateAtPoint(MFloat* intPoint);
24 void prepareInterpolationField(MInt* noReceiverCells, MFloat** receiverCoordinates);
26 void loadDonorGrid();
27 void loadDonorVariable(MString varName);
34
35 protected:
36 void buildDonorTree();
37 inline void crossProduct(MFloat result[3], MFloat vec1[3], MFloat vec2[3]);
38 inline MFloat scalarProduct(MFloat vec1[3], MFloat vec2[3]);
39 inline MInt getCellIdfromCell(MInt origin, MInt incI, MInt incJ, MInt incK, MInt solverId);
40 inline MBool approx(const MFloat&, const MFloat&, const MFloat);
41 inline MInt getBlockId(MInt cellId);
44
46 inline void transformPoint(MInt hexOrigin, MFloat intPoint[3], MFloat transformedPoint[3]);
47 inline MInt findSurroundingHexahedron(MFloat intPoint[3], MInt centerCellId, MInt stencil);
50 inline MInt cellIndex(MInt i, MInt j, MInt k, MInt solverId);
51 inline MInt ic(MInt, MInt, MInt);
53
54 // index variables
55 static const MInt xsd = 0;
56 static const MInt ysd = 1;
57 static const MInt zsd = 2;
58
61 MInt* m_noDonorCells = nullptr;
65 MFloat* m_donorVar = nullptr;
70
71 const MPI_Comm m_StructuredComm;
77
78 MInt* m_donorOriginId = nullptr; // needed if donorIds are saved for multiple interpolation
79 MFloat** m_interpolationCoefficients = nullptr; // needed if coefficients are saved for multiple interpolation
85
91
92 std::vector<Point<3>> m_donorPoints;
94
95 // pyramidPoints contains the ijk-combinations
96 // for all possible tetraeders
97 // inside a hexahedron, use together with function ic(tetraeder,side,dim)
98 static constexpr MInt m_pyramidPoints[72] = {0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0,
99 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1,
100 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 0};
101};
102
103#endif
This class is a ScratchSpace.
Definition: scratch.h:758
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.
void nearestNeighbourInterpolation(MInt, MInt, MFloat *)
Nearest neighbour interpolation.
MFloat getInterpolatedVariable(MInt, MInt)
Trilinear interpolation for single point.
MInt cellIndex(MInt i, MInt j, MInt k, MInt solverId)
MFloat interpolateVariableZonal(MFloat *, MInt)
void prepareInterpolation(MInt, MFloat **, MInt *)
Prepares interpolation neighbours and coefficients For a given number of points the methods computes ...
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])
void computeCellCentreCoordinates(MInt *, MFloatScratchSpace &, MInt, MInt)
Computes cell centered coordinates.
MBool approx(const MFloat &, const MFloat &, const MFloat)
std::vector< Point< 3 > > m_donorPoints
void interpolateField(MString, MFloat *)
interpolates a field interpolates a given varName and varF
static constexpr MInt m_pyramidPoints[72]
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)
MInt getCellIdfromCell(MInt origin, MInt incI, MInt incJ, MInt incK, MInt solverId)
void trilinearInterpolation(MFloat *, MInt, MFloat *, MInt)
void prepareZonalInterpolation(MInt, MFloat **, MInt *, MBool)
computes the interpolation coefficients Interpolates all variables with precomputed interpolation coe...
int32_t MInt
Definition: maiatypes.h:62
std::basic_string< char > MString
Definition: maiatypes.h:55
double MFloat
Definition: maiatypes.h:52
bool MBool
Definition: maiatypes.h:58
Definition: kdtree.h:73