adding a rate converter to BlackoilModelEbos

and also function updateRateConverter() to update its state.
This commit is contained in:
Kai Bao 2017-01-17 12:55:05 +01:00
parent 4ff9996f80
commit af26b70fc9

View File

@ -42,6 +42,7 @@
#include <opm/autodiff/BlackoilDetails.hpp> #include <opm/autodiff/BlackoilDetails.hpp>
#include <opm/autodiff/BlackoilModelEnums.hpp> #include <opm/autodiff/BlackoilModelEnums.hpp>
#include <opm/autodiff/NewtonIterationBlackoilInterface.hpp> #include <opm/autodiff/NewtonIterationBlackoilInterface.hpp>
#include <opm/autodiff/RateConverter.hpp>
#include <opm/core/grid.h> #include <opm/core/grid.h>
#include <opm/core/simulator/SimulatorReport.hpp> #include <opm/core/simulator/SimulatorReport.hpp>
@ -138,6 +139,10 @@ namespace Opm {
typedef ISTLSolver< MatrixBlockType, VectorBlockType > ISTLSolverType; typedef ISTLSolver< MatrixBlockType, VectorBlockType > ISTLSolverType;
//typedef typename SolutionVector :: value_type PrimaryVariables ; //typedef typename SolutionVector :: value_type PrimaryVariables ;
// For the conversion between the surface volume rate and resrevoir voidage rate
using RateConverterType = RateConverter::
SurfaceToReservoirVoidage<BlackoilPropsAdFromDeck::FluidSystem, std::vector<int> >;
struct FIPData { struct FIPData {
enum FipId { enum FipId {
FIP_AQUA = Opm::Water, FIP_AQUA = Opm::Water,
@ -187,6 +192,7 @@ namespace Opm {
, param_( param ) , param_( param )
, well_model_ (well_model) , well_model_ (well_model)
, terminal_output_ (terminal_output) , terminal_output_ (terminal_output)
, rate_converter_(fluid_.phaseUsage(), fluid_.cellPvtRegionIndex(), AutoDiffGrid::numCells(grid_), std::vector<int>(AutoDiffGrid::numCells(grid_),0))
, current_relaxation_(1.0) , current_relaxation_(1.0)
, dx_old_(AutoDiffGrid::numCells(grid_)) , dx_old_(AutoDiffGrid::numCells(grid_))
, isBeginReportStep_(false) , isBeginReportStep_(false)
@ -1229,6 +1235,9 @@ namespace Opm {
/// \brief The number of cells of the global grid. /// \brief The number of cells of the global grid.
long int global_nc_; long int global_nc_;
// rate converter between the surface volume rates and reservoir voidage rates
RateConverterType rate_converter_;
std::vector<std::vector<double>> residual_norms_history_; std::vector<std::vector<double>> residual_norms_history_;
double current_relaxation_; double current_relaxation_;
BVector dx_old_; BVector dx_old_;
@ -1429,6 +1438,33 @@ namespace Opm {
} }
void updateRateConverter(const ReservoirState& reservoir_state)
{
const int nw = numWells();
int global_number_wells = nw;
#if HAVE_MPI
if ( istlSolver_->parallelInformation().type() == typeid(ParallelISTLInformation) )
{
const auto& info =
boost::any_cast<const ParallelISTLInformation&>(istlSolver_->parallelInformation());
global_number_wells = info.communicator().sum(global_number_wells);
if ( global_number_wells )
{
rate_converter_.defineState(reservoir_state, boost::any_cast<const ParallelISTLInformation&>(istlSolver_->parallelInformation()));
}
}
else
#endif
{
if ( global_number_wells )
{
rate_converter_.defineState(reservoir_state);
}
}
}
public: public:
void beginReportStep() void beginReportStep()
{ {