added: ASMsxDLag::findElement

this finds the element of a parameter value
and optionally calculates the local coordinates
of an integration point.
This commit is contained in:
Arne Morten Kvarving 2021-06-21 09:29:34 +02:00
parent f3cdb440a2
commit a97b78af8a
4 changed files with 48 additions and 0 deletions

View File

@ -773,3 +773,21 @@ bool ASMs2DLag::write(std::ostream& os, int) const
{
return this->writeLagBasis(os, "quad");
}
int ASMs2DLag::findElement(double u, double v,
double* xi, double* eta) const
{
double du = 1.0 / (nx-1);
double dv = 1.0 / (ny-1);
int elmx = std::min(nx-2.0, floor(u / du));
int elmy = std::min(ny-2.0, floor(v / dv));
if (xi)
*xi = -1.0 + (u - elmx*du)*2.0 / du;
if (eta)
*eta = -1.0 + (v - elmy*dv)*2.0 / dv;
return 1 + elmx + elmy*(nx-1);
}

View File

@ -81,6 +81,10 @@ protected:
//! \param[in] Xnod Coordinates of the node
void setCoord(size_t inod, const Vec3& Xnod);
//! \brief Find element for parameter, and optionally calculate local coordinates.
int findElement(double u, double v,
double* xi = nullptr, double* eta = nullptr) const;
public:
//! \brief Updates the nodal coordinates for this patch.
//! \param[in] displ Incremental displacements to update the coordinates with

View File

@ -954,6 +954,28 @@ bool ASMs3DLag::evalSolution (Matrix& sField, const Vector& locSol,
}
int ASMs3DLag::findElement(double u, double v, double w,
double* xi, double* eta, double* zeta) const
{
double du = 1.0 / (nx-1);
double dv = 1.0 / (ny-1);
double dw = 1.0 / (nz-1);
int elmx = std::min(nx-2.0, floor(u / du));
int elmy = std::min(ny-2.0, floor(v / dv));
int elmz = std::min(nz-2.0, floor(w / dw));
if (xi)
*xi = -1.0 + (u - elmx*du)*2.0 / du;
if (eta)
*eta = -1.0 + (v - elmy*dv)*2.0 / dv;
if (zeta)
*zeta = -1.0 + (w - elmz*dw)*2.0 / dw;
return 1 + elmx + elmy*(nx-1) + elmz*(ny-1)*(nx-1);
}
bool ASMs3DLag::evalSolution (Matrix& sField, const Vector& locSol,
const RealArray*, bool, int, int) const
{

View File

@ -81,6 +81,10 @@ public:
//! \param[in] nSegSpan Number of visualization segments over each knot-span
virtual bool getGridParameters(RealArray& prm, int dir, int nSegSpan) const;
//! \brief Find element for parameter, and optionally calculate local coordinates.
virtual int findElement(double u, double v, double w, double* xi = nullptr,
double* eta = nullptr, double* zeta = nullptr) const;
protected:
//! \brief Assigned global coordinates for the given node.
//! \param[in] inod 1-based node index local to current patch