use finishInit() properly for all problems

this means that all code which could potentially throw an exception is
moved to this method(). (In particular FluidSystem::init() proved
troublesome in the past.) Besides avoiding segmentation the faults
which stem from exceptions thrown in constructors, this also has the
advantage that simulations which spend a noticable amount of time to
initialize stop at the "correct" place, i.e. after the "Finish init of
the problem" message was printed by the simulator...
This commit is contained in:
Andreas Lauser 2014-08-06 16:31:48 +02:00
parent 6ff728565b
commit 2922a8e3a0
18 changed files with 138 additions and 10 deletions

View File

@ -227,7 +227,15 @@ public:
*/
Co2InjectionProblem(Simulator &simulator)
: ParentType(simulator)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
eps_ = 1e-6;
temperatureLow_ = EWOMS_GET_PARAM(TypeTag, Scalar, FluidSystemTemperatureLow);

View File

@ -185,7 +185,15 @@ public:
CuvetteProblem(Simulator &simulator)
: ParentType(simulator)
, eps_(1e-6)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
if (Valgrind::IsRunning())
FluidSystem::init(/*minT=*/283.15, /*maxT=*/500.0, /*nT=*/20,
/*minp=*/0.8e5, /*maxp=*/2e5, /*np=*/10);

View File

@ -170,7 +170,15 @@ public:
*/
DiffusionProblem(Simulator &simulator)
: ParentType(simulator)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
FluidSystem::init();
temperature_ = 273.15 + 20.0;

View File

@ -216,8 +216,11 @@ public:
EclProblem(Simulator &simulator)
: ParentType(simulator)
, wellManager_(simulator)
{}
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();

View File

@ -193,11 +193,7 @@ public:
*/
FingerProblem(Simulator &simulator)
: ParentType(simulator)
{
eps_ = 3e-6;
temperature_ = 273.15 + 20; // -> 20°C
}
{ }
/*!
* \name Auxiliary methods
@ -229,6 +225,10 @@ public:
{
ParentType::finishInit();
eps_ = 3e-6;
temperature_ = 273.15 + 20; // -> 20°C
FluidSystem::init();
// parameters for the Van Genuchten law of the main imbibition

View File

@ -217,7 +217,15 @@ public:
*/
FractureProblem(Simulator &simulator)
: ParentType(simulator)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
eps_ = 3e-6;
temperature_ = 273.15 + 20; // -> 20°C

View File

@ -154,7 +154,15 @@ public:
*/
GroundWaterProblem(Simulator &simulator)
: ParentType(simulator)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
eps_ = 1.0e-3;
lensLowerLeft_[0] = EWOMS_GET_PARAM(TypeTag, Scalar, LensLowerLeftX);

View File

@ -187,7 +187,15 @@ public:
InfiltrationProblem(Simulator &simulator)
: ParentType(simulator)
, eps_(1e-6)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
temperature_ = 273.15 + 10.0; // -> 10 degrees Celsius
FluidSystem::init(/*tempMin=*/temperature_ - 1,
/*tempMax=*/temperature_ + 1,

View File

@ -24,6 +24,8 @@
#ifndef EWOMS_LENS_PROBLEM_HH
#define EWOMS_LENS_PROBLEM_HH
#include <dune/grid/cpgrid/IntersectionMapper.hpp>
#include "lensgridmanager.hh"
#include <ewoms/models/immiscible/immiscibleproperties.hh>
@ -218,7 +220,15 @@ public:
*/
LensProblem(Simulator &simulator)
: ParentType(simulator)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
eps_ = 3e-6;
FluidSystem::init();

View File

@ -175,7 +175,15 @@ public:
*/
ObstacleProblem(Simulator &simulator)
: ParentType(simulator)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
eps_ = 1e-6;
temperature_ = 273.15 + 25; // -> 25°C

View File

@ -134,7 +134,15 @@ public:
OutflowProblem(Simulator &simulator)
: ParentType(simulator)
, eps_(1e-6)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
temperature_ = 273.15 + 20;
FluidSystem::init(/*minT=*/temperature_ - 1, /*maxT=*/temperature_ + 2,
/*numT=*/3,

View File

@ -191,7 +191,15 @@ public:
*/
PowerInjectionProblem(Simulator &simulator)
: ParentType(simulator)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
eps_ = 3e-6;
FluidSystem::init();

View File

@ -172,8 +172,11 @@ public:
*/
ReservoirProblem(Simulator &simulator)
: ParentType(simulator)
{}
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();

View File

@ -181,7 +181,15 @@ public:
RichardsLensProblem(Simulator &simulator)
: ParentType(simulator)
, pnRef_(1e5)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
eps_ = 3e-6;
pnRef_ = 1e5;

View File

@ -124,7 +124,15 @@ public:
*/
Stokes2cTestProblem(Simulator &simulator)
: ParentType(simulator)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
eps_ = 1e-6;
// initialize the tables of the fluid system

View File

@ -137,7 +137,15 @@ public:
*/
StokesNiTestProblem(Simulator &simulator)
: ParentType(simulator)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
eps_ = 1e-6;
// initialize the tables of the fluid system

View File

@ -150,8 +150,7 @@ namespace Ewoms {
* K/m.
*/
template <class TypeTag >
class WaterAirProblem
: public GET_PROP_TYPE(TypeTag, BaseProblem)
class WaterAirProblem : public GET_PROP_TYPE(TypeTag, BaseProblem)
{
typedef typename GET_PROP_TYPE(TypeTag, BaseProblem) ParentType;
@ -209,7 +208,15 @@ public:
*/
WaterAirProblem(Simulator &simulator)
: ParentType(simulator)
{ }
/*!
* \copydoc FvBaseProblem::finishInit
*/
void finishInit()
{
ParentType::finishInit();
maxDepth_ = 1000.0; // [m]
eps_ = 1e-6;

View File

@ -163,11 +163,20 @@ class Tutorial1Problem
enum { contiNonWettingEqIdx = Indices::conti0EqIdx + nonWettingPhaseIdx };
public:
//! The constructor of the problem
//! The constructor of the problem. This only _allocates_ the memory required by the
//! problem. The constructor is supposed to _never ever_ throw an exception.
Tutorial1Problem(Simulator &simulator)
: ParentType(simulator)
, eps_(3e-6)
{ }
//! This method initializes the data structures allocated by the problem
//! constructor. In contrast to the constructor, exceptions thrown from within this
//! method won't lead to segmentation faults.
void finishInit()
{
ParentType::finishInit();
// Use an isotropic and homogeneous intrinsic permeability
K_ = this->toDimMatrix_(1e-7);