From dce989f1c61303d2e3ae3f2f3e6b6ef0b4d79a90 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 23 Aug 2023 10:23:09 +0200 Subject: [PATCH] changed: remove proj members in ASMs2D and ASMs3D as these are stored as projB in ASMstruct. less confusion as there are less member pointers. --- src/ASM/ASMs2D.C | 26 +++++++++++++------------- src/ASM/ASMs2D.h | 1 - src/ASM/ASMs2DLag.C | 2 +- src/ASM/ASMs2Dmx.C | 9 ++++----- src/ASM/ASMs2Drecovery.C | 2 ++ src/ASM/ASMs3D.C | 27 ++++++++++++++------------- src/ASM/ASMs3D.h | 1 - src/ASM/ASMs3DLag.C | 2 +- src/ASM/ASMs3Dmx.C | 9 ++++----- src/ASM/ASMs3Drecovery.C | 2 ++ 10 files changed, 41 insertions(+), 40 deletions(-) diff --git a/src/ASM/ASMs2D.C b/src/ASM/ASMs2D.C index 1e8f3655..072ec9c7 100644 --- a/src/ASM/ASMs2D.C +++ b/src/ASM/ASMs2D.C @@ -43,7 +43,7 @@ ASMs2D::ASMs2D (unsigned char n_s, unsigned char n_f) : ASMstruct(2,n_s,n_f), nodeInd(myNodeInd) { - surf = proj = nullptr; + surf = nullptr; bou[0] = bou[1] = bou[2] = bou[3] = nullptr; swapV = false; } @@ -53,7 +53,6 @@ ASMs2D::ASMs2D (const ASMs2D& patch, unsigned char n_f) : ASMstruct(patch,n_f), nodeInd(patch.myNodeInd) { surf = patch.surf; - proj = patch.proj; for (int i = 0; i < 4; i++) bou[i] = patch.bou[i]; @@ -70,7 +69,6 @@ ASMs2D::ASMs2D (const ASMs2D& patch, unsigned char n_f) ASMs2D::ASMs2D (const ASMs2D& patch) : ASMstruct(patch), nodeInd(myNodeInd) { surf = patch.surf; - proj = patch.proj; for (int i = 0; i < 4; i++) bou[i] = patch.bou[i]; @@ -175,9 +173,9 @@ void ASMs2D::clear (bool retainGeometry) if (!retainGeometry) { // Erase spline data - if (proj && proj != surf) delete proj; + if (projB != surf) delete projB; if (surf && !shareFE) delete surf; - geomB = projB = surf = proj = nullptr; + geomB = projB = surf = nullptr; } // Erase the FE data @@ -449,11 +447,11 @@ bool ASMs2D::createProjectionBasis (bool init) { if (!surf) return false; - else if (init && !proj) - projB = proj = surf->clone(); + else if (init && !projB) + projB = surf->clone(); std::swap(geomB,projB); - std::swap(surf,proj); + surf = static_cast(geomB); return true; } @@ -461,7 +459,7 @@ bool ASMs2D::createProjectionBasis (bool init) bool ASMs2D::generateFEMTopology () { if (!surf) return false; - if (!proj) proj = surf; + if (!projB) projB = surf; const int n1 = surf->numCoefs_u(); const int n2 = surf->numCoefs_v(); @@ -3095,7 +3093,7 @@ int ASMs2D::getCorner (int I, int J, int basis) const Field* ASMs2D::getProjectedField (const Vector& coefs) const { if (this->getNoProjectionNodes() == coefs.size()) - return new SplineField2D(proj,coefs); + return new SplineField2D(static_cast(projB),coefs); std::cerr <<" *** ASMs2D::getProjectedField: Non-matching coefficent array," <<" size="<< coefs.size() <<" nnod="<< this->getNoProjectionNodes() @@ -3106,12 +3104,12 @@ Field* ASMs2D::getProjectedField (const Vector& coefs) const Fields* ASMs2D::getProjectedFields (const Vector& coefs, size_t) const { - if (proj == this->getBasis(1) || this->getNoProjectionNodes() == 0) + if (projB == this->getBasis(1) || this->getNoProjectionNodes() == 0) return nullptr; size_t ncmp = coefs.size() / this->getNoProjectionNodes(); if (ncmp*this->getNoProjectionNodes() == coefs.size()) - return new SplineFields2D(proj,coefs,ncmp); + return new SplineFields2D(static_cast(projB),coefs,ncmp); std::cerr <<" *** ASMs2D::getProjectedFields: Non-matching coefficent array," <<" size="<< coefs.size() <<" nnod="<< this->getNoProjectionNodes() @@ -3122,7 +3120,9 @@ Fields* ASMs2D::getProjectedFields (const Vector& coefs, size_t) const size_t ASMs2D::getNoProjectionNodes () const { - if (!proj) return 0; + if (!projB) return 0; + + const Go::SplineSurface* proj = static_cast(projB); return proj->numCoefs_u() * proj->numCoefs_v(); } diff --git a/src/ASM/ASMs2D.h b/src/ASM/ASMs2D.h index 7ba8b475..8501dce6 100644 --- a/src/ASM/ASMs2D.h +++ b/src/ASM/ASMs2D.h @@ -784,7 +784,6 @@ private: protected: Go::SplineSurface* surf; //!< Pointer to the actual spline surface object - Go::SplineSurface* proj; //!< Pointer to spline surface for projection basis Go::SplineCurve* bou[4]; //!< Pointers to the four boundary curves bool swapV; //!< Has the v-parameter direction been swapped? diff --git a/src/ASM/ASMs2DLag.C b/src/ASM/ASMs2DLag.C index 6c233cbd..05fa032d 100644 --- a/src/ASM/ASMs2DLag.C +++ b/src/ASM/ASMs2DLag.C @@ -134,7 +134,7 @@ bool ASMs2DLag::addXElms (short int dim, short int item, size_t nXn, bool ASMs2DLag::generateFEMTopology () { if (!surf) return false; - if (!proj) proj = surf; + if (!projB) projB = surf; // Order of basis in the two parametric directions (order = degree + 1) p1 = surf->order_u(); diff --git a/src/ASM/ASMs2Dmx.C b/src/ASM/ASMs2Dmx.C index 294b1d78..cb8527cc 100644 --- a/src/ASM/ASMs2Dmx.C +++ b/src/ASM/ASMs2Dmx.C @@ -96,7 +96,7 @@ bool ASMs2Dmx::readBasis (std::istream& is, size_t basis) bool ASMs2Dmx::write (std::ostream& os, int basis) const { if (basis == -1) - os <<"200 1 0 0\n" << *proj; + os <<"200 1 0 0\n" << *projB; else if (basis < 1 || basis > (int)m_basis.size()) os <<"200 1 0 0\n" << *surf; else if (m_basis[basis-1]) @@ -203,13 +203,13 @@ bool ASMs2Dmx::generateFEMTopology () if (ASMmxBase::Type == ASMmxBase::REDUCED_CONT_RAISE_BASIS1 || ASMmxBase::Type == ASMmxBase::REDUCED_CONT_RAISE_BASIS2 || ASMmxBase::Type == ASMmxBase::DIV_COMPATIBLE) - projB = proj = ASMmxBase::raiseBasis(surf); + projB = ASMmxBase::raiseBasis(surf); else if (ASMmxBase::Type == ASMmxBase::SUBGRID) { - projB = proj = m_basis.front()->clone(); + projB = m_basis.front()->clone(); projB2 = ASMmxBase::raiseBasis(surf); } else if (geoBasis < 3) - projB = proj = m_basis[2-geoBasis]->clone(); + projB = m_basis[2-geoBasis]->clone(); else return false; // Logic error } @@ -1113,7 +1113,6 @@ void ASMs2Dmx::swapProjectionBasis () if (projB2) { ASMmxBase::geoBasis = ASMmxBase::geoBasis == 1 ? 2 : 1; std::swap(projB, projB2); - proj = static_cast(projB); surf = this->getBasis(ASMmxBase::geoBasis); } } diff --git a/src/ASM/ASMs2Drecovery.C b/src/ASM/ASMs2Drecovery.C index 2ab68118..0c6cb0e5 100644 --- a/src/ASM/ASMs2Drecovery.C +++ b/src/ASM/ASMs2Drecovery.C @@ -166,6 +166,8 @@ bool ASMs2D::assembleL2matrices (SparseMatrix& A, StdVector& B, { const size_t nnod = this->getNoProjectionNodes(); + const Go::SplineSurface* proj = static_cast(projB); + const int g1 = surf->order_u(); const int g2 = surf->order_v(); const int p1 = proj->order_u(); diff --git a/src/ASM/ASMs3D.C b/src/ASM/ASMs3D.C index 144ec479..146df70f 100644 --- a/src/ASM/ASMs3D.C +++ b/src/ASM/ASMs3D.C @@ -41,7 +41,7 @@ ASMs3D::ASMs3D (unsigned char n_f) : ASMstruct(3,3,n_f), nodeInd(myNodeInd) { - svol = proj = nullptr; + svol = nullptr; swapW = false; } @@ -50,7 +50,6 @@ ASMs3D::ASMs3D (const ASMs3D& patch, unsigned char n_f) : ASMstruct(patch,n_f), nodeInd(patch.myNodeInd) { svol = patch.svol; - proj = patch.proj; swapW = patch.swapW; @@ -62,7 +61,7 @@ ASMs3D::ASMs3D (const ASMs3D& patch, unsigned char n_f) ASMs3D::ASMs3D (const ASMs3D& patch) - : ASMstruct(patch), svol(patch.svol), proj(patch.proj), + : ASMstruct(patch), svol(patch.svol), nodeInd(myNodeInd), myNodeInd(patch.nodeInd), dirich(patch.dirich) { swapW = patch.swapW; @@ -145,9 +144,9 @@ void ASMs3D::clear (bool retainGeometry) if (!retainGeometry) { // Erase spline data - if (proj && proj != svol) delete proj; + if (projB != svol) delete projB; if (svol && !shareFE) delete svol; - geomB = projB = svol = proj = nullptr; + geomB = projB = svol = nullptr; } // Erase the FE data @@ -382,11 +381,11 @@ bool ASMs3D::createProjectionBasis (bool init) { if (!svol) return false; - else if (init && !proj) - projB = proj = svol->clone(); + else if (init && !projB) + projB = svol->clone(); std::swap(geomB,projB); - std::swap(svol,proj); + svol = static_cast(geomB); return true; } @@ -394,7 +393,7 @@ bool ASMs3D::createProjectionBasis (bool init) bool ASMs3D::generateFEMTopology () { if (!svol) return false; - if (!proj) proj = svol; + if (!projB) projB = svol; const int n1 = svol->numCoefs(0); const int n2 = svol->numCoefs(1); @@ -3620,7 +3619,7 @@ bool ASMs3D::getFaceSize (int& n1, int& n2, int basis, int face) const Field* ASMs3D::getProjectedField (const Vector& coefs) const { if (this->getNoProjectionNodes() == coefs.size()) - return new SplineField3D(proj,coefs); + return new SplineField3D(static_cast(projB),coefs); std::cerr <<" *** ASMs3D::getProjectedField: Non-matching coefficent array," <<" size="<< coefs.size() <<" nnod="<< this->getNoProjectionNodes() @@ -3631,12 +3630,12 @@ Field* ASMs3D::getProjectedField (const Vector& coefs) const Fields* ASMs3D::getProjectedFields (const Vector& coefs, size_t) const { - if (proj == this->getBasis(1) || this->getNoProjectionNodes() == 0) + if (projB == this->getBasis(1) || this->getNoProjectionNodes() == 0) return nullptr; size_t ncmp = coefs.size() / this->getNoProjectionNodes(); if (ncmp*this->getNoProjectionNodes() == coefs.size()) - return new SplineFields3D(proj,coefs,ncmp); + return new SplineFields3D(static_cast(projB),coefs,ncmp); std::cerr <<" *** ASMs3D::getProjectedFields: Non-matching coefficent array," <<" size="<< coefs.size() <<" nnod="<< this->getNoProjectionNodes() @@ -3647,7 +3646,9 @@ Fields* ASMs3D::getProjectedFields (const Vector& coefs, size_t) const size_t ASMs3D::getNoProjectionNodes () const { - if (!proj) return 0; + if (!projB) return 0; + + const Go::SplineVolume* proj = static_cast(projB); return proj->numCoefs(0) * proj->numCoefs(1) * proj->numCoefs(2); } diff --git a/src/ASM/ASMs3D.h b/src/ASM/ASMs3D.h index ac6986e6..c18a062f 100644 --- a/src/ASM/ASMs3D.h +++ b/src/ASM/ASMs3D.h @@ -875,7 +875,6 @@ private: protected: Go::SplineVolume* svol; //!< Pointer to the actual spline volume object - Go::SplineVolume* proj; //!< Pointer to spline volume for projection basis bool swapW; //!< Has the w-parameter direction been swapped? const IndexVec& nodeInd; //!< IJK-triplets for the control points (nodes) diff --git a/src/ASM/ASMs3DLag.C b/src/ASM/ASMs3DLag.C index 8ec41888..99a8b37f 100644 --- a/src/ASM/ASMs3DLag.C +++ b/src/ASM/ASMs3DLag.C @@ -144,7 +144,7 @@ bool ASMs3DLag::addXElms (short int dim, short int item, size_t nXn, bool ASMs3DLag::generateFEMTopology () { if (!svol) return false; - if (!proj) proj = svol; + if (!projB) projB = svol; // Order of basis in the three parametric directions (order = degree + 1) p1 = svol->order(0); diff --git a/src/ASM/ASMs3Dmx.C b/src/ASM/ASMs3Dmx.C index 0743813f..bf568269 100644 --- a/src/ASM/ASMs3Dmx.C +++ b/src/ASM/ASMs3Dmx.C @@ -97,7 +97,7 @@ bool ASMs3Dmx::readBasis (std::istream& is, size_t basis) bool ASMs3Dmx::write (std::ostream& os, int basis) const { if (basis == -1) - os <<"700 1 0 0\n" << *proj; + os <<"700 1 0 0\n" << *projB; else if (basis < 1 || basis > (int)m_basis.size()) os <<"700 1 0 0\n" << *svol; else if (m_basis[basis-1]) @@ -204,13 +204,13 @@ bool ASMs3Dmx::generateFEMTopology () if (ASMmxBase::Type == ASMmxBase::REDUCED_CONT_RAISE_BASIS1 || ASMmxBase::Type == ASMmxBase::REDUCED_CONT_RAISE_BASIS2 || ASMmxBase::Type == ASMmxBase::DIV_COMPATIBLE) - projB = proj = ASMmxBase::raiseBasis(svol); + projB = ASMmxBase::raiseBasis(svol); else if (ASMmxBase::Type == ASMmxBase::SUBGRID) { - projB = proj = m_basis.front()->clone(); + projB = m_basis.front()->clone(); projB2 = ASMmxBase::raiseBasis(svol); } else if (geoBasis < 3) - projB = proj = m_basis[2-geoBasis]->clone(); + projB = m_basis[2-geoBasis]->clone(); else return false; // Logic error } @@ -1265,7 +1265,6 @@ void ASMs3Dmx::swapProjectionBasis () if (projB2) { ASMmxBase::geoBasis = ASMmxBase::geoBasis == 1 ? 2 : 1; std::swap(projB, projB2); - proj = static_cast(projB); svol = this->getBasis(ASMmxBase::geoBasis); } } diff --git a/src/ASM/ASMs3Drecovery.C b/src/ASM/ASMs3Drecovery.C index 8678cff0..77de200a 100644 --- a/src/ASM/ASMs3Drecovery.C +++ b/src/ASM/ASMs3Drecovery.C @@ -166,6 +166,8 @@ bool ASMs3D::assembleL2matrices (SparseMatrix& A, StdVector& B, { const size_t nnod = this->getNoProjectionNodes(); + const Go::SplineVolume* proj = static_cast(projB); + const int g1 = svol->order(0); const int g2 = svol->order(1); const int g3 = svol->order(2);