changed: remove proj members in ASMs2D and ASMs3D

as these are stored as projB in ASMstruct.
less confusion as there are less member pointers.
This commit is contained in:
Arne Morten Kvarving 2023-08-23 10:23:09 +02:00
parent 086592c2f9
commit dce989f1c6
10 changed files with 41 additions and 40 deletions

View File

@ -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<Go::SplineSurface*>(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<const Go::SplineSurface*>(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<const Go::SplineSurface*>(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<const Go::SplineSurface*>(projB);
return proj->numCoefs_u() * proj->numCoefs_v();
}

View File

@ -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?

View File

@ -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();

View File

@ -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<Go::SplineSurface*>(projB);
surf = this->getBasis(ASMmxBase::geoBasis);
}
}

View File

@ -166,6 +166,8 @@ bool ASMs2D::assembleL2matrices (SparseMatrix& A, StdVector& B,
{
const size_t nnod = this->getNoProjectionNodes();
const Go::SplineSurface* proj = static_cast<const Go::SplineSurface*>(projB);
const int g1 = surf->order_u();
const int g2 = surf->order_v();
const int p1 = proj->order_u();

View File

@ -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<Go::SplineVolume*>(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<const Go::SplineVolume*>(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<const Go::SplineVolume*>(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<const Go::SplineVolume*>(projB);
return proj->numCoefs(0) * proj->numCoefs(1) * proj->numCoefs(2);
}

View File

@ -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)

View File

@ -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);

View File

@ -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<Go::SplineVolume*>(projB);
svol = this->getBasis(ASMmxBase::geoBasis);
}
}

View File

@ -166,6 +166,8 @@ bool ASMs3D::assembleL2matrices (SparseMatrix& A, StdVector& B,
{
const size_t nnod = this->getNoProjectionNodes();
const Go::SplineVolume* proj = static_cast<const Go::SplineVolume*>(projB);
const int g1 = svol->order(0);
const int g2 = svol->order(1);
const int g3 = svol->order(2);