From be6dd45918abcb52d5068f1266ea33ef332b1457 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Tue, 23 May 2023 15:28:46 +0200 Subject: [PATCH] changed: make getCoordinates a static and public method for reuse in field classes --- src/ASM/LR/ASMu2D.C | 12 +++++++----- src/ASM/LR/ASMu2D.h | 18 ++++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/ASM/LR/ASMu2D.C b/src/ASM/LR/ASMu2D.C index cf15cfdb..8a59d8b0 100644 --- a/src/ASM/LR/ASMu2D.C +++ b/src/ASM/LR/ASMu2D.C @@ -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 diff --git a/src/ASM/LR/ASMu2D.h b/src/ASM/LR/ASMu2D.h index 8fa1ad10..618ceccc 100644 --- a/src/ASM/LR/ASMu2D.h +++ b/src/ASM/LR/ASMu2D.h @@ -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 lrspline; //!< Pointer to the LR-spline surface object std::shared_ptr projBasis; //!< Basis to project onto