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, map< PtsInfo, int > ptsInfo=NullPtsInfoMap) | |
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) |
vector< NekDouble > | GetBoxSize () const |
void | SetBoxSize (const vector< NekDouble > boxsize) |
template<typename FuncPointerT , typename ObjectPointerT > | |
void | setProgressCallback (FuncPointerT func, ObjectPointerT obj) |
Public Attributes | |
map< PtsInfo, int > | m_ptsInfo |
map for information about points that can be added through PtsInfo enum More... | |
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 m_dim 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... | |
vector< NekDouble > | m_boxSize |
vector of box size xmin,xmax,ymin,ymax,zmin,zmax More... | |
boost::function< void(const int position, const int goal)> | m_progressCallback |
Definition at line 98 of file PtsField.h.
Nektar::LibUtilities::PtsField::PtsField | ( | const int | dim, |
const Array< OneD, Array< OneD, NekDouble > > & | pts | ||
) |
Definition at line 198 of file PtsField.cpp.
References GetNFields(), and m_fieldNames.
|
inline |
Definition at line 105 of file PtsField.h.
|
inline |
Definition at line 118 of file PtsField.h.
void Nektar::LibUtilities::PtsField::AddField | ( | const Array< OneD, NekDouble > & | pts, |
const std::string | fieldName | ||
) |
Definition at line 280 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 394 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 491 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 439 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 566 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 593 of file PtsField.cpp.
References DistSq(), m_dim, m_pts, and npts.
Referenced by CalcW_Shepard().
vector< NekDouble > Nektar::LibUtilities::PtsField::GetBoxSize | ( | ) | const |
Definition at line 374 of file PtsField.cpp.
References m_boxSize.
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 219 of file PtsField.cpp.
References m_ptsConn.
int Nektar::LibUtilities::PtsField::GetDim | ( | ) | const |
Definition at line 247 of file PtsField.cpp.
References m_dim.
std::string Nektar::LibUtilities::PtsField::GetFieldName | ( | const int | i | ) | const |
Definition at line 265 of file PtsField.cpp.
References m_fieldNames.
vector< std::string > Nektar::LibUtilities::PtsField::GetFieldNames | ( | ) | const |
Definition at line 259 of file PtsField.cpp.
References m_fieldNames.
int Nektar::LibUtilities::PtsField::GetNFields | ( | ) | const |
Definition at line 253 of file PtsField.cpp.
References m_fieldNames.
Referenced by PtsField().
int Nektar::LibUtilities::PtsField::GetNpoints | ( | ) | const |
Definition at line 302 of file PtsField.cpp.
References m_pts.
vector< int > Nektar::LibUtilities::PtsField::GetPointsPerEdge | ( | ) | const |
Definition at line 335 of file PtsField.cpp.
References m_nPtsPerEdge.
int Nektar::LibUtilities::PtsField::GetPointsPerEdge | ( | const int | i | ) | const |
Definition at line 341 of file PtsField.cpp.
References m_nPtsPerEdge.
NekDouble Nektar::LibUtilities::PtsField::GetPointVal | ( | const int | fieldInd, |
const int | ptInd | ||
) | const |
Definition at line 308 of file PtsField.cpp.
References m_pts.
Definition at line 314 of file PtsField.cpp.
References m_pts.
Definition at line 320 of file PtsField.cpp.
References m_pts.
PtsType Nektar::LibUtilities::PtsField::GetPtsType | ( | ) | const |
Definition at line 363 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, m_weights, and Nektar::NekMeshUtils::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.
Definition at line 379 of file PtsField.cpp.
References m_boxSize.
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 232 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 241 of file PtsField.cpp.
References m_dim.
void Nektar::LibUtilities::PtsField::SetFieldNames | ( | const vector< std::string > | fieldNames | ) |
Definition at line 271 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, 2 for ePtsPlane and 3 for ePtsBox |
Definition at line 353 of file PtsField.cpp.
References ASSERTL0, Nektar::LibUtilities::ePtsBox, Nektar::LibUtilities::ePtsLine, Nektar::LibUtilities::ePtsPlane, m_nPtsPerEdge, and m_ptsType.
|
inline |
Definition at line 201 of file PtsField.h.
Definition at line 326 of file PtsField.cpp.
References ASSERTL1, and m_pts.
Definition at line 369 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, m_weights, and Nektar::NekMeshUtils::weights().
|
private |
vector of box size xmin,xmax,ymin,ymax,zmin,zmax
Definition at line 237 of file PtsField.h.
Referenced by GetBoxSize(), and SetBoxSize().
|
private |
Dimension of the pts field.
Definition at line 213 of file PtsField.h.
Referenced by CalcW_Shepard(), CalcWeights(), FindNeighbours(), GetDim(), Interpolate(), SetDim(), and SetFieldNames().
|
private |
Names of the field variables.
Definition at line 215 of file PtsField.h.
Referenced by AddField(), GetFieldName(), GetFieldNames(), GetNFields(), Interpolate(), PtsField(), and SetFieldNames().
Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourIdx].
Definition at line 234 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 222 of file PtsField.h.
Referenced by GetPointsPerEdge(), and SetPointsPerEdge().
|
private |
Definition at line 239 of file PtsField.h.
Referenced by CalcWeights().
Point data. For a n-dimensional field, the first m_dim fields are the points spatial coordinates. Structure: m_pts[fieldIdx][ptIdx].
Definition at line 218 of file PtsField.h.
Referenced by AddField(), CalcW_Linear(), CalcW_Quadratic(), CalcW_Shepard(), CalcWeights(), FindNeighbours(), GetNpoints(), GetPointVal(), GetPts(), Interpolate(), SetFieldNames(), 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 226 of file PtsField.h.
Referenced by GetConnectivity(), and SetConnectivity().
map<PtsInfo,int> Nektar::LibUtilities::PtsField::m_ptsInfo |
map for information about points that can be added through PtsInfo enum
Definition at line 208 of file PtsField.h.
|
private |
Type of the PtsField.
Definition at line 228 of file PtsField.h.
Referenced by GetPtsType(), SetConnectivity(), SetPointsPerEdge(), and SetPtsType().
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx].
Definition at line 231 of file PtsField.h.
Referenced by CalcW_Linear(), CalcW_Quadratic(), CalcW_Shepard(), CalcWeights(), GetWeights(), Interpolate(), and SetWeights().