mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
introduce a "SimulatorBase" class
so, far it is just a copy of the old "SimulatorFullyImplicitBlackoil" class (which became a simple forward to the base class). The intention is to unify the common simulator code in this class to avoid excessive copy-and-pasting.
This commit is contained in:
parent
a991eb55e3
commit
3eec9f3432
113
opm/autodiff/SimulatorBase.hpp
Normal file
113
opm/autodiff/SimulatorBase.hpp
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
Copyright 2013 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_SIMULATORBASE_HEADER_INCLUDED
|
||||||
|
#define OPM_SIMULATORBASE_HEADER_INCLUDED
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct UnstructuredGrid;
|
||||||
|
struct Wells;
|
||||||
|
struct FlowBoundaryConditions;
|
||||||
|
|
||||||
|
namespace Opm
|
||||||
|
{
|
||||||
|
namespace parameter { class ParameterGroup; }
|
||||||
|
class BlackoilPropsAdInterface;
|
||||||
|
class RockCompressibility;
|
||||||
|
class DerivedGeology;
|
||||||
|
class NewtonIterationBlackoilInterface;
|
||||||
|
class SimulatorTimer;
|
||||||
|
class BlackoilState;
|
||||||
|
class WellStateFullyImplicitBlackoil;
|
||||||
|
class EclipseState;
|
||||||
|
class BlackoilOutputWriter;
|
||||||
|
struct SimulatorReport;
|
||||||
|
|
||||||
|
/// Class collecting all necessary components for a two-phase simulation.
|
||||||
|
template<class GridT, class Implementation>
|
||||||
|
class SimulatorBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/// \brief The type of the grid that we use.
|
||||||
|
typedef GridT Grid;
|
||||||
|
/// Initialise from parameters and objects to observe.
|
||||||
|
/// \param[in] param parameters, this class accepts the following:
|
||||||
|
/// parameter (default) effect
|
||||||
|
/// -----------------------------------------------------------
|
||||||
|
/// output (true) write output to files?
|
||||||
|
/// output_dir ("output") output directoty
|
||||||
|
/// output_interval (1) output every nth step
|
||||||
|
/// nl_pressure_residual_tolerance (0.0) pressure solver residual tolerance (in Pascal)
|
||||||
|
/// nl_pressure_change_tolerance (1.0) pressure solver change tolerance (in Pascal)
|
||||||
|
/// nl_pressure_maxiter (10) max nonlinear iterations in pressure
|
||||||
|
/// nl_maxiter (30) max nonlinear iterations in transport
|
||||||
|
/// nl_tolerance (1e-9) transport solver absolute residual tolerance
|
||||||
|
/// num_transport_substeps (1) number of transport steps per pressure step
|
||||||
|
/// use_segregation_split (false) solve for gravity segregation (if false,
|
||||||
|
/// segregation is ignored).
|
||||||
|
///
|
||||||
|
/// \param[in] grid grid data structure
|
||||||
|
/// \param[in] geo derived geological properties
|
||||||
|
/// \param[in] props fluid and rock properties
|
||||||
|
/// \param[in] rock_comp_props if non-null, rock compressibility properties
|
||||||
|
/// \param[in] linsolver linear solver
|
||||||
|
/// \param[in] gravity if non-null, gravity vector
|
||||||
|
/// \param[in] disgas true for dissolved gas option
|
||||||
|
/// \param[in] vapoil true for vaporized oil option
|
||||||
|
/// \param[in] eclipse_state
|
||||||
|
/// \param[in] output_writer
|
||||||
|
/// \param[in] threshold_pressures_by_face if nonempty, threshold pressures that inhibit flow
|
||||||
|
SimulatorBase(const parameter::ParameterGroup& param,
|
||||||
|
const Grid& grid,
|
||||||
|
const DerivedGeology& geo,
|
||||||
|
BlackoilPropsAdInterface& props,
|
||||||
|
const RockCompressibility* rock_comp_props,
|
||||||
|
NewtonIterationBlackoilInterface& linsolver,
|
||||||
|
const double* gravity,
|
||||||
|
const bool disgas,
|
||||||
|
const bool vapoil,
|
||||||
|
std::shared_ptr<EclipseState> eclipse_state,
|
||||||
|
BlackoilOutputWriter& output_writer,
|
||||||
|
const std::vector<double>& threshold_pressures_by_face);
|
||||||
|
|
||||||
|
/// Run the simulation.
|
||||||
|
/// This will run succesive timesteps until timer.done() is true. It will
|
||||||
|
/// modify the reservoir and well states.
|
||||||
|
/// \param[in,out] timer governs the requested reporting timesteps
|
||||||
|
/// \param[in,out] state state of reservoir: pressure, fluxes
|
||||||
|
/// \param[in,out] well_state state of wells: bhp, perforation rates
|
||||||
|
/// \return simulation report, with timing data
|
||||||
|
SimulatorReport run(SimulatorTimer& timer,
|
||||||
|
BlackoilState& state);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Implementation& asImp_() { return *static_cast<Implementation*>(this); }
|
||||||
|
const Implementation& asImp_() const { return *static_cast<const Implementation*>(this); }
|
||||||
|
|
||||||
|
class Impl;
|
||||||
|
// Using shared_ptr instead of scoped_ptr since scoped_ptr requires complete type for Impl.
|
||||||
|
std::shared_ptr<Impl> pimpl_;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Opm
|
||||||
|
|
||||||
|
#include "SimulatorBase_impl.hpp"
|
||||||
|
#endif // OPM_SIMULATORBASE_HEADER_INCLUDED
|
@ -73,8 +73,8 @@
|
|||||||
|
|
||||||
namespace Opm
|
namespace Opm
|
||||||
{
|
{
|
||||||
template<class T>
|
template<class GridT, class Implementation>
|
||||||
class SimulatorFullyImplicitBlackoil<T>::Impl
|
class SimulatorBase<GridT, Implementation>::Impl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Impl(const parameter::ParameterGroup& param,
|
Impl(const parameter::ParameterGroup& param,
|
||||||
@ -134,19 +134,19 @@ namespace Opm
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class GridT, class Implementation>
|
||||||
SimulatorFullyImplicitBlackoil<T>::SimulatorFullyImplicitBlackoil(const parameter::ParameterGroup& param,
|
SimulatorBase<GridT, Implementation>::SimulatorBase(const parameter::ParameterGroup& param,
|
||||||
const Grid& grid,
|
const Grid& grid,
|
||||||
const DerivedGeology& geo,
|
const DerivedGeology& geo,
|
||||||
BlackoilPropsAdInterface& props,
|
BlackoilPropsAdInterface& props,
|
||||||
const RockCompressibility* rock_comp_props,
|
const RockCompressibility* rock_comp_props,
|
||||||
NewtonIterationBlackoilInterface& linsolver,
|
NewtonIterationBlackoilInterface& linsolver,
|
||||||
const double* gravity,
|
const double* gravity,
|
||||||
const bool has_disgas,
|
const bool has_disgas,
|
||||||
const bool has_vapoil,
|
const bool has_vapoil,
|
||||||
std::shared_ptr<EclipseState> eclipse_state,
|
std::shared_ptr<EclipseState> eclipse_state,
|
||||||
BlackoilOutputWriter& output_writer,
|
BlackoilOutputWriter& output_writer,
|
||||||
const std::vector<double>& threshold_pressures_by_face)
|
const std::vector<double>& threshold_pressures_by_face)
|
||||||
|
|
||||||
{
|
{
|
||||||
pimpl_.reset(new Impl(param, grid, geo, props, rock_comp_props, linsolver, gravity, has_disgas, has_vapoil,
|
pimpl_.reset(new Impl(param, grid, geo, props, rock_comp_props, linsolver, gravity, has_disgas, has_vapoil,
|
||||||
@ -157,28 +157,28 @@ namespace Opm
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class GridT, class Implementation>
|
||||||
SimulatorReport SimulatorFullyImplicitBlackoil<T>::run(SimulatorTimer& timer,
|
SimulatorReport SimulatorBase<GridT, Implementation>::run(SimulatorTimer& timer,
|
||||||
BlackoilState& state)
|
BlackoilState& state)
|
||||||
{
|
{
|
||||||
return pimpl_->run(timer, state);
|
return pimpl_->run(timer, state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// \TODO: Treat bcs.
|
// \TODO: Treat bcs.
|
||||||
template<class T>
|
template<class GridT, class Implementation>
|
||||||
SimulatorFullyImplicitBlackoil<T>::Impl::Impl(const parameter::ParameterGroup& param,
|
SimulatorBase<GridT, Implementation>::Impl::Impl(const parameter::ParameterGroup& param,
|
||||||
const Grid& grid,
|
const Grid& grid,
|
||||||
const DerivedGeology& geo,
|
const DerivedGeology& geo,
|
||||||
BlackoilPropsAdInterface& props,
|
BlackoilPropsAdInterface& props,
|
||||||
const RockCompressibility* rock_comp_props,
|
const RockCompressibility* rock_comp_props,
|
||||||
NewtonIterationBlackoilInterface& linsolver,
|
NewtonIterationBlackoilInterface& linsolver,
|
||||||
const double* gravity,
|
const double* gravity,
|
||||||
const bool has_disgas,
|
const bool has_disgas,
|
||||||
const bool has_vapoil,
|
const bool has_vapoil,
|
||||||
std::shared_ptr<EclipseState> eclipse_state,
|
std::shared_ptr<EclipseState> eclipse_state,
|
||||||
BlackoilOutputWriter& output_writer,
|
BlackoilOutputWriter& output_writer,
|
||||||
const std::vector<double>& threshold_pressures_by_face)
|
const std::vector<double>& threshold_pressures_by_face)
|
||||||
: param_(param),
|
: param_(param),
|
||||||
grid_(grid),
|
grid_(grid),
|
||||||
props_(props),
|
props_(props),
|
||||||
@ -217,9 +217,9 @@ namespace Opm
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class GridT, class Implementation>
|
||||||
SimulatorReport SimulatorFullyImplicitBlackoil<T>::Impl::run(SimulatorTimer& timer,
|
SimulatorReport SimulatorBase<GridT, Implementation>::Impl::run(SimulatorTimer& timer,
|
||||||
BlackoilState& state)
|
BlackoilState& state)
|
||||||
{
|
{
|
||||||
WellStateFullyImplicitBlackoil prev_well_state;
|
WellStateFullyImplicitBlackoil prev_well_state;
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ namespace Opm
|
|||||||
std::string tstep_filename = output_writer_.outputDirectory() + "/step_timing.txt";
|
std::string tstep_filename = output_writer_.outputDirectory() + "/step_timing.txt";
|
||||||
std::ofstream tstep_os(tstep_filename.c_str());
|
std::ofstream tstep_os(tstep_filename.c_str());
|
||||||
|
|
||||||
typedef T Grid;
|
typedef GridT Grid;
|
||||||
typedef BlackoilModel<Grid> Model;
|
typedef BlackoilModel<Grid> Model;
|
||||||
typedef typename Model::ModelParameters ModelParams;
|
typedef typename Model::ModelParameters ModelParams;
|
||||||
ModelParams modelParams( param_ );
|
ModelParams modelParams( param_ );
|
||||||
@ -475,9 +475,9 @@ namespace Opm
|
|||||||
}
|
}
|
||||||
} // namespace SimFIBODetails
|
} // namespace SimFIBODetails
|
||||||
|
|
||||||
template <class T>
|
template <class GridT, class Implementation>
|
||||||
void
|
void
|
||||||
SimulatorFullyImplicitBlackoil<T>::
|
SimulatorBase<GridT, Implementation>::
|
||||||
Impl::computeRESV(const std::size_t step,
|
Impl::computeRESV(const std::size_t step,
|
||||||
const Wells* wells,
|
const Wells* wells,
|
||||||
const BlackoilState& x,
|
const BlackoilState& x,
|
@ -20,91 +20,35 @@
|
|||||||
#ifndef OPM_SIMULATORFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
|
#ifndef OPM_SIMULATORFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
|
||||||
#define OPM_SIMULATORFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
|
#define OPM_SIMULATORFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
|
||||||
|
|
||||||
#include <memory>
|
#include "SimulatorBase.hpp"
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
struct UnstructuredGrid;
|
namespace Opm {
|
||||||
struct Wells;
|
|
||||||
struct FlowBoundaryConditions;
|
|
||||||
|
|
||||||
namespace Opm
|
/// a simulator for the blackoil model
|
||||||
|
template<class GridT>
|
||||||
|
class SimulatorFullyImplicitBlackoil
|
||||||
|
: public SimulatorBase<GridT, SimulatorFullyImplicitBlackoil<GridT> >
|
||||||
{
|
{
|
||||||
namespace parameter { class ParameterGroup; }
|
typedef SimulatorBase<GridT, SimulatorFullyImplicitBlackoil<GridT> > Base;
|
||||||
class BlackoilPropsAdInterface;
|
public:
|
||||||
class RockCompressibility;
|
// forward the constructor to the base class
|
||||||
class DerivedGeology;
|
SimulatorFullyImplicitBlackoil(const parameter::ParameterGroup& param,
|
||||||
class NewtonIterationBlackoilInterface;
|
const typename Base::Grid& grid,
|
||||||
class SimulatorTimer;
|
const DerivedGeology& geo,
|
||||||
class BlackoilState;
|
BlackoilPropsAdInterface& props,
|
||||||
class WellStateFullyImplicitBlackoil;
|
const RockCompressibility* rock_comp_props,
|
||||||
class EclipseState;
|
NewtonIterationBlackoilInterface& linsolver,
|
||||||
class BlackoilOutputWriter;
|
const double* gravity,
|
||||||
struct SimulatorReport;
|
const bool disgas,
|
||||||
|
const bool vapoil,
|
||||||
/// Class collecting all necessary components for a two-phase simulation.
|
std::shared_ptr<EclipseState> eclipse_state,
|
||||||
template<class T>
|
BlackoilOutputWriter& output_writer,
|
||||||
class SimulatorFullyImplicitBlackoil
|
const std::vector<double>& threshold_pressures_by_face)
|
||||||
{
|
: Base(param, grid, geo, props, rock_comp_props, linsolver, gravity, disgas, vapoil,
|
||||||
public:
|
eclipse_state, output_writer, threshold_pressures_by_face)
|
||||||
/// \brief The type of the grid that we use.
|
{}
|
||||||
typedef T Grid;
|
};
|
||||||
/// Initialise from parameters and objects to observe.
|
|
||||||
/// \param[in] param parameters, this class accepts the following:
|
|
||||||
/// parameter (default) effect
|
|
||||||
/// -----------------------------------------------------------
|
|
||||||
/// output (true) write output to files?
|
|
||||||
/// output_dir ("output") output directoty
|
|
||||||
/// output_interval (1) output every nth step
|
|
||||||
/// nl_pressure_residual_tolerance (0.0) pressure solver residual tolerance (in Pascal)
|
|
||||||
/// nl_pressure_change_tolerance (1.0) pressure solver change tolerance (in Pascal)
|
|
||||||
/// nl_pressure_maxiter (10) max nonlinear iterations in pressure
|
|
||||||
/// nl_maxiter (30) max nonlinear iterations in transport
|
|
||||||
/// nl_tolerance (1e-9) transport solver absolute residual tolerance
|
|
||||||
/// num_transport_substeps (1) number of transport steps per pressure step
|
|
||||||
/// use_segregation_split (false) solve for gravity segregation (if false,
|
|
||||||
/// segregation is ignored).
|
|
||||||
///
|
|
||||||
/// \param[in] grid grid data structure
|
|
||||||
/// \param[in] geo derived geological properties
|
|
||||||
/// \param[in] props fluid and rock properties
|
|
||||||
/// \param[in] rock_comp_props if non-null, rock compressibility properties
|
|
||||||
/// \param[in] linsolver linear solver
|
|
||||||
/// \param[in] gravity if non-null, gravity vector
|
|
||||||
/// \param[in] disgas true for dissolved gas option
|
|
||||||
/// \param[in] vapoil true for vaporized oil option
|
|
||||||
/// \param[in] eclipse_state
|
|
||||||
/// \param[in] output_writer
|
|
||||||
/// \param[in] threshold_pressures_by_face if nonempty, threshold pressures that inhibit flow
|
|
||||||
SimulatorFullyImplicitBlackoil(const parameter::ParameterGroup& param,
|
|
||||||
const Grid& grid,
|
|
||||||
const DerivedGeology& geo,
|
|
||||||
BlackoilPropsAdInterface& props,
|
|
||||||
const RockCompressibility* rock_comp_props,
|
|
||||||
NewtonIterationBlackoilInterface& linsolver,
|
|
||||||
const double* gravity,
|
|
||||||
const bool disgas,
|
|
||||||
const bool vapoil,
|
|
||||||
std::shared_ptr<EclipseState> eclipse_state,
|
|
||||||
BlackoilOutputWriter& output_writer,
|
|
||||||
const std::vector<double>& threshold_pressures_by_face);
|
|
||||||
|
|
||||||
/// Run the simulation.
|
|
||||||
/// This will run succesive timesteps until timer.done() is true. It will
|
|
||||||
/// modify the reservoir and well states.
|
|
||||||
/// \param[in,out] timer governs the requested reporting timesteps
|
|
||||||
/// \param[in,out] state state of reservoir: pressure, fluxes
|
|
||||||
/// \param[in,out] well_state state of wells: bhp, perforation rates
|
|
||||||
/// \return simulation report, with timing data
|
|
||||||
SimulatorReport run(SimulatorTimer& timer,
|
|
||||||
BlackoilState& state);
|
|
||||||
|
|
||||||
private:
|
|
||||||
class Impl;
|
|
||||||
// Using shared_ptr instead of scoped_ptr since scoped_ptr requires complete type for Impl.
|
|
||||||
std::shared_ptr<Impl> pimpl_;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Opm
|
} // namespace Opm
|
||||||
|
|
||||||
#include "SimulatorFullyImplicitBlackoil_impl.hpp"
|
|
||||||
#endif // OPM_SIMULATORFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
|
#endif // OPM_SIMULATORFULLYIMPLICITBLACKOIL_HEADER_INCLUDED
|
||||||
|
Loading…
Reference in New Issue
Block a user