mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
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:
parent
6ff728565b
commit
2922a8e3a0
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -170,7 +170,15 @@ public:
|
||||
*/
|
||||
DiffusionProblem(Simulator &simulator)
|
||||
: ParentType(simulator)
|
||||
{ }
|
||||
|
||||
/*!
|
||||
* \copydoc FvBaseProblem::finishInit
|
||||
*/
|
||||
void finishInit()
|
||||
{
|
||||
ParentType::finishInit();
|
||||
|
||||
FluidSystem::init();
|
||||
|
||||
temperature_ = 273.15 + 20.0;
|
||||
|
@ -216,8 +216,11 @@ public:
|
||||
EclProblem(Simulator &simulator)
|
||||
: ParentType(simulator)
|
||||
, wellManager_(simulator)
|
||||
{}
|
||||
{ }
|
||||
|
||||
/*!
|
||||
* \copydoc FvBaseProblem::finishInit
|
||||
*/
|
||||
void finishInit()
|
||||
{
|
||||
ParentType::finishInit();
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
|
@ -191,7 +191,15 @@ public:
|
||||
*/
|
||||
PowerInjectionProblem(Simulator &simulator)
|
||||
: ParentType(simulator)
|
||||
{ }
|
||||
|
||||
/*!
|
||||
* \copydoc FvBaseProblem::finishInit
|
||||
*/
|
||||
void finishInit()
|
||||
{
|
||||
ParentType::finishInit();
|
||||
|
||||
eps_ = 3e-6;
|
||||
FluidSystem::init();
|
||||
|
||||
|
@ -172,8 +172,11 @@ public:
|
||||
*/
|
||||
ReservoirProblem(Simulator &simulator)
|
||||
: ParentType(simulator)
|
||||
{}
|
||||
{ }
|
||||
|
||||
/*!
|
||||
* \copydoc FvBaseProblem::finishInit
|
||||
*/
|
||||
void finishInit()
|
||||
{
|
||||
ParentType::finishInit();
|
||||
|
@ -181,7 +181,15 @@ public:
|
||||
RichardsLensProblem(Simulator &simulator)
|
||||
: ParentType(simulator)
|
||||
, pnRef_(1e5)
|
||||
{ }
|
||||
|
||||
/*!
|
||||
* \copydoc FvBaseProblem::finishInit
|
||||
*/
|
||||
void finishInit()
|
||||
{
|
||||
ParentType::finishInit();
|
||||
|
||||
eps_ = 3e-6;
|
||||
pnRef_ = 1e5;
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user