本文整理汇总了C++中scalarField::interpolateLS方法的典型用法代码示例。如果您正苦于以下问题:C++ scalarField::interpolateLS方法的具体用法?C++ scalarField::interpolateLS怎么用?C++ scalarField::interpolateLS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scalarField
的用法示例。
在下文中一共展示了scalarField::interpolateLS方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bgGridIntegration
double bgGridIntegration(const pointSet& mesh, const scalarField& data)
{
//cout << "Integrating over domain" << endl;
// Get bounding box
double xmin, ymin, xmax, ymax;
mesh.getBoundingBox(xmin, xmax, ymin, ymax);
// Get smoothing length
double sl = mesh.getMinSL();
double h = 0.15*sl;
// Calc dimensions
int nx = (int) ((xmax-xmin)/h)+2;
int ny = (int) ((ymax-ymin)/h)+2;
// Build background grid
#ifndef USE_STACK
vector<point> P;
P.reserve(nx*ny);
#else
point P[nx*ny];
#endif
double val;
for (int i=0; i<nx; i++)
{
for (int j=0; j<ny; j++)
{
#ifndef USE_STACK
point pTmp;
pTmp.X = xmin + i*h;
pTmp.Y = ymin + j*h;
P.push_back(pTmp);
#else
P[i*ny+j].X = xmin + i*h;
P[i*ny+j].Y = ymin + j*h;
#endif
}
}
// Interpolate scalarField values onto bg grid
int n = nx*ny;
int ix, iy;
double sum = 0;
for (int i=0; i<n; i++)
{
mesh.getQuad(P[i], ix, iy);
const vector<int>& bndquad = mesh.getQuad(ix, iy, false);
int bqSize = bndquad.size();
// Point definitely in / out domain?
if (bqSize == 0)
{
const vector<int>& quad = mesh.getQuad(ix, iy);
if (quad.size() != 0)
{
sum += data.interpolateLS(P[i]);
}
}
// No? Check in/out with normals
else
{
// Find nearest bnd point
double minDist = 1e100;
int minPos = -1;
for (int j=0; j<bqSize; j++)
{
if (minDist > mesh.P(bndquad[j]).dist(P[i]))
{
minDist = mesh.P(bndquad[j]).dist(P[i]);
minPos = bndquad[j];
}
}
double vecX = P[i].X - mesh.P(minPos).X;
double vecY = P[i].Y - mesh.P(minPos).Y;
double nDir = mesh.P(minPos).Nx*vecX + mesh.P(minPos).Ny*vecY;
if (nDir <= 0)
{
sum += data.interpolateLS(P[i]);
}
}
}
sum *= h*h;
return sum;
}