changed: use shared pointers in 3D LR ASM
- same as in 2D - difficult to keep track of which pointers to delete or not. now it's simple: you never delete a bare pointer.
This commit is contained in:
parent
fd3b040348
commit
2562a61d4c
@ -83,7 +83,6 @@ void LR::getGaussPointParameters (const LR::LRSpline* lrspline, RealArray& uGP,
|
||||
|
||||
ASMunstruct::~ASMunstruct ()
|
||||
{
|
||||
if (geo) delete geo;
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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<LR::LRSplineVolume> 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
|
||||
|
Loading…
Reference in New Issue
Block a user