2015-06-18 06:43:59 -05:00
|
|
|
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
// vi: set et ts=4 sw=4 sts=4:
|
2014-04-15 11:30:06 -05:00
|
|
|
/*
|
|
|
|
Copyright (C) 2014 by Andreas Lauser
|
|
|
|
|
|
|
|
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 2 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/>.
|
|
|
|
*/
|
|
|
|
/*!
|
|
|
|
* \file
|
|
|
|
*
|
|
|
|
* \copydoc Ewoms::EclProblem
|
|
|
|
*/
|
|
|
|
#ifndef EWOMS_ECL_PROBLEM_HH
|
|
|
|
#define EWOMS_ECL_PROBLEM_HH
|
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
#include <opm/material/localad/Evaluation.hpp>
|
|
|
|
|
2014-11-28 05:58:48 -06:00
|
|
|
#include "eclgridmanager.hh"
|
|
|
|
#include "eclwellmanager.hh"
|
2015-07-29 06:43:17 -05:00
|
|
|
#include "eclequilinitializer.hh"
|
2014-11-28 05:58:48 -06:00
|
|
|
#include "eclwriter.hh"
|
|
|
|
#include "eclsummarywriter.hh"
|
|
|
|
#include "ecloutputblackoilmodule.hh"
|
2014-12-27 08:19:15 -06:00
|
|
|
#include "ecltransmissibility.hh"
|
|
|
|
#include "ecldummygradientcalculator.hh"
|
|
|
|
#include "eclfluxmodule.hh"
|
2015-01-25 10:27:08 -06:00
|
|
|
#include "ecldeckunits.hh"
|
2014-11-28 05:58:48 -06:00
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
#include <ewoms/models/blackoil/blackoilmodel.hh>
|
|
|
|
#include <ewoms/disc/ecfv/ecfvdiscretization.hh>
|
|
|
|
|
2015-07-28 10:24:40 -05:00
|
|
|
#include <opm/material/fluidmatrixinteractions/EclMaterialLawManager.hpp>
|
2014-04-15 11:30:06 -05:00
|
|
|
#include <opm/material/fluidstates/CompositionalFluidState.hpp>
|
2015-07-28 10:24:40 -05:00
|
|
|
#include <opm/material/fluidsystems/BlackOilFluidSystem.hpp>
|
2015-02-03 06:58:18 -06:00
|
|
|
#include <opm/material/fluidsystems/blackoilpvt/DryGasPvt.hpp>
|
|
|
|
#include <opm/material/fluidsystems/blackoilpvt/WetGasPvt.hpp>
|
|
|
|
#include <opm/material/fluidsystems/blackoilpvt/LiveOilPvt.hpp>
|
|
|
|
#include <opm/material/fluidsystems/blackoilpvt/DeadOilPvt.hpp>
|
|
|
|
#include <opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityOilPvt.hpp>
|
|
|
|
#include <opm/material/fluidsystems/blackoilpvt/ConstantCompressibilityWaterPvt.hpp>
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
// for this simulator to make sense, dune-cornerpoint and opm-parser
|
|
|
|
// must be available
|
|
|
|
#include <dune/grid/CpGrid.hpp>
|
|
|
|
#include <opm/parser/eclipse/Deck/Deck.hpp>
|
2014-09-17 06:42:13 -05:00
|
|
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
#include <dune/common/version.hh>
|
|
|
|
#include <dune/common/fvector.hh>
|
|
|
|
#include <dune/common/fmatrix.hh>
|
|
|
|
|
|
|
|
#include <boost/date_time.hpp>
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
namespace Ewoms {
|
|
|
|
template <class TypeTag>
|
|
|
|
class EclProblem;
|
|
|
|
|
|
|
|
namespace Properties {
|
2014-11-28 05:58:48 -06:00
|
|
|
NEW_TYPE_TAG(EclBaseProblem, INHERITS_FROM(EclGridManager, EclOutputBlackOil));
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2014-05-02 09:08:22 -05:00
|
|
|
// Write all solutions for visualization, not just the ones for the
|
|
|
|
// report steps...
|
|
|
|
NEW_PROP_TAG(EnableWriteAllSolutions);
|
|
|
|
|
2015-03-03 07:31:58 -06:00
|
|
|
// The number of time steps skipped between writing two consequtive restart files
|
|
|
|
NEW_PROP_TAG(RestartWritingInterval);
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
// Set the problem property
|
|
|
|
SET_TYPE_PROP(EclBaseProblem, Problem, Ewoms::EclProblem<TypeTag>);
|
|
|
|
|
|
|
|
// Select the element centered finite volume method as spatial discretization
|
|
|
|
SET_TAG_PROP(EclBaseProblem, SpatialDiscretizationSplice, EcfvDiscretization);
|
|
|
|
|
2015-05-21 09:18:47 -05:00
|
|
|
//! for ebos, use automatic differentiation to linearize the system of PDEs
|
|
|
|
SET_TAG_PROP(EclBaseProblem, LocalLinearizerSplice, AutoDiffLocalLinearizer);
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
// Set the material Law
|
|
|
|
SET_PROP(EclBaseProblem, MaterialLaw)
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
|
2014-04-28 12:12:53 -05:00
|
|
|
|
|
|
|
typedef Opm::ThreePhaseMaterialTraits<Scalar,
|
|
|
|
/*wettingPhaseIdx=*/FluidSystem::waterPhaseIdx,
|
|
|
|
/*nonWettingPhaseIdx=*/FluidSystem::oilPhaseIdx,
|
2015-07-28 10:24:40 -05:00
|
|
|
/*gasPhaseIdx=*/FluidSystem::gasPhaseIdx> Traits;
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
public:
|
2015-07-28 10:24:40 -05:00
|
|
|
typedef Opm::EclMaterialLawManager<Traits> EclMaterialLawManager;
|
|
|
|
|
|
|
|
typedef typename EclMaterialLawManager::MaterialLaw type;
|
2014-04-15 11:30:06 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
// Enable gravity
|
|
|
|
SET_BOOL_PROP(EclBaseProblem, EnableGravity, true);
|
|
|
|
|
|
|
|
// Reuse the last linearization if possible?
|
2015-01-21 07:40:51 -06:00
|
|
|
SET_BOOL_PROP(EclBaseProblem, EnableLinearizationRecycling, false);
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2014-12-19 08:30:55 -06:00
|
|
|
// Only relinearize the parts where the current solution is sufficiently "bad"
|
2015-03-04 10:48:13 -06:00
|
|
|
SET_BOOL_PROP(EclBaseProblem, EnablePartialRelinearization, false);
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2014-05-02 09:08:22 -05:00
|
|
|
// only write the solutions for the report steps to disk
|
|
|
|
SET_BOOL_PROP(EclBaseProblem, EnableWriteAllSolutions, false);
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
// The default for the end time of the simulation [s]
|
|
|
|
//
|
2014-07-09 05:01:07 -05:00
|
|
|
// By default, stop it after the universe will probably have stopped
|
|
|
|
// to exist. (the ECL problem will finish the simulation explicitly
|
|
|
|
// after it simulated the last episode specified in the deck.)
|
|
|
|
SET_SCALAR_PROP(EclBaseProblem, EndTime, 1e100);
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
// The default for the initial time step size of the simulation [s].
|
|
|
|
//
|
|
|
|
// The chosen value means that the size of the first time step is the
|
|
|
|
// one of the initial episode (if the length of the initial episode is
|
|
|
|
// not millions of trillions of years, that is...)
|
|
|
|
SET_SCALAR_PROP(EclBaseProblem, InitialTimeStepSize, 1e100);
|
|
|
|
|
2014-11-28 06:12:15 -06:00
|
|
|
// increase the default raw tolerance for the newton solver to 10^-4 because this is what
|
|
|
|
// everone else seems to be doing...
|
|
|
|
SET_SCALAR_PROP(EclBaseProblem, NewtonRawTolerance, 1e-4);
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
// Disable the VTK output by default for this problem ...
|
|
|
|
SET_BOOL_PROP(EclBaseProblem, EnableVtkOutput, false);
|
|
|
|
|
2014-11-28 05:58:48 -06:00
|
|
|
// ... but enable the ECL output by default
|
|
|
|
SET_BOOL_PROP(EclBaseProblem, EnableEclOutput, true);
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2014-11-21 09:39:47 -06:00
|
|
|
// also enable the summary output.
|
2014-11-28 05:58:48 -06:00
|
|
|
SET_BOOL_PROP(EclBaseProblem, EnableEclSummaryOutput, true);
|
2014-11-21 09:39:47 -06:00
|
|
|
|
2014-12-18 09:03:18 -06:00
|
|
|
// the cache for intensive quantities can be used for ECL problems and also yields a
|
|
|
|
// decent speedup...
|
|
|
|
SET_BOOL_PROP(EclBaseProblem, EnableIntensiveQuantityCache, true);
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
// Use the "velocity module" which uses the Eclipse "NEWTRAN" transmissibilities
|
2015-01-04 12:11:02 -06:00
|
|
|
SET_TYPE_PROP(EclBaseProblem, FluxModule, Ewoms::EclTransFluxModule<TypeTag>);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
// Use the dummy gradient calculator in order not to do unnecessary work.
|
|
|
|
SET_TYPE_PROP(EclBaseProblem, GradientCalculator, Ewoms::EclDummyGradientCalculator<TypeTag>);
|
|
|
|
|
2014-12-18 09:03:18 -06:00
|
|
|
// The default name of the data file to load
|
2014-05-08 08:25:48 -05:00
|
|
|
SET_STRING_PROP(EclBaseProblem, GridFile, "data/ecl.DATA");
|
2015-03-03 07:31:58 -06:00
|
|
|
|
|
|
|
// The frequency of writing restart (*.ers) files. This is the number of time steps
|
|
|
|
// between writing restart files
|
|
|
|
SET_INT_PROP(EclBaseProblem, RestartWritingInterval, 0xffffff); // disable
|
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
} // namespace Properties
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
/*!
|
2014-12-22 12:19:03 -06:00
|
|
|
* \ingroup EclBlackOilSimulator
|
2014-04-15 11:30:06 -05:00
|
|
|
*
|
2014-11-28 05:58:48 -06:00
|
|
|
* \brief This problem simulates an input file given in the data format used by the
|
|
|
|
* commercial ECLiPSE simulator.
|
2014-04-15 11:30:06 -05:00
|
|
|
*/
|
|
|
|
template <class TypeTag>
|
|
|
|
class EclProblem : public GET_PROP_TYPE(TypeTag, BaseProblem)
|
|
|
|
{
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, BaseProblem) ParentType;
|
|
|
|
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
|
2015-07-28 10:24:44 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
|
2014-04-15 11:30:06 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
|
|
|
|
|
|
|
|
// Grid and world dimension
|
|
|
|
enum { dim = GridView::dimension };
|
|
|
|
enum { dimWorld = GridView::dimensionworld };
|
|
|
|
|
|
|
|
// copy some indices for convenience
|
2015-05-21 09:18:45 -05:00
|
|
|
enum { numEq = GET_PROP_VALUE(TypeTag, NumEq) };
|
2014-04-15 11:30:06 -05:00
|
|
|
enum { numPhases = FluidSystem::numPhases };
|
|
|
|
enum { numComponents = FluidSystem::numComponents };
|
|
|
|
enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
|
|
|
|
enum { oilPhaseIdx = FluidSystem::oilPhaseIdx };
|
|
|
|
enum { waterPhaseIdx = FluidSystem::waterPhaseIdx };
|
|
|
|
enum { gasCompIdx = FluidSystem::gasCompIdx };
|
|
|
|
enum { oilCompIdx = FluidSystem::oilCompIdx };
|
|
|
|
enum { waterCompIdx = FluidSystem::waterCompIdx };
|
|
|
|
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, RateVector) RateVector;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, BoundaryRateVector) BoundaryRateVector;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
|
2015-07-28 10:24:44 -05:00
|
|
|
typedef typename GridView::template Codim<0>::Entity Element;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
|
2015-07-28 10:24:40 -05:00
|
|
|
typedef typename GET_PROP(TypeTag, MaterialLaw)::EclMaterialLawManager EclMaterialLawManager;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
|
2014-04-15 11:30:06 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, MaterialLawParams) MaterialLawParams;
|
2015-05-21 09:18:45 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
typedef Opm::CompositionalFluidState<Scalar, FluidSystem> ScalarFluidState;
|
|
|
|
typedef Opm::MathToolbox<Evaluation> Toolbox;
|
2014-11-28 05:58:48 -06:00
|
|
|
typedef Ewoms::EclSummaryWriter<TypeTag> EclSummaryWriter;
|
2014-04-15 11:30:06 -05:00
|
|
|
typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix;
|
|
|
|
|
2014-12-04 12:22:56 -06:00
|
|
|
struct RockParams {
|
|
|
|
Scalar referencePressure;
|
|
|
|
Scalar compressibility;
|
|
|
|
};
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseProblem::registerParameters
|
|
|
|
*/
|
|
|
|
static void registerParameters()
|
|
|
|
{
|
|
|
|
ParentType::registerParameters();
|
|
|
|
|
2014-11-28 05:58:48 -06:00
|
|
|
Ewoms::EclOutputBlackOilModule<TypeTag>::registerParameters();
|
|
|
|
|
2014-05-02 09:08:22 -05:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, bool, EnableWriteAllSolutions,
|
2014-05-07 08:07:39 -05:00
|
|
|
"Write all solutions to disk instead of only the ones for the "
|
|
|
|
"report steps");
|
2014-11-28 05:58:48 -06:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, bool, EnableEclOutput,
|
|
|
|
"Write binary output which is compatible with the commercial "
|
|
|
|
"Eclipse simulator");
|
2015-03-03 07:31:58 -06:00
|
|
|
EWOMS_REGISTER_PARAM(TypeTag, int, RestartWritingInterval,
|
|
|
|
"The frequencies of which time steps are serialized to disk");
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \copydoc Doxygen::defaultProblemConstructor
|
|
|
|
*/
|
|
|
|
EclProblem(Simulator &simulator)
|
|
|
|
: ParentType(simulator)
|
2014-12-27 08:19:15 -06:00
|
|
|
, transmissibilities_(simulator)
|
2014-05-07 08:07:39 -05:00
|
|
|
, wellManager_(simulator)
|
2015-01-25 10:27:08 -06:00
|
|
|
, deckUnits_(simulator)
|
2014-11-28 05:58:48 -06:00
|
|
|
, eclWriter_(simulator)
|
2014-11-21 09:39:47 -06:00
|
|
|
, summaryWriter_(simulator)
|
2014-11-28 05:58:48 -06:00
|
|
|
{
|
|
|
|
// add the output module for the Ecl binary output
|
|
|
|
simulator.model().addOutputModule(new Ewoms::EclOutputBlackOilModule<TypeTag>(simulator));
|
|
|
|
}
|
2014-07-25 08:31:01 -05:00
|
|
|
|
2014-08-06 09:31:48 -05:00
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseProblem::finishInit
|
|
|
|
*/
|
2014-07-25 08:31:01 -05:00
|
|
|
void finishInit()
|
2014-04-15 11:30:06 -05:00
|
|
|
{
|
2014-07-25 08:31:01 -05:00
|
|
|
ParentType::finishInit();
|
|
|
|
|
2014-05-07 08:07:39 -05:00
|
|
|
auto& simulator = this->simulator();
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
// invert the direction of the gravity vector for ECL problems
|
|
|
|
// (z coodinates represent depth, not height.)
|
|
|
|
this->gravity_[dim - 1] *= -1;
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
// the "NOGRAV" keyword from Frontsim disables gravity...
|
|
|
|
const auto& deck = simulator.gridManager().deck();
|
2015-01-12 10:49:16 -06:00
|
|
|
if (deck->hasKeyword("NOGRAV") || !EWOMS_GET_PARAM(TypeTag, bool, EnableGravity))
|
2014-12-27 08:19:15 -06:00
|
|
|
this->gravity_ = 0.0;
|
|
|
|
|
2014-06-04 11:05:12 -05:00
|
|
|
initFluidSystem_();
|
2014-12-04 12:22:56 -06:00
|
|
|
readRockParameters_();
|
2014-06-04 11:05:12 -05:00
|
|
|
readMaterialParameters_();
|
2014-12-27 08:19:15 -06:00
|
|
|
transmissibilities_.finishInit();
|
2014-06-04 11:05:12 -05:00
|
|
|
readInitialCondition_();
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2014-09-08 11:10:24 -05:00
|
|
|
// initialize the wells. Note that this needs to be done after initializing the
|
|
|
|
// intrinsic permeabilities because the well model uses them...
|
2014-11-28 05:58:48 -06:00
|
|
|
wellManager_.init(simulator.gridManager().eclState());
|
2014-05-07 08:07:39 -05:00
|
|
|
|
2015-03-03 07:48:11 -06:00
|
|
|
// Set the start time of the simulation
|
2014-04-15 11:30:06 -05:00
|
|
|
Opm::TimeMapConstPtr timeMap = simulator.gridManager().schedule()->getTimeMap();
|
|
|
|
tm curTime = boost::posix_time::to_tm(timeMap->getStartTime(/*timeStepIdx=*/0));
|
|
|
|
|
2014-04-25 12:25:04 -05:00
|
|
|
Scalar startTime = std::mktime(&curTime);
|
|
|
|
simulator.setStartTime(startTime);
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2015-03-03 07:48:11 -06:00
|
|
|
// We want the episode index to be the same as the report step index to make
|
|
|
|
// things simpler, so we have to set the episode index to -1 because it is
|
|
|
|
// incremented inside beginEpisode()...
|
|
|
|
simulator.setEpisodeIndex(-1);
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
|
|
|
|
2015-01-19 09:40:26 -06:00
|
|
|
/*!
|
|
|
|
* \brief This method restores the complete state of the well
|
|
|
|
* from disk.
|
|
|
|
*
|
|
|
|
* It is the inverse of the serialize() method.
|
|
|
|
*
|
|
|
|
* \tparam Restarter The deserializer type
|
|
|
|
*
|
|
|
|
* \param res The deserializer object
|
|
|
|
*/
|
|
|
|
template <class Restarter>
|
|
|
|
void deserialize(Restarter &res)
|
2015-03-03 07:48:11 -06:00
|
|
|
{
|
|
|
|
// reload the current episode/report step from the deck
|
2015-04-08 07:25:23 -05:00
|
|
|
beginEpisode(/*isOnRestart=*/true);
|
2015-03-03 07:48:11 -06:00
|
|
|
|
|
|
|
// deserialize the wells
|
|
|
|
wellManager_.deserialize(res);
|
|
|
|
}
|
2015-01-19 09:40:26 -06:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief This method writes the complete state of the well
|
|
|
|
* to the harddisk.
|
|
|
|
*/
|
|
|
|
template <class Restarter>
|
|
|
|
void serialize(Restarter &res)
|
|
|
|
{ wellManager_.serialize(res); }
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
/*!
|
2014-07-09 05:01:07 -05:00
|
|
|
* \brief Called by the simulator before an episode begins.
|
2014-04-15 11:30:06 -05:00
|
|
|
*/
|
2015-04-08 07:25:23 -05:00
|
|
|
void beginEpisode(bool isOnRestart = false)
|
2015-03-03 07:48:11 -06:00
|
|
|
{
|
|
|
|
// Proceed to the next report step
|
|
|
|
Simulator &simulator = this->simulator();
|
|
|
|
Opm::EclipseStateConstPtr eclState = this->simulator().gridManager().eclState();
|
|
|
|
Opm::TimeMapConstPtr timeMap = eclState->getSchedule()->getTimeMap();
|
|
|
|
|
|
|
|
// Opm::TimeMap deals with points in time, so the number of time intervals (i.e.,
|
|
|
|
// report steps) is one less!
|
|
|
|
int numReportSteps = timeMap->size() - 1;
|
|
|
|
|
|
|
|
// start the next episode if there are additional report steps, else finish the
|
|
|
|
// simulation
|
|
|
|
int nextEpisodeIdx = simulator.episodeIndex();
|
|
|
|
while (nextEpisodeIdx < numReportSteps &&
|
|
|
|
simulator.time() >= timeMap->getTimePassedUntil(nextEpisodeIdx + 1)*(1 - 1e-10))
|
|
|
|
{
|
|
|
|
++ nextEpisodeIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (nextEpisodeIdx < numReportSteps) {
|
|
|
|
simulator.startNextEpisode(timeMap->getTimeStepLength(nextEpisodeIdx));
|
|
|
|
simulator.setTimeStepSize(timeMap->getTimeStepLength(nextEpisodeIdx));
|
|
|
|
}
|
|
|
|
|
|
|
|
// set up the wells
|
2015-04-08 07:25:23 -05:00
|
|
|
wellManager_.beginEpisode(this->simulator().gridManager().eclState(), isOnRestart);
|
2015-03-03 07:48:11 -06:00
|
|
|
}
|
2014-07-09 05:01:07 -05:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Called by the simulator before each time integration.
|
|
|
|
*/
|
2014-05-07 08:07:39 -05:00
|
|
|
void beginTimeStep()
|
|
|
|
{ wellManager_.beginTimeStep(); }
|
2015-07-28 10:24:44 -05:00
|
|
|
|
2014-05-07 08:07:39 -05:00
|
|
|
/*!
|
|
|
|
* \brief Called by the simulator before each Newton-Raphson iteration.
|
|
|
|
*/
|
|
|
|
void beginIteration()
|
|
|
|
{ wellManager_.beginIteration(); }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Called by the simulator after each Newton-Raphson iteration.
|
|
|
|
*/
|
|
|
|
void endIteration()
|
|
|
|
{ wellManager_.endIteration(); }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Called by the simulator after each time integration.
|
|
|
|
*/
|
2014-07-22 05:41:56 -05:00
|
|
|
void endTimeStep()
|
|
|
|
{
|
2014-05-07 08:07:39 -05:00
|
|
|
wellManager_.endTimeStep();
|
2014-07-22 05:41:56 -05:00
|
|
|
|
2015-03-31 09:26:06 -05:00
|
|
|
// write the summary information after each time step
|
|
|
|
summaryWriter_.write(wellManager_);
|
|
|
|
|
2015-07-28 10:24:44 -05:00
|
|
|
updateHysteresis_();
|
|
|
|
|
2014-05-07 08:07:39 -05:00
|
|
|
#ifndef NDEBUG
|
2015-03-31 09:26:06 -05:00
|
|
|
// in debug mode, we don't care about performance, so we check if the model does
|
|
|
|
// the right thing (i.e., the mass change inside the whole reservoir must be
|
|
|
|
// equivalent to the fluxes over the grid's boundaries plus the source rates
|
|
|
|
// specified by the problem)
|
2014-05-07 08:07:39 -05:00
|
|
|
this->model().checkConservativeness(/*tolerance=*/-1, /*verbose=*/true);
|
2014-07-22 05:41:56 -05:00
|
|
|
#endif // NDEBUG
|
|
|
|
}
|
2014-07-09 05:01:07 -05:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Called by the simulator after the end of an episode.
|
|
|
|
*/
|
|
|
|
void endEpisode()
|
2014-04-15 11:30:06 -05:00
|
|
|
{
|
2015-04-01 07:33:54 -05:00
|
|
|
auto& simulator = this->simulator();
|
2015-03-31 09:26:06 -05:00
|
|
|
const auto& eclState = simulator.gridManager().eclState();
|
|
|
|
auto& linearizer = this->model().linearizer();
|
|
|
|
int episodeIdx = simulator.episodeIndex();
|
2015-03-03 07:31:58 -06:00
|
|
|
|
2015-04-01 07:33:54 -05:00
|
|
|
std::cout << "Episode " << episodeIdx + 1 << " finished.\n";
|
|
|
|
|
2015-03-31 09:26:06 -05:00
|
|
|
bool wellsWillChange = wellManager_.wellsChanged(eclState, episodeIdx + 1);
|
|
|
|
linearizer.setLinearizationReusable(!wellsWillChange);
|
|
|
|
|
2015-04-01 07:33:54 -05:00
|
|
|
Opm::TimeMapConstPtr timeMap = eclState->getSchedule()->getTimeMap();
|
|
|
|
int numReportSteps = timeMap->size() - 1;
|
|
|
|
if (episodeIdx + 1 >= numReportSteps) {
|
|
|
|
simulator.setFinished(true);
|
|
|
|
return;
|
|
|
|
}
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns true if the current solution should be written
|
|
|
|
* to disk for visualization.
|
|
|
|
*
|
|
|
|
* For the ECL simulator we only write at the end of
|
|
|
|
* episodes/report steps...
|
|
|
|
*/
|
2015-01-19 09:40:26 -06:00
|
|
|
bool shouldWriteOutput() const
|
2014-04-15 11:30:06 -05:00
|
|
|
{
|
2014-08-04 10:07:49 -05:00
|
|
|
if (this->simulator().timeStepIndex() < 0)
|
2014-04-15 11:30:06 -05:00
|
|
|
// always write the initial solution
|
|
|
|
return true;
|
|
|
|
|
2014-05-02 09:08:22 -05:00
|
|
|
if (EWOMS_GET_PARAM(TypeTag, bool, EnableWriteAllSolutions))
|
|
|
|
return true;
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
return this->simulator().episodeWillBeOver();
|
|
|
|
}
|
|
|
|
|
2015-02-04 05:15:55 -06:00
|
|
|
/*!
|
|
|
|
* \brief Returns true if an eWoms restart file should be written to disk.
|
|
|
|
*/
|
|
|
|
bool shouldWriteRestartFile() const
|
2015-03-03 07:31:58 -06:00
|
|
|
{
|
|
|
|
int n = EWOMS_GET_PARAM(TypeTag, int, RestartWritingInterval);
|
|
|
|
int i = this->simulator().timeStepIndex();
|
|
|
|
if (i > 0 && (i%n) == 0)
|
|
|
|
return true; // we don't write a restart file for the initial condition
|
|
|
|
return false;
|
|
|
|
}
|
2015-02-04 05:15:55 -06:00
|
|
|
|
2014-11-28 05:58:48 -06:00
|
|
|
/*!
|
|
|
|
* \brief Write the requested quantities of the current solution into the output
|
|
|
|
* files.
|
|
|
|
*/
|
|
|
|
void writeOutput(bool verbose = true)
|
|
|
|
{
|
|
|
|
// calculate the time _after_ the time was updated
|
|
|
|
Scalar t = this->simulator().time() + this->simulator().timeStepSize();
|
|
|
|
|
|
|
|
// prepare the ECL and the VTK writers
|
|
|
|
if (enableEclOutput_())
|
|
|
|
eclWriter_.beginWrite(t);
|
|
|
|
|
|
|
|
// use the generic code to prepare the output fields and to
|
|
|
|
// write the desired VTK files.
|
|
|
|
ParentType::writeOutput(verbose);
|
|
|
|
|
|
|
|
if (enableEclOutput_()) {
|
|
|
|
this->model().appendOutputFields(eclWriter_);
|
|
|
|
eclWriter_.endWrite();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-25 10:27:08 -06:00
|
|
|
/*!
|
|
|
|
* \brief Returns the object which converts between SI and deck units.
|
|
|
|
*/
|
|
|
|
const EclDeckUnits<TypeTag>& deckUnits() const
|
|
|
|
{ return deckUnits_; }
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseMultiPhaseProblem::intrinsicPermeability
|
|
|
|
*/
|
|
|
|
template <class Context>
|
|
|
|
const DimMatrix &intrinsicPermeability(const Context &context,
|
|
|
|
int spaceIdx,
|
|
|
|
int timeIdx) const
|
|
|
|
{
|
|
|
|
int globalSpaceIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
|
|
|
|
return intrinsicPermeability_[globalSpaceIdx];
|
|
|
|
}
|
|
|
|
|
2014-07-02 10:50:35 -05:00
|
|
|
/*!
|
2014-12-27 08:19:15 -06:00
|
|
|
* \brief This method returns the intrinsic permeability tensor
|
|
|
|
* given a global element index.
|
|
|
|
*
|
|
|
|
* Its main (only?) usage is the ECL transmissibility calculation code...
|
2014-07-02 10:50:35 -05:00
|
|
|
*/
|
2014-12-27 08:19:15 -06:00
|
|
|
const DimMatrix &intrinsicPermeability(int globalElemIdx) const
|
|
|
|
{ return intrinsicPermeability_[globalElemIdx]; }
|
2014-07-02 10:50:35 -05:00
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseMultiPhaseProblem::transmissibility
|
|
|
|
*/
|
|
|
|
Scalar transmissibility(int elem1Idx, int elem2Idx) const
|
|
|
|
{ return transmissibilities_.transmissibility(elem1Idx, elem2Idx); }
|
2014-07-02 10:50:35 -05:00
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseMultiPhaseProblem::porosity
|
|
|
|
*/
|
|
|
|
template <class Context>
|
|
|
|
Scalar porosity(const Context &context, int spaceIdx, int timeIdx) const
|
|
|
|
{
|
|
|
|
int globalSpaceIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
|
|
|
|
return porosity_[globalSpaceIdx];
|
|
|
|
}
|
|
|
|
|
2014-12-04 12:22:56 -06:00
|
|
|
/*!
|
|
|
|
* \copydoc BlackoilProblem::rockCompressibility
|
|
|
|
*/
|
|
|
|
template <class Context>
|
|
|
|
Scalar rockCompressibility(const Context &context, int spaceIdx, int timeIdx) const
|
|
|
|
{
|
|
|
|
if (rockParams_.empty())
|
|
|
|
return 0.0;
|
|
|
|
|
|
|
|
int tableIdx = 0;
|
|
|
|
if (!rockTableIdx_.empty()) {
|
|
|
|
int globalSpaceIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
|
|
|
|
tableIdx = rockTableIdx_[globalSpaceIdx];
|
|
|
|
}
|
|
|
|
|
|
|
|
return rockParams_[tableIdx].compressibility;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \copydoc BlackoilProblem::rockReferencePressure
|
|
|
|
*/
|
|
|
|
template <class Context>
|
|
|
|
Scalar rockReferencePressure(const Context &context, int spaceIdx, int timeIdx) const
|
|
|
|
{
|
|
|
|
if (rockParams_.empty())
|
|
|
|
return 1e5;
|
|
|
|
|
|
|
|
int tableIdx = 0;
|
|
|
|
if (!rockTableIdx_.empty()) {
|
|
|
|
int globalSpaceIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
|
|
|
|
tableIdx = rockTableIdx_[globalSpaceIdx];
|
|
|
|
}
|
|
|
|
|
|
|
|
return rockParams_[tableIdx].referencePressure;
|
|
|
|
}
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseMultiPhaseProblem::materialLawParams
|
|
|
|
*/
|
|
|
|
template <class Context>
|
|
|
|
const MaterialLawParams &materialLawParams(const Context &context,
|
|
|
|
int spaceIdx, int timeIdx) const
|
|
|
|
{
|
2015-07-28 10:24:40 -05:00
|
|
|
int globalSpaceIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
|
2015-07-29 06:43:17 -05:00
|
|
|
return materialLawParams(globalSpaceIdx);
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
|
|
|
|
2015-07-29 06:43:17 -05:00
|
|
|
const MaterialLawParams& materialLawParams(int globalDofIdx) const
|
|
|
|
{ return materialLawManager_->materialLawParams(globalDofIdx); }
|
|
|
|
|
2014-08-05 09:52:52 -05:00
|
|
|
/*!
|
|
|
|
* \brief Returns the index of the relevant region for thermodynmic properties
|
|
|
|
*/
|
|
|
|
template <class Context>
|
|
|
|
int pvtRegionIndex(const Context &context, int spaceIdx, int timeIdx) const
|
2015-08-26 09:04:10 -05:00
|
|
|
{ return pvtRegionIndex(context.globalSpaceIndex(spaceIdx, timeIdx)); }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the index the relevant PVT region given a cell index
|
|
|
|
*/
|
|
|
|
int pvtRegionIndex(int elemIdx) const
|
2014-08-05 09:52:52 -05:00
|
|
|
{
|
|
|
|
Opm::DeckConstPtr deck = this->simulator().gridManager().deck();
|
|
|
|
|
|
|
|
if (!deck->hasKeyword("PVTNUM"))
|
|
|
|
return 0;
|
|
|
|
|
2015-01-27 06:15:06 -06:00
|
|
|
const auto& gridManager = this->simulator().gridManager();
|
2014-08-05 09:52:52 -05:00
|
|
|
|
2015-08-26 09:04:10 -05:00
|
|
|
int cartesianDofIdx = gridManager.cartesianCellId(elemIdx);
|
2014-08-05 09:52:52 -05:00
|
|
|
|
|
|
|
return deck->getKeyword("PVTNUM")->getIntData()[cartesianDofIdx] - 1;
|
|
|
|
}
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseProblem::name
|
|
|
|
*/
|
2014-04-25 10:22:28 -05:00
|
|
|
std::string name() const
|
2014-04-25 10:48:41 -05:00
|
|
|
{ return this->simulator().gridManager().caseName(); }
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseMultiPhaseProblem::temperature
|
|
|
|
*/
|
|
|
|
template <class Context>
|
|
|
|
Scalar temperature(const Context &context, int spaceIdx, int timeIdx) const
|
2015-02-04 04:19:05 -06:00
|
|
|
{
|
|
|
|
// use the temporally constant temperature, i.e. use the initial temperature of
|
|
|
|
// the DOF
|
|
|
|
int globalDofIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
|
|
|
|
return initialFluidStates_[globalDofIdx].temperature(/*phaseIdx=*/0);
|
|
|
|
}
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseProblem::boundary
|
|
|
|
*
|
2014-11-28 05:58:48 -06:00
|
|
|
* ECLiPSE uses no-flow conditions for all boundaries. \todo really?
|
2014-04-15 11:30:06 -05:00
|
|
|
*/
|
|
|
|
template <class Context>
|
|
|
|
void boundary(BoundaryRateVector &values,
|
|
|
|
const Context &context,
|
|
|
|
int spaceIdx,
|
|
|
|
int timeIdx) const
|
|
|
|
{ values.setNoFlow(); }
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseProblem::initial
|
|
|
|
*
|
|
|
|
* The reservoir problem uses a constant boundary condition for
|
|
|
|
* the whole domain.
|
|
|
|
*/
|
|
|
|
template <class Context>
|
|
|
|
void initial(PrimaryVariables &values, const Context &context, int spaceIdx, int timeIdx) const
|
|
|
|
{
|
|
|
|
int globalDofIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
|
|
|
|
|
2015-01-19 13:31:01 -06:00
|
|
|
values.setPvtRegionIndex(pvtRegionIndex(context, spaceIdx, timeIdx));
|
|
|
|
|
2015-07-29 06:43:17 -05:00
|
|
|
if (useMassConservativeInitialCondition_) {
|
|
|
|
const auto& matParams = materialLawParams(context, spaceIdx, timeIdx);
|
|
|
|
values.assignMassConservative(initialFluidStates_[globalDofIdx], matParams);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
values.assignNaive(initialFluidStates_[globalDofIdx]);
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
|
|
|
|
2015-07-28 10:24:44 -05:00
|
|
|
void initialSolutionApplied()
|
|
|
|
{
|
|
|
|
updateHysteresis_();
|
|
|
|
}
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
/*!
|
|
|
|
* \copydoc FvBaseProblem::source
|
|
|
|
*
|
|
|
|
* For this problem, the source term of all components is 0 everywhere.
|
|
|
|
*/
|
|
|
|
template <class Context>
|
2014-05-07 08:07:39 -05:00
|
|
|
void source(RateVector &rate,
|
|
|
|
const Context &context,
|
|
|
|
int spaceIdx,
|
2014-04-15 11:30:06 -05:00
|
|
|
int timeIdx) const
|
|
|
|
{
|
2015-05-21 09:18:45 -05:00
|
|
|
rate = Toolbox::createConstant(0);
|
|
|
|
|
|
|
|
for (int eqIdx = 0; eqIdx < numEq; ++ eqIdx)
|
|
|
|
rate[eqIdx] = Toolbox::createConstant(0.0);
|
|
|
|
|
2014-05-07 08:07:39 -05:00
|
|
|
wellManager_.computeTotalRatesForDof(rate, context, spaceIdx, timeIdx);
|
|
|
|
|
|
|
|
// convert the source term from the total mass rate of the
|
|
|
|
// cell to the one per unit of volume as used by the model.
|
|
|
|
int globalDofIdx = context.globalSpaceIndex(spaceIdx, timeIdx);
|
2015-05-21 09:18:45 -05:00
|
|
|
for (int eqIdx = 0; eqIdx < numEq; ++ eqIdx)
|
|
|
|
rate[eqIdx] /= this->model().dofTotalVolume(globalDofIdx);
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2014-11-28 05:58:48 -06:00
|
|
|
static bool enableEclOutput_()
|
|
|
|
{ return EWOMS_GET_PARAM(TypeTag, bool, EnableEclOutput); }
|
|
|
|
|
2014-12-04 12:22:56 -06:00
|
|
|
void readRockParameters_()
|
|
|
|
{
|
|
|
|
auto deck = this->simulator().gridManager().deck();
|
|
|
|
auto eclState = this->simulator().gridManager().eclState();
|
2015-07-29 06:41:12 -05:00
|
|
|
const auto& gridManager = this->simulator().gridManager();
|
2014-12-04 12:22:56 -06:00
|
|
|
|
|
|
|
// the ROCK keyword has not been specified, so we don't need
|
|
|
|
// to read rock parameters
|
|
|
|
if (!deck->hasKeyword("ROCK"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
const auto rockKeyword = deck->getKeyword("ROCK");
|
|
|
|
rockParams_.resize(rockKeyword->size());
|
2014-12-08 12:09:05 -06:00
|
|
|
for (size_t rockRecordIdx = 0; rockRecordIdx < rockKeyword->size(); ++ rockRecordIdx) {
|
2014-12-04 12:22:56 -06:00
|
|
|
const auto rockRecord = rockKeyword->getRecord(rockRecordIdx);
|
|
|
|
rockParams_[rockRecordIdx].referencePressure =
|
|
|
|
rockRecord->getItem("PREF")->getSIDouble(0);
|
|
|
|
rockParams_[rockRecordIdx].compressibility =
|
|
|
|
rockRecord->getItem("COMPRESSIBILITY")->getSIDouble(0);
|
|
|
|
}
|
|
|
|
|
2015-07-29 06:41:12 -05:00
|
|
|
// PVTNUM has not been specified, so everything is in the first region and we
|
|
|
|
// don't need to care...
|
|
|
|
if (!eclState->hasIntGridProperty("PVTNUM"))
|
2014-12-04 12:22:56 -06:00
|
|
|
return;
|
|
|
|
|
2015-07-29 06:41:12 -05:00
|
|
|
const std::vector<int>& pvtnumData =
|
|
|
|
eclState->getIntGridProperty("PVTNUM")->getData();
|
|
|
|
rockTableIdx_.resize(gridManager.gridView().size(/*codim=*/0));
|
|
|
|
for (size_t elemIdx = 0; elemIdx < rockTableIdx_.size(); ++ elemIdx) {
|
|
|
|
int cartElemIdx = gridManager.cartesianCellId(elemIdx);
|
|
|
|
|
|
|
|
// reminder: Eclipse uses FORTRAN-style indices
|
|
|
|
rockTableIdx_[elemIdx] = pvtnumData[cartElemIdx] - 1;
|
|
|
|
}
|
2014-12-04 12:22:56 -06:00
|
|
|
}
|
|
|
|
|
2014-06-04 11:05:12 -05:00
|
|
|
void readMaterialParameters_()
|
2014-04-15 11:30:06 -05:00
|
|
|
{
|
2015-01-27 06:15:06 -06:00
|
|
|
const auto &gridManager = this->simulator().gridManager();
|
|
|
|
auto deck = gridManager.deck();
|
|
|
|
auto eclState = gridManager.eclState();
|
2014-07-02 10:50:35 -05:00
|
|
|
|
2014-10-06 09:23:21 -05:00
|
|
|
size_t numDof = this->model().numGridDof();
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
intrinsicPermeability_.resize(numDof);
|
|
|
|
porosity_.resize(numDof);
|
|
|
|
|
2014-07-02 10:50:35 -05:00
|
|
|
////////////////////////////////
|
|
|
|
// permeability
|
|
|
|
|
2014-11-28 05:58:48 -06:00
|
|
|
// read the intrinsic permeabilities from the eclState. Note that all arrays
|
|
|
|
// provided by eclState are one-per-cell of "uncompressed" grid, whereas the
|
2014-07-02 10:50:35 -05:00
|
|
|
// dune-cornerpoint grid object might remove a few elements...
|
2014-11-28 05:58:48 -06:00
|
|
|
if (eclState->hasDoubleGridProperty("PERMX")) {
|
2014-04-15 11:30:06 -05:00
|
|
|
const std::vector<double> &permxData =
|
2014-11-28 05:58:48 -06:00
|
|
|
eclState->getDoubleGridProperty("PERMX")->getData();
|
2014-04-15 11:30:06 -05:00
|
|
|
std::vector<double> permyData(permxData);
|
2014-11-28 05:58:48 -06:00
|
|
|
if (eclState->hasDoubleGridProperty("PERMY"))
|
|
|
|
permyData = eclState->getDoubleGridProperty("PERMY")->getData();
|
2014-04-15 11:30:06 -05:00
|
|
|
std::vector<double> permzData(permxData);
|
2014-11-28 05:58:48 -06:00
|
|
|
if (eclState->hasDoubleGridProperty("PERMZ"))
|
|
|
|
permzData = eclState->getDoubleGridProperty("PERMZ")->getData();
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx) {
|
2015-01-27 06:15:06 -06:00
|
|
|
int cartesianElemIdx = gridManager.cartesianCellId(dofIdx);
|
2014-04-15 11:30:06 -05:00
|
|
|
intrinsicPermeability_[dofIdx] = 0.0;
|
2014-07-02 10:50:35 -05:00
|
|
|
intrinsicPermeability_[dofIdx][0][0] = permxData[cartesianElemIdx];
|
|
|
|
intrinsicPermeability_[dofIdx][1][1] = permyData[cartesianElemIdx];
|
|
|
|
intrinsicPermeability_[dofIdx][2][2] = permzData[cartesianElemIdx];
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
|
|
|
|
2014-07-02 10:50:35 -05:00
|
|
|
// for now we don't care about non-diagonal entries
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
OPM_THROW(std::logic_error,
|
2014-11-28 05:58:48 -06:00
|
|
|
"Can't read the intrinsic permeability from the ecl state. "
|
2014-06-04 11:05:12 -05:00
|
|
|
"(The PERM{X,Y,Z} keywords are missing)");
|
2014-07-02 10:50:35 -05:00
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
// compute the porosity
|
2015-02-13 07:01:07 -06:00
|
|
|
if (!eclState->hasDoubleGridProperty("PORO") && !eclState->hasDoubleGridProperty("PORV"))
|
|
|
|
OPM_THROW(std::runtime_error,
|
|
|
|
"Can't read the porosity from the ECL state object. "
|
|
|
|
"(The PORO and PORV keywords are missing)");
|
|
|
|
|
2014-11-28 05:58:48 -06:00
|
|
|
if (eclState->hasDoubleGridProperty("PORO")) {
|
2014-04-15 11:30:06 -05:00
|
|
|
const std::vector<double> &poroData =
|
2014-11-28 05:58:48 -06:00
|
|
|
eclState->getDoubleGridProperty("PORO")->getData();
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2014-07-02 10:50:35 -05:00
|
|
|
for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx) {
|
2015-01-27 06:15:06 -06:00
|
|
|
int cartesianElemIdx = gridManager.cartesianCellId(dofIdx);
|
2014-07-02 10:50:35 -05:00
|
|
|
porosity_[dofIdx] = poroData[cartesianElemIdx];
|
|
|
|
}
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
2015-02-13 07:01:07 -06:00
|
|
|
|
|
|
|
// overwrite the porosity using the PORV keyword for the elements for which PORV
|
|
|
|
// is defined...
|
|
|
|
if (eclState->hasDoubleGridProperty("PORV")) {
|
|
|
|
const std::vector<double> &porvData =
|
|
|
|
eclState->getDoubleGridProperty("PORV")->getData();
|
|
|
|
|
|
|
|
for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx) {
|
|
|
|
int cartesianElemIdx = gridManager.cartesianCellId(dofIdx);
|
|
|
|
if (std::isfinite(porvData[cartesianElemIdx])) {
|
|
|
|
Scalar dofVolume = this->simulator().model().dofTotalVolume(dofIdx);
|
|
|
|
porosity_[dofIdx] = porvData[cartesianElemIdx]/dofVolume;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2014-07-02 10:50:35 -05:00
|
|
|
// apply the NTG keyword to the porosity
|
2014-11-28 05:58:48 -06:00
|
|
|
if (eclState->hasDoubleGridProperty("NTG")) {
|
2014-07-02 10:50:35 -05:00
|
|
|
const std::vector<double> &ntgData =
|
2014-11-28 05:58:48 -06:00
|
|
|
eclState->getDoubleGridProperty("NTG")->getData();
|
2014-07-02 10:50:35 -05:00
|
|
|
|
2015-01-27 06:15:06 -06:00
|
|
|
for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx)
|
|
|
|
porosity_[dofIdx] *= ntgData[gridManager.cartesianCellId(dofIdx)];
|
2014-07-02 10:50:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// apply the MULTPV keyword to the porosity
|
2014-11-28 05:58:48 -06:00
|
|
|
if (eclState->hasDoubleGridProperty("MULTPV")) {
|
2014-07-02 10:50:35 -05:00
|
|
|
const std::vector<double> &multpvData =
|
2014-11-28 05:58:48 -06:00
|
|
|
eclState->getDoubleGridProperty("MULTPV")->getData();
|
2014-07-02 10:50:35 -05:00
|
|
|
|
2015-01-27 06:15:06 -06:00
|
|
|
for (size_t dofIdx = 0; dofIdx < numDof; ++ dofIdx)
|
|
|
|
porosity_[dofIdx] *= multpvData[gridManager.cartesianCellId(dofIdx)];
|
2014-07-02 10:50:35 -05:00
|
|
|
}
|
|
|
|
|
2015-07-28 10:24:40 -05:00
|
|
|
// the fluid-matrix interactions for ECL problems are dealt with by a separate class
|
2015-08-06 10:01:58 -05:00
|
|
|
std::vector<int> compressedToCartesianElemIdx(numDof);
|
|
|
|
for (unsigned elemIdx = 0; elemIdx < numDof; ++elemIdx)
|
|
|
|
compressedToCartesianElemIdx[elemIdx] = gridManager.cartesianCellId(elemIdx);
|
|
|
|
|
2015-07-29 06:43:17 -05:00
|
|
|
materialLawManager_ = std::make_shared<EclMaterialLawManager>();
|
|
|
|
materialLawManager_->initFromDeck(deck, eclState, compressedToCartesianElemIdx);
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
|
|
|
|
2014-06-04 11:05:12 -05:00
|
|
|
void initFluidSystem_()
|
2014-04-15 11:30:06 -05:00
|
|
|
{
|
2014-06-04 11:05:12 -05:00
|
|
|
const auto deck = this->simulator().gridManager().deck();
|
2014-11-28 05:58:48 -06:00
|
|
|
const auto eclState = this->simulator().gridManager().eclState();
|
2014-06-04 11:05:12 -05:00
|
|
|
|
2015-02-03 06:58:18 -06:00
|
|
|
auto densityKeyword = deck->getKeyword("DENSITY");
|
|
|
|
int numRegions = densityKeyword->size();
|
|
|
|
FluidSystem::initBegin(numRegions);
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2015-02-10 06:56:50 -06:00
|
|
|
FluidSystem::setEnableDissolvedGas(deck->hasKeyword("DISGAS"));
|
|
|
|
FluidSystem::setEnableVaporizedOil(deck->hasKeyword("VAPOIL"));
|
|
|
|
|
2015-02-03 06:58:18 -06:00
|
|
|
// set the reference densities of all PVT regions
|
2014-08-05 09:52:52 -05:00
|
|
|
for (int regionIdx = 0; regionIdx < numRegions; ++regionIdx) {
|
2015-02-03 06:58:18 -06:00
|
|
|
Opm::DeckRecordConstPtr densityRecord = densityKeyword->getRecord(regionIdx);
|
2014-08-12 08:49:47 -05:00
|
|
|
FluidSystem::setReferenceDensities(densityRecord->getItem("OIL")->getSIDouble(0),
|
2015-01-19 09:40:26 -06:00
|
|
|
densityRecord->getItem("WATER")->getSIDouble(0),
|
|
|
|
densityRecord->getItem("GAS")->getSIDouble(0),
|
|
|
|
regionIdx);
|
2014-08-05 09:52:52 -05:00
|
|
|
}
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
typedef std::shared_ptr<const Opm::GasPvtInterface<Scalar, Evaluation> > GasPvtSharedPtr;
|
2015-02-03 06:58:18 -06:00
|
|
|
GasPvtSharedPtr gasPvt(createGasPvt_(deck, eclState));
|
|
|
|
FluidSystem::setGasPvt(gasPvt);
|
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
typedef std::shared_ptr<const Opm::OilPvtInterface<Scalar, Evaluation> > OilPvtSharedPtr;
|
2015-02-03 06:58:18 -06:00
|
|
|
OilPvtSharedPtr oilPvt(createOilPvt_(deck, eclState));
|
|
|
|
FluidSystem::setOilPvt(oilPvt);
|
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
typedef std::shared_ptr<const Opm::WaterPvtInterface<Scalar, Evaluation> > WaterPvtSharedPtr;
|
2015-02-03 06:58:18 -06:00
|
|
|
WaterPvtSharedPtr waterPvt(createWaterPvt_(deck, eclState));
|
|
|
|
FluidSystem::setWaterPvt(waterPvt);
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
FluidSystem::initEnd();
|
|
|
|
}
|
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
Opm::OilPvtInterface<Scalar, Evaluation>* createOilPvt_(Opm::DeckConstPtr deck,
|
|
|
|
Opm::EclipseStateConstPtr eclState)
|
2015-02-03 06:58:18 -06:00
|
|
|
{
|
2015-09-02 17:30:19 -05:00
|
|
|
const auto tableManager = eclState->getTableManager();
|
2015-02-03 06:58:18 -06:00
|
|
|
Opm::DeckKeywordConstPtr densityKeyword = deck->getKeyword("DENSITY");
|
|
|
|
int numPvtRegions = densityKeyword->size();
|
|
|
|
|
|
|
|
if (deck->hasKeyword("PVTO")) {
|
2015-05-21 09:18:45 -05:00
|
|
|
Opm::LiveOilPvt<Scalar, Evaluation> *oilPvt = new Opm::LiveOilPvt<Scalar, Evaluation>;
|
2015-02-03 06:58:18 -06:00
|
|
|
oilPvt->setNumRegions(numPvtRegions);
|
|
|
|
|
|
|
|
for (int regionIdx = 0; regionIdx < numPvtRegions; ++regionIdx)
|
2015-09-02 17:30:19 -05:00
|
|
|
oilPvt->setPvtoTable(regionIdx, tableManager->getPvtoTables()[regionIdx]);
|
2015-02-03 06:58:18 -06:00
|
|
|
|
|
|
|
oilPvt->initEnd();
|
|
|
|
return oilPvt;
|
|
|
|
}
|
|
|
|
else if (deck->hasKeyword("PVDO")) {
|
2015-05-21 09:18:45 -05:00
|
|
|
Opm::DeadOilPvt<Scalar, Evaluation> *oilPvt = new Opm::DeadOilPvt<Scalar, Evaluation>;
|
2015-02-03 06:58:18 -06:00
|
|
|
oilPvt->setNumRegions(numPvtRegions);
|
|
|
|
|
|
|
|
for (int regionIdx = 0; regionIdx < numPvtRegions; ++regionIdx)
|
2015-09-02 17:30:19 -05:00
|
|
|
oilPvt->setPvdoTable(regionIdx, tableManager->getPvdoTables()[regionIdx]);
|
2015-02-03 06:58:18 -06:00
|
|
|
|
|
|
|
oilPvt->initEnd();
|
|
|
|
return oilPvt;
|
|
|
|
}
|
|
|
|
else if (deck->hasKeyword("PVCDO")) {
|
2015-05-21 09:18:45 -05:00
|
|
|
Opm::ConstantCompressibilityOilPvt<Scalar, Evaluation> *oilPvt =
|
|
|
|
new Opm::ConstantCompressibilityOilPvt<Scalar, Evaluation>;
|
2015-02-03 06:58:18 -06:00
|
|
|
oilPvt->setNumRegions(numPvtRegions);
|
|
|
|
|
|
|
|
for (int regionIdx = 0; regionIdx < numPvtRegions; ++regionIdx)
|
|
|
|
oilPvt->setPvcdo(regionIdx, deck->getKeyword("PVCDO"));
|
|
|
|
|
|
|
|
oilPvt->initEnd();
|
|
|
|
return oilPvt;
|
|
|
|
}
|
|
|
|
// TODO (?): PVCO (this is not very hard but the opm-parser requires support for
|
|
|
|
// an additional table)
|
|
|
|
|
|
|
|
OPM_THROW(std::logic_error, "Not implemented: Oil PVT of this deck!");
|
|
|
|
}
|
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
Opm::GasPvtInterface<Scalar, Evaluation>* createGasPvt_(Opm::DeckConstPtr deck,
|
|
|
|
Opm::EclipseStateConstPtr eclState)
|
2015-02-03 06:58:18 -06:00
|
|
|
{
|
|
|
|
Opm::DeckKeywordConstPtr densityKeyword = deck->getKeyword("DENSITY");
|
2015-09-02 17:30:19 -05:00
|
|
|
const auto tableManager = eclState->getTableManager();
|
2015-02-03 06:58:18 -06:00
|
|
|
int numPvtRegions = densityKeyword->size();
|
|
|
|
|
|
|
|
if (deck->hasKeyword("PVTG")) {
|
2015-05-21 09:18:45 -05:00
|
|
|
Opm::WetGasPvt<Scalar, Evaluation> *gasPvt = new Opm::WetGasPvt<Scalar, Evaluation>;
|
2015-02-03 06:58:18 -06:00
|
|
|
gasPvt->setNumRegions(numPvtRegions);
|
|
|
|
|
|
|
|
for (int regionIdx = 0; regionIdx < numPvtRegions; ++regionIdx)
|
2015-09-02 17:30:19 -05:00
|
|
|
gasPvt->setPvtgTable(regionIdx, tableManager->getPvtgTables()[regionIdx]);
|
2015-02-03 06:58:18 -06:00
|
|
|
|
|
|
|
gasPvt->initEnd();
|
|
|
|
return gasPvt;
|
|
|
|
}
|
|
|
|
else if (deck->hasKeyword("PVDG")) {
|
2015-05-21 09:18:45 -05:00
|
|
|
Opm::DryGasPvt<Scalar, Evaluation> *gasPvt = new Opm::DryGasPvt<Scalar, Evaluation>;
|
2015-02-03 06:58:18 -06:00
|
|
|
gasPvt->setNumRegions(numPvtRegions);
|
|
|
|
|
|
|
|
for (int regionIdx = 0; regionIdx < numPvtRegions; ++regionIdx)
|
2015-09-02 17:30:19 -05:00
|
|
|
gasPvt->setPvdgTable(regionIdx, tableManager->getPvdgTables()[regionIdx]);
|
2015-02-03 06:58:18 -06:00
|
|
|
|
|
|
|
gasPvt->initEnd();
|
|
|
|
return gasPvt;
|
|
|
|
}
|
|
|
|
OPM_THROW(std::logic_error, "Not implemented: Gas PVT of this deck!");
|
|
|
|
}
|
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
Opm::WaterPvtInterface<Scalar, Evaluation>* createWaterPvt_(Opm::DeckConstPtr deck,
|
|
|
|
Opm::EclipseStateConstPtr eclState)
|
2015-02-03 06:58:18 -06:00
|
|
|
{
|
|
|
|
Opm::DeckKeywordConstPtr densityKeyword = deck->getKeyword("DENSITY");
|
|
|
|
int numPvtRegions = densityKeyword->size();
|
|
|
|
|
|
|
|
if (deck->hasKeyword("PVTW")) {
|
2015-05-21 09:18:45 -05:00
|
|
|
Opm::ConstantCompressibilityWaterPvt<Scalar, Evaluation> *waterPvt =
|
|
|
|
new Opm::ConstantCompressibilityWaterPvt<Scalar, Evaluation>;
|
2015-02-03 06:58:18 -06:00
|
|
|
waterPvt->setNumRegions(numPvtRegions);
|
|
|
|
|
|
|
|
for (int regionIdx = 0; regionIdx < numPvtRegions; ++regionIdx)
|
|
|
|
waterPvt->setPvtw(regionIdx, deck->getKeyword("PVTW"));
|
|
|
|
|
|
|
|
waterPvt->initEnd();
|
|
|
|
return waterPvt;
|
|
|
|
}
|
|
|
|
|
|
|
|
OPM_THROW(std::logic_error, "Not implemented: Water PVT of this deck!");
|
|
|
|
}
|
|
|
|
|
2014-06-04 11:05:12 -05:00
|
|
|
void readInitialCondition_()
|
2015-07-29 06:43:17 -05:00
|
|
|
{
|
|
|
|
const auto &gridManager = this->simulator().gridManager();
|
|
|
|
const auto deck = gridManager.deck();
|
|
|
|
|
|
|
|
if (!deck->hasKeyword("EQUIL"))
|
|
|
|
readExplicitInitialCondition_();
|
|
|
|
else
|
|
|
|
readEquilInitialCondition_();
|
|
|
|
}
|
|
|
|
|
|
|
|
void readEquilInitialCondition_()
|
|
|
|
{
|
|
|
|
// The EQUIL initializer also modifies the material law manager according to
|
|
|
|
// SWATINIT (although it does not belong there strictly speaking)
|
|
|
|
typedef Ewoms::EclEquilInitializer<TypeTag> EquilInitializer;
|
|
|
|
EquilInitializer equilInitializer(this->simulator(), materialLawManager_);
|
|
|
|
|
|
|
|
// since the EquilInitializer provides fluid states that are consistent with the
|
|
|
|
// black-oil model, we can use naive instead of mass conservative determination
|
|
|
|
// of the primary variables.
|
|
|
|
useMassConservativeInitialCondition_ = false;
|
|
|
|
|
|
|
|
size_t numElems = this->model().numGridDof();
|
|
|
|
initialFluidStates_.resize(numElems);
|
|
|
|
for (size_t elemIdx = 0; elemIdx < numElems; ++elemIdx) {
|
|
|
|
auto &elemFluidState = initialFluidStates_[elemIdx];
|
|
|
|
elemFluidState.assign(equilInitializer.initialFluidState(elemIdx));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void readExplicitInitialCondition_()
|
2014-04-15 11:30:06 -05:00
|
|
|
{
|
2015-01-20 06:19:50 -06:00
|
|
|
const auto &gridManager = this->simulator().gridManager();
|
2015-02-03 06:58:18 -06:00
|
|
|
const auto deck = gridManager.deck();
|
|
|
|
const auto eclState = gridManager.eclState();
|
2014-07-07 05:45:15 -05:00
|
|
|
|
2015-07-29 06:43:17 -05:00
|
|
|
// since the values specified in the deck do not need to be consistent, we use an
|
|
|
|
// initial condition that conserves the total mass specified by these values.
|
|
|
|
useMassConservativeInitialCondition_ = true;
|
|
|
|
|
2015-02-10 06:56:50 -06:00
|
|
|
bool enableDisgas = deck->hasKeyword("DISGAS");
|
|
|
|
bool enableVapoil = deck->hasKeyword("VAPOIL");
|
|
|
|
|
|
|
|
// make sure all required quantities are enables
|
2015-07-29 06:43:17 -05:00
|
|
|
if (!deck->hasKeyword("SWAT") ||
|
|
|
|
!deck->hasKeyword("SGAS"))
|
|
|
|
OPM_THROW(std::runtime_error,
|
|
|
|
"The ECL input file requires the presence of the SWAT "
|
|
|
|
"and SGAS keywords if the model is initialized explicitly");
|
|
|
|
if (!deck->hasKeyword("PRESSURE"))
|
|
|
|
OPM_THROW(std::runtime_error,
|
|
|
|
"The ECL input file requires the presence of the PRESSURE "
|
|
|
|
"keyword if the model is initialized explicitly");
|
|
|
|
if (enableDisgas && !deck->hasKeyword("RS"))
|
|
|
|
OPM_THROW(std::runtime_error,
|
|
|
|
"The ECL input file requires the RS keyword to be present if"
|
|
|
|
" dissolved gas is enabled");
|
|
|
|
if (enableVapoil && !deck->hasKeyword("RV"))
|
|
|
|
OPM_THROW(std::runtime_error,
|
|
|
|
"The ECL input file requires the RV keyword to be present if"
|
|
|
|
" vaporized oil is enabled");
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2014-10-06 09:23:21 -05:00
|
|
|
size_t numDof = this->model().numGridDof();
|
2014-08-05 09:52:52 -05:00
|
|
|
|
|
|
|
initialFluidStates_.resize(numDof);
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
const std::vector<double> &waterSaturationData =
|
|
|
|
deck->getKeyword("SWAT")->getSIDoubleData();
|
|
|
|
const std::vector<double> &gasSaturationData =
|
|
|
|
deck->getKeyword("SGAS")->getSIDoubleData();
|
|
|
|
const std::vector<double> &pressureData =
|
|
|
|
deck->getKeyword("PRESSURE")->getSIDoubleData();
|
2015-02-10 06:56:50 -06:00
|
|
|
const std::vector<double> *rsData = 0;
|
|
|
|
if (enableDisgas)
|
|
|
|
rsData = &deck->getKeyword("RS")->getSIDoubleData();
|
|
|
|
const std::vector<double> *rvData = 0;
|
|
|
|
if (enableVapoil)
|
|
|
|
rvData = &deck->getKeyword("RV")->getSIDoubleData();
|
2015-02-04 04:19:05 -06:00
|
|
|
// initial reservoir temperature
|
|
|
|
const std::vector<double> &tempiData =
|
|
|
|
eclState->getDoubleGridProperty("TEMPI")->getData();
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
// make sure that the size of the data arrays is correct
|
2014-08-04 17:20:19 -05:00
|
|
|
#ifndef NDEBUG
|
2015-01-19 09:22:34 -06:00
|
|
|
const auto &cartSize = this->simulator().gridManager().logicalCartesianSize();
|
2014-08-04 17:20:19 -05:00
|
|
|
size_t numCartesianCells = cartSize[0] * cartSize[1] * cartSize[2];
|
2014-07-07 05:45:15 -05:00
|
|
|
assert(waterSaturationData.size() == numCartesianCells);
|
|
|
|
assert(gasSaturationData.size() == numCartesianCells);
|
|
|
|
assert(pressureData.size() == numCartesianCells);
|
2015-02-10 06:56:50 -06:00
|
|
|
if (enableDisgas)
|
|
|
|
assert(rsData->size() == numCartesianCells);
|
|
|
|
if (enableVapoil)
|
|
|
|
assert(rvData->size() == numCartesianCells);
|
2014-08-04 17:20:19 -05:00
|
|
|
#endif
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
// calculate the initial fluid states
|
|
|
|
for (size_t dofIdx = 0; dofIdx < numDof; ++dofIdx) {
|
|
|
|
auto &dofFluidState = initialFluidStates_[dofIdx];
|
|
|
|
|
2015-01-27 06:15:06 -06:00
|
|
|
size_t cartesianDofIdx = gridManager.cartesianCellId(dofIdx);
|
2014-07-07 05:45:15 -05:00
|
|
|
assert(0 <= cartesianDofIdx);
|
|
|
|
assert(cartesianDofIdx <= numCartesianCells);
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
//////
|
2015-02-04 04:19:05 -06:00
|
|
|
// set temperature
|
2014-04-15 11:30:06 -05:00
|
|
|
//////
|
2015-02-04 04:19:05 -06:00
|
|
|
Scalar temperature = tempiData[cartesianDofIdx];
|
|
|
|
if (!std::isfinite(temperature) || temperature <= 0)
|
|
|
|
temperature = FluidSystem::surfaceTemperature;
|
|
|
|
dofFluidState.setTemperature(temperature);
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
//////
|
|
|
|
// set saturations
|
|
|
|
//////
|
|
|
|
dofFluidState.setSaturation(FluidSystem::waterPhaseIdx,
|
2014-07-07 05:45:15 -05:00
|
|
|
waterSaturationData[cartesianDofIdx]);
|
2014-04-15 11:30:06 -05:00
|
|
|
dofFluidState.setSaturation(FluidSystem::gasPhaseIdx,
|
2014-07-07 05:45:15 -05:00
|
|
|
gasSaturationData[cartesianDofIdx]);
|
2014-04-15 11:30:06 -05:00
|
|
|
dofFluidState.setSaturation(FluidSystem::oilPhaseIdx,
|
|
|
|
1
|
2014-07-07 05:45:15 -05:00
|
|
|
- waterSaturationData[cartesianDofIdx]
|
|
|
|
- gasSaturationData[cartesianDofIdx]);
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
//////
|
2015-02-11 09:52:41 -06:00
|
|
|
// set phase pressures
|
2014-04-15 11:30:06 -05:00
|
|
|
//////
|
2014-07-07 05:45:15 -05:00
|
|
|
Scalar oilPressure = pressureData[cartesianDofIdx];
|
2015-02-11 09:52:41 -06:00
|
|
|
|
|
|
|
// this assumes that capillary pressures only depend on the phase saturations
|
|
|
|
// and possibly on temperature. (this is always the case for ECL problems.)
|
|
|
|
Scalar pc[numPhases];
|
2015-07-29 06:43:17 -05:00
|
|
|
const auto& matParams = materialLawParams(dofIdx);
|
2015-02-11 09:52:41 -06:00
|
|
|
MaterialLaw::capillaryPressures(pc, matParams, dofFluidState);
|
2015-05-21 09:18:45 -05:00
|
|
|
Valgrind::CheckDefined(oilPressure);
|
|
|
|
Valgrind::CheckDefined(pc);
|
2015-02-11 09:52:41 -06:00
|
|
|
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
|
|
|
dofFluidState.setPressure(phaseIdx, oilPressure + (pc[phaseIdx] - pc[oilPhaseIdx]));
|
2015-02-10 06:56:50 -06:00
|
|
|
Scalar gasPressure = dofFluidState.pressure(gasPhaseIdx);
|
2014-04-15 11:30:06 -05:00
|
|
|
|
|
|
|
//////
|
|
|
|
// set compositions
|
|
|
|
//////
|
|
|
|
|
|
|
|
// reset all mole fractions to 0
|
|
|
|
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx)
|
|
|
|
for (int compIdx = 0; compIdx < numComponents; ++compIdx)
|
|
|
|
dofFluidState.setMoleFraction(phaseIdx, compIdx, 0.0);
|
|
|
|
|
2015-02-10 06:56:50 -06:00
|
|
|
// by default, assume immiscibility for all phases
|
2014-04-15 11:30:06 -05:00
|
|
|
dofFluidState.setMoleFraction(waterPhaseIdx, waterCompIdx, 1.0);
|
|
|
|
dofFluidState.setMoleFraction(gasPhaseIdx, gasCompIdx, 1.0);
|
2015-02-10 06:56:50 -06:00
|
|
|
dofFluidState.setMoleFraction(oilPhaseIdx, oilCompIdx, 1.0);
|
|
|
|
|
|
|
|
if (enableDisgas) {
|
|
|
|
// set the composition of the oil phase:
|
|
|
|
//
|
|
|
|
// first, retrieve the relevant black-oil parameters from
|
|
|
|
// the fluid system.
|
2015-02-11 09:52:41 -06:00
|
|
|
//
|
|
|
|
// note that we use the gas pressure here. this is because the primary
|
|
|
|
// varibles and the intensive quantities of the black oil model also do
|
|
|
|
// this...
|
2015-05-21 09:18:45 -05:00
|
|
|
Scalar RsSat = FluidSystem::gasDissolutionFactor(temperature,
|
|
|
|
gasPressure,
|
|
|
|
/*regionIdx=*/0);
|
2015-02-10 06:56:50 -06:00
|
|
|
Scalar RsReal = (*rsData)[cartesianDofIdx];
|
|
|
|
|
|
|
|
if (RsReal > RsSat) {
|
|
|
|
std::array<int, 3> ijk;
|
|
|
|
gridManager.getIJK(dofIdx, ijk);
|
|
|
|
std::cerr << "Warning: The specified amount gas (R_s = " << RsReal << ") is more"
|
|
|
|
<< " than the maximium\n"
|
|
|
|
<< " amount which can be dissolved in oil"
|
|
|
|
<< " (R_s,max=" << RsSat << ")"
|
|
|
|
<< " for cell (" << ijk[0] << ", " << ijk[1] << ", " << ijk[2] << ")."
|
|
|
|
<< " Ignoring.\n";
|
|
|
|
RsReal = RsSat;
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate composition of the real and the saturated oil phase in terms of
|
|
|
|
// mass fractions.
|
|
|
|
Scalar rhooRef = FluidSystem::referenceDensity(oilPhaseIdx, /*regionIdx=*/0);
|
|
|
|
Scalar rhogRef = FluidSystem::referenceDensity(gasPhaseIdx, /*regionIdx=*/0);
|
|
|
|
Scalar XoGReal = RsReal/(RsReal + rhooRef/rhogRef);
|
|
|
|
|
|
|
|
// convert mass to mole fractions
|
|
|
|
Scalar MG = FluidSystem::molarMass(gasCompIdx);
|
|
|
|
Scalar MO = FluidSystem::molarMass(oilCompIdx);
|
|
|
|
|
|
|
|
Scalar xoGReal = XoGReal * MO / ((MO - MG) * XoGReal + MG);
|
|
|
|
Scalar xoOReal = 1 - xoGReal;
|
|
|
|
|
|
|
|
// finally, set the oil-phase composition
|
|
|
|
dofFluidState.setMoleFraction(oilPhaseIdx, gasCompIdx, xoGReal);
|
|
|
|
dofFluidState.setMoleFraction(oilPhaseIdx, oilCompIdx, xoOReal);
|
2014-07-07 05:46:47 -05:00
|
|
|
}
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2015-02-10 06:56:50 -06:00
|
|
|
if (enableVapoil) {
|
|
|
|
// set the composition of the gas phase:
|
|
|
|
//
|
|
|
|
// first, retrieve the relevant black-gas parameters from
|
|
|
|
// the fluid system.
|
2015-05-21 09:18:45 -05:00
|
|
|
Scalar RvSat = FluidSystem::oilVaporizationFactor(temperature,
|
|
|
|
gasPressure,
|
|
|
|
/*regionIdx=*/0);
|
2015-02-10 06:56:50 -06:00
|
|
|
Scalar RvReal = (*rvData)[cartesianDofIdx];
|
|
|
|
|
|
|
|
if (RvReal > RvSat) {
|
|
|
|
std::array<int, 3> ijk;
|
|
|
|
gridManager.getIJK(dofIdx, ijk);
|
|
|
|
std::cerr << "Warning: The specified amount oil (R_v = " << RvReal << ") is more"
|
|
|
|
<< " than the maximium\n"
|
|
|
|
<< " amount which can be dissolved in gas"
|
|
|
|
<< " (R_v,max=" << RvSat << ")"
|
|
|
|
<< " for cell (" << ijk[0] << ", " << ijk[1] << ", " << ijk[2] << ")."
|
|
|
|
<< " Ignoring.\n";
|
|
|
|
RvReal = RvSat;
|
|
|
|
}
|
|
|
|
|
|
|
|
// calculate composition of the real and the saturated gas phase in terms of
|
|
|
|
// mass fractions.
|
|
|
|
Scalar rhooRef = FluidSystem::referenceDensity(oilPhaseIdx, /*regionIdx=*/0);
|
|
|
|
Scalar rhogRef = FluidSystem::referenceDensity(gasPhaseIdx, /*regionIdx=*/0);
|
|
|
|
Scalar XgOReal = RvReal/(RvReal + rhogRef/rhooRef);
|
|
|
|
|
|
|
|
// convert mass to mole fractions
|
|
|
|
Scalar MG = FluidSystem::molarMass(gasCompIdx);
|
|
|
|
Scalar MO = FluidSystem::molarMass(oilCompIdx);
|
|
|
|
|
|
|
|
Scalar xgOReal = XgOReal * MG / ((MG - MO) * XgOReal + MO);
|
|
|
|
Scalar xgGReal = 1 - xgOReal;
|
|
|
|
|
|
|
|
// finally, set the gas-phase composition
|
|
|
|
dofFluidState.setMoleFraction(gasPhaseIdx, oilCompIdx, xgOReal);
|
|
|
|
dofFluidState.setMoleFraction(gasPhaseIdx, gasCompIdx, xgGReal);
|
|
|
|
}
|
2014-04-15 11:30:06 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-28 10:24:44 -05:00
|
|
|
// update the hysteresis parameters of the material laws for the whole grid
|
|
|
|
void updateHysteresis_()
|
|
|
|
{
|
2015-07-29 06:43:17 -05:00
|
|
|
if (!materialLawManager_->enableHysteresis())
|
2015-07-28 10:24:44 -05:00
|
|
|
return;
|
|
|
|
|
|
|
|
ElementContext elemCtx(this->simulator());
|
|
|
|
const auto& gridManager = this->simulator().gridManager();
|
|
|
|
auto elemIt = gridManager.gridView().template begin</*codim=*/0>();
|
|
|
|
const auto &elemEndIt = gridManager.gridView().template end</*codim=*/0>();
|
|
|
|
for (; elemIt != elemEndIt; ++elemIt) {
|
|
|
|
const Element& elem = *elemIt;
|
|
|
|
if (elem.partitionType() != Dune::InteriorEntity)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
elemCtx.updateStencil(elem);
|
|
|
|
elemCtx.updatePrimaryIntensiveQuantities(/*timeIdx=*/0);
|
|
|
|
|
|
|
|
int compressedDofIdx = elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0);
|
|
|
|
const auto& intQuants = elemCtx.intensiveQuantities(/*spaceIdx=*/0, /*timeIdx=*/0);
|
2015-07-29 06:43:17 -05:00
|
|
|
materialLawManager_->updateHysteresis(intQuants.fluidState(), compressedDofIdx);
|
2015-07-28 10:24:44 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-15 11:30:06 -05:00
|
|
|
std::vector<Scalar> porosity_;
|
|
|
|
std::vector<DimMatrix> intrinsicPermeability_;
|
2014-12-27 08:19:15 -06:00
|
|
|
EclTransmissibility<TypeTag> transmissibilities_;
|
2014-07-02 10:50:35 -05:00
|
|
|
|
2015-07-29 06:43:17 -05:00
|
|
|
std::shared_ptr<EclMaterialLawManager> materialLawManager_;
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2014-12-04 12:22:56 -06:00
|
|
|
std::vector<unsigned short> rockTableIdx_;
|
|
|
|
std::vector<RockParams> rockParams_;
|
|
|
|
|
2015-07-29 06:43:17 -05:00
|
|
|
bool useMassConservativeInitialCondition_;
|
2015-05-21 09:18:45 -05:00
|
|
|
std::vector<ScalarFluidState> initialFluidStates_;
|
2014-04-15 11:30:06 -05:00
|
|
|
|
2014-05-07 08:07:39 -05:00
|
|
|
EclWellManager<TypeTag> wellManager_;
|
2014-11-28 05:58:48 -06:00
|
|
|
|
2015-01-25 10:27:08 -06:00
|
|
|
EclDeckUnits<TypeTag> deckUnits_;
|
|
|
|
|
2014-11-28 05:58:48 -06:00
|
|
|
EclWriter<TypeTag> eclWriter_;
|
|
|
|
EclSummaryWriter summaryWriter_;
|
2014-04-15 11:30:06 -05:00
|
|
|
};
|
|
|
|
} // namespace Ewoms
|
|
|
|
|
|
|
|
#endif
|