mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #212 from dr-robertk/master
separat solver parameters
This commit is contained in:
commit
3c97fa0d64
@ -52,19 +52,40 @@ namespace Opm {
|
|||||||
class FullyImplicitBlackoilSolver
|
class FullyImplicitBlackoilSolver
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
// the Newton relaxation type
|
||||||
|
enum RelaxType { DAMPEN, SOR };
|
||||||
|
|
||||||
|
// class holding the solver parameters
|
||||||
|
struct SolverParameter
|
||||||
|
{
|
||||||
|
double dp_max_rel_;
|
||||||
|
double ds_max_;
|
||||||
|
double drs_max_rel_;
|
||||||
|
enum RelaxType relax_type_;
|
||||||
|
double relax_max_;
|
||||||
|
double relax_increment_;
|
||||||
|
double relax_rel_tol_;
|
||||||
|
int max_iter_;
|
||||||
|
|
||||||
|
SolverParameter( const parameter::ParameterGroup& param );
|
||||||
|
SolverParameter();
|
||||||
|
|
||||||
|
void reset();
|
||||||
|
};
|
||||||
|
|
||||||
/// \brief The type of the grid that we use.
|
/// \brief The type of the grid that we use.
|
||||||
typedef T Grid;
|
typedef T Grid;
|
||||||
/// Construct a solver. It will retain references to the
|
/// Construct a solver. It will retain references to the
|
||||||
/// arguments of this functions, and they are expected to
|
/// arguments of this functions, and they are expected to
|
||||||
/// remain in scope for the lifetime of the solver.
|
/// remain in scope for the lifetime of the solver.
|
||||||
/// \param[in] param parameters
|
/// \param[in] param parameters
|
||||||
/// \param[in] grid grid data structure
|
/// \param[in] grid grid data structure
|
||||||
/// \param[in] fluid fluid properties
|
/// \param[in] fluid fluid properties
|
||||||
/// \param[in] geo rock properties
|
/// \param[in] geo rock properties
|
||||||
/// \param[in] rock_comp_props if non-null, rock compressibility properties
|
/// \param[in] rock_comp_props if non-null, rock compressibility properties
|
||||||
/// \param[in] wells well structure
|
/// \param[in] wells well structure
|
||||||
/// \param[in] linsolver linear solver
|
/// \param[in] linsolver linear solver
|
||||||
FullyImplicitBlackoilSolver(const parameter::ParameterGroup& param,
|
FullyImplicitBlackoilSolver(const SolverParameter& param,
|
||||||
const Grid& grid ,
|
const Grid& grid ,
|
||||||
const BlackoilPropsAdInterface& fluid,
|
const BlackoilPropsAdInterface& fluid,
|
||||||
const DerivedGeology& geo ,
|
const DerivedGeology& geo ,
|
||||||
@ -137,8 +158,6 @@ namespace Opm {
|
|||||||
Oil = BlackoilPropsAdInterface::Oil ,
|
Oil = BlackoilPropsAdInterface::Oil ,
|
||||||
Gas = BlackoilPropsAdInterface::Gas };
|
Gas = BlackoilPropsAdInterface::Gas };
|
||||||
|
|
||||||
// the Newton relaxation type
|
|
||||||
enum RelaxType { DAMPEN, SOR };
|
|
||||||
enum PrimalVariables { Sg = 0, RS = 1, RV = 2 };
|
enum PrimalVariables { Sg = 0, RS = 1, RV = 2 };
|
||||||
|
|
||||||
// Member data
|
// Member data
|
||||||
@ -157,14 +176,8 @@ namespace Opm {
|
|||||||
const WellOps wops_;
|
const WellOps wops_;
|
||||||
const bool has_disgas_;
|
const bool has_disgas_;
|
||||||
const bool has_vapoil_;
|
const bool has_vapoil_;
|
||||||
double dp_max_rel_;
|
|
||||||
double ds_max_;
|
SolverParameter param_;
|
||||||
double drs_max_rel_;
|
|
||||||
enum RelaxType relax_type_;
|
|
||||||
double relax_max_;
|
|
||||||
double relax_increment_;
|
|
||||||
double relax_rel_tol_;
|
|
||||||
int max_iter_;
|
|
||||||
bool use_threshold_pressure_;
|
bool use_threshold_pressure_;
|
||||||
V threshold_pressures_by_interior_face_;
|
V threshold_pressures_by_interior_face_;
|
||||||
|
|
||||||
@ -322,14 +335,14 @@ namespace Opm {
|
|||||||
|
|
||||||
void stablizeNewton(V& dx, V& dxOld, const double omega, const RelaxType relax_type) const;
|
void stablizeNewton(V& dx, V& dxOld, const double omega, const RelaxType relax_type) const;
|
||||||
|
|
||||||
double dpMaxRel() const { return dp_max_rel_; }
|
double dpMaxRel() const { return param_.dp_max_rel_; }
|
||||||
double dsMax() const { return ds_max_; }
|
double dsMax() const { return param_.ds_max_; }
|
||||||
double drsMaxRel() const { return drs_max_rel_; }
|
double drsMaxRel() const { return param_.drs_max_rel_; }
|
||||||
enum RelaxType relaxType() const { return relax_type_; }
|
enum RelaxType relaxType() const { return param_.relax_type_; }
|
||||||
double relaxMax() const { return relax_max_; };
|
double relaxMax() const { return param_.relax_max_; };
|
||||||
double relaxIncrement() const { return relax_increment_; };
|
double relaxIncrement() const { return param_.relax_increment_; };
|
||||||
double relaxRelTol() const { return relax_rel_tol_; };
|
double relaxRelTol() const { return param_.relax_rel_tol_; };
|
||||||
double maxIter() const { return max_iter_; }
|
double maxIter() const { return param_.max_iter_; }
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
@ -156,11 +156,57 @@ namespace {
|
|||||||
|
|
||||||
} // Anonymous namespace
|
} // Anonymous namespace
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
void FullyImplicitBlackoilSolver<T>::SolverParameter::
|
||||||
|
reset()
|
||||||
|
{
|
||||||
|
// default values for the solver parameters
|
||||||
|
dp_max_rel_ = 1.0e9;
|
||||||
|
ds_max_ = 0.2;
|
||||||
|
drs_max_rel_ = 1.0e9;
|
||||||
|
relax_type_ = DAMPEN;
|
||||||
|
relax_max_ = 0.5;
|
||||||
|
relax_increment_ = 0.1;
|
||||||
|
relax_rel_tol_ = 0.2;
|
||||||
|
max_iter_ = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
FullyImplicitBlackoilSolver<T>::SolverParameter::
|
||||||
|
SolverParameter()
|
||||||
|
{
|
||||||
|
// set default values
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
FullyImplicitBlackoilSolver<T>::SolverParameter::
|
||||||
|
SolverParameter( const parameter::ParameterGroup& param )
|
||||||
|
{
|
||||||
|
// set default values
|
||||||
|
reset();
|
||||||
|
|
||||||
|
// overload with given parameters
|
||||||
|
dp_max_rel_ = param.getDefault("dp_max_rel", dp_max_rel_);
|
||||||
|
ds_max_ = param.getDefault("ds_max", ds_max_);
|
||||||
|
drs_max_rel_ = param.getDefault("drs_max_rel", drs_max_rel_);
|
||||||
|
relax_max_ = param.getDefault("relax_max", relax_max_);
|
||||||
|
max_iter_ = param.getDefault("max_iter", max_iter_);
|
||||||
|
|
||||||
|
std::string relaxation_type = param.getDefault("relax_type", std::string("dampen"));
|
||||||
|
if (relaxation_type == "dampen") {
|
||||||
|
relax_type_ = DAMPEN;
|
||||||
|
} else if (relaxation_type == "sor") {
|
||||||
|
relax_type_ = SOR;
|
||||||
|
} else {
|
||||||
|
OPM_THROW(std::runtime_error, "Unknown Relaxtion Type " << relaxation_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
FullyImplicitBlackoilSolver<T>::
|
FullyImplicitBlackoilSolver<T>::
|
||||||
FullyImplicitBlackoilSolver(const parameter::ParameterGroup& param,
|
FullyImplicitBlackoilSolver(const SolverParameter& param,
|
||||||
const Grid& grid ,
|
const Grid& grid ,
|
||||||
const BlackoilPropsAdInterface& fluid,
|
const BlackoilPropsAdInterface& fluid,
|
||||||
const DerivedGeology& geo ,
|
const DerivedGeology& geo ,
|
||||||
@ -182,14 +228,7 @@ namespace {
|
|||||||
, wops_ (wells)
|
, wops_ (wells)
|
||||||
, has_disgas_(has_disgas)
|
, has_disgas_(has_disgas)
|
||||||
, has_vapoil_(has_vapoil)
|
, has_vapoil_(has_vapoil)
|
||||||
, dp_max_rel_ (1.0e9)
|
, param_( param )
|
||||||
, ds_max_ (0.2)
|
|
||||||
, drs_max_rel_ (1.0e9)
|
|
||||||
, relax_type_ (DAMPEN)
|
|
||||||
, relax_max_ (0.5)
|
|
||||||
, relax_increment_ (0.1)
|
|
||||||
, relax_rel_tol_ (0.2)
|
|
||||||
, max_iter_ (15)
|
|
||||||
, use_threshold_pressure_(false)
|
, use_threshold_pressure_(false)
|
||||||
, rq_ (fluid.numPhases())
|
, rq_ (fluid.numPhases())
|
||||||
, phaseCondition_(AutoDiffGrid::numCells(grid))
|
, phaseCondition_(AutoDiffGrid::numCells(grid))
|
||||||
@ -197,20 +236,6 @@ namespace {
|
|||||||
ADB::null(),
|
ADB::null(),
|
||||||
ADB::null() } )
|
ADB::null() } )
|
||||||
{
|
{
|
||||||
dp_max_rel_ = param.getDefault("dp_max_rel", dp_max_rel_);
|
|
||||||
ds_max_ = param.getDefault("ds_max", ds_max_);
|
|
||||||
drs_max_rel_ = param.getDefault("drs_max_rel", drs_max_rel_);
|
|
||||||
relax_max_ = param.getDefault("relax_max", relax_max_);
|
|
||||||
max_iter_ = param.getDefault("max_iter", max_iter_);
|
|
||||||
|
|
||||||
std::string relaxation_type = param.getDefault("relax_type", std::string("dampen"));
|
|
||||||
if (relaxation_type == "dampen") {
|
|
||||||
relax_type_ = DAMPEN;
|
|
||||||
} else if (relaxation_type == "sor") {
|
|
||||||
relax_type_ = SOR;
|
|
||||||
} else {
|
|
||||||
OPM_THROW(std::runtime_error, "Unknown Relaxtion Type " << relaxation_type);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -291,6 +291,8 @@ namespace Opm
|
|||||||
std::string tstep_filename = output_dir_ + "/step_timing.txt";
|
std::string tstep_filename = output_dir_ + "/step_timing.txt";
|
||||||
std::ofstream tstep_os(tstep_filename.c_str());
|
std::ofstream tstep_os(tstep_filename.c_str());
|
||||||
|
|
||||||
|
typename FullyImplicitBlackoilSolver<T>::SolverParameter solverParam( param_ );
|
||||||
|
|
||||||
// Main simulation loop.
|
// Main simulation loop.
|
||||||
while (!timer.done()) {
|
while (!timer.done()) {
|
||||||
// Report timestep.
|
// Report timestep.
|
||||||
@ -340,7 +342,7 @@ namespace Opm
|
|||||||
|
|
||||||
// Run a single step of the solver.
|
// Run a single step of the solver.
|
||||||
solver_timer.start();
|
solver_timer.start();
|
||||||
FullyImplicitBlackoilSolver<T> solver(param_, grid_, props_, geo_, rock_comp_props_, *wells, solver_, has_disgas_, has_vapoil_);
|
FullyImplicitBlackoilSolver<T> solver(solverParam, grid_, props_, geo_, rock_comp_props_, *wells, solver_, has_disgas_, has_vapoil_);
|
||||||
if (!threshold_pressures_by_face_.empty()) {
|
if (!threshold_pressures_by_face_.empty()) {
|
||||||
solver.setThresholdPressures(threshold_pressures_by_face_);
|
solver.setThresholdPressures(threshold_pressures_by_face_);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user