diff --git a/src/ASM/LR/ASMLRSpline.C b/src/ASM/LR/ASMLRSpline.C index f3281f69..68c56c9a 100644 --- a/src/ASM/LR/ASMLRSpline.C +++ b/src/ASM/LR/ASMLRSpline.C @@ -83,7 +83,6 @@ void LR::getGaussPointParameters (const LR::LRSpline* lrspline, RealArray& uGP, ASMunstruct::~ASMunstruct () { - if (geo) delete geo; } diff --git a/src/ASM/LR/ASMu3D.C b/src/ASM/LR/ASMu3D.C index b91a95cc..c05d5d38 100644 --- a/src/ASM/LR/ASMu3D.C +++ b/src/ASM/LR/ASMu3D.C @@ -56,18 +56,18 @@ ASMu3D::ASMu3D (const ASMu3D& patch, unsigned char n_f) bool ASMu3D::read (std::istream& is) { if (shareFE) return true; - if (lrspline) delete lrspline; + lrspline.reset(); // read inputfile as either an LRSpline file directly or a tensor product B-spline and convert char firstline[256]; is.getline(firstline, 256); if(strncmp(firstline, "# LRSPLINE", 10) == 0) { - lrspline = new LR::LRSplineVolume(); + lrspline.reset(new LR::LRSplineVolume()); is >> *lrspline; } else { // probably a SplineVolume, so we'll read that and convert tensorspline = new Go::SplineVolume(); is >> *tensorspline; - lrspline = new LR::LRSplineVolume(tensorspline); + lrspline.reset(new LR::LRSplineVolume(tensorspline)); } // Eat white-space characters to see if there is more data to read @@ -81,20 +81,18 @@ bool ASMu3D::read (std::istream& is) if (!is.good() && !is.eof()) { std::cerr <<" *** ASMu3D::read: Failure reading spline data"<< std::endl; - delete lrspline; - lrspline = 0; + lrspline.reset(); return false; } else if (lrspline->dimension() < 3) { std::cerr <<" *** ASMu3D::read: Invalid spline volume patch, dim=" << lrspline->dimension() << std::endl; - delete lrspline; - lrspline = 0; + lrspline.reset(); return false; } - geo = lrspline; + geo = lrspline.get(); return true; } @@ -114,9 +112,8 @@ void ASMu3D::clear (bool retainGeometry) if (!retainGeometry) { // Erase spline data if (!shareFE) { - delete lrspline; + lrspline.reset(); delete tensorspline; - lrspline = nullptr; } geo = nullptr; tensorspline = nullptr; @@ -157,8 +154,8 @@ bool ASMu3D::refine (int dir, const RealArray& xi) } tensorspline->insertKnot(dir,extraKnots); - if(lrspline) delete lrspline; - geo = lrspline = new LR::LRSplineVolume(tensorspline); + lrspline.reset(new LR::LRSplineVolume(tensorspline)); + geo = lrspline.get(); return true; } @@ -183,8 +180,8 @@ bool ASMu3D::uniformRefine (int dir, int nInsert) } tensorspline->insertKnot(dir,extraKnots); - if(lrspline) delete lrspline; - geo = lrspline = new LR::LRSplineVolume(tensorspline); + lrspline.reset(new LR::LRSplineVolume(tensorspline)); + geo = lrspline.get(); return true; } @@ -194,8 +191,8 @@ bool ASMu3D::raiseOrder (int ru, int rv, int rw) if (shareFE) return true; tensorspline->raiseOrder(ru,rv,rw); - delete lrspline; - geo = lrspline = new LR::LRSplineVolume(tensorspline); + lrspline.reset(new LR::LRSplineVolume(tensorspline)); + geo = lrspline.get(); return true; } diff --git a/src/ASM/LR/ASMu3D.h b/src/ASM/LR/ASMu3D.h index d47e2dac..185e5257 100644 --- a/src/ASM/LR/ASMu3D.h +++ b/src/ASM/LR/ASMu3D.h @@ -44,7 +44,7 @@ public: virtual ~ASMu3D() {} //! \brief Returns the spline volume representing the geometry of this patch. - LR::LRSplineVolume* getVolume() const { return lrspline; } + LR::LRSplineVolume* getVolume() const { return lrspline.get(); } // Methods for model generation and refinement @@ -299,6 +299,9 @@ public: virtual bool evalSolution(Matrix& sField, const IntegrandBase& integrand, const int* npe = 0, char project = '\0') const; + //! \brief Returns the spline volume representing the basis of this patch. + virtual const LR::LRSplineVolume* getBasis(int = 1) const { return lrspline.get(); } + public: //! \brief Projects the secondary solution field onto the primary basis. //! \param[in] integrand Object with problem-specific data and methods @@ -395,7 +398,7 @@ public: virtual size_t getNoBoundaryElms(char lIndex, char ldim) const; protected: - LR::LRSplineVolume* lrspline; //!< Pointer to the LR-spline volume object + std::shared_ptr lrspline; //!< Pointer to the LR-spline volume object Go::SplineVolume* tensorspline; //!< Pointer to original tensor spline object // The tensor spline object is kept for backward compatability with the REFINE