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) |
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 neares neighbours of a point. More... | |
void | FindNNeighbours (const PtsPoint &searchPt, std::vector< PtsPoint > &neighbourPts, const unsigned int numPts=1) |
Finds the neares 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 70 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 174 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 autpomatically.
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 91 of file LibUtilities/BasicUtils/Interpolator.h.
References CalcWeights(), GetCoordId(), GetDim(), GetFiltWidth(), GetInField(), GetInterpMethod(), GetOutField(), Interpolate(), LIB_UTILITIES_EXPORT, and PrintStatistics().
|
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 345 of file LibUtilities/BasicUtils/Interpolator.cpp.
References Nektar::LibUtilities::Interpolator::PtsPoint::idx.
|
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 398 of file LibUtilities/BasicUtils/Interpolator.cpp.
References ASSERTL0, Nektar::LibUtilities::Interpolator::PtsPoint::coords, Nektar::LibUtilities::Interpolator::PtsPoint::idx, and Nektar::NekConstants::kNekZeroTol.
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 439 of file LibUtilities/BasicUtils/Interpolator.cpp.
References Nektar::LibUtilities::Interpolator::PtsPoint::idx.
|
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 513 of file LibUtilities/BasicUtils/Interpolator.cpp.
References ASSERTL0, Nektar::LibUtilities::Interpolator::PtsPoint::coords, Nektar::LibUtilities::Interpolator::PtsPoint::idx, and Nektar::NekConstants::kNekZeroTol.
|
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 466 of file LibUtilities/BasicUtils/Interpolator.cpp.
References Nektar::LibUtilities::Interpolator::PtsPoint::idx, and Nektar::NekConstants::kNekZeroTol.
void Nektar::LibUtilities::Interpolator::CalcWeights | ( | const LibUtilities::PtsFieldSharedPtr | ptsInField, |
LibUtilities::PtsFieldSharedPtr & | ptsOutField | ||
) |
Compute interpolation weights without doing any interpolation.
ptsInField | input field |
ptsOutField | output field |
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, Nektar::LibUtilities::eGauss, Nektar::LibUtilities::eNearestNeighbour, Nektar::LibUtilities::eNoMethod, Nektar::LibUtilities::eQuadratic, Nektar::LibUtilities::eShepard, Nektar::NekConstants::kNekZeroTol, and NEKERROR.
Referenced by Interpolator().
|
private |
Finds the neares 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 669 of file LibUtilities/BasicUtils/Interpolator.cpp.
References Nektar::LibUtilities::Interpolator::PtsPoint::coords.
|
private |
Finds the neares 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 635 of file LibUtilities/BasicUtils/Interpolator.cpp.
References Nektar::LibUtilities::Interpolator::PtsPoint::coords.
int Nektar::LibUtilities::Interpolator::GetCoordId | ( | ) | const |
Returns the coordinate id along which the interpolation should be performed.
Definition at line 288 of file LibUtilities/BasicUtils/Interpolator.cpp.
Referenced by Interpolator().
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 283 of file LibUtilities/BasicUtils/Interpolator.cpp.
Referenced by Interpolator().
NekDouble Nektar::LibUtilities::Interpolator::GetFiltWidth | ( | ) | const |
Returns the filter width.
Definition at line 293 of file LibUtilities/BasicUtils/Interpolator.cpp.
Referenced by Interpolator().
LibUtilities::PtsFieldSharedPtr Nektar::LibUtilities::Interpolator::GetInField | ( | ) | const |
Returns the input field.
Definition at line 303 of file LibUtilities/BasicUtils/Interpolator.cpp.
Referenced by Interpolator().
InterpMethod Nektar::LibUtilities::Interpolator::GetInterpMethod | ( | ) | const |
Returns the interpolation method used by this interpolator.
Definition at line 298 of file LibUtilities/BasicUtils/Interpolator.cpp.
Referenced by Interpolator().
LibUtilities::PtsFieldSharedPtr Nektar::LibUtilities::Interpolator::GetOutField | ( | ) | const |
Returns the output field.
Definition at line 308 of file LibUtilities/BasicUtils/Interpolator.cpp.
Referenced by Interpolator().
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 235 of file LibUtilities/BasicUtils/Interpolator.cpp.
References ASSERTL0.
Referenced by Nektar::Utilities::ProcessCurve::EvaluateCoordinate(), and Interpolator().
void Nektar::LibUtilities::Interpolator::PrintStatistics | ( | ) |
Returns if the weights have already been computed.
Definition at line 313 of file LibUtilities/BasicUtils/Interpolator.cpp.
Referenced by Interpolator().
|
inline |
sets a callback funtion which gets called every time the interpolation progresses
Definition at line 134 of file LibUtilities/BasicUtils/Interpolator.h.
References m_progressCallback.
Referenced by Nektar::FieldUtils::ProcessInterpPoints::InterpolateFieldToPts(), Nektar::FieldUtils::ProcessInterpPtsToPts::InterpolatePtsToPts(), Nektar::FieldUtils::ProcessInterpField::Process(), and Nektar::FieldUtils::ProcessInterpPointDataToFld::Process().
|
private |
Definition at line 584 of file LibUtilities/BasicUtils/Interpolator.cpp.
References Nektar::NekConstants::kNekZeroTol.
|
private |
coordinate id along which the interpolation should be performed
Definition at line 195 of file LibUtilities/BasicUtils/Interpolator.h.
|
staticprivate |
dimension of this interpolator. Hardcoded to 3
Definition at line 171 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Filter width used for some interpolation algorithms.
Definition at line 191 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Max number of interpolation points.
Definition at line 193 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Interpolation Method.
Definition at line 179 of file LibUtilities/BasicUtils/Interpolator.h.
Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourIdx].
Definition at line 189 of file LibUtilities/BasicUtils/Interpolator.h.
|
protected |
Definition at line 148 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by SetProgressCallback().
|
protected |
input field
Definition at line 143 of file LibUtilities/BasicUtils/Interpolator.h.
|
protected |
output field
Definition at line 145 of file LibUtilities/BasicUtils/Interpolator.h.
|
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.
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx].
Definition at line 186 of file LibUtilities/BasicUtils/Interpolator.h.