diff --git a/src/ASM/ASMenums.h b/src/ASM/ASMenums.h index f632e5ba..2a567841 100644 --- a/src/ASM/ASMenums.h +++ b/src/ASM/ASMenums.h @@ -46,6 +46,15 @@ namespace ASM //! Assembly scope FULL_CACHE //!< Cache basis function values up front }; + //! \brief Enumeration of different basis types. + //! \details Entries should have non-positive values + enum BasisType { + GEOMETRY_BASIS = 0, //!< Geometry basis + PROJECTION_BASIS = -1, //!< Projection basis + PROJECTION_BASIS_2 = -2, //!< Second projection basis + REFINEMENT_BASIS = -3, //!< Refinement basis + INTEGRATION_BASIS = -4, //!< Integration basis + }; } #endif diff --git a/src/ASM/ASMs2D.C b/src/ASM/ASMs2D.C index 3035e12b..bc7337a2 100644 --- a/src/ASM/ASMs2D.C +++ b/src/ASM/ASMs2D.C @@ -38,6 +38,7 @@ #include "MPC.h" #include "IFEM.h" #include +#include ASMs2D::ASMs2D (unsigned char n_s, unsigned char n_f) @@ -100,6 +101,29 @@ Go::SplineCurve* ASMs2D::getBoundary (int dir, int) } +const Go::SplineSurface* ASMs2D::getBasis (int basis) const +{ + switch (basis) { + case ASM::GEOMETRY_BASIS: + return static_cast(geomB); + case ASM::PROJECTION_BASIS: + return static_cast(projB); + case ASM::PROJECTION_BASIS_2: + return static_cast(projB2); + case ASM::REFINEMENT_BASIS: + return nullptr; + default: + return surf; + } +} + + +Go::SplineSurface* ASMs2D::getBasis (int basis) +{ + return const_cast(std::as_const(*this).getBasis(basis)); +} + + void ASMs2D::copyParameterDomain (const ASMbase* other) { const ASMs2D* o = dynamic_cast(other); @@ -3061,7 +3085,7 @@ short int ASMs2D::InterfaceChecker::hasContribution (int, bool ASMs2D::evaluate (const FunctionBase* func, RealArray& vec, int basisNum, double time) const { - Go::SplineSurface* oldSurf = this->getBasis(basisNum); + const Go::SplineSurface* oldSurf = this->getBasis(basisNum); Go::SplineSurface* newSurf = SplineUtils::project(oldSurf,*func, func->dim(),time); if (!newSurf) diff --git a/src/ASM/ASMs2D.h b/src/ASM/ASMs2D.h index 359b528a..2047cca0 100644 --- a/src/ASM/ASMs2D.h +++ b/src/ASM/ASMs2D.h @@ -192,8 +192,10 @@ public: //! \brief Returns the spline curve representing a boundary of this patch. //! \param[in] dir Parameter direction defining which boundary to return virtual Go::SplineCurve* getBoundary(int dir, int = 1); - //! \brief Returns the spline surface representing the basis of this patch. - virtual Go::SplineSurface* getBasis(int = 1) const { return surf; } + //! \brief Returns the spline surface representing a basis of this patch. + virtual Go::SplineSurface* getBasis(int basis = 1); + //! \brief Returns the spline surface representing a basis of this patch. + virtual const Go::SplineSurface* getBasis(int basis = 1) const; //! \brief Copies the parameter domain from the \a other patch. virtual void copyParameterDomain(const ASMbase* other); diff --git a/src/ASM/ASMs2Dmx.C b/src/ASM/ASMs2Dmx.C index 566eb059..203ca81a 100644 --- a/src/ASM/ASMs2Dmx.C +++ b/src/ASM/ASMs2Dmx.C @@ -28,6 +28,7 @@ #include "Profiler.h" #include #include +#include ASMs2Dmx::ASMs2Dmx (unsigned char n_s, const CharVec& n_f) @@ -44,15 +45,24 @@ ASMs2Dmx::ASMs2Dmx (const ASMs2Dmx& patch, const CharVec& n_f) } -Go::SplineSurface* ASMs2Dmx::getBasis (int basis) const +const Go::SplineSurface* ASMs2Dmx::getBasis (int basis) const { - if (basis < 1 || basis > (int)m_basis.size()) - return surf; + if (basis < 1) + return this->ASMs2D::getBasis(basis); + + if (basis > static_cast(m_basis.size())) + return nullptr; return m_basis[basis-1].get(); } +Go::SplineSurface* ASMs2Dmx::getBasis (int basis) +{ + return const_cast(std::as_const(*this).getBasis(basis)); +} + + Go::SplineCurve* ASMs2Dmx::getBoundary (int dir, int basis) { if (dir < -2 || dir == 0 || dir > 2) diff --git a/src/ASM/ASMs2Dmx.h b/src/ASM/ASMs2Dmx.h index 70eeb037..79adb0bb 100644 --- a/src/ASM/ASMs2Dmx.h +++ b/src/ASM/ASMs2Dmx.h @@ -39,8 +39,11 @@ public: //! \brief Empty destructor. virtual ~ASMs2Dmx() {} - //! \brief Returns the spline surface representing the basis of this patch. - virtual Go::SplineSurface* getBasis(int basis = 1) const; + //! \brief Returns the spline surface representing a basis of this patch. + virtual const Go::SplineSurface* getBasis(int basis = 1) const; + //! \brief Returns the spline surface representing a basis of this patch. + virtual Go::SplineSurface* getBasis(int basis = 1); + //! \brief Returns the spline curve representing a boundary of this patch. //! \param[in] dir Parameter direction defining which boundary to return //! \param[in] basis Basis of boundary to return diff --git a/src/ASM/ASMs2Drecovery.C b/src/ASM/ASMs2Drecovery.C index 0c6cb0e5..4d648bb1 100644 --- a/src/ASM/ASMs2Drecovery.C +++ b/src/ASM/ASMs2Drecovery.C @@ -83,7 +83,7 @@ bool ASMs2D::evaluate (const ASMbase* basis, const Vector& locVec, if (!pch->evalSolution(sValues,locVec,gpar.data())) return false; - Go::SplineSurface* surf = this->getBasis(basisNum); + const Go::SplineSurface* surf = this->getBasis(basisNum); // Project the results onto the spline basis to find control point // values based on the result values evaluated at the Greville points. diff --git a/src/ASM/ASMs3D.C b/src/ASM/ASMs3D.C index dd6ff773..5884b43b 100644 --- a/src/ASM/ASMs3D.C +++ b/src/ASM/ASMs3D.C @@ -37,6 +37,7 @@ #include "MPC.h" #include "IFEM.h" #include +#include ASMs3D::ASMs3D (unsigned char n_f) : ASMstruct(3,3,n_f), nodeInd(myNodeInd) @@ -79,6 +80,29 @@ Go::SplineSurface* ASMs3D::getBoundary (int dir, int) } +const Go::SplineVolume* ASMs3D::getBasis (int basis) const +{ + switch (basis) { + case ASM::GEOMETRY_BASIS: + return static_cast(geomB); + case ASM::PROJECTION_BASIS: + return static_cast(projB); + case ASM::PROJECTION_BASIS_2: + return static_cast(projB2); + case ASM::REFINEMENT_BASIS: + return nullptr; + default: + return svol; + } +} + + +Go::SplineVolume* ASMs3D::getBasis (int basis) +{ + return const_cast(std::as_const(*this).getBasis(basis)); +} + + void ASMs3D::copyParameterDomain (const ASMbase* other) { const ASMs3D* o = dynamic_cast(other); @@ -3572,7 +3596,7 @@ short int ASMs3D::InterfaceChecker::hasContribution (int, int I, int J, int K) c bool ASMs3D::evaluate (const FunctionBase* func, RealArray& vec, int basisNum, double time) const { - Go::SplineVolume* oldVol = this->getBasis(basisNum); + const Go::SplineVolume* oldVol = this->getBasis(basisNum); Go::SplineVolume* newVol = SplineUtils::project(oldVol,*func, func->dim(),time); if (!newVol) diff --git a/src/ASM/ASMs3D.h b/src/ASM/ASMs3D.h index d75d4ccb..29c5e7a4 100644 --- a/src/ASM/ASMs3D.h +++ b/src/ASM/ASMs3D.h @@ -211,8 +211,10 @@ public: //! \brief Returns the spline surface representing a boundary of this patch. //! \param[in] dir Parameter direction defining which boundary to return virtual Go::SplineSurface* getBoundary(int dir, int = 1); - //! \brief Returns the spline volume representing the basis of this patch. - virtual Go::SplineVolume* getBasis(int = 1) const { return svol; } + //! \brief Returns the spline volume representing a basis of this patch. + virtual const Go::SplineVolume* getBasis(int basis = 1) const; + //! \brief Returns the spline volume representing a basis of this patch. + virtual Go::SplineVolume* getBasis(int basis = 1); //! \brief Copies the parameter domain from the \a other patch. virtual void copyParameterDomain(const ASMbase* other); diff --git a/src/ASM/ASMs3Dmx.C b/src/ASM/ASMs3Dmx.C index 6f92918e..dcd84198 100644 --- a/src/ASM/ASMs3Dmx.C +++ b/src/ASM/ASMs3Dmx.C @@ -31,6 +31,7 @@ #include "Vec3Oper.h" #include #include +#include #ifdef USE_OPENMP #include #endif @@ -50,15 +51,24 @@ ASMs3Dmx::ASMs3Dmx (const ASMs3Dmx& patch, const CharVec& n_f) } -Go::SplineVolume* ASMs3Dmx::getBasis (int basis) const +const Go::SplineVolume* ASMs3Dmx::getBasis (int basis) const { - if (basis < 1 || basis > (int)m_basis.size()) - return svol; + if (basis < 1) + return this->ASMs3D::getBasis(basis); + + if (basis > static_cast(m_basis.size())) + return nullptr; return m_basis[basis-1].get(); } +Go::SplineVolume* ASMs3Dmx::getBasis (int basis) +{ + return const_cast(std::as_const(*this).getBasis(basis)); +} + + Go::SplineSurface* ASMs3Dmx::getBoundary (int dir, int basis) { if (dir < -3 || dir == 0 || dir > 3) diff --git a/src/ASM/ASMs3Dmx.h b/src/ASM/ASMs3Dmx.h index fffc627e..18bb1419 100644 --- a/src/ASM/ASMs3Dmx.h +++ b/src/ASM/ASMs3Dmx.h @@ -39,8 +39,10 @@ public: //! \brief Empty Destructor. virtual ~ASMs3Dmx() {} - //! \brief Returns the spline surface representing the basis of this patch. - virtual Go::SplineVolume* getBasis(int basis = 1) const; + //! \brief Returns the spline surface representing a basis of this patch. + virtual const Go::SplineVolume* getBasis(int basis = 1) const; + //! \brief Returns the spline surface representing a basis of this patch. + virtual Go::SplineVolume* getBasis(int basis = 1); //! \brief Returns the spline curve representing a boundary of this patch. //! \param[in] dir Parameter direction defining which boundary to return //! \param[in] basis The basis to get the boundary for diff --git a/src/ASM/ASMs3Drecovery.C b/src/ASM/ASMs3Drecovery.C index 77de200a..04d2f9f1 100644 --- a/src/ASM/ASMs3Drecovery.C +++ b/src/ASM/ASMs3Drecovery.C @@ -81,7 +81,7 @@ bool ASMs3D::evaluate (const ASMbase* basis, const Vector& locVec, if (!pch->evalSolution(sValues,locVec,gpar.data())) return false; - Go::SplineVolume* svol = this->getBasis(basisNum); + const Go::SplineVolume* svol = this->getBasis(basisNum); // Project the results onto the spline basis to find control point // values based on the result values evaluated at the Greville points. diff --git a/src/ASM/LR/ASMu2D.C b/src/ASM/LR/ASMu2D.C index 65344b80..70342373 100644 --- a/src/ASM/LR/ASMu2D.C +++ b/src/ASM/LR/ASMu2D.C @@ -39,6 +39,7 @@ #include "IFEM.h" #include #include +#include ASMu2D::ASMu2D (unsigned char n_s, unsigned char n_f) @@ -65,6 +66,32 @@ ASMu2D::ASMu2D (const ASMu2D& patch, unsigned char n_f) } +const LR::LRSplineSurface* ASMu2D::getBasis (int basis) const +{ + switch (basis) { + case ASM::GEOMETRY_BASIS: + return static_cast(geomB.get()); + case ASM::PROJECTION_BASIS: + return static_cast(projB.get()); + case ASM::PROJECTION_BASIS_2: + return static_cast(projB2.get()); + case ASM::REFINEMENT_BASIS: + return static_cast(refB.get()); + default: + return lrspline.get(); + } +} + + +LR::LRSplineSurface* ASMu2D::getBasis (int basis) +{ + if (tensorspline) + this->createLRfromTensor(); + + return const_cast(std::as_const(*this).getBasis(basis)); +} + + bool ASMu2D::read (std::istream& is) { if (shareFE) return true; diff --git a/src/ASM/LR/ASMu2D.h b/src/ASM/LR/ASMu2D.h index 8f68268b..895e19fb 100644 --- a/src/ASM/LR/ASMu2D.h +++ b/src/ASM/LR/ASMu2D.h @@ -138,10 +138,10 @@ public: //! \brief Returns the spline surface representing the geometry of this patch. const LR::LRSplineSurface* getSurface() const { return lrspline.get(); } - //! \brief Returns the spline surface representing the basis of this patch. - virtual const LR::LRSplineSurface* getBasis(int = 1) const { return lrspline.get(); } - //! \brief Returns the spline surface representing the basis of this patch. - virtual LR::LRSplineSurface* getBasis(int = 1) { return lrspline.get(); } + //! \brief Returns the spline surface representing a basis of this patch. + virtual const LR::LRSplineSurface* getBasis(int basis = 1) const; + //! \brief Returns the spline surface representing a basis of this patch. + virtual LR::LRSplineSurface* getBasis(int basis = 1); // Methods for model generation and refinement diff --git a/src/ASM/LR/ASMu2Dmx.C b/src/ASM/LR/ASMu2Dmx.C index 5cfee5b4..35f6e3c0 100644 --- a/src/ASM/LR/ASMu2Dmx.C +++ b/src/ASM/LR/ASMu2Dmx.C @@ -35,6 +35,7 @@ #include #include #include +#include ASMu2Dmx::ASMu2Dmx (unsigned char n_s, const CharVec& n_f) @@ -56,7 +57,10 @@ ASMu2Dmx::ASMu2Dmx (const ASMu2Dmx& patch, const CharVec& n_f) const LR::LRSplineSurface* ASMu2Dmx::getBasis (int basis) const { - if (basis < 1 || basis > (int)m_basis.size()) + if (basis < 1) + return this->ASMu2D::getBasis(basis); + + if (basis > static_cast(m_basis.size())) return nullptr; return m_basis[basis-1].get(); @@ -65,10 +69,7 @@ const LR::LRSplineSurface* ASMu2Dmx::getBasis (int basis) const LR::LRSplineSurface* ASMu2Dmx::getBasis (int basis) { - if (basis < 1 || basis > (int)m_basis.size()) - return nullptr; - - return m_basis[basis-1].get(); + return const_cast(std::as_const(*this).getBasis(basis)); } diff --git a/src/ASM/LR/ASMu2Dmx.h b/src/ASM/LR/ASMu2Dmx.h index 0662688d..5ecda19d 100644 --- a/src/ASM/LR/ASMu2Dmx.h +++ b/src/ASM/LR/ASMu2Dmx.h @@ -65,11 +65,10 @@ public: //! \brief Empty destructor. virtual ~ASMu2Dmx() {} - //! \brief Returns the spline surface representing the basis of this patch. - virtual LR::LRSplineSurface* getBasis(int basis = 1); - - //! \brief Returns the spline surface representing the basis of this patch. + //! \brief Returns the spline surface representing a basis of this patch. virtual const LR::LRSplineSurface* getBasis(int basis = 1) const; + //! \brief Returns the spline surface representing a basis of this patch. + virtual LR::LRSplineSurface* getBasis(int basis = 1); // Methods for model generation // ============================ diff --git a/src/ASM/LR/ASMu3D.C b/src/ASM/LR/ASMu3D.C index a8fc8adc..7a6a2851 100644 --- a/src/ASM/LR/ASMu3D.C +++ b/src/ASM/LR/ASMu3D.C @@ -38,6 +38,7 @@ #include "Point.h" #include "IFEM.h" #include +#include ASMu3D::ASMu3D (unsigned char n_f) @@ -63,6 +64,32 @@ ASMu3D::ASMu3D (const ASMu3D& patch, unsigned char n_f) } +const LR::LRSplineVolume* ASMu3D::getBasis (int basis) const +{ + switch (basis) { + case ASM::GEOMETRY_BASIS: + return static_cast(geomB.get()); + case ASM::PROJECTION_BASIS: + return static_cast(projB.get()); + case ASM::PROJECTION_BASIS_2: + return static_cast(projB2.get()); + case ASM::REFINEMENT_BASIS: + return static_cast(refB.get()); + default: + return lrspline.get(); + } +} + + +LR::LRSplineVolume* ASMu3D::getBasis (int basis) +{ + if (tensorspline) + this->createLRfromTensor(); + + return const_cast(std::as_const(*this).getBasis(basis)); +} + + bool ASMu3D::read (std::istream& is) { if (shareFE) return true; diff --git a/src/ASM/LR/ASMu3D.h b/src/ASM/LR/ASMu3D.h index c7d49ef3..7d06ce1c 100644 --- a/src/ASM/LR/ASMu3D.h +++ b/src/ASM/LR/ASMu3D.h @@ -121,10 +121,10 @@ public: //! \brief Returns the spline volume representing the geometry of this patch. const LR::LRSplineVolume* getVolume() const { return lrspline.get(); } - //! \brief Returns the spline volume representing the basis of this patch. - virtual const LR::LRSplineVolume* getBasis(int = 1) const { return lrspline.get(); } - //! \brief Returns the spline volume representing the basis of this patch. - virtual LR::LRSplineVolume* getBasis(int = 1) { return lrspline.get(); } + //! \brief Returns the spline volume representing a basis of this patch. + virtual const LR::LRSplineVolume* getBasis(int basis = 1) const; + //! \brief Returns the spline volume representing a basis of this patch. + virtual LR::LRSplineVolume* getBasis(int basis = 1); // Methods for model generation and refinement diff --git a/src/ASM/LR/ASMu3Dmx.C b/src/ASM/LR/ASMu3Dmx.C index a5d17981..9483d60a 100644 --- a/src/ASM/LR/ASMu3Dmx.C +++ b/src/ASM/LR/ASMu3Dmx.C @@ -34,6 +34,7 @@ #include #include +#include ASMu3Dmx::ASMu3Dmx (const CharVec& n_f) @@ -59,7 +60,10 @@ ASMu3Dmx::ASMu3Dmx (const ASMu3Dmx& patch, const CharVec& n_f) const LR::LRSplineVolume* ASMu3Dmx::getBasis (int basis) const { - if (basis < 1 || basis > (int)m_basis.size()) + if (basis < 1) + return this->ASMu3D::getBasis(basis); + + if (basis > static_cast(m_basis.size())) return nullptr; return m_basis[basis-1].get(); @@ -68,10 +72,7 @@ const LR::LRSplineVolume* ASMu3Dmx::getBasis (int basis) const LR::LRSplineVolume* ASMu3Dmx::getBasis (int basis) { - if (basis < 1 || basis > (int)m_basis.size()) - return nullptr; - - return m_basis[basis-1].get(); + return const_cast(std::as_const(*this).getBasis(basis)); } diff --git a/src/ASM/LR/ASMu3Dmx.h b/src/ASM/LR/ASMu3Dmx.h index bc848a13..c16df3e5 100644 --- a/src/ASM/LR/ASMu3Dmx.h +++ b/src/ASM/LR/ASMu3Dmx.h @@ -65,11 +65,10 @@ public: //! \brief Empty destructor. virtual ~ASMu3Dmx() {} - //! \brief Returns the spline surface representing the basis of this patch. - virtual LR::LRSplineVolume* getBasis(int basis = 1); - - //! \brief Returns the spline surface representing the basis of this patch. + //! \brief Returns the spline volume representing a basis of this patch. virtual const LR::LRSplineVolume* getBasis(int basis = 1) const; + //! \brief Returns the spline volume representing a basis of this patch. + virtual LR::LRSplineVolume* getBasis(int basis = 1); // Methods for model generation // ============================ diff --git a/src/ASM/SplineFields2Dmx.C b/src/ASM/SplineFields2Dmx.C index fb92f27c..2ef12436 100644 --- a/src/ASM/SplineFields2Dmx.C +++ b/src/ASM/SplineFields2Dmx.C @@ -79,7 +79,7 @@ bool SplineFields2Dmx::valueFE (const ItgPoint& x, Vector& vals) const auto vit = values.begin(); auto rit = vals.begin(); for (int b : bases) { - Go::SplineSurface* basis = surf->getBasis(b); + const Go::SplineSurface* basis = surf->getBasis(b); Go::BasisPtsSf spline; #pragma omp critical basis->computeBasis(x.u,x.v,spline); diff --git a/src/ASM/SplineFields3Dmx.C b/src/ASM/SplineFields3Dmx.C index 12ec11d9..5fc06c5b 100644 --- a/src/ASM/SplineFields3Dmx.C +++ b/src/ASM/SplineFields3Dmx.C @@ -79,7 +79,7 @@ bool SplineFields3Dmx::valueFE (const ItgPoint& x, Vector& vals) const auto vit = values.begin(); auto rit = vals.begin(); for (int b : bases) { - Go::SplineVolume* basis = svol->getBasis(b); + const Go::SplineVolume* basis = svol->getBasis(b); Go::BasisPts spline; #pragma omp critical basis->computeBasis(x.u,x.v,x.w,spline);