mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Make sure subclass functions are not called before subclass is initialized.
This at least slightly improves the old design. In that design the subclass had no own constructor but inherited the one of the base class. That base class constructor called certain subclass functions (createGrids_, filterConnections_, updateOutputDir_, and finalizeInit_)that would initialize raw pointers of the subclass. Hence subclasses where not allowed to have non-pod members and those used later (e.g. deleted in the destructor) had to be initialized in these functions. The new (still ugly) design introduces constructors into the subclasses and skips inheriting constructors. Now one must call a base class function classImplementationInit which will still call the functions createGrids_, filterConnections_, updateOutputDir_, and finalizeInit_, but at least at this point the baseclass is fully constructed and the subclass is constructed as much as possible/needed (non-pod types will be initialized now.)
This commit is contained in:
parent
4e6bbddbf5
commit
cb396dfac6
@ -88,15 +88,6 @@ public:
|
||||
this->callImplementationInit();
|
||||
}
|
||||
|
||||
~EclCpGridVanguard()
|
||||
{
|
||||
delete cartesianIndexMapper_;
|
||||
delete equilCartesianIndexMapper_;
|
||||
delete grid_;
|
||||
delete equilGrid_;
|
||||
delete globalTrans_;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Return a reference to the simulation grid.
|
||||
*/
|
||||
@ -137,11 +128,8 @@ public:
|
||||
*/
|
||||
void releaseEquilGrid()
|
||||
{
|
||||
delete equilGrid_;
|
||||
equilGrid_ = 0;
|
||||
|
||||
delete equilCartesianIndexMapper_;
|
||||
equilCartesianIndexMapper_ = 0;
|
||||
equilGrid_.reset();
|
||||
equilCartesianIndexMapper_.reset();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -162,16 +150,12 @@ public:
|
||||
// its edge weights. since this is (kind of) a layering violation and
|
||||
// transmissibilities are relatively expensive to compute, we only do it if
|
||||
// more than a single process is involved in the simulation.
|
||||
cartesianIndexMapper_ = new CartesianIndexMapper(*grid_);
|
||||
cartesianIndexMapper_.reset(new CartesianIndexMapper(*grid_));
|
||||
if (grid_->size(0))
|
||||
{
|
||||
globalTrans_ = new EclTransmissibility<TypeTag>(*this);
|
||||
globalTrans_.reset(new EclTransmissibility<TypeTag>(*this));
|
||||
globalTrans_->update();
|
||||
}
|
||||
else
|
||||
{
|
||||
globalTrans_ = nullptr;
|
||||
}
|
||||
|
||||
Dune::EdgeWeightMethod edgeWeightsMethod = this->edgeWeightsMethod();
|
||||
|
||||
@ -214,12 +198,11 @@ public:
|
||||
}
|
||||
grid_->switchToDistributedView();
|
||||
|
||||
delete cartesianIndexMapper_;
|
||||
cartesianIndexMapper_ = nullptr;
|
||||
cartesianIndexMapper_.reset();
|
||||
}
|
||||
#endif
|
||||
|
||||
cartesianIndexMapper_ = new CartesianIndexMapper(*grid_);
|
||||
cartesianIndexMapper_.reset(new CartesianIndexMapper(*grid_));
|
||||
|
||||
this->updateGridView_();
|
||||
}
|
||||
@ -231,8 +214,7 @@ public:
|
||||
*/
|
||||
void releaseGlobalTransmissibilities()
|
||||
{
|
||||
delete globalTrans_;
|
||||
globalTrans_ = nullptr;
|
||||
globalTrans_.reset();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -267,8 +249,7 @@ public:
|
||||
|
||||
void releaseGlobalTransmissibility()
|
||||
{
|
||||
delete globalTrans_;
|
||||
globalTrans_ = nullptr;
|
||||
globalTrans_.reset();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -277,7 +258,7 @@ protected:
|
||||
const auto& gridProps = this->eclState().get3DProperties();
|
||||
const std::vector<double>& porv = gridProps.getDoubleGridProperty("PORV").getData();
|
||||
|
||||
grid_ = new Dune::CpGrid();
|
||||
grid_.reset(new Dune::CpGrid());
|
||||
grid_->processEclipseFormat(this->eclState().getInputGrid(),
|
||||
/*isPeriodic=*/false,
|
||||
/*flipNormals=*/false,
|
||||
@ -293,16 +274,9 @@ protected:
|
||||
// equilGrid_being a shallow copy only the global view.
|
||||
if (grid_->size(0))
|
||||
{
|
||||
equilGrid_ = new Dune::CpGrid(*grid_);
|
||||
equilCartesianIndexMapper_ = new CartesianIndexMapper(*equilGrid_);
|
||||
equilGrid_.reset(new Dune::CpGrid(*grid_));
|
||||
equilCartesianIndexMapper_.reset(new CartesianIndexMapper(*equilGrid_));
|
||||
}
|
||||
else
|
||||
{
|
||||
equilGrid_ = nullptr;
|
||||
equilCartesianIndexMapper_ = nullptr;
|
||||
}
|
||||
|
||||
globalTrans_ = nullptr;
|
||||
}
|
||||
|
||||
// removing some connection located in inactive grid cells
|
||||
@ -315,12 +289,12 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
Grid* grid_;
|
||||
EquilGrid* equilGrid_;
|
||||
CartesianIndexMapper* cartesianIndexMapper_;
|
||||
CartesianIndexMapper* equilCartesianIndexMapper_;
|
||||
std::unique_ptr<Grid> grid_;
|
||||
std::unique_ptr<EquilGrid> equilGrid_;
|
||||
std::unique_ptr<CartesianIndexMapper> cartesianIndexMapper_;
|
||||
std::unique_ptr<CartesianIndexMapper> equilCartesianIndexMapper_;
|
||||
|
||||
EclTransmissibility<TypeTag>* globalTrans_;
|
||||
std::unique_ptr<EclTransmissibility<TypeTag> > globalTrans_;
|
||||
std::unordered_set<std::string> defunctWellNames_;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user