Nektar++
|
A class that contains algorithms for interpolation between pts fields, expansions and different meshes. More...
#include <Interpolator.h>
Classes | |
class | PtsPoint |
Public Member Functions | |
Interpolator (InterpMethod method=eNoMethod, short int coordId=-1, NekDouble filtWidth=0.0, int maxPts=1000) | |
Constructor of the Interpolator class. More... | |
void | CalcWeights (const LibUtilities::PtsFieldSharedPtr ptsInField, LibUtilities::PtsFieldSharedPtr &ptsOutField, bool reuseTree=false) |
Compute interpolation weights without doing any interpolation. More... | |
void | Interpolate (const LibUtilities::PtsFieldSharedPtr ptsInField, LibUtilities::PtsFieldSharedPtr &ptsOutField) |
Interpolate from a pts field to a pts field. More... | |
int | GetDim () const |
returns the dimension of the Interpolator. Should be higher than the dimensions of the interpolated fields More... | |
NekDouble | GetFiltWidth () const |
Returns the filter width. More... | |
int | GetCoordId () const |
Returns the coordinate id along which the interpolation should be performed. More... | |
InterpMethod | GetInterpMethod () const |
Returns the interpolation method used by this interpolator. More... | |
LibUtilities::PtsFieldSharedPtr | GetInField () const |
Returns the input field. More... | |
LibUtilities::PtsFieldSharedPtr | GetOutField () const |
Returns the output field. More... | |
void | PrintStatistics () |
Returns if the weights have already been computed. More... | |
template<typename FuncPointerT , typename ObjectPointerT > | |
void | SetProgressCallback (FuncPointerT func, ObjectPointerT obj) |
sets a callback funtion which gets called every time the interpolation progresses More... | |
Protected Attributes | |
LibUtilities::PtsFieldSharedPtr | m_ptsInField |
input field More... | |
LibUtilities::PtsFieldSharedPtr | m_ptsOutField |
output field More... | |
std::function< void(const int position, const int goal)> | m_progressCallback |
Private Types | |
typedef boost::geometry::model::point< NekDouble, m_dim, boost::geometry::cs::cartesian > | BPoint |
typedef std::pair< BPoint, unsigned int > | PtsPointPair |
typedef boost::geometry::index::rtree< PtsPointPair, boost::geometry::index::rstar< 16 > > | PtsRtree |
Private Member Functions | |
void | CalcW_Gauss (const PtsPoint &searchPt, const NekDouble sigma, const int maxPts=250) |
Computes interpolation weights using gaussian interpolation. More... | |
void | CalcW_Linear (const PtsPoint &searchPt, int coordId) |
Computes interpolation weights using linear interpolation. More... | |
void | CalcW_NNeighbour (const PtsPoint &searchPt) |
Computes interpolation weights using nearest neighbour interpolation. More... | |
void | CalcW_Shepard (const PtsPoint &searchPt, int numPts) |
Computes interpolation weights using linear interpolation. More... | |
void | CalcW_Quadratic (const PtsPoint &searchPt, int coordId) |
Computes interpolation weights using quadratic interpolation. More... | |
void | SetupTree () |
void | FindNeighbours (const PtsPoint &searchPt, std::vector< PtsPoint > &neighbourPts, const NekDouble dist, const unsigned int maxPts=1) |
Finds the nearest neighbours of a point. More... | |
void | FindNNeighbours (const PtsPoint &searchPt, std::vector< PtsPoint > &neighbourPts, const unsigned int numPts=1) |
Finds the nearest neighbours of a point. More... | |
Private Attributes | |
InterpMethod | m_method |
Interpolation Method. More... | |
std::shared_ptr< PtsRtree > | m_rtree |
A tree structure to speed up the neighbour search. Note that we fill it with an iterator, so instead of rstar, the packing algorithm is used. More... | |
Array< TwoD, NekDouble > | m_weights |
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx]. More... | |
Array< TwoD, unsigned int > | m_neighInds |
Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourIdx]. More... | |
NekDouble | m_filtWidth |
Filter width used for some interpolation algorithms. More... | |
int | m_maxPts |
Max number of interpolation points. More... | |
short int | m_coordId |
coordinate id along which the interpolation should be performed More... | |
Static Private Attributes | |
static const int | m_dim = 3 |
dimension of this interpolator. Hardcoded to 3 More... | |
A class that contains algorithms for interpolation between pts fields, expansions and different meshes.
Definition at line 71 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Definition at line 172 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Definition at line 173 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Definition at line 176 of file LibUtilities/BasicUtils/Interpolator.h.
|
inline |
Constructor of the Interpolator class.
method | interpolation method, defaults to a sensible value if not set |
coordId | coordinate id along which the interpolation should be performed |
filtWidth | filter width, required by some algorithms such as eGauss |
maxPts | limit number of considered points |
if method is not specified, the best algorithm is chosen automatically.
If coordId is not specified, a full 1D/2D/3D interpolation is performed without collapsing any coordinate.
filtWidth must be specified for the eGauss algorithm only.
Definition at line 92 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Computes interpolation weights using gaussian interpolation.
searchPt | point for which the weights are computed |
sigma | standard deviation of the gauss function |
Performs an interpolation using gauss weighting. Ideal for filtering fields. The filter width should be half the FWHM (= 1.1774 sigma) and must be set in the constructor of the Interpolator class.
Definition at line 350 of file LibUtilities/BasicUtils/Interpolator.cpp.
References FindNeighbours(), Nektar::LibUtilities::Interpolator::PtsPoint::idx, m_neighInds, and m_weights.
Referenced by CalcWeights().
|
private |
Computes interpolation weights using linear interpolation.
searchPt | point for which the weights are computed |
m_coordId | coordinate id along which the interpolation should be performed |
Currently, only implemented for 1D
Definition at line 402 of file LibUtilities/BasicUtils/Interpolator.cpp.
References ASSERTL0, Nektar::LibUtilities::Interpolator::PtsPoint::coords, Nektar::LibUtilities::Interpolator::PtsPoint::idx, Nektar::NekConstants::kNekZeroTol, m_coordId, m_neighInds, m_ptsInField, and m_weights.
Referenced by CalcWeights().
Computes interpolation weights using nearest neighbour interpolation.
searchPt | point for which the weights are computed |
m_coordId | coordinate id along which the interpolation should be performed |
Definition at line 443 of file LibUtilities/BasicUtils/Interpolator.cpp.
References FindNNeighbours(), Nektar::LibUtilities::Interpolator::PtsPoint::idx, m_neighInds, and m_weights.
Referenced by CalcWeights().
|
private |
Computes interpolation weights using quadratic interpolation.
searchPt | point for which the weights are computed |
m_coordId | coordinate id along which the interpolation should be performed |
Currently, only implemented for 1D. Falls back to linear interpolation if only 2 values are available.
Definition at line 516 of file LibUtilities/BasicUtils/Interpolator.cpp.
References ASSERTL0, Nektar::LibUtilities::Interpolator::PtsPoint::coords, Nektar::LibUtilities::Interpolator::PtsPoint::idx, Nektar::NekConstants::kNekZeroTol, m_coordId, m_neighInds, m_ptsInField, and m_weights.
Referenced by CalcWeights().
|
private |
Computes interpolation weights using linear interpolation.
searchPt | point for which the weights are computed |
m_coordId | coordinate id along which the interpolation should be performed |
The algorithm is based on Shepard, D. (1968). A two-dimensional interpolation function for irregularly-spaced data. Proceedings of the 1968 23rd ACM National Conference. pp. 517–524.
In order to save memory, for n dimesnions, only 2^n points are considered. Contrary to Shepard, we use a fixed number of points with fixed weighting factors 1/d^n.
Definition at line 470 of file LibUtilities/BasicUtils/Interpolator.cpp.
References FindNNeighbours(), Nektar::LibUtilities::Interpolator::PtsPoint::idx, Nektar::NekConstants::kNekZeroTol, m_neighInds, m_ptsInField, and m_weights.
Referenced by CalcWeights().
void Nektar::LibUtilities::Interpolator::CalcWeights | ( | const LibUtilities::PtsFieldSharedPtr | ptsInField, |
LibUtilities::PtsFieldSharedPtr & | ptsOutField, | ||
bool | reuseTree = false |
||
) |
Compute interpolation weights without doing any interpolation.
ptsInField | input field |
ptsOutField | output field |
reuseTree | if an r-tree has been constructed already, reuse it (e.g. for repeated calls over the same input points). |
In and output fields must have the same dimension. The most suitable algorithm is chosen automatically if it wasnt set explicitly.
Definition at line 58 of file LibUtilities/BasicUtils/Interpolator.cpp.
References ASSERTL0, CalcW_Gauss(), CalcW_Linear(), CalcW_NNeighbour(), CalcW_Quadratic(), CalcW_Shepard(), Nektar::ErrorUtil::efatal, Nektar::LibUtilities::eGauss, Nektar::LibUtilities::eNearestNeighbour, Nektar::LibUtilities::eNoMethod, Nektar::LibUtilities::eQuadratic, Nektar::LibUtilities::eShepard, Nektar::NekConstants::kNekZeroTol, m_coordId, m_dim, m_filtWidth, m_maxPts, m_method, m_neighInds, m_progressCallback, m_ptsInField, m_ptsOutField, m_rtree, m_weights, NEKERROR, and SetupTree().
Referenced by Nektar::SolverUtils::SessionFunction::EvaluatePts(), and Interpolate().
|
private |
Finds the nearest neighbours of a point.
searchPt | point for which the neighbours are searched |
neighbourPts | possible neighbour points |
dist | limits the distance of the neighbours |
Definition at line 671 of file LibUtilities/BasicUtils/Interpolator.cpp.
References Nektar::LibUtilities::Interpolator::PtsPoint::coords, Nektar::UnitTests::d(), m_dim, m_ptsInField, and m_rtree.
Referenced by CalcW_Gauss().
|
private |
Finds the nearest neighbours of a point.
searchPt | point for which the neighbours are searched |
neighbourPts | possible neighbour points |
numPts | limits the number of neighbours found to the numPts nearest ones |
Definition at line 637 of file LibUtilities/BasicUtils/Interpolator.cpp.
References Nektar::LibUtilities::Interpolator::PtsPoint::coords, Nektar::UnitTests::d(), m_dim, m_ptsInField, and m_rtree.
Referenced by CalcW_NNeighbour(), and CalcW_Shepard().
int Nektar::LibUtilities::Interpolator::GetCoordId | ( | ) | const |
Returns the coordinate id along which the interpolation should be performed.
Definition at line 293 of file LibUtilities/BasicUtils/Interpolator.cpp.
References m_coordId.
int Nektar::LibUtilities::Interpolator::GetDim | ( | ) | const |
returns the dimension of the Interpolator. Should be higher than the dimensions of the interpolated fields
Definition at line 288 of file LibUtilities/BasicUtils/Interpolator.cpp.
References m_dim.
NekDouble Nektar::LibUtilities::Interpolator::GetFiltWidth | ( | ) | const |
Returns the filter width.
Definition at line 298 of file LibUtilities/BasicUtils/Interpolator.cpp.
References m_filtWidth.
LibUtilities::PtsFieldSharedPtr Nektar::LibUtilities::Interpolator::GetInField | ( | ) | const |
Returns the input field.
Definition at line 308 of file LibUtilities/BasicUtils/Interpolator.cpp.
References m_ptsInField.
InterpMethod Nektar::LibUtilities::Interpolator::GetInterpMethod | ( | ) | const |
Returns the interpolation method used by this interpolator.
Definition at line 303 of file LibUtilities/BasicUtils/Interpolator.cpp.
References m_method.
LibUtilities::PtsFieldSharedPtr Nektar::LibUtilities::Interpolator::GetOutField | ( | ) | const |
Returns the output field.
Definition at line 313 of file LibUtilities/BasicUtils/Interpolator.cpp.
References m_ptsOutField.
void Nektar::LibUtilities::Interpolator::Interpolate | ( | const LibUtilities::PtsFieldSharedPtr | ptsInField, |
LibUtilities::PtsFieldSharedPtr & | ptsOutField | ||
) |
Interpolate from a pts field to a pts field.
ptsInField | input field |
ptsOutField | output field |
In and output fields must have the same dimension and number of fields. The most suitable algorithm is chosen automatically if it wasnt set explicitly.
Definition at line 240 of file LibUtilities/BasicUtils/Interpolator.cpp.
References ASSERTL0, CalcWeights(), m_dim, m_neighInds, m_ptsInField, m_ptsOutField, and m_weights.
Referenced by Nektar::FieldUtils::Interpolator< T >::Interpolate().
void Nektar::LibUtilities::Interpolator::PrintStatistics | ( | ) |
Returns if the weights have already been computed.
Definition at line 318 of file LibUtilities/BasicUtils/Interpolator.cpp.
References m_neighInds.
Referenced by Nektar::SolverUtils::SessionFunction::EvaluatePts().
|
inline |
sets a callback funtion which gets called every time the interpolation progresses
Definition at line 135 of file LibUtilities/BasicUtils/Interpolator.h.
References m_progressCallback.
Referenced by Nektar::SolverUtils::SessionFunction::EvaluatePts(), Nektar::FieldUtils::ProcessInterpPoints::InterpolateFieldToPts(), Nektar::FieldUtils::ProcessInterpPtsToPts::InterpolatePtsToPts(), Nektar::FieldUtils::ProcessInterpField::v_Process(), and Nektar::FieldUtils::ProcessInterpPointDataToFld::v_Process().
|
private |
Definition at line 587 of file LibUtilities/BasicUtils/Interpolator.cpp.
References Nektar::MemoryManager< DataType >::AllocateSharedPtr(), Nektar::NekConstants::kNekZeroTol, m_ptsInField, and m_rtree.
Referenced by CalcWeights().
|
private |
coordinate id along which the interpolation should be performed
Definition at line 195 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcW_Linear(), CalcW_Quadratic(), CalcWeights(), and GetCoordId().
|
staticprivate |
dimension of this interpolator. Hardcoded to 3
Definition at line 169 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcWeights(), FindNeighbours(), FindNNeighbours(), GetDim(), and Interpolate().
|
private |
Filter width used for some interpolation algorithms.
Definition at line 191 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcWeights(), and GetFiltWidth().
|
private |
Max number of interpolation points.
Definition at line 193 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcWeights().
|
private |
Interpolation Method.
Definition at line 179 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcWeights(), and GetInterpMethod().
Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourIdx].
Definition at line 189 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcW_Gauss(), CalcW_Linear(), CalcW_NNeighbour(), CalcW_Quadratic(), CalcW_Shepard(), CalcWeights(), Interpolate(), and PrintStatistics().
|
protected |
Definition at line 147 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcWeights(), and SetProgressCallback().
|
protected |
input field
Definition at line 143 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcW_Linear(), CalcW_Quadratic(), CalcW_Shepard(), CalcWeights(), FindNeighbours(), FindNNeighbours(), GetInField(), Interpolate(), and SetupTree().
|
protected |
output field
Definition at line 145 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcWeights(), GetOutField(), and Interpolate().
|
private |
A tree structure to speed up the neighbour search. Note that we fill it with an iterator, so instead of rstar, the packing algorithm is used.
Definition at line 183 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcWeights(), FindNeighbours(), FindNNeighbours(), and SetupTree().
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx].
Definition at line 186 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by CalcW_Gauss(), CalcW_Linear(), CalcW_NNeighbour(), CalcW_Quadratic(), CalcW_Shepard(), CalcWeights(), and Interpolate().