mirror of
https://github.com/OPM/opm-upscaling.git
synced 2025-02-25 18:45:23 -06:00
Add eclipse format output to SteadyStateUpscalerImplicit.
Option activated with output_ecl=true. Requires libert support in opm-core. If opm-core has not been compiled with the necessary --with-ert=</usr/local or similar> option, the program should abort upon trying to write the output. Hopefully this enables to keep ERT-detection macros and the like out of this module.
This commit is contained in:
parent
ca0c3eb5f2
commit
a814aa618d
@ -39,6 +39,7 @@
|
||||
#include <dune/upscaling/UpscalerBase.hpp>
|
||||
#include <dune/porsol/euler/EulerUpstream.hpp>
|
||||
#include <dune/porsol/euler/ImplicitCapillarity.hpp>
|
||||
#include <opm/core/GridAdapter.hpp>
|
||||
#include <boost/array.hpp>
|
||||
|
||||
namespace Dune
|
||||
@ -51,7 +52,7 @@ namespace Dune
|
||||
class SteadyStateUpscalerImplicit : public UpscalerBase<Traits>
|
||||
{
|
||||
public:
|
||||
// ------- Typedefs and enums -------
|
||||
// ------- Typedefs and enums -------
|
||||
|
||||
typedef UpscalerBase<Traits> Super;
|
||||
typedef typename Super::permtensor_t permtensor_t;
|
||||
@ -59,32 +60,32 @@ namespace Dune
|
||||
typedef typename UpscalerBase<Traits>::GridType GridType;
|
||||
enum { Dimension = UpscalerBase<Traits>::Dimension };
|
||||
|
||||
// ------- Methods -------
|
||||
// ------- Methods -------
|
||||
|
||||
/// Default constructor.
|
||||
SteadyStateUpscalerImplicit();
|
||||
/// Default constructor.
|
||||
SteadyStateUpscalerImplicit();
|
||||
|
||||
/// Does a steady-state upscaling.
|
||||
/// @param flow_direction The cardinal direction in which to impose a pressure gradient for the purpose of converging to steady state.
|
||||
/// @param initial_saturation the initial saturation profile for the steady-state computation.
|
||||
/// The vector must have size equal to the number of cells in the grid.
|
||||
/// @param boundary_saturation the saturation of fluid flowing in across the boundary,
|
||||
/// only needed for nonperiodic upscaling.
|
||||
/// @param pressure_drop the pressure drop in Pascal over the domain.
|
||||
/// @param upscaled_perm typically the output of upscaleSinglePhase().
|
||||
/// @return the upscaled relative permeability matrices of both phases.
|
||||
/// The relative permeability matrix, call it k, is such that if K_w is the phase
|
||||
/// permeability and K the absolute permeability, K_w = k*K.
|
||||
/// Does a steady-state upscaling.
|
||||
/// @param flow_direction The cardinal direction in which to impose a pressure gradient for the purpose of converging to steady state.
|
||||
/// @param initial_saturation the initial saturation profile for the steady-state computation.
|
||||
/// The vector must have size equal to the number of cells in the grid.
|
||||
/// @param boundary_saturation the saturation of fluid flowing in across the boundary,
|
||||
/// only needed for nonperiodic upscaling.
|
||||
/// @param pressure_drop the pressure drop in Pascal over the domain.
|
||||
/// @param upscaled_perm typically the output of upscaleSinglePhase().
|
||||
/// @return the upscaled relative permeability matrices of both phases.
|
||||
/// The relative permeability matrix, call it k, is such that if K_w is the phase
|
||||
/// permeability and K the absolute permeability, K_w = k*K.
|
||||
std::pair<permtensor_t, permtensor_t> upscaleSteadyState(const int flow_direction,
|
||||
const std::vector<double>& initial_saturation,
|
||||
const double boundary_saturation,
|
||||
const double pressure_drop,
|
||||
const permtensor_t& upscaled_perm,bool& success);
|
||||
|
||||
/// Accessor for the steady state saturation field. This is empty until
|
||||
/// upscaleSteadyState() is called, at which point it will
|
||||
/// contain the last computed (steady) saturation state.
|
||||
const std::vector<double>& lastSaturationState() const;
|
||||
/// Accessor for the steady state saturation field. This is empty until
|
||||
/// upscaleSteadyState() is called, at which point it will
|
||||
/// contain the last computed (steady) saturation state.
|
||||
const std::vector<double>& lastSaturationState() const;
|
||||
|
||||
/// Computes the upscaled saturation corresponding to the saturation field
|
||||
/// returned by lastSaturationState(). Does this by computing total saturated
|
||||
@ -98,32 +99,34 @@ namespace Dune
|
||||
|
||||
|
||||
protected:
|
||||
// ------- Typedefs -------
|
||||
// ------- Typedefs -------
|
||||
typedef typename Traits::template TransportSolver<GridInterface, typename Super::BCs>::Type TransportSolver;
|
||||
|
||||
// ------- Methods -------
|
||||
template <class FlowSol>
|
||||
void computeInOutFlows(std::pair<double, double>& water_inout,
|
||||
std::pair<double, double>& oil_inout,
|
||||
const FlowSol& flow_solution,
|
||||
const std::vector<double>& saturations) const;
|
||||
/// Override from superclass.
|
||||
virtual void initImpl(const Opm::parameter::ParameterGroup& param);
|
||||
// ------- Methods -------
|
||||
template <class FlowSol>
|
||||
void computeInOutFlows(std::pair<double, double>& water_inout,
|
||||
std::pair<double, double>& oil_inout,
|
||||
const FlowSol& flow_solution,
|
||||
const std::vector<double>& saturations) const;
|
||||
/// Override from superclass.
|
||||
virtual void initImpl(const Opm::parameter::ParameterGroup& param);
|
||||
|
||||
|
||||
// ------- Data members -------
|
||||
std::vector<double> last_saturation_state_;
|
||||
bool output_vtk_;
|
||||
bool print_inoutflows_;
|
||||
int simulation_steps_;
|
||||
double init_stepsize_;
|
||||
double relperm_threshold_;
|
||||
double maximum_mobility_contrast_;
|
||||
double sat_change_year_;
|
||||
int max_it_;
|
||||
double max_stepsize_;
|
||||
double dt_sat_tol_;
|
||||
TransportSolver transport_solver_;
|
||||
// ------- Data members -------
|
||||
std::vector<double> last_saturation_state_;
|
||||
bool output_vtk_;
|
||||
bool output_ecl_;
|
||||
bool print_inoutflows_;
|
||||
int simulation_steps_;
|
||||
double init_stepsize_;
|
||||
double relperm_threshold_;
|
||||
double maximum_mobility_contrast_;
|
||||
double sat_change_year_;
|
||||
int max_it_;
|
||||
double max_stepsize_;
|
||||
double dt_sat_tol_;
|
||||
TransportSolver transport_solver_;
|
||||
GridAdapter grid_adapter_;
|
||||
};
|
||||
|
||||
} // namespace Dune
|
||||
|
@ -43,6 +43,8 @@
|
||||
#include <dune/porsol/common/ReservoirPropertyFixedMobility.hpp>
|
||||
#include <dune/porsol/euler/MatchSaturatedVolumeFunctor.hpp>
|
||||
#include <opm/core/utility/Units.hpp>
|
||||
#include <opm/core/utility/writeECLData.hpp>
|
||||
#include <opm/core/utility/miscUtilities.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace Dune
|
||||
@ -54,6 +56,7 @@ namespace Dune
|
||||
inline SteadyStateUpscalerImplicit<Traits>::SteadyStateUpscalerImplicit()
|
||||
: Super(),
|
||||
output_vtk_(false),
|
||||
output_ecl_(false),
|
||||
print_inoutflows_(false),
|
||||
simulation_steps_(10),
|
||||
init_stepsize_(10),
|
||||
@ -74,6 +77,10 @@ namespace Dune
|
||||
{
|
||||
Super::initImpl(param);
|
||||
output_vtk_ = param.getDefault("output_vtk", output_vtk_);
|
||||
output_ecl_ = param.getDefault("output_ecl", output_ecl_);
|
||||
if (output_ecl_) {
|
||||
grid_adapter_.init(Super::grid());
|
||||
}
|
||||
print_inoutflows_ = param.getDefault("print_inoutflows", print_inoutflows_);
|
||||
simulation_steps_ = param.getDefault("simulation_steps", simulation_steps_);
|
||||
init_stepsize_ = Opm::unit::convert::from(param.getDefault("init_stepsize", init_stepsize_),
|
||||
@ -177,6 +184,9 @@ namespace Dune
|
||||
bool stationary = false;
|
||||
int it_count = 0;
|
||||
double stepsize = init_stepsize_;
|
||||
double ecl_time = 0.0;
|
||||
std::vector<double> ecl_sat;
|
||||
std::vector<double> ecl_press;
|
||||
std::vector<double> init_saturation(saturation);
|
||||
while ((!stationary) && (it_count < max_it_)) { // && transport_cost < max_transport_cost_)
|
||||
// Run transport solver.
|
||||
@ -214,6 +224,22 @@ namespace Dune
|
||||
+ '-' + boost::lexical_cast<std::string>(flow_direction)
|
||||
+ '-' + boost::lexical_cast<std::string>(it_count));
|
||||
}
|
||||
if (output_ecl_) {
|
||||
const char* fd = "xyz";
|
||||
std::string basename = std::string("ecldump-steadystate")
|
||||
+ '-' + boost::lexical_cast<std::string>(boundary_saturation)
|
||||
+ '-' + boost::lexical_cast<std::string>(fd[flow_direction])
|
||||
+ '-' + boost::lexical_cast<std::string>(pressure_drop);
|
||||
Opm::toBothSat(saturation, ecl_sat);
|
||||
getCellPressure(ecl_press, this->ginterf_, this->flow_solver_.getSolution());
|
||||
Opm::DataMap datamap;
|
||||
datamap["saturation"] = &ecl_sat;
|
||||
datamap["pressure"] = &ecl_press;
|
||||
ecl_time += stepsize;
|
||||
boost::posix_time::ptime ecl_startdate( boost::gregorian::date(2012, 1, 1) );
|
||||
boost::posix_time::ptime ecl_curdate = ecl_startdate + boost::posix_time::seconds(int(ecl_time));
|
||||
Opm::writeECLData(*grid_adapter_.c_grid(), datamap, it_count, ecl_time, ecl_curdate, "./", basename);
|
||||
}
|
||||
// Comparing old to new.
|
||||
int num_cells = saturation.size();
|
||||
double maxdiff = 0.0;
|
||||
|
Loading…
Reference in New Issue
Block a user