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;
441 for (
int i = 0; i < numPts; ++i)
451 for (
int i = 0; i < numPts; ++i)
453 m_weights[physPtIdx][i] = 1 / pow(
double(neighbourPts[i].m_distSq),
454 double(
m_dim /
float(2)));
458 for (
int i = 0; i < numPts; ++i)
483 for (i = 0; i < npts - 1; ++i)
485 if ((
m_pts[0][i] <= coord) && (coord <=
m_pts[0][i + 1]))
493 NekDouble pdiff2 = m_pts[0][i + 2] - m_pts[0][i + 1];
495 h1 = (m_pts[0][i + 1] - coord)
496 * (m_pts[0][i + 2] - coord)
497 / (pdiff * (pdiff + pdiff2));
498 h2 = (coord - m_pts[0][i])
499 * (m_pts[0][i + 2] - coord)
501 h3 = (coord - m_pts[0][i])
502 * (coord - m_pts[0][i + 1])
503 / ((pdiff + pdiff2) * pdiff2);
512 NekDouble pdiff2 = m_pts[0][i] - m_pts[0][i - 1];
514 h1 = (m_pts[0][i + 1] - coord)
515 * (coord - m_pts[0][i - 1])
517 h2 = (coord - m_pts[0][i])
518 * (coord - m_pts[0][i - 1])
519 / (pdiff * (pdiff + pdiff2));
520 h3 = (m_pts[0][i] - coord)
521 * (m_pts[0][i + 1] - coord)
522 / ((pdiff + pdiff2) * pdiff);
530 m_weights[physPtIdx][0] = h1;
531 m_weights[physPtIdx][1] = h2;
532 m_weights[physPtIdx][2] = h3;
537 ASSERTL0(i != npts - 1,
"Failed to find coordinate " +
538 boost::lexical_cast<string>(coord) +
539 " within provided input points");
554 for (
int i = 0; i < point1.num_elements(); i++)
556 tmp = point1[i] - point2[i];
577 vector< PtsPoint > &neighbourPts,
578 const unsigned int numPts)
583 for (
int i = 0; i < numPts; ++i)
586 neighbourPts.push_back(intPt);
590 for (
int i = 0; i <
npts; ++i)
593 for (
int j = 0; j <
m_dim; ++j)
595 coords[j] =
m_pts[j][i];
599 if (d < neighbourPts.back().m_distSq)
606 neighbourPts.push_back(intPt);
607 sort(neighbourPts.begin(), neighbourPts.end());
608 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...
static const NekDouble kNekSqrtTol
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.
int Nnan(int n, const T *x, const int incx)
Return number of NaN elements of x.
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.