Nektar++
|
#include <PtsField.h>
Public Member Functions | |
PtsField (const int dim, const Array< OneD, Array< OneD, NekDouble > > &pts) | |
PtsField (const int dim, const vector< std::string > fieldnames, const Array< OneD, Array< OneD, NekDouble > > &pts) | |
PtsField (const int dim, const vector< std::string > fieldnames, const Array< OneD, Array< OneD, NekDouble > > &pts, const Array< OneD, Array< OneD, float > > &weights, const Array< OneD, Array< OneD, unsigned int > > &neighInds) | |
void | CalcWeights (const Array< OneD, Array< OneD, NekDouble > > &physCoords, short int coordId=-1) |
Compute the weights for an interpolation of the field values to physical points. More... | |
void | Interpolate (const Array< OneD, Array< OneD, NekDouble > > &physCoords, Array< OneD, Array< OneD, NekDouble > > &intFields, short int coordId=-1) |
Compute weights and perform the interpolate of field values to physical points. More... | |
void | Interpolate (Array< OneD, Array< OneD, NekDouble > > &intFields) |
Perform the interpolate of field values to physical points. More... | |
void | SetWeights (const Array< OneD, Array< OneD, float > > &weights, const Array< OneD, Array< OneD, unsigned int > > &neighbourInds) |
Set the interpolation weights for an interpolation. More... | |
void | GetWeights (Array< OneD, Array< OneD, float > > &weights, Array< OneD, Array< OneD, unsigned int > > &neighbourInds) const |
Get the interpolation weights and corresponding neighbour indices. More... | |
void | GetConnectivity (vector< Array< OneD, int > > &conn) const |
Set the connectivity data for ePtsTetBlock and ePtsTriBlock. More... | |
void | SetConnectivity (const vector< Array< OneD, int > > &conn) |
Get the connectivity data for ePtsTetBlock and ePtsTriBlock. More... | |
void | SetDim (const int ptsDim) |
int | GetDim () const |
int | GetNFields () const |
vector< std::string > | GetFieldNames () const |
std::string | GetFieldName (const int i) const |
void | SetFieldNames (const vector< std::string > fieldNames) |
void | AddField (const Array< OneD, NekDouble > &pts, const std::string fieldName) |
int | GetNpoints () const |
NekDouble | GetPointVal (const int fieldInd, const int ptInd) const |
void | GetPts (Array< OneD, Array< OneD, NekDouble > > &pts) const |
Array< OneD, NekDouble > | GetPts (const int fieldInd) const |
void | SetPts (Array< OneD, Array< OneD, NekDouble > > &pts) |
vector< int > | GetPointsPerEdge () const |
int | GetPointsPerEdge (const int i) const |
void | SetPointsPerEdge (const vector< int > nPtsPerEdge) |
Set the number of points per edge. More... | |
PtsType | GetPtsType () const |
void | SetPtsType (const PtsType type) |
template<typename FuncPointerT , typename ObjectPointerT > | |
void | setProgressCallback (FuncPointerT func, ObjectPointerT obj) |
Private Member Functions | |
void | CalcW_Linear (const int physPtIdx, const NekDouble coord) |
Compute interpolation weights for a 1D physical point using linear interpolation. More... | |
void | CalcW_Shepard (const int physPtIdx, const Array< OneD, NekDouble > &physPtCoords) |
Compute interpolation weights for a physical point using a modified Shepard algorithm. More... | |
void | CalcW_Quadratic (const int physPtIdx, const NekDouble coord) |
Compute interpolation weights for a 1D physical point using quadratic interpolation. More... | |
NekDouble | DistSq (const Array< OneD, NekDouble > &point1, const Array< OneD, NekDouble > &point2) const |
Compute the square of the euclidean distance between point1 and point2. More... | |
void | FindNeighbours (const Array< OneD, NekDouble > &physPtCoords, vector< PtsPoint > &neighbourPts, const unsigned int numPts=1) |
Find nearest neighbours using a brute-force "algorithm". More... | |
Private Attributes | |
int | m_dim |
Dimension of the pts field. More... | |
vector< std::string > | m_fieldNames |
Names of the field variables. More... | |
Array< OneD, Array< OneD, NekDouble > > | m_pts |
Point data. For a n-dimensional field, the first n fields are the points spatial coordinates. Structure: m_pts[fieldIdx][ptIdx]. More... | |
vector< int > | m_nPtsPerEdge |
Number of points per edge. Empty if the point data has no specific shape (ePtsLine) or is a block (ePtsTetBlock, ePtsTriBlock), size=1 for ePtsLine and 2 for a ePtsPlane. More... | |
vector< Array< OneD, int > > | m_ptsConn |
Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each, m_ptsConn is a vector of n arrays with 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries. More... | |
PtsType | m_ptsType |
Type of the PtsField. More... | |
Array< OneD, Array< OneD, float > > | m_weights |
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx]. More... | |
Array< OneD, Array< OneD, unsigned int > > | m_neighInds |
Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourIdx]. More... | |
boost::function< void(const int position, const int goal)> | m_progressCallback |
Definition at line 90 of file PtsField.h.
|
inline |
Definition at line 94 of file PtsField.h.
|
inline |
Definition at line 103 of file PtsField.h.
|
inline |
Definition at line 114 of file PtsField.h.
void Nektar::LibUtilities::PtsField::AddField | ( | const Array< OneD, NekDouble > & | pts, |
const std::string | fieldName | ||
) |
Definition at line 267 of file PtsField.cpp.
References ASSERTL1, m_fieldNames, and m_pts.
|
private |
Compute interpolation weights for a 1D physical point using linear interpolation.
physPtIdx | The index of the physical point in its storage array |
coord | The coordinate of the physical point |
Definition at line 377 of file PtsField.cpp.
References ASSERTL0, m_neighInds, m_pts, m_weights, and npts.
Referenced by CalcWeights().
|
private |
Compute interpolation weights for a 1D physical point using quadratic interpolation.
physPtIdx | The index of the physical point in its storage array |
coord | The coordinate of the physical point |
Definition at line 474 of file PtsField.cpp.
References ASSERTL0, m_neighInds, m_pts, m_weights, and npts.
Referenced by CalcWeights().
|
private |
Compute interpolation weights for a physical point using a modified Shepard algorithm.
physPtIdx | The index of the physical point in its storage array |
physPt | The coordinates of the physical point |
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 422 of file PtsField.cpp.
References ASSERTL0, FindNeighbours(), Nektar::NekConstants::kNekSqrtTol, m_dim, m_neighInds, m_pts, m_weights, and Vmath::Nnan().
Referenced by CalcWeights().
void Nektar::LibUtilities::PtsField::CalcWeights | ( | const Array< OneD, Array< OneD, NekDouble > > & | physCoords, |
short int | coordId = -1 |
||
) |
Compute the weights for an interpolation of the field values to physical points.
physCoords | coordinates of the physical points |
coord_id | id of the coordinate to use for interpolation. |
Set coord_id to -1 to use n-D interpolation for an n-dimensional field. The most suitable algorithm is chosen automatically.
Definition at line 53 of file PtsField.cpp.
References ASSERTL1, CalcW_Linear(), CalcW_Quadratic(), CalcW_Shepard(), m_dim, m_neighInds, m_progressCallback, m_pts, and m_weights.
Referenced by Interpolate().
|
private |
Compute the square of the euclidean distance between point1 and point2.
point1 | The first point |
point2 | The second point |
Definition at line 549 of file PtsField.cpp.
Referenced by FindNeighbours().
|
private |
Find nearest neighbours using a brute-force "algorithm".
physPt | Coordinates of the physical point its neighbours we are looking for |
neighbourPts | The points we found |
numPts | The number of points to find |
This iterates over all points, computes the (squared) euclidean distance and chooses the numPts closest points. Thus, its very expensive and inefficient.
Definition at line 576 of file PtsField.cpp.
References DistSq(), m_dim, m_pts, and npts.
Referenced by CalcW_Shepard().
Set the connectivity data for ePtsTetBlock and ePtsTriBlock.
conn | Connectivity data Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each, m_ptsConn is a vector of n arrays with 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries. |
Definition at line 206 of file PtsField.cpp.
References m_ptsConn.
int Nektar::LibUtilities::PtsField::GetDim | ( | ) | const |
Definition at line 234 of file PtsField.cpp.
References m_dim.
std::string Nektar::LibUtilities::PtsField::GetFieldName | ( | const int | i | ) | const |
Definition at line 252 of file PtsField.cpp.
References m_fieldNames.
vector< std::string > Nektar::LibUtilities::PtsField::GetFieldNames | ( | ) | const |
Definition at line 246 of file PtsField.cpp.
References m_fieldNames.
int Nektar::LibUtilities::PtsField::GetNFields | ( | ) | const |
Definition at line 240 of file PtsField.cpp.
References m_fieldNames.
int Nektar::LibUtilities::PtsField::GetNpoints | ( | ) | const |
Definition at line 289 of file PtsField.cpp.
References m_pts.
vector< int > Nektar::LibUtilities::PtsField::GetPointsPerEdge | ( | ) | const |
Definition at line 322 of file PtsField.cpp.
References m_nPtsPerEdge.
int Nektar::LibUtilities::PtsField::GetPointsPerEdge | ( | const int | i | ) | const |
Definition at line 328 of file PtsField.cpp.
References m_nPtsPerEdge.
NekDouble Nektar::LibUtilities::PtsField::GetPointVal | ( | const int | fieldInd, |
const int | ptInd | ||
) | const |
Definition at line 295 of file PtsField.cpp.
References m_pts.
Definition at line 301 of file PtsField.cpp.
References m_pts.
Definition at line 307 of file PtsField.cpp.
References m_pts.
PtsType Nektar::LibUtilities::PtsField::GetPtsType | ( | ) | const |
Definition at line 358 of file PtsField.cpp.
References m_ptsType.
void Nektar::LibUtilities::PtsField::GetWeights | ( | Array< OneD, Array< OneD, float > > & | weights, |
Array< OneD, Array< OneD, unsigned int > > & | neighbourInds | ||
) | const |
Get the interpolation weights and corresponding neighbour indices.
weights | Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx] |
neighbourInds | Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourIdx] |
Definition at line 190 of file PtsField.cpp.
References m_neighInds, and m_weights.
void Nektar::LibUtilities::PtsField::Interpolate | ( | const Array< OneD, Array< OneD, NekDouble > > & | physCoords, |
Array< OneD, Array< OneD, NekDouble > > & | intFields, | ||
short int | coordId = -1 |
||
) |
Compute weights and perform the interpolate of field values to physical points.
physCoords | coordinates of the physical points |
intFields | interpolated field at the physical points |
coord_id | id of the coordinate to use for interpolation. |
Set coord_id to -1 to use n-D interpolation for an n-dimensional field. The most suitable algorithm is chosen automatically.
Definition at line 116 of file PtsField.cpp.
References CalcWeights().
void Nektar::LibUtilities::PtsField::Interpolate | ( | Array< OneD, Array< OneD, NekDouble > > & | intFields | ) |
Perform the interpolate of field values to physical points.
intFields | interpolated field at the physical points |
The weights must have already been computed by or set by .
Definition at line 134 of file PtsField.cpp.
References ASSERTL1, m_dim, m_fieldNames, m_neighInds, m_pts, and m_weights.
Get the connectivity data for ePtsTetBlock and ePtsTriBlock.
conn | Connectivity data Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each, m_ptsConn is a vector of n arrays with 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries. |
Definition at line 219 of file PtsField.cpp.
References ASSERTL1, Nektar::LibUtilities::ePtsTetBlock, Nektar::LibUtilities::ePtsTriBlock, m_ptsConn, and m_ptsType.
void Nektar::LibUtilities::PtsField::SetDim | ( | const int | ptsDim | ) |
Definition at line 228 of file PtsField.cpp.
References m_dim.
void Nektar::LibUtilities::PtsField::SetFieldNames | ( | const vector< std::string > | fieldNames | ) |
Definition at line 258 of file PtsField.cpp.
References ASSERTL0, m_dim, m_fieldNames, and m_pts.
void Nektar::LibUtilities::PtsField::SetPointsPerEdge | ( | const vector< int > | nPtsPerEdge | ) |
Set the number of points per edge.
nPtsPerEdge | Number of points per edge. Empty if the point data has no specific shape (ePtsLine) or is a block (ePtsTetBlock, ePtsTriBlock), size=1 for ePtsLine and 2 for a ePtsPlane |
Definition at line 340 of file PtsField.cpp.
References ASSERTL0, Nektar::LibUtilities::ePtsLine, Nektar::LibUtilities::ePtsPlane, m_nPtsPerEdge, m_pts, and m_ptsType.
|
inline |
Definition at line 193 of file PtsField.h.
Definition at line 313 of file PtsField.cpp.
References ASSERTL1, and m_pts.
Definition at line 364 of file PtsField.cpp.
References m_ptsType.
void Nektar::LibUtilities::PtsField::SetWeights | ( | const Array< OneD, Array< OneD, float > > & | weights, |
const Array< OneD, Array< OneD, unsigned int > > & | neighbourInds | ||
) |
Set the interpolation weights for an interpolation.
weights | Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx] |
neighbourInds | Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourIdx] |
Definition at line 170 of file PtsField.cpp.
References ASSERTL0, m_neighInds, and m_weights.
|
private |
Dimension of the pts field.
Definition at line 202 of file PtsField.h.
Referenced by CalcW_Shepard(), CalcWeights(), FindNeighbours(), GetDim(), Interpolate(), SetDim(), and SetFieldNames().
|
private |
Names of the field variables.
Definition at line 204 of file PtsField.h.
Referenced by AddField(), GetFieldName(), GetFieldNames(), GetNFields(), Interpolate(), and SetFieldNames().
Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourIdx].
Definition at line 223 of file PtsField.h.
Referenced by CalcW_Linear(), CalcW_Quadratic(), CalcW_Shepard(), CalcWeights(), GetWeights(), Interpolate(), and SetWeights().
|
private |
Number of points per edge. Empty if the point data has no specific shape (ePtsLine) or is a block (ePtsTetBlock, ePtsTriBlock), size=1 for ePtsLine and 2 for a ePtsPlane.
Definition at line 211 of file PtsField.h.
Referenced by GetPointsPerEdge(), and SetPointsPerEdge().
|
private |
Definition at line 225 of file PtsField.h.
Referenced by CalcWeights().
Point data. For a n-dimensional field, the first n fields are the points spatial coordinates. Structure: m_pts[fieldIdx][ptIdx].
Definition at line 207 of file PtsField.h.
Referenced by AddField(), CalcW_Linear(), CalcW_Quadratic(), CalcW_Shepard(), CalcWeights(), FindNeighbours(), GetNpoints(), GetPointVal(), GetPts(), Interpolate(), SetFieldNames(), SetPointsPerEdge(), and SetPts().
Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each, m_ptsConn is a vector of n arrays with 3*m (ePtsTriBlock) or 4*m (ePtsTetBlock) entries.
Definition at line 215 of file PtsField.h.
Referenced by GetConnectivity(), and SetConnectivity().
|
private |
Type of the PtsField.
Definition at line 217 of file PtsField.h.
Referenced by GetPtsType(), SetConnectivity(), SetPointsPerEdge(), and SetPtsType().
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx].
Definition at line 220 of file PtsField.h.
Referenced by CalcW_Linear(), CalcW_Quadratic(), CalcW_Shepard(), CalcWeights(), GetWeights(), Interpolate(), and SetWeights().