changed: make getCoordinates a static and public method

for reuse in field classes
This commit is contained in:
Arne Morten Kvarving 2023-05-23 15:28:46 +02:00
parent 046b242920
commit be6dd45918
2 changed files with 19 additions and 11 deletions

View File

@ -902,10 +902,12 @@ double ASMu2D::getParametricLength (int iel, int dir) const
Consider introducing ASMbase::getCoefficients() to lessen confusion.
*/
bool ASMu2D::getCoordinates (Matrix& X, int iel) const
bool ASMu2D::getCoordinates (Matrix& X, unsigned char nsd,
const LR::LRSplineSurface& spline,
int iel)
{
const LR::Element* elm = iel > 0 ? lrspline->getElement(iel-1) : nullptr;
X.resize(nsd, iel > 0 ? elm->nBasisFunctions() : lrspline->nBasisFunctions());
const LR::Element* elm = iel > 0 ? spline.getElement(iel-1) : nullptr;
X.resize(nsd, iel > 0 ? elm->nBasisFunctions() : spline.nBasisFunctions());
// Lambda-function inserting coordinates for a given basis function
// into the array X, accounting for the weights in case of NURBS
@ -933,7 +935,7 @@ bool ASMu2D::getCoordinates (Matrix& X, int iel) const
for (LR::Basisfunction* b : elm->support())
status &= insertCoords(nsd,++inod,b);
else
for (LR::Basisfunction* b : lrspline->getAllBasisfunctions())
for (LR::Basisfunction* b : spline.getAllBasisfunctions())
status &= insertCoords(nsd,++inod,b);
return status;
@ -950,7 +952,7 @@ bool ASMu2D::getElementCoordinates (Matrix& X, int iel) const
return false;
}
#endif
bool status = this->getCoordinates(X,iel);
bool status = this->getCoordinates(X,nsd,*lrspline,iel);
#if SP_DEBUG > 2
std::cout <<"\nCoordinates for element "<< iel << X << std::endl;
#endif

View File

@ -129,7 +129,8 @@ public:
//! \brief Returns a matrix with all nodal coordinates within the patch.
//! \param[out] X 3\f$\times\f$n-matrix, where \a n is the number of nodes
//! in the patch
virtual void getNodalCoordinates(Matrix& X) const { this->getCoordinates(X); }
virtual void getNodalCoordinates(Matrix& X) const
{ this->getCoordinates(X, nsd, *lrspline); }
//! \brief Returns the global coordinates for the given node.
//! \param[in] inod 1-based node index local to current patch
@ -652,11 +653,6 @@ protected:
//! \brief Generate bezier extraction operators.
void generateBezierExtraction();
//! \brief Returns a matrix with control point coordinates.
//! \param[out] X 3\f$\times\f$n-matrix, where \a n is the number of points
//! \param[in] iel 1-based element index, if -1 return for all control points
bool getCoordinates(Matrix& X, int iel = -1) const;
public:
//! \brief Returns the number of elements on a boundary.
virtual size_t getNoBoundaryElms(char lIndex, char ldim) const;
@ -664,6 +660,16 @@ public:
//! \brief Query whether basis is rational or not.
bool rational() const { return is_rational; }
//! \brief Returns a matrix with control point coordinates.
//! \param[out] X 3\f$\times\f$n-matrix, where \a n is the number of points
//! \param[in] nsd Number of spatial dimensions
//! \param[in] spline Spline to extract coefficients from
//! \param[in] iel 1-based element index, if -1 return for all control points
static bool getCoordinates(Matrix& X,
unsigned char nsd,
const LR::LRSplineSurface& spline,
int iel = -1);
protected:
std::shared_ptr<LR::LRSplineSurface> lrspline; //!< Pointer to the LR-spline surface object
std::shared_ptr<LR::LRSplineSurface> projBasis; //!< Basis to project onto