Commit 03efb3f4 authored by Bernd Flemisch's avatar Bernd Flemisch
Browse files

Replace standard by smart pointers for decoupled. This

partially implements FS#182.
Reviewed by Benjamin and Markus.


git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@10177 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent ca0f5c40
......@@ -77,8 +77,7 @@ public:
DiffusionProblem1P(TimeManager &timeManager, const GridView &gridView)
: ParentType(timeManager, gridView), gravity_(0)
{
spatialParams_ = new SpatialParams(gridView);
newSpatialParams_ = true;
spatialParams_ = Dune::make_shared<SpatialParams>(gridView);
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
gravity_[dim - 1] = -9.81;
......@@ -93,7 +92,6 @@ public:
DiffusionProblem1P(TimeManager &timeManager, const GridView &gridView, SpatialParams &spatialParams)
: ParentType(timeManager, gridView), gravity_(0), spatialParams_(&spatialParams)
{
newSpatialParams_ = false;
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
gravity_[dim - 1] = -9.81;
......@@ -106,8 +104,7 @@ public:
DiffusionProblem1P(const GridView &gridView)
: ParentType(gridView, false), gravity_(0)
{
spatialParams_ = new SpatialParams(gridView);
newSpatialParams_ = true;
spatialParams_ = Dune::make_shared<SpatialParams>(gridView);
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
gravity_[dim - 1] = -9.81;
......@@ -121,20 +118,11 @@ public:
DiffusionProblem1P(const GridView &gridView, SpatialParams &spatialParams)
: ParentType(gridView, false), gravity_(0), spatialParams_(&spatialParams)
{
newSpatialParams_ = false;
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
gravity_[dim - 1] = -9.81;
}
virtual ~DiffusionProblem1P()
{
if (newSpatialParams_)
{
delete spatialParams_;
}
}
/*!
* \name Problem parameters
*/
......@@ -251,8 +239,7 @@ private:
GlobalPosition gravity_;
// fluids and material properties
SpatialParams* spatialParams_;
bool newSpatialParams_;
Dune::shared_ptr<SpatialParams> spatialParams_;
};
}
......
......@@ -77,8 +77,7 @@ public:
DiffusionProblem2P(TimeManager &timeManager, const GridView &gridView)
: ParentType(timeManager, gridView), gravity_(0)
{
spatialParams_ = new SpatialParams(gridView);
newSpatialParams_ = true;
spatialParams_ = Dune::make_shared<SpatialParams>(gridView);
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
gravity_[dim - 1] = -9.81;
......@@ -93,7 +92,6 @@ public:
DiffusionProblem2P(TimeManager &timeManager, const GridView &gridView, SpatialParams &spatialParams)
: ParentType(timeManager, gridView), gravity_(0), spatialParams_(&spatialParams)
{
newSpatialParams_ = false;
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
gravity_[dim - 1] = -9.81;
......@@ -107,8 +105,7 @@ public:
DiffusionProblem2P(const GridView &gridView)
: ParentType(gridView, false), gravity_(0)
{
spatialParams_ = new SpatialParams(gridView);
newSpatialParams_ = true;
spatialParams_ = Dune::make_shared<SpatialParams>(gridView);
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
gravity_[dim - 1] = -9.81;
......@@ -122,21 +119,11 @@ public:
DiffusionProblem2P(const GridView &gridView, SpatialParams &spatialParams)
: ParentType(gridView, false), gravity_(0), spatialParams_(&spatialParams)
{
newSpatialParams_ = false;
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
gravity_[dim - 1] = -9.81;
}
//! Destructor
virtual ~DiffusionProblem2P()
{
if (newSpatialParams_)
{
delete spatialParams_;
}
}
/*!
* \name Problem parameters
*/
......@@ -245,7 +232,7 @@ private:
GlobalPosition gravity_;
// fluids and material properties
SpatialParams* spatialParams_;
Dune::shared_ptr<SpatialParams> spatialParams_;
bool newSpatialParams_;
};
......
......@@ -80,8 +80,7 @@ public:
: ParentType(timeManager, gridView),
gravity_(0)
{
newSpatialParams_ = true;
spatialParams_ = new SpatialParams(gridView);
spatialParams_ = Dune::make_shared<SpatialParams>(gridView);
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
......@@ -98,22 +97,11 @@ public:
: ParentType(timeManager, gridView),
gravity_(0),spatialParams_(&spatialParams)
{
newSpatialParams_ = false;
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
gravity_[dim - 1] = - 9.81;
}
//! Destructor
virtual ~IMPESProblem2P()
{
if (newSpatialParams_)
{
delete spatialParams_;
}
}
/*!
* \name Problem parameters
*/
......@@ -204,8 +192,7 @@ private:
GlobalPosition gravity_;
// fluids and material properties
SpatialParams* spatialParams_;
bool newSpatialParams_;
Dune::shared_ptr<SpatialParams> spatialParams_;
};
}
......
......@@ -401,26 +401,18 @@ public:
DUNE_THROW(Dune::NotImplemented, "Velocity type not supported!");
}
capillaryFlux_ = new CapillaryFlux(problem);
gravityFlux_ = new GravityFlux(problem);
velocity_ = new Velocity(problem);
capillaryFlux_ = Dune::make_shared<CapillaryFlux>(problem);
gravityFlux_ = Dune::make_shared<GravityFlux>(problem);
velocity_ = Dune::make_shared<Velocity>(problem);
vtkOutputLevel_ = GET_PARAM_FROM_GROUP(TypeTag, int, Vtk, OutputLevel);
}
//! Destructor
~FVSaturation2P()
{
delete capillaryFlux_;
delete gravityFlux_;
delete velocity_;
}
private:
Problem& problem_;
Velocity* velocity_;
CapillaryFlux* capillaryFlux_;
GravityFlux* gravityFlux_;
Dune::shared_ptr<Velocity> velocity_;
Dune::shared_ptr<CapillaryFlux> capillaryFlux_;
Dune::shared_ptr<GravityFlux> gravityFlux_;
int vtkOutputLevel_;
......
......@@ -98,8 +98,7 @@ public:
{
cFLFactor_ = GET_PARAM_FROM_GROUP(TypeTag, Scalar, Impet, CFLFactor);
newSpatialParams_ = true;
spatialParams_ = new SpatialParams(gridView);
spatialParams_ = Dune::make_shared<SpatialParams>(gridView);
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
......@@ -119,21 +118,11 @@ public:
{
cFLFactor_ = GET_PARAM_FROM_GROUP(TypeTag, Scalar, Impet, CFLFactor);
newSpatialParams_ = false;
gravity_ = 0;
if (GET_PARAM_FROM_GROUP(TypeTag, bool, Problem, EnableGravity))
gravity_[dim - 1] = - 9.81;
}
~TransportProblem2P()
{
if (newSpatialParams_)
{
delete spatialParams_;
}
}
/*!
* \name Problem parameters
*/
......@@ -243,8 +232,7 @@ private:
GlobalPosition gravity_;
// material properties
SpatialParams* spatialParams_;
bool newSpatialParams_;
Dune::shared_ptr<SpatialParams> spatialParams_;
Scalar cFLFactor_;
};
......
......@@ -84,13 +84,12 @@ protected:
int globalIdx_;
Scalar perimeter_;
FluidState* fluidState_;
Dune::shared_ptr<FluidState> fluidState_;
FluxData fluxData_;
public:
//! Constructor for a local CellData object
CellData2P2C() :
fluidState_(0)
CellData2P2C()
{
for (int i = 0; i < numPhases;i++)
{
......@@ -360,7 +359,7 @@ public:
FluidState& manipulateFluidState()
{
if(!fluidState_)
fluidState_ = new FluidState;
fluidState_ = Dune::make_shared<FluidState>();
return *fluidState_;
}
......
......@@ -76,7 +76,7 @@ private:
private:
int subdomain_;
int fluidStateType_;
SimpleFluidState* simpleFluidState_;
Dune::shared_ptr<SimpleFluidState> simpleFluidState_;
// FluxData fluxData_;
public:
......@@ -285,12 +285,11 @@ public:
fluidStateType_ = simple;
if(this->fluidState_)
{
delete this->fluidState_;
this->fluidState_ = NULL;
this->fluidState_.template reset<FluidState>(0);
}
if(!simpleFluidState_)
simpleFluidState_ = new SimpleFluidState;
simpleFluidState_ = Dune::make_shared<SimpleFluidState>();
return *simpleFluidState_;
}
//! Allows manipulation of the complex fluid state
......@@ -303,12 +302,11 @@ public:
fluidStateType_ = complex;
if(simpleFluidState_)
{
delete simpleFluidState_;
simpleFluidState_ = NULL;
simpleFluidState_.template reset<SimpleFluidState>(0);
}
if(!this->fluidState_)
this->fluidState_ = new FluidState;
this->fluidState_ = Dune::make_shared<FluidState>();
return *this->fluidState_;
}
......
......@@ -228,7 +228,7 @@ protected:
bool enableMPFA; //!< Enables mpfa method to calculate the fluxes near hanging nodes
bool enableSecondHalfEdge; //!< If possible, 2 interaction volumes are used for the mpfa method near hanging nodes
//! The 2p Mpfa pressure module, that is only used for the calulation of transmissibility of the second interaction volumes
FVMPFAL2PFABoundPressure2PAdaptive<TypeTag>* pressureModelAdaptive2p_;
Dune::shared_ptr<FVMPFAL2PFABoundPressure2PAdaptive<TypeTag> > pressureModelAdaptive2p_;
};
......@@ -1205,7 +1205,7 @@ int FVPressure2P2CAdaptive<TypeTag>::transmissibilityAdapter_(const Intersection
if(!pressureModelAdaptive2p_)
pressureModelAdaptive2p_= new FVMPFAL2PFABoundPressure2PAdaptive<TypeTag>(problem()) ;
pressureModelAdaptive2p_= Dune::make_shared<FVMPFAL2PFABoundPressure2PAdaptive<TypeTag> >(problem()) ;
// create Interaction Volume object
Dumux::FVMPFALInteractionVolume<TypeTag> interactionVolume;
......
......@@ -179,13 +179,7 @@ public:
FVTransport(Problem& problem) :
problem_(problem), switchNormals_(GET_PARAM_FROM_GROUP(TypeTag, bool, Impet, SwitchNormals))
{
evalCflFluxFunction_ = new EvalCflFluxFunction(problem);
}
//! Destructor
~FVTransport()
{
delete evalCflFluxFunction_;
evalCflFluxFunction_ = Dune::make_shared<EvalCflFluxFunction>(problem);
}
private:
......@@ -200,7 +194,7 @@ private:
Problem& problem_;
bool switchNormals_;
EvalCflFluxFunction* evalCflFluxFunction_;
Dune::shared_ptr<EvalCflFluxFunction> evalCflFluxFunction_;
};
/*! \brief Calculate the update vector.
......
......@@ -98,7 +98,6 @@ public:
*/
IMPETProblem(TimeManager &timeManager, const GridView &gridView)
: gridView_(gridView),
grid_(0),
bboxMin_(std::numeric_limits<double>::max()),
bboxMax_(-std::numeric_limits<double>::max()),
timeManager_(&timeManager),
......@@ -124,30 +123,18 @@ public:
bboxMax_[i] = gridView.comm().max(bboxMax_[i]);
}
pressModel_ = new PressureModel(asImp_());
pressModel_ = Dune::make_shared<PressureModel>(asImp_());
transportModel_ = new TransportModel(asImp_());
model_ = new IMPETModel(asImp_()) ;
transportModel_ = Dune::make_shared<TransportModel>(asImp_());
model_ = Dune::make_shared<IMPETModel>(asImp_()) ;
// create an Object to handle adaptive grids
if (adaptiveGrid)
gridAdapt_ = new GridAdaptModel(asImp_());
gridAdapt_ = Dune::make_shared<GridAdaptModel>(asImp_());
resultWriter_ = NULL;
vtkOutputLevel_ = GET_PARAM_FROM_GROUP(TypeTag, int, Vtk, OutputLevel);
}
//! destructor
virtual ~IMPETProblem ()
{
delete pressModel_;
delete transportModel_;
delete model_;
delete resultWriter_;
if (adaptiveGrid)
delete gridAdapt_;
}
/*!
* \brief Specifies which kind of boundary condition should be
* used for which equation on a given boundary segment.
......@@ -774,7 +761,7 @@ public:
std::cout << "Writing result file for current time step\n";
if (!resultWriter_)
resultWriter_ = new VtkMultiWriter(gridView_, asImp_().name());
resultWriter_ = Dune::make_shared<VtkMultiWriter>(gridView_, asImp_().name());
if (adaptiveGrid)
resultWriter_->gridChanged();
resultWriter_->beginWrite(timeManager().time() + timeManager().timeStepSize());
......@@ -790,14 +777,14 @@ protected:
VtkMultiWriter& resultWriter()
{
if (!resultWriter_)
resultWriter_ = new VtkMultiWriter(gridView_, asImp_().name());
resultWriter_ = Dune::make_shared<VtkMultiWriter>(gridView_, asImp_().name());
return *resultWriter_;
}
//! \copydoc Dumux::IMPETProblem::resultWriter()
VtkMultiWriter& resultWriter() const
{
if (!resultWriter_)
resultWriter_ = new VtkMultiWriter(gridView_, asImp_().name());
resultWriter_ = Dune::make_shared<VtkMultiWriter>(gridView_, asImp_().name());
return *resultWriter_;
}
......@@ -815,7 +802,7 @@ private:
// for example.
const GridView gridView_;
// pointer to a possibly adaptive grid.
Grid* grid_;
Grid *grid_;
GlobalPosition bboxMin_;
GlobalPosition bboxMax_;
......@@ -824,15 +811,15 @@ private:
Variables variables_;
PressureModel* pressModel_;//!< object including the pressure model
TransportModel* transportModel_;//!< object including the saturation model
IMPETModel* model_;
Dune::shared_ptr<PressureModel> pressModel_;//!< object including the pressure model
Dune::shared_ptr<TransportModel> transportModel_;//!< object including the saturation model
Dune::shared_ptr<IMPETModel> model_;
VtkMultiWriter *resultWriter_;
Dune::shared_ptr<VtkMultiWriter> resultWriter_;
int outputInterval_;
Scalar outputTimeInterval_;
int vtkOutputLevel_;
GridAdaptModel* gridAdapt_;
Dune::shared_ptr<GridAdaptModel> gridAdapt_;
};
}
#endif
......@@ -94,7 +94,6 @@ public:
: gridView_(gridView),
bboxMin_(std::numeric_limits<double>::max()),
bboxMax_(-std::numeric_limits<double>::max()),
deleteTimeManager_(true),
variables_(gridView),
outputInterval_(1)
{
......@@ -108,11 +107,9 @@ public:
}
}
timeManager_ = new TimeManager(verbose);
timeManager_ = Dune::make_shared<TimeManager>(verbose);
model_ = new Model(asImp_()) ;
resultWriter_ = NULL;
model_ = Dune::make_shared<Model>(asImp_()) ;
}
//! Constructs an object of type OneModelProblemProblem
......@@ -125,7 +122,6 @@ public:
bboxMin_(std::numeric_limits<double>::max()),
bboxMax_(-std::numeric_limits<double>::max()),
timeManager_(&timeManager),
deleteTimeManager_(false),
variables_(gridView),
outputInterval_(1)
{
......@@ -139,18 +135,7 @@ public:
}
}
model_ = new Model(asImp_()) ;
resultWriter_ = NULL;
}
//! destructor
virtual ~OneModelProblem ()
{
delete model_;
delete resultWriter_;
if (deleteTimeManager_)
delete timeManager_;
model_ = Dune::make_shared<Model>(asImp_()) ;
}
/*!
......@@ -444,7 +429,7 @@ public:
if (verbose && gridView().comm().rank() == 0)
std::cout << "Writing result file for current time step\n";
if (!resultWriter_)
resultWriter_ = new VtkMultiWriter(gridView(), asImp_().name());
resultWriter_ = Dune::make_shared<VtkMultiWriter>(gridView(), asImp_().name());
resultWriter_->beginWrite(timeManager().time() + timeManager().timeStepSize());
model().addOutputVtkFields(*resultWriter_);
asImp_().addOutputVtkFields();
......@@ -613,14 +598,14 @@ protected:
VtkMultiWriter& resultWriter()
{
if (!resultWriter_)
resultWriter_ = new VtkMultiWriter(gridView_, asImp_().name());
resultWriter_ = Dune::make_shared<VtkMultiWriter>(gridView_, asImp_().name());
return *resultWriter_;
}
VtkMultiWriter& resultWriter() const
{
if (!resultWriter_)
resultWriter_ = new VtkMultiWriter(gridView_, asImp_().name());
resultWriter_ = Dune::make_shared<VtkMultiWriter>(gridView_, asImp_().name());
return *resultWriter_;
}
......@@ -641,14 +626,13 @@ private:
GlobalPosition bboxMin_;
GlobalPosition bboxMax_;
TimeManager *timeManager_;
bool deleteTimeManager_;
Dune::shared_ptr<TimeManager> timeManager_;
Variables variables_;
Model* model_;
Dune::shared_ptr<Model> model_;
VtkMultiWriter *resultWriter_;
Dune::shared_ptr<VtkMultiWriter> resultWriter_;
int outputInterval_;
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment