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 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 73 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Definition at line 174 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Definition at line 175 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Definition at line 178 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 94 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 356 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 408 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 449 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 523 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 476 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, | ||
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 60 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 Nektar::SolverUtils::SessionFunction::EvaluatePts().
|
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 678 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 644 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 299 of file LibUtilities/BasicUtils/Interpolator.cpp.
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 294 of file LibUtilities/BasicUtils/Interpolator.cpp.
NekDouble Nektar::LibUtilities::Interpolator::GetFiltWidth | ( | ) | const |
Returns the filter width.
Definition at line 304 of file LibUtilities/BasicUtils/Interpolator.cpp.
LibUtilities::PtsFieldSharedPtr Nektar::LibUtilities::Interpolator::GetInField | ( | ) | const |
Returns the input field.
Definition at line 314 of file LibUtilities/BasicUtils/Interpolator.cpp.
InterpMethod Nektar::LibUtilities::Interpolator::GetInterpMethod | ( | ) | const |
Returns the interpolation method used by this interpolator.
Definition at line 309 of file LibUtilities/BasicUtils/Interpolator.cpp.
LibUtilities::PtsFieldSharedPtr Nektar::LibUtilities::Interpolator::GetOutField | ( | ) | const |
Returns the output field.
Definition at line 319 of file LibUtilities/BasicUtils/Interpolator.cpp.
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 246 of file LibUtilities/BasicUtils/Interpolator.cpp.
References ASSERTL0.
void Nektar::LibUtilities::Interpolator::PrintStatistics | ( | ) |
Returns if the weights have already been computed.
Definition at line 324 of file LibUtilities/BasicUtils/Interpolator.cpp.
Referenced by Nektar::SolverUtils::SessionFunction::EvaluatePts().
|
inline |
sets a callback funtion which gets called every time the interpolation progresses
Definition at line 137 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 594 of file LibUtilities/BasicUtils/Interpolator.cpp.
References Nektar::NekConstants::kNekZeroTol.
|
private |
coordinate id along which the interpolation should be performed
Definition at line 197 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 193 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Max number of interpolation points.
Definition at line 195 of file LibUtilities/BasicUtils/Interpolator.h.
|
private |
Interpolation Method.
Definition at line 181 of file LibUtilities/BasicUtils/Interpolator.h.
Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourIdx].
Definition at line 191 of file LibUtilities/BasicUtils/Interpolator.h.
|
protected |
Definition at line 149 of file LibUtilities/BasicUtils/Interpolator.h.
Referenced by SetProgressCallback().
|
protected |
input field
Definition at line 145 of file LibUtilities/BasicUtils/Interpolator.h.
|
protected |
output field
Definition at line 147 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 185 of file LibUtilities/BasicUtils/Interpolator.h.
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx].
Definition at line 188 of file LibUtilities/BasicUtils/Interpolator.h.