mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
flow: switch it to use the eWoms parameter system
this has several advanges: - a consistent and complete help message is now printed by passing the -h or --help command line parameters. most notably this allows to generically implement tab completion of parameters for bash - the full list of runtime parameters can now be printed before the simulator has been run. - all runtime parameters understood by ebos can be specified - no hacks to marry the two parameter systems anymore - command parameters now follow the standard unix convention, i.e., `--param-name=value` instead of `param_name=value` on the negative side, some parameters have been renamed and the syntax has changed so calls to `flow` that specify parameters must adapted.
This commit is contained in:
parent
976ab03f68
commit
b5cddef928
@ -275,6 +275,7 @@ list (APPEND PUBLIC_HEADER_FILES
|
||||
opm/autodiff/BlackoilModelBase_impl.hpp
|
||||
opm/autodiff/BlackoilModelEnums.hpp
|
||||
opm/autodiff/BlackoilModelParameters.hpp
|
||||
opm/autodiff/BlackoilModelParametersEbos.hpp
|
||||
opm/autodiff/BlackoilPressureModel.hpp
|
||||
opm/autodiff/BlackoilPropsAdFromDeck.hpp
|
||||
opm/autodiff/Compat.hpp
|
||||
|
@ -218,14 +218,19 @@ add_test_compareECLFiles(CASENAME ctaquifer_2d_oilwater
|
||||
REL_TOL ${rel_tol}
|
||||
DIR aquifer-oilwater)
|
||||
|
||||
foreach(SIM flow flow_legacy)
|
||||
add_test_compareECLFiles(CASENAME spe3
|
||||
FILENAME SPE3CASE1
|
||||
SIMULATOR ${SIM}
|
||||
ABS_TOL ${abs_tol}
|
||||
REL_TOL ${coarse_rel_tol}
|
||||
TEST_ARGS tolerance_wells=1e-6 max_iter=20)
|
||||
endforeach()
|
||||
add_test_compareECLFiles(CASENAME spe3
|
||||
FILENAME SPE3CASE1
|
||||
SIMULATOR flow
|
||||
ABS_TOL ${abs_tol}
|
||||
REL_TOL ${coarse_rel_tol}
|
||||
TEST_ARGS --flow-tolerance-wells=1e-6 --flow-newton-max-iterations=20)
|
||||
|
||||
add_test_compareECLFiles(CASENAME spe3
|
||||
FILENAME SPE3CASE1
|
||||
SIMULATOR flow_legacy
|
||||
ABS_TOL ${abs_tol}
|
||||
REL_TOL ${coarse_rel_tol}
|
||||
TEST_ARGS tolerance_wells=1e-6 max_iter=20)
|
||||
|
||||
foreach(SIM flow flow_legacy)
|
||||
add_test_compareECLFiles(CASENAME spe9
|
||||
@ -246,14 +251,14 @@ add_test_compareECLFiles(CASENAME msw_2d_h
|
||||
SIMULATOR flow
|
||||
ABS_TOL ${abs_tol}
|
||||
REL_TOL ${coarse_rel_tol}
|
||||
TEST_ARGS use_multisegment_well=true)
|
||||
TEST_ARGS --flow-use-multisegment-well=true)
|
||||
|
||||
add_test_compareECLFiles(CASENAME msw_3d_hfa
|
||||
FILENAME 3D_MSW
|
||||
SIMULATOR flow
|
||||
ABS_TOL ${abs_tol}
|
||||
REL_TOL ${rel_tol}
|
||||
TEST_ARGS use_multisegment_well=true)
|
||||
TEST_ARGS --flow-use-multisegment-well=true)
|
||||
|
||||
add_test_compareECLFiles(CASENAME polymer_oilwater
|
||||
FILENAME 2D_OILWATER_POLYMER
|
||||
@ -267,14 +272,14 @@ add_test_compareECLFiles(CASENAME polymer_simple2D
|
||||
SIMULATOR flow
|
||||
ABS_TOL ${abs_tol}
|
||||
REL_TOL ${coarse_rel_tol}
|
||||
TEST_ARGS max_iter=20)
|
||||
TEST_ARGS --flow-newton-max-iterations=20)
|
||||
|
||||
add_test_compareECLFiles(CASENAME spe5
|
||||
FILENAME SPE5CASE1
|
||||
SIMULATOR flow
|
||||
ABS_TOL ${abs_tol}
|
||||
REL_TOL ${coarse_rel_tol}
|
||||
TEST_ARGS max_iter=20)
|
||||
TEST_ARGS --flow-newton-max-iterations=20)
|
||||
|
||||
add_test_compareECLFiles(CASENAME wecon_wtest
|
||||
FILENAME 3D_WECON
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include <opm/simulators/flow_ebos_energy.hpp>
|
||||
#include <opm/simulators/flow_ebos_oilwater_polymer.hpp>
|
||||
|
||||
#include <opm/autodiff/SimulatorFullyImplicitBlackoilEbos.hpp>
|
||||
#include <opm/autodiff/FlowMainEbos.hpp>
|
||||
#include <ewoms/common/propertysystem.hh>
|
||||
#include <ewoms/common/parametersystem.hh>
|
||||
#include <opm/autodiff/MissingFeatures.hpp>
|
||||
#include <opm/common/utility/parameters/ParameterGroup.hpp>
|
||||
#include <opm/material/common/ResetLocale.hpp>
|
||||
@ -43,6 +47,14 @@
|
||||
#include <dune/common/parallel/mpihelper.hh>
|
||||
#endif
|
||||
|
||||
BEGIN_PROPERTIES
|
||||
|
||||
// this is a dummy type tag that is used to setup the parameters before the actual
|
||||
// simulator.
|
||||
NEW_TYPE_TAG(FlowEarlyBird, INHERITS_FROM(EclFlowProblem));
|
||||
|
||||
END_PROPERTIES
|
||||
|
||||
namespace detail
|
||||
{
|
||||
boost::filesystem::path simulationCaseName( const std::string& casename ) {
|
||||
@ -96,32 +108,20 @@ int main(int argc, char** argv)
|
||||
// with incorrect locale settings.
|
||||
Opm::resetLocale();
|
||||
|
||||
Opm::ParameterGroup param(argc, argv, false, outputCout);
|
||||
// this is a work-around for a catch 22: we do not know what code path to use without
|
||||
// parsing the deck, but we don't know the deck without having access to the
|
||||
// parameters and this requires to know the type tag to be used. To solve this, we
|
||||
// use a type tag just for parsing the parameters before we instantiate the actual
|
||||
// simulator object. (Which parses the parameters again, but since this is done in an
|
||||
// identical manner it does not matter.)
|
||||
typedef TTAG(FlowEarlyBird) PreTypeTag;
|
||||
int status = Opm::FlowMainEbos<PreTypeTag>::setupParameters_(argc, argv);
|
||||
if (status != 0)
|
||||
return status;
|
||||
|
||||
// See if a deck was specified on the command line.
|
||||
if (!param.unhandledArguments().empty()) {
|
||||
if (param.unhandledArguments().size() != 1) {
|
||||
if (outputCout)
|
||||
std::cerr << "You can only specify a single input deck on the command line.\n";
|
||||
return EXIT_FAILURE;
|
||||
} else {
|
||||
const auto casename = detail::simulationCaseName( param.unhandledArguments()[ 0 ] );
|
||||
param.insertParameter("deck_filename", casename.string() );
|
||||
}
|
||||
}
|
||||
|
||||
// We must have an input deck. Grid and props will be read from that.
|
||||
if (!param.has("deck_filename")) {
|
||||
if (outputCout)
|
||||
std::cerr << "This program must be run with an input deck.\n"
|
||||
"Specify the deck filename either\n"
|
||||
" a) as a command line argument by itself\n"
|
||||
" b) as a command line parameter with the syntax deck_filename=<path to your deck>, or\n"
|
||||
" c) as a parameter in a parameter file (.param or .xml) passed to the program.\n";
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
std::string deckFilename = param.get<std::string>("deck_filename");
|
||||
std::string deckFilename = EWOMS_GET_PARAM(PreTypeTag, std::string, EclDeckFileName);
|
||||
typedef typename GET_PROP_TYPE(PreTypeTag, Vanguard) PreVanguard;
|
||||
deckFilename = PreVanguard::canonicalDeckPath(deckFilename).string();
|
||||
|
||||
// Create Deck and EclipseState.
|
||||
try {
|
||||
|
@ -27,7 +27,10 @@
|
||||
#include <ebos/eclproblem.hh>
|
||||
#include <ewoms/common/start.hh>
|
||||
|
||||
#include <opm/autodiff/BlackoilModelParameters.hpp>
|
||||
#include <opm/simulators/timestepping/AdaptiveTimeSteppingEbos.hpp>
|
||||
|
||||
#include <opm/autodiff/NonlinearSolverEbos.hpp>
|
||||
#include <opm/autodiff/BlackoilModelParametersEbos.hpp>
|
||||
#include <opm/autodiff/BlackoilWellModel.hpp>
|
||||
#include <opm/autodiff/BlackoilAquiferModel.hpp>
|
||||
#include <opm/autodiff/WellConnectionAuxiliaryModule.hpp>
|
||||
@ -65,10 +68,9 @@
|
||||
//#include <fstream>
|
||||
|
||||
|
||||
BEGIN_PROPERTIES
|
||||
|
||||
namespace Ewoms {
|
||||
namespace Properties {
|
||||
NEW_TYPE_TAG(EclFlowProblem, INHERITS_FROM(BlackOilModel, EclBaseProblem));
|
||||
NEW_TYPE_TAG(EclFlowProblem, INHERITS_FROM(BlackOilModel, EclBaseProblem, FlowNonLinearSolver, FlowIstlSolver, FlowModelParameters, FlowTimeSteppingParameters));
|
||||
SET_STRING_PROP(EclFlowProblem, OutputDir, "");
|
||||
SET_BOOL_PROP(EclFlowProblem, DisableWells, true);
|
||||
SET_BOOL_PROP(EclFlowProblem, EnableDebuggingChecks, false);
|
||||
@ -82,7 +84,8 @@ SET_BOOL_PROP(EclFlowProblem, EnablePolymer, false);
|
||||
SET_BOOL_PROP(EclFlowProblem, EnableSolvent, false);
|
||||
SET_BOOL_PROP(EclFlowProblem, EnableTemperature, true);
|
||||
SET_BOOL_PROP(EclFlowProblem, EnableEnergy, false);
|
||||
}}
|
||||
|
||||
END_PROPERTIES
|
||||
|
||||
namespace Opm {
|
||||
/// A model implementation for three-phase black oil.
|
||||
@ -98,7 +101,7 @@ namespace Opm {
|
||||
// --------- Types and enums ---------
|
||||
typedef BlackoilState ReservoirState;
|
||||
typedef WellStateFullyImplicitBlackoil WellState;
|
||||
typedef BlackoilModelParameters ModelParameters;
|
||||
typedef BlackoilModelParametersEbos<TypeTag> ModelParameters;
|
||||
|
||||
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
|
||||
|
229
opm/autodiff/BlackoilModelParametersEbos.hpp
Normal file
229
opm/autodiff/BlackoilModelParametersEbos.hpp
Normal file
@ -0,0 +1,229 @@
|
||||
/*
|
||||
Copyright 2015 SINTEF ICT, Applied Mathematics.
|
||||
|
||||
This file is part of the Open Porous Media project (OPM).
|
||||
|
||||
OPM is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OPM is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_BLACKOILMODELPARAMETERS_EBOS_HEADER_INCLUDED
|
||||
#define OPM_BLACKOILMODELPARAMETERS_EBOS_HEADER_INCLUDED
|
||||
|
||||
#include <ewoms/common/propertysystem.hh>
|
||||
#include <ewoms/common/parametersystem.hh>
|
||||
|
||||
#include <string>
|
||||
|
||||
BEGIN_PROPERTIES
|
||||
|
||||
NEW_TYPE_TAG(FlowModelParameters);
|
||||
|
||||
NEW_PROP_TAG(Scalar);
|
||||
NEW_PROP_TAG(EclDeckFileName);
|
||||
|
||||
NEW_PROP_TAG(FlowDpMaxRel);
|
||||
NEW_PROP_TAG(FlowDsMax);
|
||||
NEW_PROP_TAG(FlowDrMaxRel);
|
||||
NEW_PROP_TAG(FlowDbphMaxRel);
|
||||
NEW_PROP_TAG(FlowDWellFractionMax);
|
||||
NEW_PROP_TAG(FlowMaxResidualAllowed);
|
||||
NEW_PROP_TAG(FlowToleranceMb);
|
||||
NEW_PROP_TAG(FlowToleranceCnv);
|
||||
NEW_PROP_TAG(FlowToleranceCnvRelaxed);
|
||||
NEW_PROP_TAG(FlowToleranceWells);
|
||||
NEW_PROP_TAG(FlowToleranceWellControl);
|
||||
NEW_PROP_TAG(FlowMaxWelleqIter);
|
||||
NEW_PROP_TAG(FlowUseMultisegmentWell);
|
||||
NEW_PROP_TAG(FlowMaxSinglePrecisionDays);
|
||||
NEW_PROP_TAG(FlowMaxStrictIter);
|
||||
NEW_PROP_TAG(FlowSolveWelleqInitially);
|
||||
NEW_PROP_TAG(FlowUpdateEquationsScaling);
|
||||
NEW_PROP_TAG(FlowUseUpdateStabilization);
|
||||
NEW_PROP_TAG(FlowMatrixAddWellContributions);
|
||||
NEW_PROP_TAG(FlowPreconditionerAddWellContributions);
|
||||
|
||||
// parameters for multisegment wells
|
||||
NEW_PROP_TAG(FlowTolerancePressureMsWells);
|
||||
NEW_PROP_TAG(FlowMaxPressureChangeMsWells);
|
||||
NEW_PROP_TAG(FlowUseInnerIterationsMsWells);
|
||||
NEW_PROP_TAG(FlowMaxInnerIterMsWells);
|
||||
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowDpMaxRel, 0.3);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowDsMax, 0.2);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowDrMaxRel, 1e9);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowDbphMaxRel, 1.0);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowDWellFractionMax, 0.2);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowMaxResidualAllowed, 1e7);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowToleranceMb, 1e-5);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowToleranceCnv,1e-2);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowToleranceCnvRelaxed, 1e9);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowToleranceWells, 1e-4);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowToleranceWellControl, 1e-7);
|
||||
SET_INT_PROP(FlowModelParameters, FlowMaxWelleqIter, 15);
|
||||
SET_BOOL_PROP(FlowModelParameters, FlowUseMultisegmentWell, false);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowMaxSinglePrecisionDays, 20.0);
|
||||
SET_INT_PROP(FlowModelParameters, FlowMaxStrictIter, 8);
|
||||
SET_BOOL_PROP(FlowModelParameters, FlowSolveWelleqInitially, true);
|
||||
SET_BOOL_PROP(FlowModelParameters, FlowUpdateEquationsScaling, false);
|
||||
SET_BOOL_PROP(FlowModelParameters, FlowUseUpdateStabilization, true);
|
||||
SET_BOOL_PROP(FlowModelParameters, FlowMatrixAddWellContributions, false);
|
||||
SET_BOOL_PROP(FlowModelParameters, FlowPreconditionerAddWellContributions, false);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowTolerancePressureMsWells, 0.01 *1e5);
|
||||
SET_SCALAR_PROP(FlowModelParameters, FlowMaxPressureChangeMsWells, 2.0 *1e5);
|
||||
SET_BOOL_PROP(FlowModelParameters, FlowUseInnerIterationsMsWells, true);
|
||||
SET_INT_PROP(FlowModelParameters, FlowMaxInnerIterMsWells, 10);
|
||||
|
||||
END_PROPERTIES
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
/// Solver parameters for the BlackoilModel.
|
||||
template <class TypeTag>
|
||||
struct BlackoilModelParametersEbos
|
||||
{
|
||||
private:
|
||||
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
|
||||
|
||||
public:
|
||||
/// Max relative change in pressure in single iteration.
|
||||
double dp_max_rel_;
|
||||
/// Max absolute change in saturation in single iteration.
|
||||
double ds_max_;
|
||||
/// Max relative change in gas-oil or oil-gas ratio in single iteration.
|
||||
double dr_max_rel_;
|
||||
/// Max relative change in bhp in single iteration.
|
||||
double dbhp_max_rel_;
|
||||
/// Max absolute change in well volume fraction in single iteration.
|
||||
double dwell_fraction_max_;
|
||||
/// Absolute max limit for residuals.
|
||||
double max_residual_allowed_;
|
||||
/// Relative mass balance tolerance (total mass balance error).
|
||||
double tolerance_mb_;
|
||||
/// Local convergence tolerance (max of local saturation errors).
|
||||
double tolerance_cnv_;
|
||||
/// Relaxed local convergence tolerance (used when iter >= max_strict_iter_).
|
||||
double tolerance_cnv_relaxed_;
|
||||
/// Well convergence tolerance.
|
||||
double tolerance_wells_;
|
||||
/// Tolerance for the well control equations
|
||||
// TODO: it might need to distinguish between rate control and pressure control later
|
||||
double tolerance_well_control_;
|
||||
/// Tolerance for the pressure equations for multisegment wells
|
||||
double tolerance_pressure_ms_wells_;
|
||||
/// Maximum pressure change over an iteratio for ms wells
|
||||
double max_pressure_change_ms_wells_;
|
||||
|
||||
/// Whether to use inner iterations for ms wells
|
||||
bool use_inner_iterations_ms_wells_;
|
||||
|
||||
/// Maximum inner iteration number for ms wells
|
||||
int max_inner_iter_ms_wells_;
|
||||
|
||||
/// Maximum iteration number of the well equation solution
|
||||
int max_welleq_iter_;
|
||||
|
||||
/// Tolerance for time step in seconds where single precision can be used
|
||||
/// for solving for the Jacobian
|
||||
double maxSinglePrecisionTimeStep_;
|
||||
|
||||
/// Maximum number of Newton iterations before we give up on the CNV convergence criterion
|
||||
int max_strict_iter_;
|
||||
|
||||
/// Solve well equation initially
|
||||
bool solve_welleq_initially_;
|
||||
|
||||
/// Update scaling factors for mass balance equations
|
||||
bool update_equations_scaling_;
|
||||
|
||||
/// Try to detect oscillation or stagnation.
|
||||
bool use_update_stabilization_;
|
||||
|
||||
/// Whether to use MultisegmentWell to handle multisegment wells
|
||||
/// it is something temporary before the multisegment well model is considered to be
|
||||
/// well developed and tested.
|
||||
/// if it is false, we will handle multisegment wells as standard wells, which will be
|
||||
/// the default behavoir for the moment. Later, we might set it to be true by default if necessary
|
||||
bool use_multisegment_well_;
|
||||
|
||||
/// The file name of the deck
|
||||
std::string deck_file_name_;
|
||||
|
||||
// Whether to add influences of wells between cells to the matrix and preconditioner matrix
|
||||
bool matrix_add_well_contributions_;
|
||||
|
||||
// Whether to add influences of wells between cells to the preconditioner matrix only
|
||||
bool preconditioner_add_well_contributions_;
|
||||
|
||||
/// Construct from user parameters or defaults.
|
||||
BlackoilModelParametersEbos()
|
||||
{
|
||||
dp_max_rel_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowDpMaxRel);
|
||||
ds_max_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowDsMax);
|
||||
dr_max_rel_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowDrMaxRel);
|
||||
dbhp_max_rel_= EWOMS_GET_PARAM(TypeTag, Scalar, FlowDbphMaxRel);
|
||||
dwell_fraction_max_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowDWellFractionMax);
|
||||
max_residual_allowed_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowMaxResidualAllowed);
|
||||
tolerance_mb_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowToleranceMb);
|
||||
tolerance_cnv_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowToleranceCnv);
|
||||
tolerance_cnv_relaxed_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowToleranceCnvRelaxed);
|
||||
tolerance_wells_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowToleranceWells);
|
||||
tolerance_well_control_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowToleranceWellControl);
|
||||
max_welleq_iter_ = EWOMS_GET_PARAM(TypeTag, int, FlowMaxWelleqIter);
|
||||
use_multisegment_well_ = EWOMS_GET_PARAM(TypeTag, bool, FlowUseMultisegmentWell);
|
||||
tolerance_pressure_ms_wells_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowTolerancePressureMsWells);
|
||||
max_pressure_change_ms_wells_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowMaxPressureChangeMsWells);
|
||||
use_inner_iterations_ms_wells_ = EWOMS_GET_PARAM(TypeTag, bool, FlowUseInnerIterationsMsWells);
|
||||
max_inner_iter_ms_wells_ = EWOMS_GET_PARAM(TypeTag, int, FlowMaxInnerIterMsWells);
|
||||
maxSinglePrecisionTimeStep_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowMaxSinglePrecisionDays) *24*60*60;
|
||||
max_strict_iter_ = EWOMS_GET_PARAM(TypeTag, int, FlowMaxStrictIter);
|
||||
solve_welleq_initially_ = EWOMS_GET_PARAM(TypeTag, bool, FlowSolveWelleqInitially);
|
||||
update_equations_scaling_ = EWOMS_GET_PARAM(TypeTag, bool, FlowUpdateEquationsScaling);
|
||||
use_update_stabilization_ = EWOMS_GET_PARAM(TypeTag, bool, FlowUseUpdateStabilization);
|
||||
matrix_add_well_contributions_ = EWOMS_GET_PARAM(TypeTag, bool, FlowMatrixAddWellContributions);
|
||||
preconditioner_add_well_contributions_ = EWOMS_GET_PARAM(TypeTag, bool, FlowPreconditionerAddWellContributions);
|
||||
|
||||
deck_file_name_ = EWOMS_GET_PARAM(TypeTag, std::string, EclDeckFileName);
|
||||
}
|
||||
|
||||
static void registerParameters()
|
||||
{
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowDpMaxRel, "Maximum relative change of pressure in a single iteration");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowDsMax, "Maximum absolute change of any saturation in a single iteration");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowDrMaxRel, "Maximum relative change of the gas-in-oil or oil-in-gas ratio in a single iteration");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowDbphMaxRel, "Maximum relative change of the bottom-hole pressure in a single iteration");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowDWellFractionMax, "Maximum absolute change of a well's volume fraction in a single iteration");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowMaxResidualAllowed, "Absolute maximum tolerated for residuals without cutting the time step size");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowToleranceMb, "Tolerated mass balance error relative to total mass present");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowToleranceCnv, "Local convergence tolerance (Maximum of local saturation errors)");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowToleranceCnvRelaxed, "Relaxed local convergence tolerance that applies for iterations after the iterations with the strict tolerance");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowToleranceWells, "Well convergence tolerance");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowToleranceWellControl, "Tolerance for the well control equations");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowMaxWelleqIter, "Maximum number of iterations to determine solution the well equations");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowUseMultisegmentWell, "Use the well model for multi-segment wells instead of the one for single-segment wells");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowTolerancePressureMsWells, "Tolerance for the pressure equations for multi-segment wells");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowMaxPressureChangeMsWells, "Maximum relative pressure change for a single iteration of the multi-segment well model");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowUseInnerIterationsMsWells, "Use nested iterations for multi-segment wells");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowMaxInnerIterMsWells, "Maximum number of inner iterations for multi-segment wells");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowMaxSinglePrecisionDays, "Maximum time step size where single precision floating point arithmetic can be used solving for the linear systems of equations");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowMaxStrictIter, "Maximum number of Newton iterations before relaxed tolerances are used for the CNV convergence criterion");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowSolveWelleqInitially, "Fully solve the well equations before each iteration of the reservoir model");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowUpdateEquationsScaling, "Update scaling factors for mass balance equations during the run");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowUseUpdateStabilization, "Try to detect and correct oscillations or stagnation during the Newton method");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowMatrixAddWellContributions, "Explicitly specify the influences of wells between cells in the Jacobian and preconditioner matrices");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowPreconditionerAddWellContributions, "Explicitly specify the influences of wells between cells for the preconditioner matrix only");
|
||||
}
|
||||
};
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_BLACKOILMODELPARAMETERS_EBOS_HEADER_INCLUDED
|
@ -69,7 +69,7 @@ namespace Opm {
|
||||
public:
|
||||
// --------- Types ---------
|
||||
typedef WellStateFullyImplicitBlackoil WellState;
|
||||
typedef BlackoilModelParameters ModelParameters;
|
||||
typedef BlackoilModelParametersEbos<TypeTag> ModelParameters;
|
||||
|
||||
typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
|
||||
|
@ -2,8 +2,6 @@
|
||||
|
||||
|
||||
namespace Opm {
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
BlackoilWellModel<TypeTag>::
|
||||
BlackoilWellModel(Simulator& ebosSimulator,
|
||||
@ -33,7 +31,6 @@ namespace Opm {
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
void
|
||||
BlackoilWellModel<TypeTag>::
|
||||
|
@ -56,19 +56,36 @@
|
||||
#include <dune/common/parallel/mpihelper.hh>
|
||||
#endif
|
||||
|
||||
BEGIN_PROPERTIES;
|
||||
|
||||
NEW_PROP_TAG(FlowOutputMode);
|
||||
NEW_PROP_TAG(FlowEnableDryRun);
|
||||
NEW_PROP_TAG(FlowOutputInterval);
|
||||
NEW_PROP_TAG(FlowUseAmg);
|
||||
|
||||
SET_STRING_PROP(EclFlowProblem, FlowOutputMode, "all");
|
||||
|
||||
// TODO: enumeration parameters. we use strings for now.
|
||||
SET_STRING_PROP(EclFlowProblem, FlowEnableDryRun, "auto");
|
||||
|
||||
SET_INT_PROP(EclFlowProblem, FlowOutputInterval, 1);
|
||||
|
||||
END_PROPERTIES;
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
// The FlowMain class is the ebos based black-oil simulator.
|
||||
template <class TypeTag>
|
||||
class FlowMainEbos
|
||||
{
|
||||
enum FileOutputValue{
|
||||
enum FileOutputMode
|
||||
{
|
||||
//! \brief No output to files.
|
||||
OUTPUT_NONE = 0,
|
||||
OutputModeNone = 0,
|
||||
//! \brief Output only to log files, no eclipse output.
|
||||
OUTPUT_LOG_ONLY = 1,
|
||||
OutputModeLogOnly = 1,
|
||||
//! \brief Output to all files.
|
||||
OUTPUT_ALL = 3
|
||||
OutputModeAll = 3
|
||||
};
|
||||
|
||||
public:
|
||||
@ -84,42 +101,63 @@ namespace Opm
|
||||
typedef Opm::SimulatorFullyImplicitBlackoilEbos<TypeTag> Simulator;
|
||||
typedef typename Simulator::ReservoirState ReservoirState;
|
||||
|
||||
/// This is the main function of Flow.
|
||||
/// It runs a complete simulation, with the given grid and
|
||||
/// simulator classes, based on user command-line input. The
|
||||
/// content of this function used to be in the main() function of
|
||||
/// flow.cpp.
|
||||
// Read the command line parameters. Throws an exception if something goes wrong.
|
||||
static int setupParameters_(int argc, char** argv)
|
||||
{
|
||||
// register the flow specific parameters
|
||||
EWOMS_REGISTER_PARAM(TypeTag, std::string, FlowOutputMode,
|
||||
"Specify which messages are going to be printed. Valid values are: none, log, all (default)");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, std::string, FlowEnableDryRun,
|
||||
"Specify if the simulation ought to be actually run, or just pretended to be");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowOutputInterval,
|
||||
"Specify the number of report steps between two consecutive writes of restart data");
|
||||
Simulator::registerParameters();
|
||||
|
||||
typedef typename BlackoilModelEbos<TypeTag>::ISTLSolverType ISTLSolverType;
|
||||
ISTLSolverType::registerParameters();
|
||||
|
||||
// register the parameters inherited from ebos
|
||||
Ewoms::registerAllParameters_<TypeTag>();
|
||||
|
||||
// read in the command line parameters
|
||||
return Ewoms::setupParameters_<TypeTag>(argc, const_cast<const char**>(argv), /*doRegistration=*/false);
|
||||
}
|
||||
|
||||
/// This is the main function of Flow. It runs a complete simulation with the
|
||||
/// given grid and simulator classes, based on the user-specified command-line
|
||||
/// input.
|
||||
int execute(int argc, char** argv)
|
||||
{
|
||||
try {
|
||||
setupParallelism();
|
||||
printStartupMessage();
|
||||
const bool ok = setupParameters(argc, argv);
|
||||
if (!ok) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
// deal with some administrative boilerplate
|
||||
|
||||
setupEbosSimulator();
|
||||
setupOutput();
|
||||
setupLogging();
|
||||
printPRTHeader();
|
||||
runDiagnostics();
|
||||
setupLinearSolver();
|
||||
createSimulator();
|
||||
int status = setupParameters_(argc, argv);
|
||||
if (status)
|
||||
return status;
|
||||
|
||||
// Run.
|
||||
auto ret = runSimulator();
|
||||
setupParallelism_();
|
||||
printStartupMessage_();
|
||||
setupEbosSimulator_();
|
||||
setupOutput_();
|
||||
setupLogging_();
|
||||
printPRTHeader_();
|
||||
runDiagnostics_();
|
||||
setupLinearSolver_();
|
||||
createSimulator_();
|
||||
|
||||
mergeParallelLogFiles();
|
||||
// do the actual work
|
||||
runSimulator_();
|
||||
|
||||
return ret;
|
||||
// clean up
|
||||
mergeParallelLogFiles_();
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
catch (const std::exception &e) {
|
||||
catch (const std::exception& e) {
|
||||
std::ostringstream message;
|
||||
message << "Program threw an exception: " << e.what();
|
||||
|
||||
if( output_cout_ )
|
||||
{
|
||||
if (outputCout_) {
|
||||
// in some cases exceptions are thrown before the logging system is set
|
||||
// up.
|
||||
if (OpmLog::hasBackend("STREAMLOG")) {
|
||||
@ -135,45 +173,27 @@ namespace Opm
|
||||
}
|
||||
|
||||
protected:
|
||||
void setupParallelism()
|
||||
void setupParallelism_()
|
||||
{
|
||||
// determine the rank of the current process and the number of processes
|
||||
// involved in the simulation. MPI must have already been initialized here.
|
||||
// involved in the simulation. MPI must have already been initialized
|
||||
// here. (yes, the name of this method is misleading.)
|
||||
#if HAVE_MPI
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank_);
|
||||
int mpi_size;
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
|
||||
MPI_Comm_rank(MPI_COMM_WORLD, &mpiRank_);
|
||||
MPI_Comm_size(MPI_COMM_WORLD, &mpiSize_);
|
||||
#else
|
||||
mpi_rank_ = 0;
|
||||
const int mpi_size = 1;
|
||||
mpiRank_ = 0;
|
||||
mpiSize_ = 1;
|
||||
#endif
|
||||
output_cout_ = ( mpi_rank_ == 0 );
|
||||
must_distribute_ = ( mpi_size > 1 );
|
||||
|
||||
#ifdef _OPENMP
|
||||
// OpenMP setup.
|
||||
if (!getenv("OMP_NUM_THREADS")) {
|
||||
// Default to at most 2 threads, regardless of
|
||||
// number of cores (unless ENV(OMP_NUM_THREADS) is defined)
|
||||
int num_cores = omp_get_num_procs();
|
||||
int num_threads = std::min(2, num_cores);
|
||||
omp_set_num_threads(num_threads);
|
||||
}
|
||||
// omp_get_num_threads() only works as expected within a parallel region.
|
||||
const int num_omp_threads = omp_get_max_threads();
|
||||
if (mpi_size == 1) {
|
||||
std::cout << "OpenMP using " << num_omp_threads << " threads." << std::endl;
|
||||
} else {
|
||||
std::cout << "OpenMP using " << num_omp_threads << " threads on MPI rank " << mpi_rank_ << "." << std::endl;
|
||||
}
|
||||
#endif
|
||||
outputCout_ = (mpiRank_ == 0);
|
||||
}
|
||||
|
||||
// Print startup message if on output rank.
|
||||
void printStartupMessage()
|
||||
void printStartupMessage_()
|
||||
{
|
||||
|
||||
if (output_cout_) {
|
||||
if (outputCout_) {
|
||||
const int lineLen = 70;
|
||||
const std::string version = moduleVersionName();
|
||||
const std::string banner = "This is flow "+version;
|
||||
@ -191,74 +211,41 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
// Read parameters, see if a deck was specified on the command line, and if
|
||||
// it was, insert it into parameters.
|
||||
// Extract the minimum priority and determines if log files ought to be created.
|
||||
// Writes to:
|
||||
// param_
|
||||
// Returns true if ok, false if not.
|
||||
bool setupParameters(int argc, char** argv)
|
||||
// outputToFiles_
|
||||
// outputMode_
|
||||
void setupOutput_()
|
||||
{
|
||||
param_ = ParameterGroup(argc, argv, false, output_cout_);
|
||||
|
||||
// See if a deck was specified on the command line.
|
||||
if (!param_.unhandledArguments().empty()) {
|
||||
if (param_.unhandledArguments().size() != 1) {
|
||||
std::cerr << "You can only specify a single input deck on the command line.\n";
|
||||
return false;
|
||||
} else {
|
||||
const auto casename = this->simulationCaseName( param_.unhandledArguments()[ 0 ] );
|
||||
param_.insertParameter("deck_filename", casename.string() );
|
||||
}
|
||||
const std::string outputModeString =
|
||||
EWOMS_GET_PARAM(TypeTag, std::string, FlowOutputMode);
|
||||
static std::map<std::string, FileOutputMode> stringToOutputMode =
|
||||
{ {"none", OutputModeNone },
|
||||
{"false", OutputModeLogOnly },
|
||||
{"log", OutputModeLogOnly },
|
||||
{"all" , OutputModeAll },
|
||||
{"true" , OutputModeAll }};
|
||||
auto outputModeIt = stringToOutputMode.find(outputModeString);
|
||||
if (outputModeIt != stringToOutputMode.end()) {
|
||||
outputMode_ = outputModeIt->second;
|
||||
}
|
||||
|
||||
// We must have an input deck. Grid and props will be read from that.
|
||||
if (!param_.has("deck_filename")) {
|
||||
std::cerr << "This program must be run with an input deck.\n"
|
||||
"Specify the deck filename either\n"
|
||||
" a) as a command line argument by itself\n"
|
||||
" b) as a command line parameter with the syntax deck_filename=<path to your deck>, or\n"
|
||||
" c) as a parameter in a parameter file (.param or .xml) passed to the program.\n";
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Set output_to_files_ and set/create output dir. Write parameter file.
|
||||
// Writes to:
|
||||
// output_to_files_
|
||||
// output_dir_
|
||||
// Throws std::runtime_error if failed to create (if requested) output dir.
|
||||
void setupOutput()
|
||||
{
|
||||
const std::string output = param_.getDefault("output", std::string("all"));
|
||||
static std::map<std::string, FileOutputValue> string2OutputEnum =
|
||||
{ {"none", OUTPUT_NONE },
|
||||
{"false", OUTPUT_LOG_ONLY },
|
||||
{"log", OUTPUT_LOG_ONLY },
|
||||
{"all" , OUTPUT_ALL },
|
||||
{"true" , OUTPUT_ALL }};
|
||||
auto converted = string2OutputEnum.find(output);
|
||||
if ( converted != string2OutputEnum.end() )
|
||||
{
|
||||
output_ = string2OutputEnum[output];
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cerr << "Value " << output <<
|
||||
" passed to option output was invalid. Using \"all\" instead."
|
||||
else {
|
||||
outputMode_ = OutputModeAll;
|
||||
std::cerr << "Value " << outputModeString <<
|
||||
" is not a recognized output mode. Using \"all\" instead."
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
output_to_files_ = output_cout_ && (output_ != OUTPUT_NONE);
|
||||
outputToFiles_ = outputCout_ && (outputMode_ != OutputModeNone);
|
||||
}
|
||||
|
||||
// Setup OpmLog backend with output_dir.
|
||||
void setupLogging()
|
||||
// Setup the OpmLog backends
|
||||
void setupLogging_()
|
||||
{
|
||||
std::string deck_filename = param_.get<std::string>("deck_filename");
|
||||
std::string deckFilename = EWOMS_GET_PARAM(TypeTag, std::string, EclDeckFileName);
|
||||
// create logFile
|
||||
using boost::filesystem::path;
|
||||
path fpath(deck_filename);
|
||||
path fpath(deckFilename);
|
||||
std::string baseName;
|
||||
std::ostringstream debugFileStream;
|
||||
std::ostringstream logFileStream;
|
||||
@ -269,41 +256,38 @@ namespace Opm
|
||||
baseName = path(fpath.filename()).string();
|
||||
}
|
||||
|
||||
const std::string& output_dir = eclState().getIOConfig().getOutputDir();
|
||||
logFileStream << output_dir << "/" << baseName;
|
||||
debugFileStream << output_dir << "/" << baseName;
|
||||
const std::string& outputDir = eclState_().getIOConfig().getOutputDir();
|
||||
logFileStream << outputDir << "/" << baseName;
|
||||
debugFileStream << outputDir << "/" << baseName;
|
||||
|
||||
if ( must_distribute_ && mpi_rank_ != 0 )
|
||||
{
|
||||
if (mpiRank_ != 0) {
|
||||
// Added rank to log file for non-zero ranks.
|
||||
// This prevents message loss.
|
||||
debugFileStream << "."<< mpi_rank_;
|
||||
debugFileStream << "."<< mpiRank_;
|
||||
// If the following file appears then there is a bug.
|
||||
logFileStream << "." << mpi_rank_;
|
||||
logFileStream << "." << mpiRank_;
|
||||
}
|
||||
logFileStream << ".PRT";
|
||||
debugFileStream << ".DBG";
|
||||
|
||||
logFile_ = logFileStream.str();
|
||||
|
||||
if( output_ > OUTPUT_NONE)
|
||||
{
|
||||
std::shared_ptr<EclipsePRTLog> prtLog = std::make_shared<EclipsePRTLog>(logFile_ , Log::NoDebugMessageTypes, false, output_cout_);
|
||||
if (outputMode_ > OutputModeNone) {
|
||||
std::shared_ptr<EclipsePRTLog> prtLog = std::make_shared<EclipsePRTLog>(logFile_ , Log::NoDebugMessageTypes, false, outputCout_);
|
||||
OpmLog::addBackend( "ECLIPSEPRTLOG" , prtLog );
|
||||
prtLog->setMessageLimiter(std::make_shared<MessageLimiter>());
|
||||
prtLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(false));
|
||||
}
|
||||
|
||||
if( output_ >= OUTPUT_LOG_ONLY && !param_.getDefault("no_debug_log", false) )
|
||||
{
|
||||
if (outputMode_ >= OutputModeLogOnly) {
|
||||
std::string debugFile = debugFileStream.str();
|
||||
std::shared_ptr<StreamLog> debugLog = std::make_shared<EclipsePRTLog>(debugFile, Log::DefaultMessageTypes, false, output_cout_);
|
||||
OpmLog::addBackend( "DEBUGLOG" , debugLog);
|
||||
std::shared_ptr<StreamLog> debugLog = std::make_shared<EclipsePRTLog>(debugFile, Log::DefaultMessageTypes, false, outputCout_);
|
||||
OpmLog::addBackend("DEBUGLOG", debugLog);
|
||||
}
|
||||
|
||||
std::shared_ptr<StreamLog> streamLog = std::make_shared<StreamLog>(std::cout, Log::StdoutMessageTypes);
|
||||
OpmLog::addBackend( "STREAMLOG", streamLog);
|
||||
const auto& msgLimits = schedule().getMessageLimits();
|
||||
const auto& msgLimits = schedule_().getMessageLimits();
|
||||
const std::map<int64_t, int> limits = {{Log::MessageType::Note, msgLimits.getCommentPrintLimit(0)},
|
||||
{Log::MessageType::Info, msgLimits.getMessagePrintLimit(0)},
|
||||
{Log::MessageType::Warning, msgLimits.getWarningPrintLimit(0)},
|
||||
@ -312,21 +296,15 @@ namespace Opm
|
||||
{Log::MessageType::Bug, msgLimits.getBugPrintLimit(0)}};
|
||||
streamLog->setMessageLimiter(std::make_shared<MessageLimiter>(10, limits));
|
||||
streamLog->setMessageFormatter(std::make_shared<SimpleMessageFormatter>(true));
|
||||
|
||||
if ( output_cout_ )
|
||||
{
|
||||
// Read Parameters.
|
||||
OpmLog::debug("\n--------------- Reading parameters ---------------\n");
|
||||
}
|
||||
}
|
||||
|
||||
void printPRTHeader()
|
||||
// Print an ASCII-art header to the PRT and DEBUG files.
|
||||
void printPRTHeader_()
|
||||
{
|
||||
// Print header for PRT file.
|
||||
if ( output_cout_ ) {
|
||||
if (outputCout_) {
|
||||
const std::string version = moduleVersionName();
|
||||
const double megabyte = 1024 * 1024;
|
||||
unsigned num_cpu = std::thread::hardware_concurrency();
|
||||
unsigned numCores = std::thread::hardware_concurrency();
|
||||
struct utsname arch;
|
||||
const char* user = getlogin();
|
||||
time_t now = std::time(0);
|
||||
@ -334,7 +312,7 @@ namespace Opm
|
||||
char tmstr[80];
|
||||
tstruct = *localtime(&now);
|
||||
strftime(tmstr, sizeof(tmstr), "%d-%m-%Y at %X", &tstruct);
|
||||
const double mem_size = getTotalSystemMemory() / megabyte;
|
||||
const double memSize = getTotalSystemMemory_() / megabyte;
|
||||
std::ostringstream ss;
|
||||
ss << "\n\n\n";
|
||||
ss << " ######## # ###### # #\n";
|
||||
@ -346,8 +324,8 @@ namespace Opm
|
||||
ss << " and is part of OPM.\nFor more information visit: https://opm-project.org \n\n";
|
||||
ss << "Flow Version = " + version + "\n";
|
||||
if (uname(&arch) == 0) {
|
||||
ss << "System = " << arch.nodename << " (Number of cores: " << num_cpu;
|
||||
ss << ", RAM: " << std::fixed << std::setprecision (2) << mem_size << " MB) \n";
|
||||
ss << "System = " << arch.nodename << " (Number of logical cores: " << numCores;
|
||||
ss << ", RAM: " << std::fixed << std::setprecision (2) << memSize << " MB) \n";
|
||||
ss << "Architecture = " << arch.sysname << " " << arch.machine << " (Release: " << arch.release;
|
||||
ss << ", Version: " << arch.version << " )\n";
|
||||
}
|
||||
@ -359,86 +337,52 @@ namespace Opm
|
||||
}
|
||||
}
|
||||
|
||||
void mergeParallelLogFiles()
|
||||
void mergeParallelLogFiles_()
|
||||
{
|
||||
// force closing of all log files.
|
||||
OpmLog::removeAllBackends();
|
||||
|
||||
if( mpi_rank_ != 0 || !must_distribute_ || !output_to_files_ )
|
||||
{
|
||||
if (mpiRank_ != 0 || mpiSize_ < 2 || !outputToFiles_) {
|
||||
return;
|
||||
}
|
||||
|
||||
namespace fs = boost::filesystem;
|
||||
fs::path output_path(".");
|
||||
const std::string& output_dir = eclState().getIOConfig().getOutputDir();
|
||||
if ( param_.has("output_dir") )
|
||||
{
|
||||
output_path = fs::path(output_dir);
|
||||
}
|
||||
fs::path outputPath(".");
|
||||
const std::string& outputDir = eclState_().getIOConfig().getOutputDir();
|
||||
|
||||
fs::path deck_filename(param_.get<std::string>("deck_filename"));
|
||||
std::for_each(fs::directory_iterator(output_path),
|
||||
fs::path deckFileName(EWOMS_GET_PARAM(TypeTag, std::string, EclDeckFileName));
|
||||
std::for_each(fs::directory_iterator(outputPath),
|
||||
fs::directory_iterator(),
|
||||
detail::ParallelFileMerger(output_path, deck_filename.stem().string()));
|
||||
detail::ParallelFileMerger(outputPath, deckFileName.stem().string()));
|
||||
}
|
||||
|
||||
void setupEbosSimulator()
|
||||
void setupEbosSimulator_()
|
||||
{
|
||||
std::vector<const char*> argv;
|
||||
|
||||
argv.push_back("flow_ebos");
|
||||
|
||||
std::string deckFileParam("--ecl-deck-file-name=");
|
||||
const std::string& deckFileName = param_.get<std::string>("deck_filename");
|
||||
deckFileParam += deckFileName;
|
||||
argv.push_back(deckFileParam.c_str());
|
||||
|
||||
std::string outputDirParam("--output-dir=");
|
||||
if (param_.has("output_dir")) {
|
||||
const std::string& output_dir = param_.get<std::string>("output_dir");
|
||||
outputDirParam += output_dir;
|
||||
argv.push_back(outputDirParam.c_str());
|
||||
}
|
||||
|
||||
std::string asyncOutputParam("--enable-async-ecl-output=");
|
||||
if (param_.has("async_output")) {
|
||||
const std::string& value = param_.get<std::string>("async_output");
|
||||
asyncOutputParam += value;
|
||||
argv.push_back(asyncOutputParam.c_str());
|
||||
}
|
||||
|
||||
std::string outputDoublePrecisionParam("--ecl-output-double-precision=");
|
||||
if (param_.has("restart_double_si")) {
|
||||
const std::string& value = param_.get<std::string>("restart_double_si");
|
||||
outputDoublePrecisionParam += value;
|
||||
argv.push_back(outputDoublePrecisionParam.c_str());
|
||||
}
|
||||
|
||||
#if defined(_OPENMP)
|
||||
std::string numThreadsParam("--threads-per-process=");
|
||||
int numThreads = omp_get_max_threads();
|
||||
|
||||
numThreadsParam += std::to_string(numThreads);
|
||||
argv.push_back(numThreadsParam.c_str());
|
||||
#endif // defined(_OPENMP)
|
||||
|
||||
EbosSimulator::registerParameters();
|
||||
Ewoms::setupParameters_<TypeTag>(argv.size(), &argv[0]);
|
||||
EbosThreadManager::init();
|
||||
ebosSimulator_.reset(new EbosSimulator(/*verbose=*/false));
|
||||
ebosSimulator_->model().applyInitialSolution();
|
||||
|
||||
try {
|
||||
if (output_cout_) {
|
||||
MissingFeatures::checkKeywords(deck());
|
||||
if (outputCout_) {
|
||||
MissingFeatures::checkKeywords(deck_());
|
||||
}
|
||||
|
||||
// Possible to force initialization only behavior (NOSIM).
|
||||
if (param_.has("nosim")) {
|
||||
const bool nosim = param_.get<bool>("nosim");
|
||||
auto& ioConfig = eclState().getIOConfig();
|
||||
ioConfig.overrideNOSIM( nosim );
|
||||
const std::string& dryRunString = EWOMS_GET_PARAM(TypeTag, std::string, FlowEnableDryRun);
|
||||
if (dryRunString != "" && dryRunString != "auto") {
|
||||
bool yesno;
|
||||
if (dryRunString == "true"
|
||||
|| dryRunString == "t"
|
||||
|| dryRunString == "1")
|
||||
yesno = true;
|
||||
else if (dryRunString == "false"
|
||||
|| dryRunString == "f"
|
||||
|| dryRunString == "0")
|
||||
yesno = false;
|
||||
else
|
||||
throw std::invalid_argument("Invalid value for parameter FlowEnableDryRun: '"
|
||||
+dryRunString+"'");
|
||||
auto& ioConfig = eclState_().getIOConfig();
|
||||
ioConfig.overrideNOSIM(yesno);
|
||||
}
|
||||
}
|
||||
catch (const std::invalid_argument& e) {
|
||||
@ -446,60 +390,60 @@ namespace Opm
|
||||
std::cerr << "Exception caught: " << e.what() << std::endl;
|
||||
throw;
|
||||
}
|
||||
|
||||
// Possibly override IOConfig setting (from deck) for how often RESTART files should get written to disk (every N report step)
|
||||
if (param_.has("output_interval")) {
|
||||
const int output_interval = param_.get<int>("output_interval");
|
||||
eclState().getRestartConfig().overrideRestartWriteInterval( size_t( output_interval ) );
|
||||
}
|
||||
}
|
||||
|
||||
const Deck& deck() const
|
||||
const Deck& deck_() const
|
||||
{ return ebosSimulator_->vanguard().deck(); }
|
||||
|
||||
Deck& deck()
|
||||
Deck& deck_()
|
||||
{ return ebosSimulator_->vanguard().deck(); }
|
||||
|
||||
const EclipseState& eclState() const
|
||||
const EclipseState& eclState_() const
|
||||
{ return ebosSimulator_->vanguard().eclState(); }
|
||||
|
||||
EclipseState& eclState()
|
||||
EclipseState& eclState_()
|
||||
{ return ebosSimulator_->vanguard().eclState(); }
|
||||
|
||||
const Schedule& schedule() const
|
||||
const Schedule& schedule_() const
|
||||
{ return ebosSimulator_->vanguard().schedule(); }
|
||||
|
||||
|
||||
// Run diagnostics.
|
||||
// Writes to:
|
||||
// OpmLog singleton.
|
||||
void runDiagnostics()
|
||||
void runDiagnostics_()
|
||||
{
|
||||
if( ! output_cout_ )
|
||||
{
|
||||
if (!outputCout_) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Run relperm diagnostics
|
||||
RelpermDiagnostics diagnostic;
|
||||
diagnostic.diagnosis(eclState(), deck(), this->grid());
|
||||
diagnostic.diagnosis(eclState_(), deck_(), grid_());
|
||||
}
|
||||
|
||||
// Run the simulator.
|
||||
// Returns EXIT_SUCCESS if it does not throw.
|
||||
int runSimulator()
|
||||
void runSimulator_()
|
||||
{
|
||||
const auto& schedule = this->schedule();
|
||||
const auto& schedule = schedule_();
|
||||
const auto& timeMap = schedule.getTimeMap();
|
||||
auto& ioConfig = eclState().getIOConfig();
|
||||
auto& ioConfig = eclState_().getIOConfig();
|
||||
SimulatorTimer simtimer;
|
||||
|
||||
// initialize variables
|
||||
const auto& initConfig = eclState().getInitConfig();
|
||||
const auto& initConfig = eclState_().getInitConfig();
|
||||
simtimer.init(timeMap, (size_t)initConfig.getRestartStep());
|
||||
|
||||
if (outputCout_) {
|
||||
// This allows a user to catch typos and misunderstandings in the
|
||||
// use of simulator parameters.
|
||||
std::cout << "----------------- Unrecognized parameters: -----------------\n";
|
||||
Ewoms::Parameters::printUnused<TypeTag>();
|
||||
std::cout << "----------------------------------------------------------------" << std::endl;
|
||||
}
|
||||
|
||||
if (!ioConfig.initOnly()) {
|
||||
if (output_cout_) {
|
||||
if (outputCout_) {
|
||||
std::string msg;
|
||||
msg = "\n\n================ Starting main simulation loop ===============\n";
|
||||
OpmLog::info(msg);
|
||||
@ -508,121 +452,75 @@ namespace Opm
|
||||
SimulatorReport successReport = simulator_->run(simtimer);
|
||||
SimulatorReport failureReport = simulator_->failureReport();
|
||||
|
||||
if (output_cout_) {
|
||||
if (outputCout_) {
|
||||
std::ostringstream ss;
|
||||
ss << "\n\n================ End of simulation ===============\n\n";
|
||||
successReport.reportFullyImplicit(ss, &failureReport);
|
||||
OpmLog::info(ss.str());
|
||||
if (param_.anyUnused()) {
|
||||
// This allows a user to catch typos and misunderstandings in the
|
||||
// use of simulator parameters.
|
||||
std::cout << "-------------------- Unused parameters: --------------------\n";
|
||||
param_.displayUsage();
|
||||
std::cout << "----------------------------------------------------------------" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (output_cout_) {
|
||||
if (outputCout_) {
|
||||
std::cout << "\n\n================ Simulation turned off ===============\n" << std::flush;
|
||||
}
|
||||
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
// Setup linear solver.
|
||||
// Writes to:
|
||||
// fis_solver_
|
||||
void setupLinearSolver()
|
||||
// linearSolver_
|
||||
void setupLinearSolver_()
|
||||
{
|
||||
typedef typename BlackoilModelEbos<TypeTag> :: ISTLSolverType ISTLSolverType;
|
||||
const std::string cprSolver = "cpr";
|
||||
if (!param_.has("solver_approach") )
|
||||
{
|
||||
if ( eclState().getSimulationConfig().useCPR() )
|
||||
{
|
||||
/* Deactivate selection of CPR via eclipse keyword
|
||||
as this preconditioner is still considered experimental
|
||||
and fails miserably for some models.
|
||||
param_.insertParameter("solver_approach", cprSolver);
|
||||
*/
|
||||
if ( output_cout_ )
|
||||
{
|
||||
std::ostringstream message;
|
||||
message << "Ignoring request for CPRPreconditioner "
|
||||
<< "via Eclipse keyword as it is considered "
|
||||
<<" experimental. To activate use "
|
||||
<<"\"solver_approach=cprSolver\" command "
|
||||
<<"line parameter.";
|
||||
OpmLog::info(message.str());
|
||||
}
|
||||
}
|
||||
typedef typename BlackoilModelEbos<TypeTag>::ISTLSolverType ISTLSolverType;
|
||||
|
||||
extractParallelGridInformationToISTL(grid_(), parallelInformation_);
|
||||
linearSolver_.reset(new ISTLSolverType(parallelInformation_));
|
||||
|
||||
// Deactivate selection of CPR via eclipse keyword
|
||||
// as this preconditioner is still considered experimental
|
||||
// and fails miserably for some models.
|
||||
if (outputCout_) {
|
||||
std::ostringstream message;
|
||||
message << "Ignoring request for CPRPreconditioner "
|
||||
<< "via Eclipse keyword as it is considered "
|
||||
<<" experimental. To activate use "
|
||||
<<"\"--flow-use-cpr=true\" command "
|
||||
<<"line parameter.";
|
||||
OpmLog::info(message.str());
|
||||
}
|
||||
extractParallelGridInformationToISTL(grid(), parallel_information_);
|
||||
fis_solver_.reset( new ISTLSolverType( param_, parallel_information_ ) );
|
||||
}
|
||||
|
||||
/// This is the main function of Flow.
|
||||
// Create simulator instance.
|
||||
// Writes to:
|
||||
// simulator_
|
||||
void createSimulator()
|
||||
void createSimulator_()
|
||||
{
|
||||
// Create the simulator instance.
|
||||
simulator_.reset(new Simulator(*ebosSimulator_,
|
||||
param_,
|
||||
*fis_solver_));
|
||||
simulator_.reset(new Simulator(*ebosSimulator_, *linearSolver_));
|
||||
}
|
||||
|
||||
private:
|
||||
boost::filesystem::path simulationCaseName( const std::string& casename ) {
|
||||
namespace fs = boost::filesystem;
|
||||
|
||||
const auto exists = []( const fs::path& f ) -> bool {
|
||||
if( !fs::exists( f ) ) return false;
|
||||
|
||||
if( fs::is_regular_file( f ) ) return true;
|
||||
|
||||
return fs::is_symlink( f )
|
||||
&& fs::is_regular_file( fs::read_symlink( f ) );
|
||||
};
|
||||
|
||||
auto simcase = fs::path( casename );
|
||||
|
||||
if( exists( simcase ) ) {
|
||||
return simcase;
|
||||
}
|
||||
|
||||
for( const auto& ext : { std::string("data"), std::string("DATA") } ) {
|
||||
if( exists( simcase.replace_extension( ext ) ) ) {
|
||||
return simcase;
|
||||
}
|
||||
}
|
||||
|
||||
throw std::invalid_argument( "Cannot find input case " + casename );
|
||||
}
|
||||
|
||||
unsigned long long getTotalSystemMemory()
|
||||
unsigned long long getTotalSystemMemory_()
|
||||
{
|
||||
long pages = sysconf(_SC_PHYS_PAGES);
|
||||
long page_size = sysconf(_SC_PAGE_SIZE);
|
||||
return pages * page_size;
|
||||
long pageSize = sysconf(_SC_PAGE_SIZE);
|
||||
return pages * pageSize;
|
||||
}
|
||||
|
||||
|
||||
Grid& grid()
|
||||
Grid& grid_()
|
||||
{ return ebosSimulator_->vanguard().grid(); }
|
||||
|
||||
private:
|
||||
std::unique_ptr<EbosSimulator> ebosSimulator_;
|
||||
int mpi_rank_ = 0;
|
||||
bool output_cout_ = false;
|
||||
FileOutputValue output_ = OUTPUT_ALL;
|
||||
bool must_distribute_ = false;
|
||||
ParameterGroup param_;
|
||||
bool output_to_files_ = false;
|
||||
boost::any parallel_information_;
|
||||
std::unique_ptr<NewtonIterationBlackoilInterface> fis_solver_;
|
||||
int mpiRank_ = 0;
|
||||
int mpiSize_ = 1;
|
||||
bool outputCout_ = false;
|
||||
FileOutputMode outputMode_;
|
||||
bool outputToFiles_ = false;
|
||||
boost::any parallelInformation_;
|
||||
std::unique_ptr<NewtonIterationBlackoilInterface> linearSolver_;
|
||||
std::unique_ptr<Simulator> simulator_;
|
||||
std::string logFile_;
|
||||
};
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <opm/core/linalg/ParallelIstlInformation.hpp>
|
||||
#include <opm/common/utility/platform_dependent/disable_warnings.h>
|
||||
|
||||
#include <ewoms/common/parametersystem.hh>
|
||||
#include <ewoms/common/propertysystem.hh>
|
||||
|
||||
#include <dune/istl/scalarproducts.hh>
|
||||
@ -45,6 +46,8 @@
|
||||
|
||||
BEGIN_PROPERTIES
|
||||
|
||||
NEW_TYPE_TAG(FlowIstlSolver, INHERITS_FROM(FlowIstlSolverParams));
|
||||
|
||||
NEW_PROP_TAG(Scalar);
|
||||
NEW_PROP_TAG(GlobalEqVector);
|
||||
NEW_PROP_TAG(JacobianMatrix);
|
||||
@ -366,30 +369,21 @@ namespace Detail
|
||||
typedef Dune::AssembledLinearOperator< Matrix, Vector, Vector > AssembledLinearOperatorType;
|
||||
|
||||
typedef NewtonIterationBlackoilInterface :: SolutionVector SolutionVector;
|
||||
/// Construct a system solver.
|
||||
/// \param[in] param parameters controlling the behaviour of the linear solvers
|
||||
/// \param[in] parallelInformation In the case of a parallel run
|
||||
/// with dune-istl the information about the parallelization.
|
||||
ISTLSolverEbos(const NewtonIterationBlackoilInterleavedParameters& param,
|
||||
const boost::any& parallelInformation_arg=boost::any())
|
||||
: iterations_( 0 ),
|
||||
parallelInformation_(parallelInformation_arg),
|
||||
isIORank_(isIORank(parallelInformation_arg)),
|
||||
parameters_( param )
|
||||
|
||||
static void registerParameters()
|
||||
{
|
||||
NewtonIterationBlackoilInterleavedParameters::registerParameters<TypeTag>();
|
||||
}
|
||||
|
||||
/// Construct a system solver.
|
||||
/// \param[in] param ParameterGroup controlling the behaviour of the linear solvers
|
||||
/// \param[in] parallelInformation In the case of a parallel run
|
||||
/// with dune-istl the information about the parallelization.
|
||||
ISTLSolverEbos(const ParameterGroup& param,
|
||||
const boost::any& parallelInformation_arg=boost::any())
|
||||
: iterations_( 0 ),
|
||||
parallelInformation_(parallelInformation_arg),
|
||||
isIORank_(isIORank(parallelInformation_arg)),
|
||||
parameters_( param )
|
||||
ISTLSolverEbos(const boost::any& parallelInformation_arg=boost::any())
|
||||
: iterations_( 0 )
|
||||
, parallelInformation_(parallelInformation_arg)
|
||||
, isIORank_(isIORank(parallelInformation_arg))
|
||||
{
|
||||
parameters_.template init<TypeTag>();
|
||||
}
|
||||
|
||||
// dummy method that is not implemented for this class
|
||||
@ -439,7 +433,7 @@ namespace Detail
|
||||
parallelInformation_arg.copyOwnerToAll(istlb, istlb);
|
||||
|
||||
#if FLOW_SUPPORT_AMG // activate AMG if either flow_ebos is used or UMFPack is not available
|
||||
if( parameters_.linear_solver_use_amg_ || parameters_.use_cpr_)
|
||||
if (parameters_.linear_solver_use_amg_ || parameters_.use_cpr_)
|
||||
{
|
||||
typedef ISTLUtility::CPRSelector< Matrix, Vector, Vector, POrComm> CPRSelectorType;
|
||||
typedef typename CPRSelectorType::Operator MatrixOperator;
|
||||
@ -506,9 +500,9 @@ namespace Detail
|
||||
template <class Operator>
|
||||
std::unique_ptr<SeqPreconditioner> constructPrecond(Operator& opA, const Dune::Amg::SequentialInformation&) const
|
||||
{
|
||||
const double relax = parameters_.ilu_relaxation_;
|
||||
const int ilu_fillin = parameters_.ilu_fillin_level_;
|
||||
std::unique_ptr<SeqPreconditioner> precond(new SeqPreconditioner(opA.getmat(), ilu_fillin, relax));
|
||||
const double relax = parameters_.ilu_relaxation_;
|
||||
const int iluFillin = parameters_.ilu_fillin_level_;
|
||||
std::unique_ptr<SeqPreconditioner> precond(new SeqPreconditioner(opA.getmat(), iluFillin, relax));
|
||||
return precond;
|
||||
}
|
||||
|
||||
@ -529,7 +523,7 @@ namespace Detail
|
||||
constructPrecond(Operator& opA, const Comm& comm) const
|
||||
{
|
||||
typedef std::unique_ptr<ParPreconditioner> Pointer;
|
||||
const double relax = parameters_.ilu_relaxation_;
|
||||
const double relax = parameters_.ilu_relaxation_;
|
||||
return Pointer(new ParPreconditioner(opA.getmat(), comm, relax));
|
||||
}
|
||||
#endif
|
||||
|
@ -30,9 +30,42 @@
|
||||
#include <opm/common/utility/parameters/ParameterGroup.hpp>
|
||||
#include <opm/autodiff/ParallelOverlappingILU0.hpp>
|
||||
|
||||
#include <ewoms/common/parametersystem.hh>
|
||||
|
||||
#include <array>
|
||||
#include <memory>
|
||||
|
||||
BEGIN_PROPERTIES
|
||||
|
||||
NEW_TYPE_TAG(FlowIstlSolverParams);
|
||||
|
||||
NEW_PROP_TAG(Scalar);
|
||||
NEW_PROP_TAG(FlowLinearSolverReduction);
|
||||
NEW_PROP_TAG(FlowIluRelaxation);
|
||||
NEW_PROP_TAG(FlowLinearSolverMaxIter);
|
||||
NEW_PROP_TAG(FlowLinearSolverRestart);
|
||||
NEW_PROP_TAG(FlowLinearSolverVerbosity);
|
||||
NEW_PROP_TAG(FlowIluFillinLevel);
|
||||
NEW_PROP_TAG(FlowUseGmres);
|
||||
NEW_PROP_TAG(FlowLinearSolverRequireFullSparsityPattern);
|
||||
NEW_PROP_TAG(FlowLinearSolverIgnoreConvergenceFailure);
|
||||
NEW_PROP_TAG(FlowUseAmg);
|
||||
NEW_PROP_TAG(FlowUseCpr);
|
||||
|
||||
SET_SCALAR_PROP(FlowIstlSolverParams, FlowLinearSolverReduction, 1e-2);
|
||||
SET_SCALAR_PROP(FlowIstlSolverParams, FlowIluRelaxation, 0.9);
|
||||
SET_INT_PROP(FlowIstlSolverParams, FlowLinearSolverMaxIter, 150);
|
||||
SET_INT_PROP(FlowIstlSolverParams, FlowLinearSolverRestart, 40);
|
||||
SET_INT_PROP(FlowIstlSolverParams, FlowLinearSolverVerbosity, 0);
|
||||
SET_INT_PROP(FlowIstlSolverParams, FlowIluFillinLevel, 0);
|
||||
SET_BOOL_PROP(FlowIstlSolverParams, FlowUseGmres, false);
|
||||
SET_BOOL_PROP(FlowIstlSolverParams, FlowLinearSolverRequireFullSparsityPattern, false);
|
||||
SET_BOOL_PROP(FlowIstlSolverParams, FlowLinearSolverIgnoreConvergenceFailure, false);
|
||||
SET_BOOL_PROP(FlowIstlSolverParams, FlowUseAmg, false);
|
||||
SET_BOOL_PROP(FlowIstlSolverParams, FlowUseCpr, false);
|
||||
|
||||
END_PROPERTIES
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
/// This class carries all parameters for the NewtonIterationBlackoilInterleaved class
|
||||
@ -54,6 +87,39 @@ namespace Opm
|
||||
bool linear_solver_use_amg_;
|
||||
bool use_cpr_;
|
||||
|
||||
template <class TypeTag>
|
||||
void init()
|
||||
{
|
||||
// TODO: these parameters have undocumented non-trivial dependencies
|
||||
linear_solver_reduction_ = EWOMS_GET_PARAM(TypeTag, double, FlowLinearSolverReduction);
|
||||
ilu_relaxation_ = EWOMS_GET_PARAM(TypeTag, double, FlowIluRelaxation);
|
||||
linear_solver_maxiter_ = EWOMS_GET_PARAM(TypeTag, int, FlowLinearSolverMaxIter);
|
||||
linear_solver_restart_ = EWOMS_GET_PARAM(TypeTag, int, FlowLinearSolverRestart);
|
||||
linear_solver_verbosity_ = EWOMS_GET_PARAM(TypeTag, int, FlowLinearSolverVerbosity);
|
||||
ilu_fillin_level_ = EWOMS_GET_PARAM(TypeTag, int, FlowIluFillinLevel);
|
||||
newton_use_gmres_ = EWOMS_GET_PARAM(TypeTag, bool, FlowUseGmres);
|
||||
require_full_sparsity_pattern_ = EWOMS_GET_PARAM(TypeTag, bool, FlowLinearSolverRequireFullSparsityPattern);
|
||||
ignoreConvergenceFailure_ = EWOMS_GET_PARAM(TypeTag, bool, FlowLinearSolverIgnoreConvergenceFailure);
|
||||
linear_solver_use_amg_ = EWOMS_GET_PARAM(TypeTag, bool, FlowUseAmg);
|
||||
use_cpr_ = EWOMS_GET_PARAM(TypeTag, bool, FlowUseCpr);
|
||||
}
|
||||
|
||||
template <class TypeTag>
|
||||
static void registerParameters()
|
||||
{
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowLinearSolverReduction, "The minimum reduction of the residual which the linear solver must achieve");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowIluRelaxation, "The relaxation factor of the linear solver's ILU preconditioner");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowLinearSolverMaxIter, "The maximum number of iterations of the linear solver");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowLinearSolverRestart, "The number of iterations after which GMRES is restarted");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowLinearSolverVerbosity, "The verbosity level of the linear solver (0: off, 2: all)");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowIluFillinLevel, "The fill-in level of the linear solver's ILU preconditioner");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowUseGmres, "Use GMRES as the linear solver");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowLinearSolverRequireFullSparsityPattern, "Produce the full sparsity pattern for the linear solver");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowLinearSolverIgnoreConvergenceFailure, "Continue with the simulation like nothing happened after the linear solver did not converge");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowUseAmg, "Use AMG as the linear solver's preconditioner");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowUseCpr, "Use CPR as the linear solver's preconditioner");
|
||||
}
|
||||
|
||||
NewtonIterationBlackoilInterleavedParameters() { reset(); }
|
||||
// read values from parameter class
|
||||
NewtonIterationBlackoilInterleavedParameters( const ParameterGroup& param )
|
||||
|
@ -26,18 +26,41 @@
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
#include <opm/common/Exceptions.hpp>
|
||||
#include <opm/simulators/timestepping/SimulatorTimerInterface.hpp>
|
||||
|
||||
#include <ewoms/common/parametersystem.hh>
|
||||
#include <ewoms/common/propertysystem.hh>
|
||||
|
||||
#include <dune/common/fmatrix.hh>
|
||||
#include <dune/istl/bcrsmatrix.hh>
|
||||
#include <memory>
|
||||
|
||||
BEGIN_PROPERTIES
|
||||
|
||||
NEW_TYPE_TAG(FlowNonLinearSolver);
|
||||
|
||||
NEW_PROP_TAG(Scalar);
|
||||
NEW_PROP_TAG(FlowNewtonMaxRelax);
|
||||
NEW_PROP_TAG(FlowNewtonMaxIterations);
|
||||
NEW_PROP_TAG(FlowNewtonMinIterations);
|
||||
NEW_PROP_TAG(FlowNewtonRelaxationType);
|
||||
|
||||
SET_SCALAR_PROP(FlowNonLinearSolver, FlowNewtonMaxRelax, 0.5);
|
||||
SET_INT_PROP(FlowNonLinearSolver, FlowNewtonMaxIterations, 10);
|
||||
SET_INT_PROP(FlowNonLinearSolver, FlowNewtonMinIterations, 1);
|
||||
SET_STRING_PROP(FlowNonLinearSolver, FlowNewtonRelaxationType, "dampen");
|
||||
|
||||
END_PROPERTIES
|
||||
|
||||
namespace Opm {
|
||||
|
||||
|
||||
/// A nonlinear solver class suitable for general fully-implicit models,
|
||||
/// as well as pressure, transport and sequential models.
|
||||
template <class PhysicalModel>
|
||||
template <class TypeTag, class PhysicalModel>
|
||||
class NonlinearSolverEbos
|
||||
{
|
||||
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
|
||||
|
||||
public:
|
||||
// Available relaxation scheme types.
|
||||
enum RelaxType {
|
||||
@ -46,7 +69,7 @@ namespace Opm {
|
||||
};
|
||||
|
||||
// Solver parameters controlling nonlinear process.
|
||||
struct SolverParametersEbos
|
||||
struct SolverParameters
|
||||
{
|
||||
RelaxType relaxType_;
|
||||
double relaxMax_;
|
||||
@ -55,28 +78,33 @@ namespace Opm {
|
||||
int maxIter_; // max nonlinear iterations
|
||||
int minIter_; // min nonlinear iterations
|
||||
|
||||
explicit SolverParametersEbos(const ParameterGroup& param)
|
||||
SolverParameters()
|
||||
{
|
||||
// set default values
|
||||
reset();
|
||||
|
||||
// overload with given parameters
|
||||
relaxMax_ = param.getDefault("relax_max", relaxMax_);
|
||||
maxIter_ = param.getDefault("max_iter", maxIter_);
|
||||
minIter_ = param.getDefault("min_iter", minIter_);
|
||||
relaxMax_ = EWOMS_GET_PARAM(TypeTag, Scalar, FlowNewtonMaxRelax);
|
||||
maxIter_ = EWOMS_GET_PARAM(TypeTag, int, FlowNewtonMaxIterations);
|
||||
minIter_ = EWOMS_GET_PARAM(TypeTag, int, FlowNewtonMinIterations);
|
||||
|
||||
std::string relaxationType = param.getDefault("relax_type", std::string("dampen"));
|
||||
if (relaxationType == "dampen") {
|
||||
const auto& relaxationTypeString = EWOMS_GET_PARAM(TypeTag, std::string, FlowNewtonRelaxationType);
|
||||
if (relaxationTypeString == "dampen") {
|
||||
relaxType_ = Dampen;
|
||||
} else if (relaxationType == "sor") {
|
||||
} else if (relaxationTypeString == "sor") {
|
||||
relaxType_ = SOR;
|
||||
} else {
|
||||
OPM_THROW(std::runtime_error, "Unknown Relaxtion Type " << relaxationType);
|
||||
OPM_THROW(std::runtime_error, "Unknown Relaxtion Type " << relaxationTypeString);
|
||||
}
|
||||
}
|
||||
|
||||
SolverParametersEbos()
|
||||
{ reset(); }
|
||||
static void registerParameters()
|
||||
{
|
||||
EWOMS_REGISTER_PARAM(TypeTag, Scalar, FlowNewtonMaxRelax, "The maximum relaxation factor of a Newton iteration used by flow");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowNewtonMaxIterations, "The maximum number of Newton iterations per time step used by flow");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowNewtonMinIterations, "The minimum number of Newton iterations per time step used by flow");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, std::string, FlowNewtonRelaxationType, "The type of relaxation used by flow's Newton method");
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
@ -104,7 +132,7 @@ namespace Opm {
|
||||
///
|
||||
/// \param[in] param parameters controlling nonlinear process
|
||||
/// \param[in, out] model physical simulation model.
|
||||
NonlinearSolverEbos(const SolverParametersEbos& param,
|
||||
NonlinearSolverEbos(const SolverParameters& param,
|
||||
std::unique_ptr<PhysicalModel> model)
|
||||
: param_(param)
|
||||
, model_(std::move(model))
|
||||
@ -329,13 +357,13 @@ namespace Opm {
|
||||
{ return param_.minIter_; }
|
||||
|
||||
/// Set parameters to override those given at construction time.
|
||||
void setParameters(const SolverParametersEbos& param)
|
||||
void setParameters(const SolverParameters& param)
|
||||
{ param_ = param; }
|
||||
|
||||
private:
|
||||
// --------- Data members ---------
|
||||
SimulatorReport failureReport_;
|
||||
SolverParametersEbos param_;
|
||||
SolverParameters param_;
|
||||
std::unique_ptr<PhysicalModel> model_;
|
||||
int linearizations_;
|
||||
int nonlinearIterations_;
|
||||
|
@ -234,8 +234,8 @@ namespace Opm
|
||||
events.hasEvent(ScheduleEvents::PRODUCTION_UPDATE, timer.currentStepNum()) ||
|
||||
events.hasEvent(ScheduleEvents::INJECTION_UPDATE, timer.currentStepNum()) ||
|
||||
events.hasEvent(ScheduleEvents::WELL_STATUS_CHANGE, timer.currentStepNum());
|
||||
report += adaptiveTimeStepping->step( timer, *solver, state, well_state, event, output_writer_,
|
||||
output_writer_.requireFIPNUM() ? &fipnum : nullptr );
|
||||
report += adaptiveTimeStepping->step(timer, *solver, state, well_state, event, output_writer_,
|
||||
output_writer_.requireFIPNUM() ? &fipnum : nullptr );
|
||||
}
|
||||
else {
|
||||
// solve for complete report step
|
||||
|
@ -19,13 +19,13 @@
|
||||
along with OPM. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef OPM_SIMULATORFULLYIMPLICITBLACKOILEBOS_HEADER_INCLUDED
|
||||
#define OPM_SIMULATORFULLYIMPLICITBLACKOILEBOS_HEADER_INCLUDED
|
||||
#ifndef OPM_SIMULATOR_FULLY_IMPLICIT_BLACKOIL_EBOS_HPP
|
||||
#define OPM_SIMULATOR_FULLY_IMPLICIT_BLACKOIL_EBOS_HPP
|
||||
|
||||
#include <opm/autodiff/IterationReport.hpp>
|
||||
#include <opm/autodiff/NonlinearSolverEbos.hpp>
|
||||
#include <opm/autodiff/BlackoilModelEbos.hpp>
|
||||
#include <opm/autodiff/BlackoilModelParameters.hpp>
|
||||
#include <opm/autodiff/BlackoilModelParametersEbos.hpp>
|
||||
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
|
||||
#include <opm/autodiff/BlackoilWellModel.hpp>
|
||||
#include <opm/autodiff/BlackoilAquiferModel.hpp>
|
||||
@ -36,7 +36,17 @@
|
||||
#include <opm/common/Exceptions.hpp>
|
||||
#include <opm/common/ErrorMacros.hpp>
|
||||
|
||||
#include <dune/common/unused.hh>
|
||||
BEGIN_PROPERTIES;
|
||||
|
||||
NEW_PROP_TAG(FlowEnableTerminalOutput);
|
||||
NEW_PROP_TAG(FlowEnableAdaptiveTimeStepping);
|
||||
NEW_PROP_TAG(FlowEnableTuning);
|
||||
|
||||
SET_BOOL_PROP(EclFlowProblem, FlowEnableTerminalOutput, true);
|
||||
SET_BOOL_PROP(EclFlowProblem, FlowEnableAdaptiveTimeStepping, true);
|
||||
SET_BOOL_PROP(EclFlowProblem, FlowEnableTuning, false);
|
||||
|
||||
END_PROPERTIES;
|
||||
|
||||
namespace Opm {
|
||||
|
||||
@ -56,13 +66,15 @@ public:
|
||||
typedef typename GET_PROP_TYPE(TypeTag, SolutionVector) SolutionVector ;
|
||||
typedef typename GET_PROP_TYPE(TypeTag, MaterialLawParams) MaterialLawParams;
|
||||
|
||||
typedef AdaptiveTimeSteppingEbos<TypeTag> TimeStepper;
|
||||
typedef Ewoms::BlackOilPolymerModule<TypeTag> PolymerModule;
|
||||
|
||||
typedef WellStateFullyImplicitBlackoil WellState;
|
||||
typedef BlackoilState ReservoirState;
|
||||
typedef BlackoilModelEbos<TypeTag> Model;
|
||||
typedef BlackoilModelParameters ModelParameters;
|
||||
typedef NonlinearSolverEbos<Model> Solver;
|
||||
typedef NonlinearSolverEbos<TypeTag, Model> Solver;
|
||||
typedef typename Model::ModelParameters ModelParameters;
|
||||
typedef typename Solver::SolverParameters SolverParameters;
|
||||
typedef BlackoilWellModel<TypeTag> WellModel;
|
||||
typedef BlackoilAquiferModel<TypeTag> AquiferModel;
|
||||
|
||||
@ -85,30 +97,34 @@ public:
|
||||
///
|
||||
/// \param[in] props fluid and rock properties
|
||||
/// \param[in] linsolver linear solver
|
||||
/// \param[in] has_disgas true for dissolved gas option
|
||||
/// \param[in] has_vapoil true for vaporized oil option
|
||||
/// \param[in] eclipse_state the object which represents an internalized ECL deck
|
||||
/// \param[in] output_writer
|
||||
/// \param[in] threshold_pressures_by_face if nonempty, threshold pressures that inhibit flow
|
||||
SimulatorFullyImplicitBlackoilEbos(Simulator& ebosSimulator,
|
||||
const ParameterGroup& param,
|
||||
NewtonIterationBlackoilInterface& linsolver)
|
||||
NewtonIterationBlackoilInterface& linearSolver)
|
||||
: ebosSimulator_(ebosSimulator)
|
||||
, param_(param)
|
||||
, modelParam_(param)
|
||||
, solverParam_(param)
|
||||
, solver_(linsolver)
|
||||
, phaseUsage_(phaseUsageFromDeck(eclState()))
|
||||
, terminalOutput_(param.getDefault("output_terminal", true))
|
||||
, linearSolver_(linearSolver)
|
||||
{
|
||||
#if HAVE_MPI
|
||||
if (solver_.parallelInformation().type() == typeid(ParallelISTLInformation)) {
|
||||
const ParallelISTLInformation& info =
|
||||
boost::any_cast<const ParallelISTLInformation&>(solver_.parallelInformation());
|
||||
// Only rank 0 does print to std::cout
|
||||
terminalOutput_ = terminalOutput_ && (info.communicator().rank() == 0);
|
||||
}
|
||||
#endif
|
||||
phaseUsage_ = phaseUsageFromDeck(eclState());
|
||||
|
||||
// Only rank 0 does print to std::cout
|
||||
const auto& comm = grid().comm();
|
||||
terminalOutput_ = EWOMS_GET_PARAM(TypeTag, bool, FlowEnableTerminalOutput);
|
||||
terminalOutput_ = terminalOutput_ && (comm.rank() == 0);
|
||||
}
|
||||
|
||||
static void registerParameters()
|
||||
{
|
||||
ModelParameters::registerParameters();
|
||||
SolverParameters::registerParameters();
|
||||
TimeStepper::registerParameters();
|
||||
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowEnableTerminalOutput,
|
||||
"Print high-level information about the simulation's progress to the terminal");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowEnableAdaptiveTimeStepping,
|
||||
"Use adaptive time stepping between report steps");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowEnableTuning,
|
||||
"Honor some aspects of the TUNING keyword.");
|
||||
}
|
||||
|
||||
/// Run the simulation.
|
||||
@ -139,14 +155,15 @@ public:
|
||||
|
||||
// adaptive time stepping
|
||||
const auto& events = schedule().getEvents();
|
||||
std::unique_ptr< AdaptiveTimeSteppingEbos > adaptiveTimeStepping;
|
||||
const bool useTUNING = param_.getDefault("use_TUNING", false);
|
||||
if (param_.getDefault("timestep.adaptive", true)) {
|
||||
if (useTUNING) {
|
||||
adaptiveTimeStepping.reset(new AdaptiveTimeSteppingEbos(schedule().getTuning(), timer.currentStepNum(), param_, terminalOutput_));
|
||||
std::unique_ptr<TimeStepper > adaptiveTimeStepping;
|
||||
bool enableAdaptive = EWOMS_GET_PARAM(TypeTag, bool, FlowEnableAdaptiveTimeStepping);
|
||||
bool enableTUNING = EWOMS_GET_PARAM(TypeTag, bool, FlowEnableTuning);
|
||||
if (enableAdaptive) {
|
||||
if (enableTUNING) {
|
||||
adaptiveTimeStepping.reset(new TimeStepper(schedule().getTuning(), timer.currentStepNum(), terminalOutput_));
|
||||
}
|
||||
else {
|
||||
adaptiveTimeStepping.reset(new AdaptiveTimeSteppingEbos(param_, terminalOutput_));
|
||||
adaptiveTimeStepping.reset(new TimeStepper(terminalOutput_));
|
||||
}
|
||||
|
||||
double suggestedStepSize = -1.0;
|
||||
@ -239,7 +256,7 @@ public:
|
||||
// \Note: The report steps are met in any case
|
||||
// \Note: The sub stepping will require a copy of the state variables
|
||||
if (adaptiveTimeStepping) {
|
||||
if (useTUNING) {
|
||||
if (enableTUNING) {
|
||||
if (events.hasEvent(ScheduleEvents::TUNING_CHANGE,timer.currentStepNum())) {
|
||||
adaptiveTimeStepping->updateTUNING(schedule().getTuning(), timer.currentStepNum());
|
||||
}
|
||||
@ -332,7 +349,7 @@ protected:
|
||||
modelParam_,
|
||||
wellModel,
|
||||
aquifer_model,
|
||||
solver_,
|
||||
linearSolver_,
|
||||
terminalOutput_));
|
||||
|
||||
return std::unique_ptr<Solver>(new Solver(solverParam_, std::move(model)));
|
||||
@ -367,23 +384,19 @@ protected:
|
||||
|
||||
// Data.
|
||||
Simulator& ebosSimulator_;
|
||||
|
||||
std::unique_ptr<WellConnectionAuxiliaryModule<TypeTag>> wellAuxMod_;
|
||||
typedef typename Solver::SolverParametersEbos SolverParametersEbos;
|
||||
|
||||
SimulatorReport failureReport_;
|
||||
|
||||
const ParameterGroup param_;
|
||||
ModelParameters modelParam_;
|
||||
SolverParametersEbos solverParam_;
|
||||
SolverParameters solverParam_;
|
||||
|
||||
// Observed objects.
|
||||
NewtonIterationBlackoilInterface& solver_;
|
||||
NewtonIterationBlackoilInterface& linearSolver_;
|
||||
PhaseUsage phaseUsage_;
|
||||
// Misc. data
|
||||
bool terminalOutput_;
|
||||
bool terminalOutput_;
|
||||
};
|
||||
|
||||
} // namespace Opm
|
||||
|
||||
#endif // OPM_SIMULATORFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
|
||||
#endif // OPM_SIMULATOR_FULLY_IMPLICIT_BLACKOIL_EBOS_HPP
|
||||
|
@ -41,7 +41,7 @@
|
||||
#include <opm/autodiff/VFPProdProperties.hpp>
|
||||
#include <opm/autodiff/WellHelpers.hpp>
|
||||
#include <opm/autodiff/WellStateFullyImplicitBlackoil.hpp>
|
||||
#include <opm/autodiff/BlackoilModelParameters.hpp>
|
||||
#include <opm/autodiff/BlackoilModelParametersEbos.hpp>
|
||||
#include <opm/autodiff/RateConverter.hpp>
|
||||
|
||||
#include <opm/simulators/WellSwitchingLogger.hpp>
|
||||
@ -69,7 +69,7 @@ namespace Opm
|
||||
|
||||
using WellState = WellStateFullyImplicitBlackoil;
|
||||
|
||||
typedef BlackoilModelParameters ModelParameters;
|
||||
typedef BlackoilModelParametersEbos<TypeTag> ModelParameters;
|
||||
|
||||
static const int Water = BlackoilPhases::Aqua;
|
||||
static const int Oil = BlackoilPhases::Liquid;
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <iostream>
|
||||
#include <utility>
|
||||
|
||||
#include <opm/core/simulator/SimulatorReport.hpp>
|
||||
#include <opm/grid/utility/StopWatch.hpp>
|
||||
#include <opm/common/OpmLog/OpmLog.hpp>
|
||||
#include <opm/common/utility/parameters/ParameterGroup.hpp>
|
||||
@ -14,11 +15,57 @@
|
||||
#include <opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp>
|
||||
#include <opm/simulators/timestepping/TimeStepControlInterface.hpp>
|
||||
#include <opm/simulators/timestepping/TimeStepControl.hpp>
|
||||
#include <opm/core/props/phaseUsageFromDeck.hpp>
|
||||
|
||||
BEGIN_PROPERTIES
|
||||
|
||||
NEW_TYPE_TAG(FlowTimeSteppingParameters);
|
||||
|
||||
NEW_PROP_TAG(Scalar);
|
||||
|
||||
NEW_PROP_TAG(FlowSolverRestartFactor);
|
||||
NEW_PROP_TAG(FlowSolverGrowthFactor);
|
||||
NEW_PROP_TAG(FlowSolverMaxGrowth);
|
||||
NEW_PROP_TAG(FlowSolverMaxTimeStepInDays);
|
||||
NEW_PROP_TAG(FlowSolverMaxRestarts);
|
||||
NEW_PROP_TAG(FlowSolverVerbosity);
|
||||
NEW_PROP_TAG(FlowTimeStepVerbosity);
|
||||
NEW_PROP_TAG(FlowInitialTimeStepInDays);
|
||||
NEW_PROP_TAG(FlowFullTimeStepInitially);
|
||||
NEW_PROP_TAG(FlowTimeStepAfterEventInDays);
|
||||
NEW_PROP_TAG(FlowTimeStepControl);
|
||||
NEW_PROP_TAG(FlowTimeStepControlTolerance);
|
||||
NEW_PROP_TAG(FlowTimeStepControlTargetIterations);
|
||||
NEW_PROP_TAG(FlowTimeStepControlTargetNewtonIterations);
|
||||
NEW_PROP_TAG(FlowTimeStepControlDecayRate);
|
||||
NEW_PROP_TAG(FlowTimeStepControlGrowthRate);
|
||||
NEW_PROP_TAG(FlowTimeStepControlFileName);
|
||||
|
||||
SET_SCALAR_PROP(FlowTimeSteppingParameters, FlowSolverRestartFactor, 0.33);
|
||||
SET_SCALAR_PROP(FlowTimeSteppingParameters, FlowSolverGrowthFactor, 2.0);
|
||||
SET_SCALAR_PROP(FlowTimeSteppingParameters, FlowSolverMaxGrowth, 3.0);
|
||||
SET_SCALAR_PROP(FlowTimeSteppingParameters, FlowSolverMaxTimeStepInDays, 365.0);
|
||||
SET_INT_PROP(FlowTimeSteppingParameters, FlowSolverMaxRestarts, 10);
|
||||
SET_INT_PROP(FlowTimeSteppingParameters, FlowSolverVerbosity, 1);
|
||||
SET_INT_PROP(FlowTimeSteppingParameters, FlowTimeStepVerbosity, 1);
|
||||
SET_SCALAR_PROP(FlowTimeSteppingParameters, FlowInitialTimeStepInDays, 1.0);
|
||||
SET_BOOL_PROP(FlowTimeSteppingParameters, FlowFullTimeStepInitially, false);
|
||||
SET_SCALAR_PROP(FlowTimeSteppingParameters, FlowTimeStepAfterEventInDays, -1.0);
|
||||
SET_STRING_PROP(FlowTimeSteppingParameters, FlowTimeStepControl, "pid");
|
||||
SET_SCALAR_PROP(FlowTimeSteppingParameters, FlowTimeStepControlTolerance, 1e-1);
|
||||
SET_INT_PROP(FlowTimeSteppingParameters, FlowTimeStepControlTargetIterations, 30);
|
||||
SET_INT_PROP(FlowTimeSteppingParameters, FlowTimeStepControlTargetNewtonIterations, 8);
|
||||
SET_SCALAR_PROP(FlowTimeSteppingParameters, FlowTimeStepControlDecayRate, 0.75);
|
||||
SET_SCALAR_PROP(FlowTimeSteppingParameters, FlowTimeStepControlGrowthRate, 1.25);
|
||||
SET_STRING_PROP(FlowTimeSteppingParameters, FlowTimeStepControlFileName, "timesteps");
|
||||
|
||||
END_PROPERTIES
|
||||
|
||||
namespace Opm {
|
||||
// AdaptiveTimeStepping
|
||||
//---------------------
|
||||
|
||||
template<class TypeTag>
|
||||
class AdaptiveTimeSteppingEbos
|
||||
{
|
||||
template <class Solver>
|
||||
@ -48,23 +95,21 @@ namespace Opm {
|
||||
|
||||
public:
|
||||
//! \brief contructor taking parameter object
|
||||
AdaptiveTimeSteppingEbos(const ParameterGroup& param,
|
||||
const bool terminalOutput = true)
|
||||
AdaptiveTimeSteppingEbos(const bool terminalOutput = true)
|
||||
: timeStepControl_()
|
||||
, restartFactor_( param.getDefault("solver.restartfactor", double(0.33)))
|
||||
, growthFactor_( param.getDefault("solver.growthfactor", double(2)))
|
||||
, maxGrowth_( param.getDefault("timestep.control.maxgrowth", double(3.0)))
|
||||
// default is 1 year, convert to seconds
|
||||
, maxTimeStep_( unit::convert::from(param.getDefault("timestep.max_timestep_in_days", 365.0), unit::day))
|
||||
, solverRestartMax_( param.getDefault("solver.restart", int(10)))
|
||||
, solverVerbose_( param.getDefault("solver.verbose", bool(true)) && terminalOutput)
|
||||
, timestepVerbose_( param.getDefault("timestep.verbose", bool(true)) && terminalOutput)
|
||||
, suggestedNextTimestep_( unit::convert::from(param.getDefault("timestep.initial_timestep_in_days", 1.0), unit::day))
|
||||
, fullTimestepInitially_( param.getDefault("full_timestep_initially", bool(false)))
|
||||
, timestepAfterEvent_( unit::convert::from(param.getDefault("timestep.timestep_in_days_after_event", -1.0), unit::day))
|
||||
, restartFactor_(EWOMS_GET_PARAM(TypeTag, double, FlowSolverRestartFactor)) // 0.33
|
||||
, growthFactor_(EWOMS_GET_PARAM(TypeTag, double, FlowSolverGrowthFactor)) // 2.0
|
||||
, maxGrowth_(EWOMS_GET_PARAM(TypeTag, double, FlowSolverMaxGrowth)) // 3.0
|
||||
, maxTimeStep_(EWOMS_GET_PARAM(TypeTag, double, FlowSolverMaxTimeStepInDays)*24*60*60) // 365.25
|
||||
, solverRestartMax_(EWOMS_GET_PARAM(TypeTag, int, FlowSolverMaxRestarts)) // 10
|
||||
, solverVerbose_(EWOMS_GET_PARAM(TypeTag, int, FlowSolverVerbosity) > 0 && terminalOutput) // 2
|
||||
, timestepVerbose_(EWOMS_GET_PARAM(TypeTag, int, FlowTimeStepVerbosity) > 0 && terminalOutput) // 2
|
||||
, suggestedNextTimestep_(EWOMS_GET_PARAM(TypeTag, double, FlowInitialTimeStepInDays)*24*60*60) // 1.0
|
||||
, fullTimestepInitially_(EWOMS_GET_PARAM(TypeTag, bool, FlowFullTimeStepInitially)) // false
|
||||
, timestepAfterEvent_(EWOMS_GET_PARAM(TypeTag, double, FlowTimeStepAfterEventInDays)*24*60*60) // 1e30
|
||||
, useNewtonIteration_(false)
|
||||
{
|
||||
init_(param);
|
||||
init_();
|
||||
}
|
||||
|
||||
|
||||
@ -72,26 +117,62 @@ namespace Opm {
|
||||
//! \brief contructor taking parameter object
|
||||
//! \param tuning Pointer to ecl TUNING keyword
|
||||
//! \param timeStep current report step
|
||||
//! \param param The parameter object
|
||||
AdaptiveTimeSteppingEbos(const Tuning& tuning,
|
||||
size_t timeStep,
|
||||
const ParameterGroup& param,
|
||||
const bool terminalOutput = true)
|
||||
: timeStepControl_()
|
||||
, restartFactor_(tuning.getTSFCNV(timeStep))
|
||||
, growthFactor_(tuning.getTFDIFF(timeStep))
|
||||
, maxGrowth_(tuning.getTSFMAX(timeStep))
|
||||
// default is 1 year, convert to seconds
|
||||
, maxTimeStep_(tuning.getTSMAXZ(timeStep))
|
||||
, solverRestartMax_(param.getDefault("solver.restart", int(10)))
|
||||
, solverVerbose_(param.getDefault("solver.verbose", bool(true)) && terminalOutput)
|
||||
, timestepVerbose_(param.getDefault("timestep.verbose", bool(true)) && terminalOutput)
|
||||
, suggestedNextTimestep_(tuning.getTSINIT(timeStep))
|
||||
, fullTimestepInitially_(param.getDefault("full_timestep_initially", bool(false)))
|
||||
, timestepAfterEvent_(tuning.getTMAXWC(timeStep))
|
||||
, maxTimeStep_(EWOMS_GET_PARAM(TypeTag, double, FlowSolverMaxTimeStepInDays)*24*60*60) // 365.25
|
||||
, solverRestartMax_(EWOMS_GET_PARAM(TypeTag, int, FlowSolverMaxRestarts)) // 10
|
||||
, solverVerbose_(EWOMS_GET_PARAM(TypeTag, int, FlowSolverVerbosity) > 0 && terminalOutput) // 2
|
||||
, timestepVerbose_(EWOMS_GET_PARAM(TypeTag, int, FlowTimeStepVerbosity) > 0 && terminalOutput) // 2
|
||||
, suggestedNextTimestep_(EWOMS_GET_PARAM(TypeTag, double, FlowInitialTimeStepInDays)*24*60*60) // 1.0
|
||||
, fullTimestepInitially_(EWOMS_GET_PARAM(TypeTag, bool, FlowFullTimeStepInitially)) // false
|
||||
, timestepAfterEvent_(EWOMS_GET_PARAM(TypeTag, double, FlowTimeStepAfterEventInDays)*24*60*60) // 1e30
|
||||
, useNewtonIteration_(false)
|
||||
{
|
||||
init_(param);
|
||||
init_();
|
||||
}
|
||||
|
||||
static void registerParameters()
|
||||
{
|
||||
// TODO: make sure the help messages are correct (and useful)
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowSolverRestartFactor,
|
||||
"The factor time steps are elongated after restarts");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowSolverGrowthFactor,
|
||||
"The factor time steps are elongated after a successful substep");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowSolverMaxGrowth,
|
||||
"The maximum factor time steps are elongated after a report step");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowSolverMaxTimeStepInDays,
|
||||
"The maximum size of a time step in days");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowSolverMaxRestarts,
|
||||
"The maximum number of breakdowns before a substep is given up and the simulator is terminated");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowSolverVerbosity,
|
||||
"Specify the \"chattiness\" of the non-linear solver itself");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowTimeStepVerbosity,
|
||||
"Specify the \"chattiness\" during the time integration");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowInitialTimeStepInDays,
|
||||
"The size of the initial time step in days");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, bool, FlowFullTimeStepInitially,
|
||||
"Always attempt to finish a report step using a single substep");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowTimeStepAfterEventInDays,
|
||||
"Time step size of the first time step after an event occurs during the simulation in days");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, std::string, FlowTimeStepControl,
|
||||
"The algorithm used to determine time-step sizes. valid options are: 'pid' (default), 'pid+iteration', 'pid+newtoniteration', 'iterationcount' and 'hardcoded'");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowTimeStepControlTolerance,
|
||||
"The tolerance used by the time step size control algorithm");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowTimeStepControlTargetIterations,
|
||||
"The number of linear iterations which the time step control scheme should aim for (if applicable)");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, int, FlowTimeStepControlTargetNewtonIterations,
|
||||
"The number of Newton iterations which the time step control scheme should aim for (if applicable)");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowTimeStepControlDecayRate,
|
||||
"The decay rate of the time step size of the number of target iterations is exceeded");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, double, FlowTimeStepControlGrowthRate,
|
||||
"The growth rate of the time step size of the number of target iterations is undercut");
|
||||
EWOMS_REGISTER_PARAM(TypeTag, std::string, FlowTimeStepControlFileName,
|
||||
"The name of the file which contains the hardcoded time steps sizes");
|
||||
}
|
||||
|
||||
/** \brief step method that acts like the solver::step method
|
||||
@ -322,35 +403,32 @@ namespace Opm {
|
||||
|
||||
|
||||
protected:
|
||||
void init_(const ParameterGroup& param)
|
||||
void init_()
|
||||
{
|
||||
// valid are "pid" and "pid+iteration"
|
||||
std::string control = param.getDefault("timestep.control", std::string("pid"));
|
||||
// iterations is the accumulation of all linear iterations over all newton steops per time step
|
||||
const int defaultTargetIterations = 30;
|
||||
const int defaultTargetNewtonIterations = 8;
|
||||
std::string control = EWOMS_GET_PARAM(TypeTag, std::string, FlowTimeStepControl); // "pid"
|
||||
|
||||
const double tol = param.getDefault("timestep.control.tol", double(1e-1));
|
||||
const double tol = EWOMS_GET_PARAM(TypeTag, double, FlowTimeStepControlTolerance); // 1e-1
|
||||
if (control == "pid") {
|
||||
timeStepControl_ = TimeStepControlType(new PIDTimeStepControl(tol));
|
||||
}
|
||||
else if (control == "pid+iteration") {
|
||||
const int iterations = param.getDefault("timestep.control.targetiteration", defaultTargetIterations);
|
||||
const int iterations = EWOMS_GET_PARAM(TypeTag, int, FlowTimeStepControlTargetIterations); // 30
|
||||
timeStepControl_ = TimeStepControlType(new PIDAndIterationCountTimeStepControl(iterations, tol));
|
||||
}
|
||||
else if (control == "pid+newtoniteration") {
|
||||
const int iterations = param.getDefault("timestep.control.targetiteration", defaultTargetNewtonIterations);
|
||||
const int iterations = EWOMS_GET_PARAM(TypeTag, int, FlowTimeStepControlTargetNewtonIterations); // 8
|
||||
timeStepControl_ = TimeStepControlType(new PIDAndIterationCountTimeStepControl(iterations, tol));
|
||||
useNewtonIteration_ = true;
|
||||
}
|
||||
else if (control == "iterationcount") {
|
||||
const int iterations = param.getDefault("timestep.control.targetiteration", defaultTargetIterations);
|
||||
const double decayrate = param.getDefault("timestep.control.decayrate", double(0.75));
|
||||
const double growthrate = param.getDefault("timestep.control.growthrate", double(1.25));
|
||||
const int iterations = EWOMS_GET_PARAM(TypeTag, int, FlowTimeStepControlTargetIterations); // 30
|
||||
const double decayrate = EWOMS_GET_PARAM(TypeTag, double, FlowTimeStepControlDecayRate); // 0.75
|
||||
const double growthrate = EWOMS_GET_PARAM(TypeTag, double, FlowTimeStepControlGrowthRate); // 1.25
|
||||
timeStepControl_ = TimeStepControlType(new SimpleIterationCountTimeStepControl(iterations, decayrate, growthrate));
|
||||
}
|
||||
else if (control == "hardcoded") {
|
||||
const std::string filename = param.getDefault("timestep.control.filename", std::string("timesteps"));
|
||||
const std::string filename = EWOMS_GET_PARAM(TypeTag, std::string, FlowTimeStepControlFileName); // "timesteps"
|
||||
timeStepControl_ = TimeStepControlType(new HardcodedTimeStepControl(filename));
|
||||
|
||||
}
|
||||
@ -361,7 +439,6 @@ namespace Opm {
|
||||
assert(growthFactor_ >= 1.0);
|
||||
}
|
||||
|
||||
|
||||
typedef std::unique_ptr<TimeStepControlInterface> TimeStepControlType;
|
||||
|
||||
SimulatorReport failureReport_; //!< statistics for the failed substeps of the last timestep
|
||||
@ -370,9 +447,9 @@ namespace Opm {
|
||||
double growthFactor_; //!< factor to multiply time step when solver recovered from failed convergence
|
||||
double maxGrowth_; //!< factor that limits the maximum growth of a time step
|
||||
double maxTimeStep_; //!< maximal allowed time step size
|
||||
const int solverRestartMax_; //!< how many restart of solver are allowed
|
||||
const bool solverVerbose_; //!< solver verbosity
|
||||
const bool timestepVerbose_; //!< timestep verbosity
|
||||
int solverRestartMax_; //!< how many restart of solver are allowed
|
||||
bool solverVerbose_; //!< solver verbosity
|
||||
bool timestepVerbose_; //!< timestep verbosity
|
||||
double suggestedNextTimestep_; //!< suggested size of next timestep
|
||||
bool fullTimestepInitially_; //!< beginning with the size of the time step from data file
|
||||
double timestepAfterEvent_; //!< suggested size of timestep after an event
|
||||
|
@ -21,7 +21,11 @@ TEST_ARGS="$@"
|
||||
rm -Rf ${RESULT_PATH}
|
||||
mkdir -p ${RESULT_PATH}
|
||||
cd ${RESULT_PATH}
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS} nosim=true output_dir=${RESULT_PATH}
|
||||
if test "${EXE_NAME}" = "flow"; then
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS} --flow-enable-dry-run=true --ecl-output-dir=${RESULT_PATH}
|
||||
else
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS} nosim=true output_dir=${RESULT_PATH}
|
||||
fi
|
||||
cd ..
|
||||
|
||||
ecode=0
|
||||
|
@ -19,11 +19,20 @@ TEST_ARGS="$@"
|
||||
rm -Rf ${RESULT_PATH}
|
||||
mkdir -p ${RESULT_PATH}
|
||||
cd ${RESULT_PATH}
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA linear_solver_reduction=1e-7 tolerance_cnv=5e-6 tolerance_mb=1e-8 output_dir=${RESULT_PATH}
|
||||
if test "${EXE_NAME}" = "flow"; then
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA --flow-linear-solver-reduction=1e-7 --flow-tolerance-cnv=5e-6 --flow-tolerance-mb=1e-8 --ecl-output-dir=${RESULT_PATH}
|
||||
else
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA linear_solver_reduction=1e-7 tolerance_cnv=5e-6 tolerance_mb=1e-8 output_dir=${RESULT_PATH}
|
||||
fi
|
||||
|
||||
test $? -eq 0 || exit 1
|
||||
mkdir mpi
|
||||
cd mpi
|
||||
mpirun -np 4 ${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA linear_solver_reduction=1e-7 tolerance_cnv=5e-6 tolerance_mb=1e-8 output_dir=${RESULT_PATH}/mpi
|
||||
if test "${EXE_NAME}" = "flow"; then
|
||||
mpirun -np 4 ${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA --flow-linear-solver-reduction=1e-7 --flow-tolerance-cnv=5e-6 --flow-tolerance-mb=1e-8 --ecl-output-dir=${RESULT_PATH}/mpi
|
||||
else
|
||||
mpirun -np 4 ${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA linear_solver_reduction=1e-7 tolerance_cnv=5e-6 tolerance_mb=1e-8 output_dir=${RESULT_PATH}/mpi
|
||||
fi
|
||||
test $? -eq 0 || exit 1
|
||||
cd ..
|
||||
|
||||
|
@ -21,9 +21,14 @@ TEST_ARGS="$@"
|
||||
rm -Rf ${RESULT_PATH}
|
||||
mkdir -p ${RESULT_PATH}
|
||||
cd ${RESULT_PATH}
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS} nosim=true output_dir=${RESULT_PATH}
|
||||
if test "${EXE_NAME}" = "flow"; then
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS} --flow-enable-dry-run=true --ecl-output-dir=${RESULT_PATH}
|
||||
else
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS} nosim=true output_dir=${RESULT_PATH}
|
||||
fi
|
||||
cd ..
|
||||
|
||||
|
||||
ecode=0
|
||||
${COMPARE_ECL_COMMAND} -t INIT -k PORV ${RESULT_PATH}/${FILENAME} ${INPUT_DATA_PATH}/opm-porevolume-reference/${EXE_NAME}/${FILENAME} ${ABS_TOL} ${REL_TOL}
|
||||
if [ $? -ne 0 ]
|
||||
|
@ -17,7 +17,11 @@ TEST_ARGS="$@"
|
||||
|
||||
mkdir -p ${RESULT_PATH}
|
||||
cd ${RESULT_PATH}
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS} output_dir=${RESULT_PATH}
|
||||
if test "${EXE_NAME}" = "flow"; then
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS} --ecl-output-dir=${RESULT_PATH}
|
||||
else
|
||||
${BINPATH}/${EXE_NAME} ${TEST_ARGS} output_dir=${RESULT_PATH}
|
||||
fi
|
||||
test $? -eq 0 || exit 1
|
||||
cd ..
|
||||
|
||||
|
@ -29,11 +29,21 @@ then
|
||||
else
|
||||
CMD_PREFIX=""
|
||||
fi
|
||||
${CMD_PREFIX} ${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA timestep.adaptive=false output_dir=${RESULT_PATH}
|
||||
if test "${EXE_NAME}" = "flow"; then
|
||||
${CMD_PREFIX} ${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA --flow-enable-adaptive-time-stepping=false --ecl-output-dir=${RESULT_PATH}
|
||||
else
|
||||
${CMD_PREFIX} ${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA timestep.adaptive=false output_dir=${RESULT_PATH}
|
||||
fi
|
||||
|
||||
test $? -eq 0 || exit 1
|
||||
|
||||
${OPM_PACK_COMMAND} -o ${BASE_NAME} ${TEST_ARGS}_RESTART.DATA
|
||||
${CMD_PREFIX} ${BINPATH}/${EXE_NAME} ${BASE_NAME} timestep.adaptive=false output_dir=${RESULT_PATH}
|
||||
|
||||
if test "${EXE_NAME}" = "flow"; then
|
||||
${CMD_PREFIX} ${BINPATH}/${EXE_NAME} ${TEST_ARGS}.DATA --flow-enable-adaptive-time-stepping=false --ecl-output-dir=${RESULT_PATH}
|
||||
else
|
||||
${CMD_PREFIX} ${BINPATH}/${EXE_NAME} ${BASE_NAME} timestep.adaptive=false output_dir=${RESULT_PATH}
|
||||
fi
|
||||
test $? -eq 0 || exit 1
|
||||
|
||||
ecode=0
|
||||
|
@ -44,7 +44,8 @@
|
||||
|
||||
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
|
||||
#include <opm/autodiff/GridHelpers.hpp>
|
||||
#include <opm/autodiff/BlackoilModelParameters.hpp>
|
||||
#include <opm/autodiff/FlowMainEbos.hpp>
|
||||
#include <opm/autodiff/BlackoilModelEbos.hpp>
|
||||
#include <opm/autodiff/createGlobalCellArray.hpp>
|
||||
#include <opm/autodiff/GridInit.hpp>
|
||||
|
||||
@ -56,12 +57,11 @@
|
||||
#include <opm/autodiff/StandardWell.hpp>
|
||||
#include <opm/autodiff/BlackoilWellModel.hpp>
|
||||
|
||||
// maybe should just include BlackoilModelEbos.hpp
|
||||
namespace Ewoms {
|
||||
namespace Properties {
|
||||
NEW_TYPE_TAG(EclFlowProblem, INHERITS_FROM(BlackOilModel, EclBaseProblem));
|
||||
}
|
||||
}
|
||||
#if HAVE_DUNE_FEM
|
||||
#include <dune/fem/misc/mpimanager.hh>
|
||||
#else
|
||||
#include <dune/common/parallel/mpihelper.hh>
|
||||
#endif
|
||||
|
||||
using StandardWell = Opm::StandardWell<TTAG(EclFlowProblem)>;
|
||||
|
||||
@ -120,6 +120,25 @@ struct SetupTest {
|
||||
int current_timestep;
|
||||
};
|
||||
|
||||
struct GlobalFixture {
|
||||
GlobalFixture()
|
||||
{
|
||||
int argcDummy = 1;
|
||||
const char *tmp[] = {"test_wellmodel"};
|
||||
char **argvDummy = const_cast<char**>(tmp);
|
||||
|
||||
// MPI setup.
|
||||
#if HAVE_DUNE_FEM
|
||||
Dune::Fem::MPIManager::initialize(argcDummy, argvDummy);
|
||||
#else
|
||||
Dune::MPIHelper::instance(argcDummy, argvDummy);
|
||||
#endif
|
||||
|
||||
Opm::FlowMainEbos<TTAG(EclFlowProblem)>::setupParameters_(argcDummy, argvDummy);
|
||||
}
|
||||
};
|
||||
|
||||
BOOST_GLOBAL_FIXTURE(GlobalFixture);
|
||||
|
||||
BOOST_AUTO_TEST_CASE(TestStandardWellInput) {
|
||||
const SetupTest setup_test;
|
||||
@ -127,7 +146,7 @@ BOOST_AUTO_TEST_CASE(TestStandardWellInput) {
|
||||
const auto& wells_ecl = setup_test.schedule->getWells(setup_test.current_timestep);
|
||||
BOOST_CHECK_EQUAL( wells_ecl.size(), 2);
|
||||
const Opm::Well* well = wells_ecl[1];
|
||||
const Opm::BlackoilModelParameters param;
|
||||
const Opm::BlackoilModelParametersEbos<TTAG(EclFlowProblem) > param;
|
||||
|
||||
// For the conversion between the surface volume rate and resrevoir voidage rate
|
||||
typedef Opm::BlackOilFluidSystem<double> FluidSystem;
|
||||
@ -144,8 +163,8 @@ BOOST_AUTO_TEST_CASE(TestStandardWellInput) {
|
||||
const int num_comp = wells->number_of_phases;
|
||||
|
||||
BOOST_CHECK_THROW( StandardWell( well, -1, wells, param, *rateConverter, pvtIdx, num_comp), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( StandardWell( nullptr, 4, wells, param , *rateConverter, pvtIdx, num_comp), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( StandardWell( well, 4, nullptr, param , *rateConverter, pvtIdx, num_comp), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( StandardWell( nullptr, 4, wells , param, *rateConverter, pvtIdx, num_comp), std::invalid_argument);
|
||||
BOOST_CHECK_THROW( StandardWell( well, 4, nullptr , param, *rateConverter, pvtIdx, num_comp), std::invalid_argument);
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +177,7 @@ BOOST_AUTO_TEST_CASE(TestBehavoir) {
|
||||
|
||||
{
|
||||
const int nw = wells_struct ? (wells_struct->number_of_wells) : 0;
|
||||
const Opm::BlackoilModelParameters param;
|
||||
const Opm::BlackoilModelParametersEbos<TTAG(EclFlowProblem)> param;
|
||||
|
||||
for (int w = 0; w < nw; ++w) {
|
||||
const std::string well_name(wells_struct->name[w]);
|
||||
|
Loading…
Reference in New Issue
Block a user