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... | |
FIELD_UTILS_EXPORT void | CalcWeights (const LibUtilities::PtsFieldSharedPtr ptsInField, LibUtilities::PtsFieldSharedPtr &ptsOutField) |
Compute interpolation weights without doing any interpolation. More... | |
FIELD_UTILS_EXPORT void | Interpolate (const LibUtilities::PtsFieldSharedPtr ptsInField, LibUtilities::PtsFieldSharedPtr &ptsOutField) |
Interpolate from a pts field to a pts field. More... | |
FIELD_UTILS_EXPORT void | Interpolate (const std::vector< MultiRegions::ExpListSharedPtr > expInField, std::vector< MultiRegions::ExpListSharedPtr > &expOutField, NekDouble def_value=0.0) |
Interpolate from an expansion to an expansion. More... | |
FIELD_UTILS_EXPORT void | Interpolate (const std::vector< MultiRegions::ExpListSharedPtr > expInField, LibUtilities::PtsFieldSharedPtr &ptsOutField, NekDouble def_value=0.0) |
Interpolate from an expansion to a pts field. More... | |
FIELD_UTILS_EXPORT void | Interpolate (const LibUtilities::PtsFieldSharedPtr ptsInField, std::vector< MultiRegions::ExpListSharedPtr > &expOutField) |
Interpolate from a pts field to an expansion. More... | |
FIELD_UTILS_EXPORT int | GetDim () const |
returns the dimension of the Interpolator. Should be higher than the dimensions of the interpolated fields More... | |
FIELD_UTILS_EXPORT NekDouble | GetFiltWidth () const |
Returns the filter width. More... | |
FIELD_UTILS_EXPORT int | GetCoordId () const |
Returns the coordinate id along which the interpolation should be performed. More... | |
FIELD_UTILS_EXPORT InterpMethod | GetInterpMethod () const |
Returns the interpolation method used by this interpolator. More... | |
FIELD_UTILS_EXPORT LibUtilities::PtsFieldSharedPtr | GetInField () const |
Returns the input field. More... | |
FIELD_UTILS_EXPORT LibUtilities::PtsFieldSharedPtr | GetOutField () const |
Returns the output field. More... | |
FIELD_UTILS_EXPORT void | PrintStatistics () |
Print statics of the interpolation weights. 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... | |
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 | |
FIELD_UTILS_EXPORT void | CalcW_Gauss (const PtsPoint &searchPt, const NekDouble sigma, const int maxPts=250) |
Computes interpolation weights using gaussian interpolation. More... | |
FIELD_UTILS_EXPORT void | CalcW_Linear (const PtsPoint &searchPt, int coordId) |
Computes interpolation weights using linear interpolation. More... | |
FIELD_UTILS_EXPORT void | CalcW_NNeighbour (const PtsPoint &searchPt) |
Computes interpolation weights using nearest neighbour interpolation. More... | |
FIELD_UTILS_EXPORT void | CalcW_Shepard (const PtsPoint &searchPt, int numPts) |
Computes interpolation weights using linear interpolation. More... | |
FIELD_UTILS_EXPORT void | CalcW_Quadratic (const PtsPoint &searchPt, int coordId) |
Computes interpolation weights using quadratic interpolation. More... | |
FIELD_UTILS_EXPORT void | SetupTree () |
FIELD_UTILS_EXPORT 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... | |
FIELD_UTILS_EXPORT void | FindNNeighbours (const PtsPoint &searchPt, std::vector< PtsPoint > &neighbourPts, const unsigned int numPts=1) |
Finds the neares neighbours of a point. More... | |
Private Attributes | |
LibUtilities::PtsFieldSharedPtr | m_ptsInField |
input field More... | |
LibUtilities::PtsFieldSharedPtr | m_ptsOutField |
output field More... | |
std::vector < MultiRegions::ExpListSharedPtr > | m_expInField |
input field More... | |
std::vector < MultiRegions::ExpListSharedPtr > | m_expOutField |
output field More... | |
InterpMethod | m_method |
Interpolation Method. More... | |
boost::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, float > | 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... | |
boost::function< void(const int position, const int goal)> | m_progressCallback |
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 75 of file Interpolator.h.
|
private |
Definition at line 182 of file Interpolator.h.
|
private |
Definition at line 183 of file Interpolator.h.
|
private |
Definition at line 184 of file 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 96 of file 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 599 of file Interpolator.cpp.
References Nektar::FieldUtils::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 652 of file Interpolator.cpp.
References ASSERTL0, Nektar::FieldUtils::Interpolator::PtsPoint::coords, Nektar::FieldUtils::Interpolator::PtsPoint::idx, Nektar::NekConstants::kNekZeroTol, and npts.
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 693 of file Interpolator.cpp.
References Nektar::FieldUtils::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 767 of file Interpolator.cpp.
References ASSERTL0, Nektar::FieldUtils::Interpolator::PtsPoint::coords, Nektar::FieldUtils::Interpolator::PtsPoint::idx, Nektar::NekConstants::kNekZeroTol, and npts.
|
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 720 of file Interpolator.cpp.
References Nektar::FieldUtils::Interpolator::PtsPoint::idx, and Nektar::NekConstants::kNekZeroTol.
void Nektar::FieldUtils::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 59 of file Interpolator.cpp.
References ASSERTL0, Nektar::FieldUtils::eGauss, Nektar::FieldUtils::eNearestNeighbour, Nektar::FieldUtils::eNoMethod, Nektar::FieldUtils::eQuadratic, Nektar::FieldUtils::eShepard, and Nektar::NekConstants::kNekZeroTol.
|
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 926 of file Interpolator.cpp.
References Nektar::FieldUtils::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 892 of file Interpolator.cpp.
References Nektar::FieldUtils::Interpolator::PtsPoint::coords.
int Nektar::FieldUtils::Interpolator::GetCoordId | ( | ) | const |
Returns the coordinate id along which the interpolation should be performed.
Definition at line 545 of file Interpolator.cpp.
int Nektar::FieldUtils::Interpolator::GetDim | ( | ) | const |
returns the dimension of the Interpolator. Should be higher than the dimensions of the interpolated fields
Definition at line 540 of file Interpolator.cpp.
NekDouble Nektar::FieldUtils::Interpolator::GetFiltWidth | ( | ) | const |
Returns the filter width.
Definition at line 550 of file Interpolator.cpp.
LibUtilities::PtsFieldSharedPtr Nektar::FieldUtils::Interpolator::GetInField | ( | ) | const |
Returns the input field.
Definition at line 560 of file Interpolator.cpp.
InterpMethod Nektar::FieldUtils::Interpolator::GetInterpMethod | ( | ) | const |
Returns the interpolation method used by this interpolator.
Definition at line 555 of file Interpolator.cpp.
LibUtilities::PtsFieldSharedPtr Nektar::FieldUtils::Interpolator::GetOutField | ( | ) | const |
Returns the output field.
Definition at line 565 of file Interpolator.cpp.
void Nektar::FieldUtils::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 Interpolator.cpp.
References ASSERTL0.
Referenced by Nektar::Utilities::ProcessCurve::EvaluateCoordinate(), Nektar::FieldUtils::ProcessInterpPoints::InterpolateFieldToPts(), and Nektar::FieldUtils::ProcessInterpField::Process().
void Nektar::FieldUtils::Interpolator::Interpolate | ( | const std::vector< MultiRegions::ExpListSharedPtr > | expInField, |
std::vector< MultiRegions::ExpListSharedPtr > & | expOutField, | ||
NekDouble | def_value = 0.0 |
||
) |
Interpolate from an expansion to an expansion.
Interpolate from one expansion to an other.
expInField | input field |
expOutField | output field |
In and output fields must have the same dimension and number of fields. Weights are currently not stored for later use. The interpolation is performed by evaluating the expInField at the quadrature points of expOutField, so only eNoMethod is supported. If both expansions use the same mesh, use LibUtilities/Foundations/Interp.h instead.
Definition at line 302 of file Interpolator.cpp.
References ASSERTL0, Nektar::FieldUtils::eNoMethod, and Nektar::NekConstants::kNekZeroTol.
void Nektar::FieldUtils::Interpolator::Interpolate | ( | const std::vector< MultiRegions::ExpListSharedPtr > | expInField, |
LibUtilities::PtsFieldSharedPtr & | ptsOutField, | ||
NekDouble | def_value = 0.0 |
||
) |
Interpolate from an expansion to a pts field.
expInField | input field |
ptsOutField | output field |
In and output fields must have the same dimension and number of fields. Weights are currently not stored for later use. The interpolation is performed by evaluating the expInField at the points of ptsOutField, so only eNoMethod is supported.
Definition at line 403 of file Interpolator.cpp.
References ASSERTL0, Nektar::FieldUtils::eNoMethod, and Nektar::NekConstants::kNekZeroTol.
void Nektar::FieldUtils::Interpolator::Interpolate | ( | const LibUtilities::PtsFieldSharedPtr | ptsInField, |
std::vector< MultiRegions::ExpListSharedPtr > & | expOutField | ||
) |
Interpolate from a pts field to an expansion.
ptsInField | input field |
expOutField | output field |
In and output fields must have the same dimension and number of fields.
Definition at line 483 of file Interpolator.cpp.
References ASSERTL0.
void Nektar::FieldUtils::Interpolator::PrintStatistics | ( | ) |
Print statics of the interpolation weights.
Definition at line 570 of file Interpolator.cpp.
|
inline |
sets a callback funtion which gets called every time the interpolation progresses
Definition at line 156 of file Interpolator.h.
References m_progressCallback.
Referenced by Nektar::FieldUtils::ProcessInterpPoints::InterpolateFieldToPts(), and Nektar::FieldUtils::ProcessInterpField::Process().
|
private |
Definition at line 838 of file Interpolator.cpp.
References Nektar::iterator, and Nektar::NekConstants::kNekZeroTol.
|
private |
coordinate id along which the interpolation should be performed
Definition at line 212 of file Interpolator.h.
|
staticprivate |
dimension of this interpolator. Hardcoded to 3
Definition at line 181 of file Interpolator.h.
|
private |
input field
Definition at line 191 of file Interpolator.h.
|
private |
output field
Definition at line 193 of file Interpolator.h.
|
private |
Filter width used for some interpolation algorithms.
Definition at line 208 of file Interpolator.h.
|
private |
Max number of interpolation points.
Definition at line 210 of file Interpolator.h.
|
private |
Interpolation Method.
Definition at line 196 of file Interpolator.h.
Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourIdx].
Definition at line 206 of file Interpolator.h.
|
private |
Definition at line 215 of file Interpolator.h.
Referenced by SetProgressCallback().
|
private |
input field
Definition at line 187 of file Interpolator.h.
|
private |
output field
Definition at line 189 of file 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 200 of file Interpolator.h.
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx].
Definition at line 203 of file Interpolator.h.