41 namespace LibUtilities
58 "physCoords is smaller than number of dimesnions");
60 int nPhysPts = physCoords[0].num_elements();
67 for (
int i = 0; i < nPhysPts; ++i)
70 for (
int j = 0; j <
m_dim; ++j)
72 physPt[j] = physCoords[j][i];
75 if (m_dim == 1 || coordId >= 0)
82 if (
m_pts[0].num_elements() <= 2)
96 int progress = int(100 * i / nPhysPts);
137 "weights / neighInds mismatch")
143 for (
int i = 0; i < nFields; ++i)
147 for (
int j = 0; j < nPhysPts; ++j)
149 intFields[i][j] = 0.0;
152 for (
int k = 0; k < nPts; ++k)
174 ASSERTL0(weights.num_elements() == neighbourInds.num_elements(),
175 "weights and neighbourInds not of same number of physical points")
222 "ptsType must be set before connectivity");
261 "Number of given fieldNames does not match the number of stored fields");
268 const string fieldName)
270 int nTotvars =
m_pts.num_elements();
271 int nPts =
m_pts[0].num_elements();
273 ASSERTL1(pts.num_elements() == nPts,
"Field size mismatch");
277 for (
int i = 0; i < nTotvars; ++i)
279 newpts[i] =
m_pts[i];
281 newpts[nTotvars] = pts;
291 return m_pts[0].num_elements();
297 return m_pts[fieldInd][ptInd];
309 return m_pts[fieldInd];
316 "Pts field count mismatch");
343 "SetPointsPerEdge only supported for ePtsLine and ePtsPlane .");
346 for (
int i = 0; i < nPtsPerEdge.size(); ++i)
348 totPts = totPts * nPtsPerEdge.at(i);
352 "nPtsPerEdge does not match total number of points");
386 for (i = 0; i < npts - 1; ++i)
388 if ((
m_pts[0][i] <= coord) && (coord <=
m_pts[0][i + 1]))
395 m_weights[physPtIdx][0] = (m_pts[0][i + 1] - coord) / pdiff;
396 m_weights[physPtIdx][1] = (coord - m_pts[0][i]) / pdiff;
401 ASSERTL0(i != npts - 1,
"Failed to find coordinate " +
402 boost::lexical_cast<string>(coord) +
403 " within provided input points");
426 vector<PtsPoint> neighbourPts;
427 int numPts = pow(
float(2),
m_dim);
428 numPts = min(numPts,
int(
m_pts[0].num_elements() / 2));
432 for (
int i = 0; i < numPts; i++)
434 m_neighInds[physPtIdx][i] = neighbourPts.at(i).m_idx;
440 for (
int i = 0; i < numPts; ++i)
442 if (neighbourPts[i].m_distSq == 0.0)
450 for (
int i = 0; i < numPts; ++i)
452 m_weights[physPtIdx][i] = 1 / pow(
double(neighbourPts[i].m_distSq),
453 double(
m_dim /
float(2)));
457 for (
int i = 0; i < numPts; ++i)
480 for (i = 0; i < npts - 1; ++i)
482 if ((
m_pts[0][i] <= coord) && (coord <=
m_pts[0][i + 1]))
490 NekDouble pdiff2 = m_pts[0][i + 2] - m_pts[0][i + 1];
492 h1 = (m_pts[0][i + 1] - coord)
493 * (m_pts[0][i + 2] - coord)
494 / (pdiff * (pdiff + pdiff2));
495 h2 = (coord - m_pts[0][i])
496 * (m_pts[0][i + 2] - coord)
498 h3 = (coord - m_pts[0][i])
499 * (coord - m_pts[0][i + 1])
500 / ((pdiff + pdiff2) * pdiff2);
509 NekDouble pdiff2 = m_pts[0][i] - m_pts[0][i - 1];
511 h1 = (m_pts[0][i + 1] - coord)
512 * (coord - m_pts[0][i - 1])
514 h2 = (coord - m_pts[0][i])
515 * (coord - m_pts[0][i - 1])
516 / (pdiff * (pdiff + pdiff2));
517 h3 = (m_pts[0][i] - coord)
518 * (m_pts[0][i + 1] - coord)
519 / ((pdiff + pdiff2) * pdiff);
527 m_weights[physPtIdx][0] = h1;
528 m_weights[physPtIdx][1] = h2;
529 m_weights[physPtIdx][2] = h3;
534 ASSERTL0(i != npts - 1,
"Failed to find coordinate " +
535 boost::lexical_cast<string>(coord) +
536 " within provided input points");
551 for (
int i = 0; i < point1.num_elements(); i++)
553 tmp = point1[i] - point2[i];
574 vector< PtsPoint > &neighbourPts,
575 const unsigned int numPts)
580 for (
int i = 0; i < numPts; ++i)
583 neighbourPts.push_back(intPt);
587 for (
int i = 0; i <
npts; ++i)
590 for (
int j = 0; j <
m_dim; ++j)
592 coords[j] =
m_pts[j][i];
596 if (d < neighbourPts.back().m_distSq)
603 neighbourPts.push_back(intPt);
604 sort(neighbourPts.begin(), neighbourPts.end());
605 neighbourPts.pop_back();
#define ASSERTL0(condition, msg)
NekDouble GetPointVal(const int fieldInd, const int ptInd) const
Array< OneD, Array< OneD, unsigned int > > m_neighInds
Indices of the relevant neighbours for each physical point. Structure: m_neighInds[ptIdx][neighbourId...
void SetDim(const int ptsDim)
Array< OneD, Array< OneD, float > > m_weights
Interpolation weights for each neighbour. Structure: m_weights[physPtIdx][neighbourIdx].
void SetFieldNames(const vector< std::string > fieldNames)
void AddField(const Array< OneD, NekDouble > &pts, const std::string fieldName)
vector< Array< OneD, int > > m_ptsConn
Connectivity data needed for ePtsTetBlock and ePtsTriBlock. For n Blocks with m elements each...
vector< std::string > GetFieldNames() const
std::string GetFieldName(const int i) const
void FindNeighbours(const Array< OneD, NekDouble > &physPtCoords, vector< PtsPoint > &neighbourPts, const unsigned int numPts=1)
Find nearest neighbours using a brute-force "algorithm".
vector< int > m_nPtsPerEdge
Number of points per edge. Empty if the point data has no specific shape (ePtsLine) or is a block (eP...
void SetPointsPerEdge(const vector< int > nPtsPerEdge)
Set the number of points per edge.
void GetWeights(Array< OneD, Array< OneD, float > > &weights, Array< OneD, Array< OneD, unsigned int > > &neighbourInds) const
Get the interpolation weights and corresponding neighbour indices.
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].
void GetPts(Array< OneD, Array< OneD, NekDouble > > &pts) const
void SetWeights(const Array< OneD, Array< OneD, float > > &weights, const Array< OneD, Array< OneD, unsigned int > > &neighbourInds)
Set the interpolation weights for an interpolation.
void CalcW_Quadratic(const int physPtIdx, const NekDouble coord)
Compute interpolation weights for a 1D physical point using quadratic interpolation.
PtsType m_ptsType
Type of the PtsField.
PtsType GetPtsType() const
int m_dim
Dimension of the pts field.
vector< std::string > m_fieldNames
Names of the field variables.
NekDouble DistSq(const Array< OneD, NekDouble > &point1, const Array< OneD, NekDouble > &point2) const
Compute the square of the euclidean distance between point1 and point2.
void SetPtsType(const PtsType type)
void CalcW_Shepard(const int physPtIdx, const Array< OneD, NekDouble > &physPtCoords)
Compute interpolation weights for a physical point using a modified Shepard algorithm.
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.
void CalcW_Linear(const int physPtIdx, const NekDouble coord)
Compute interpolation weights for a 1D physical point using linear interpolation. ...
vector< int > GetPointsPerEdge() const
void GetConnectivity(vector< Array< OneD, int > > &conn) const
Set the connectivity data for ePtsTetBlock and ePtsTriBlock.
void SetPts(Array< OneD, Array< OneD, NekDouble > > &pts)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
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.
boost::function< void(const int position, const int goal)> m_progressCallback
void SetConnectivity(const vector< Array< OneD, int > > &conn)
Get the connectivity data for ePtsTetBlock and ePtsTriBlock.