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-12-27 08:19:15 -06:00
|
|
|
/*
|
|
|
|
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/>.
|
2016-03-14 07:21:47 -05:00
|
|
|
|
|
|
|
Consult the COPYING file in the top-level source directory of this
|
|
|
|
module for the precise wording of the license and the list of
|
|
|
|
copyright holders.
|
2014-12-27 08:19:15 -06:00
|
|
|
*/
|
|
|
|
/*!
|
|
|
|
* \file
|
|
|
|
*
|
|
|
|
* \brief This file contains the flux module which is used for ECL problems
|
|
|
|
*
|
2015-01-04 12:11:02 -06:00
|
|
|
* This approach to fluxes is very specific to two-point flux approximation and applies
|
2017-05-04 06:21:37 -05:00
|
|
|
* what the Eclipse Technical Description calls the "NEWTRAN" transmissibility approach.
|
2014-12-27 08:19:15 -06:00
|
|
|
*/
|
|
|
|
#ifndef EWOMS_ECL_FLUX_MODULE_HH
|
|
|
|
#define EWOMS_ECL_FLUX_MODULE_HH
|
|
|
|
|
|
|
|
#include <ewoms/disc/common/fvbaseproperties.hh>
|
2019-09-16 04:22:14 -05:00
|
|
|
#include <opm/models/blackoil/blackoilproperties.hh>
|
2019-09-16 03:58:20 -05:00
|
|
|
#include <opm/models/utils/signum.hh>
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2018-02-01 07:40:01 -06:00
|
|
|
#include <opm/material/common/Valgrind.hpp>
|
|
|
|
#include <opm/material/common/Exceptions.hpp>
|
2016-11-07 08:14:07 -06:00
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
#include <dune/common/fvector.hh>
|
|
|
|
#include <dune/common/fmatrix.hh>
|
|
|
|
|
2018-06-14 09:06:05 -05:00
|
|
|
BEGIN_PROPERTIES
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
NEW_PROP_TAG(MaterialLaw);
|
2018-06-14 09:06:05 -05:00
|
|
|
|
|
|
|
END_PROPERTIES
|
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
namespace Opm {
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
template <class TypeTag>
|
|
|
|
class EclTransIntensiveQuantities;
|
|
|
|
|
|
|
|
template <class TypeTag>
|
|
|
|
class EclTransExtensiveQuantities;
|
|
|
|
|
|
|
|
template <class TypeTag>
|
|
|
|
class EclTransBaseProblem;
|
|
|
|
|
|
|
|
/*!
|
2015-06-18 07:18:42 -05:00
|
|
|
* \ingroup EclBlackOilSimulator
|
2015-01-04 12:11:02 -06:00
|
|
|
* \brief Specifies a flux module which uses ECL transmissibilities.
|
2014-12-27 08:19:15 -06:00
|
|
|
*/
|
|
|
|
template <class TypeTag>
|
2015-01-04 12:11:02 -06:00
|
|
|
struct EclTransFluxModule
|
2014-12-27 08:19:15 -06:00
|
|
|
{
|
2015-01-04 12:11:02 -06:00
|
|
|
typedef EclTransIntensiveQuantities<TypeTag> FluxIntensiveQuantities;
|
|
|
|
typedef EclTransExtensiveQuantities<TypeTag> FluxExtensiveQuantities;
|
|
|
|
typedef EclTransBaseProblem<TypeTag> FluxBaseProblem;
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
/*!
|
2015-01-04 12:11:02 -06:00
|
|
|
* \brief Register all run-time parameters for the flux module.
|
2014-12-27 08:19:15 -06:00
|
|
|
*/
|
|
|
|
static void registerParameters()
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
2015-06-18 07:18:42 -05:00
|
|
|
* \ingroup EclBlackOilSimulator
|
2014-12-27 08:19:15 -06:00
|
|
|
* \brief Provides the defaults for the parameters required by the
|
|
|
|
* transmissibility based volume flux calculation.
|
|
|
|
*/
|
|
|
|
template <class TypeTag>
|
|
|
|
class EclTransBaseProblem
|
|
|
|
{ };
|
|
|
|
|
|
|
|
/*!
|
2015-06-18 07:18:42 -05:00
|
|
|
* \ingroup EclBlackOilSimulator
|
2015-01-04 12:11:02 -06:00
|
|
|
* \brief Provides the intensive quantities for the ECL flux module
|
2014-12-27 08:19:15 -06:00
|
|
|
*/
|
|
|
|
template <class TypeTag>
|
|
|
|
class EclTransIntensiveQuantities
|
|
|
|
{
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
|
|
|
|
protected:
|
2017-01-17 06:21:16 -06:00
|
|
|
void update_(const ElementContext& elemCtx OPM_UNUSED, unsigned dofIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED)
|
2014-12-27 08:19:15 -06:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
2015-06-18 07:18:42 -05:00
|
|
|
* \ingroup EclBlackOilSimulator
|
2015-01-04 12:11:02 -06:00
|
|
|
* \brief Provides the ECL flux module
|
2014-12-27 08:19:15 -06:00
|
|
|
*/
|
|
|
|
template <class TypeTag>
|
|
|
|
class EclTransExtensiveQuantities
|
|
|
|
{
|
2017-05-05 03:46:53 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, ExtensiveQuantities) Implementation;
|
|
|
|
|
2016-11-15 11:00:48 -06:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
|
2014-12-27 08:19:15 -06:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
|
2015-05-21 09:18:45 -05:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, Evaluation) Evaluation;
|
2014-12-27 08:19:15 -06:00
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
|
|
|
|
typedef typename GET_PROP_TYPE(TypeTag, MaterialLaw) MaterialLaw;
|
|
|
|
|
|
|
|
enum { dimWorld = GridView::dimensionworld };
|
2017-05-05 03:46:53 -05:00
|
|
|
enum { gasPhaseIdx = FluidSystem::gasPhaseIdx };
|
|
|
|
enum { numPhases = FluidSystem::numPhases };
|
|
|
|
enum { enableSolvent = GET_PROP_VALUE(TypeTag, EnableSolvent) };
|
2018-01-30 04:46:23 -06:00
|
|
|
enum { enableEnergy = GET_PROP_VALUE(TypeTag, EnableEnergy) };
|
2019-03-12 09:51:41 -05:00
|
|
|
enum { enableExperiments = GET_PROP_VALUE(TypeTag, EnableExperiments) };
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
typedef Opm::MathToolbox<Evaluation> Toolbox;
|
2014-12-27 08:19:15 -06:00
|
|
|
typedef Dune::FieldVector<Scalar, dimWorld> DimVector;
|
2015-05-21 09:18:45 -05:00
|
|
|
typedef Dune::FieldVector<Evaluation, dimWorld> EvalDimVector;
|
2014-12-27 08:19:15 -06:00
|
|
|
typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix;
|
|
|
|
|
|
|
|
public:
|
|
|
|
/*!
|
|
|
|
* \brief Return the intrinsic permeability tensor at a face [m^2]
|
|
|
|
*/
|
|
|
|
const DimMatrix& intrinsicPermeability() const
|
|
|
|
{
|
2018-02-01 07:40:01 -06:00
|
|
|
throw std::invalid_argument("The ECL transmissibility module does not provide an explicit intrinsic permeability");
|
2014-12-27 08:19:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Return the pressure potential gradient of a fluid phase at the
|
|
|
|
* face's integration point [Pa/m]
|
|
|
|
*
|
|
|
|
* \param phaseIdx The index of the fluid phase
|
|
|
|
*/
|
2017-01-17 06:21:16 -06:00
|
|
|
const EvalDimVector& potentialGrad(unsigned phaseIdx OPM_UNUSED) const
|
2014-12-27 08:19:15 -06:00
|
|
|
{
|
2018-02-01 07:40:01 -06:00
|
|
|
throw std::invalid_argument("The ECL transmissibility module does not provide explicit potential gradients");
|
2014-12-27 08:19:15 -06:00
|
|
|
}
|
|
|
|
|
2016-02-22 11:10:39 -06:00
|
|
|
/*!
|
|
|
|
* \brief Return the gravity corrected pressure difference between the interior and
|
|
|
|
* the exterior of a face.
|
|
|
|
*
|
|
|
|
* \param phaseIdx The index of the fluid phase
|
|
|
|
*/
|
2016-08-02 06:45:52 -05:00
|
|
|
const Evaluation& pressureDifference(unsigned phaseIdx) const
|
|
|
|
{ return pressureDifference_[phaseIdx]; }
|
2016-02-22 11:10:39 -06:00
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
/*!
|
2015-01-04 12:11:02 -06:00
|
|
|
* \brief Return the filter velocity of a fluid phase at the face's integration point
|
|
|
|
* [m/s]
|
2014-12-27 08:19:15 -06:00
|
|
|
*
|
|
|
|
* \param phaseIdx The index of the fluid phase
|
|
|
|
*/
|
2017-01-17 06:21:16 -06:00
|
|
|
const EvalDimVector& filterVelocity(unsigned phaseIdx OPM_UNUSED) const
|
2014-12-27 08:19:15 -06:00
|
|
|
{
|
2018-02-01 07:40:01 -06:00
|
|
|
throw std::invalid_argument("The ECL transmissibility module does not provide explicit filter velocities");
|
2014-12-27 08:19:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Return the volume flux of a fluid phase at the face's integration point
|
|
|
|
* \f$[m^3/s / m^2]\f$
|
|
|
|
*
|
|
|
|
* This is the fluid volume of a phase per second and per square meter of face
|
|
|
|
* area.
|
|
|
|
*
|
|
|
|
* \param phaseIdx The index of the fluid phase
|
|
|
|
*/
|
2015-11-18 04:54:35 -06:00
|
|
|
const Evaluation& volumeFlux(unsigned phaseIdx) const
|
2015-05-21 09:18:45 -05:00
|
|
|
{ return volumeFlux_[phaseIdx]; }
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
protected:
|
|
|
|
/*!
|
|
|
|
* \brief Returns the local index of the degree of freedom in which is
|
|
|
|
* in upstream direction.
|
|
|
|
*
|
|
|
|
* i.e., the DOF which exhibits a higher effective pressure for
|
|
|
|
* the given phase.
|
|
|
|
*/
|
2015-11-18 04:54:35 -06:00
|
|
|
unsigned upstreamIndex_(unsigned phaseIdx) const
|
2014-12-27 08:19:15 -06:00
|
|
|
{
|
|
|
|
assert(0 <= phaseIdx && phaseIdx < numPhases);
|
2016-06-14 04:19:32 -05:00
|
|
|
|
|
|
|
return upIdx_[phaseIdx];
|
2014-12-27 08:19:15 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the local index of the degree of freedom in which is
|
|
|
|
* in downstream direction.
|
|
|
|
*
|
|
|
|
* i.e., the DOF which exhibits a lower effective pressure for the
|
|
|
|
* given phase.
|
|
|
|
*/
|
2015-11-18 04:54:35 -06:00
|
|
|
unsigned downstreamIndex_(unsigned phaseIdx) const
|
2014-12-27 08:19:15 -06:00
|
|
|
{
|
|
|
|
assert(0 <= phaseIdx && phaseIdx < numPhases);
|
2016-06-14 04:19:32 -05:00
|
|
|
|
|
|
|
return dnIdx_[phaseIdx];
|
2014-12-27 08:19:15 -06:00
|
|
|
}
|
|
|
|
|
2017-05-05 03:46:53 -05:00
|
|
|
void updateSolvent(const ElementContext& elemCtx, unsigned scvfIdx, unsigned timeIdx)
|
|
|
|
{ asImp_().updateVolumeFluxTrans(elemCtx, scvfIdx, timeIdx); }
|
|
|
|
|
2017-06-01 00:51:44 -05:00
|
|
|
void updatePolymer(const ElementContext& elemCtx, unsigned scvfIdx, unsigned timeIdx)
|
|
|
|
{ asImp_().updateShearMultipliers(elemCtx, scvfIdx, timeIdx); }
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
/*!
|
|
|
|
* \brief Update the required gradients for interior faces
|
|
|
|
*/
|
2016-11-07 08:14:07 -06:00
|
|
|
void calculateGradients_(const ElementContext& elemCtx, unsigned scvfIdx, unsigned timeIdx)
|
2014-12-27 08:19:15 -06:00
|
|
|
{
|
2017-02-09 11:25:44 -06:00
|
|
|
Opm::Valgrind::SetUndefined(*this);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
const auto& problem = elemCtx.problem();
|
|
|
|
const auto& stencil = elemCtx.stencil(timeIdx);
|
|
|
|
const auto& scvf = stencil.interiorFace(scvfIdx);
|
|
|
|
|
|
|
|
interiorDofIdx_ = scvf.interiorIndex();
|
|
|
|
exteriorDofIdx_ = scvf.exteriorIndex();
|
|
|
|
assert(interiorDofIdx_ != exteriorDofIdx_);
|
|
|
|
|
2016-02-25 08:56:30 -06:00
|
|
|
unsigned I = stencil.globalSpaceIndex(interiorDofIdx_);
|
|
|
|
unsigned J = stencil.globalSpaceIndex(exteriorDofIdx_);
|
2017-05-04 06:23:06 -05:00
|
|
|
|
|
|
|
Scalar trans = problem.transmissibility(elemCtx, interiorDofIdx_, exteriorDofIdx_);
|
|
|
|
Scalar faceArea = scvf.area();
|
|
|
|
Scalar thpres = problem.thresholdPressure(I, J);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
// estimate the gravity correction: for performance reasons we use a simplified
|
|
|
|
// approach for this flux module that assumes that gravity is constant and always
|
|
|
|
// acts into the downwards direction. (i.e., no centrifuge experiments, sorry.)
|
|
|
|
Scalar g = elemCtx.problem().gravity()[dimWorld - 1];
|
|
|
|
|
2016-11-07 08:14:07 -06:00
|
|
|
const auto& intQuantsIn = elemCtx.intensiveQuantities(interiorDofIdx_, timeIdx);
|
|
|
|
const auto& intQuantsEx = elemCtx.intensiveQuantities(exteriorDofIdx_, timeIdx);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2016-08-05 07:43:56 -05:00
|
|
|
// this is quite hacky because the dune grid interface does not provide a
|
2016-10-30 12:42:00 -05:00
|
|
|
// cellCenterDepth() method (so we ask the problem to provide it). The "good"
|
|
|
|
// solution would be to take the Z coordinate of the element centroids, but since
|
|
|
|
// ECL seems to like to be inconsistent on that front, it needs to be done like
|
|
|
|
// here...
|
2016-10-25 08:54:14 -05:00
|
|
|
Scalar zIn = problem.dofCenterDepth(elemCtx, interiorDofIdx_, timeIdx);
|
|
|
|
Scalar zEx = problem.dofCenterDepth(elemCtx, exteriorDofIdx_, timeIdx);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2015-11-12 12:43:57 -06:00
|
|
|
// the distances from the DOF's depths. (i.e., the additional depth of the
|
|
|
|
// exterior DOF)
|
|
|
|
Scalar distZ = zIn - zEx;
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2015-11-18 04:54:35 -06:00
|
|
|
for (unsigned phaseIdx=0; phaseIdx < numPhases; phaseIdx++) {
|
2016-11-15 11:00:48 -06:00
|
|
|
if (!FluidSystem::phaseIsActive(phaseIdx))
|
|
|
|
continue;
|
|
|
|
|
2016-10-25 10:49:39 -05:00
|
|
|
// check shortcut: if the mobility of the phase is zero in the interior as
|
|
|
|
// well as the exterior DOF, we can skip looking at the phase.
|
2017-05-04 07:34:19 -05:00
|
|
|
if (intQuantsIn.mobility(phaseIdx) <= 0.0 &&
|
|
|
|
intQuantsEx.mobility(phaseIdx) <= 0.0)
|
|
|
|
{
|
2016-11-17 12:48:07 -06:00
|
|
|
upIdx_[phaseIdx] = interiorDofIdx_;
|
|
|
|
dnIdx_[phaseIdx] = exteriorDofIdx_;
|
2016-10-25 10:49:39 -05:00
|
|
|
pressureDifference_[phaseIdx] = 0.0;
|
|
|
|
volumeFlux_[phaseIdx] = 0.0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-11-12 12:43:57 -06:00
|
|
|
// do the gravity correction: compute the hydrostatic pressure for the
|
|
|
|
// external at the depth of the internal one
|
2015-05-21 09:18:45 -05:00
|
|
|
const Evaluation& rhoIn = intQuantsIn.fluidState().density(phaseIdx);
|
|
|
|
Scalar rhoEx = Toolbox::value(intQuantsEx.fluidState().density(phaseIdx));
|
2015-11-04 06:38:51 -06:00
|
|
|
Evaluation rhoAvg = (rhoIn + rhoEx)/2;
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2015-11-12 12:43:57 -06:00
|
|
|
const Evaluation& pressureInterior = intQuantsIn.fluidState().pressure(phaseIdx);
|
2015-11-04 06:38:51 -06:00
|
|
|
Evaluation pressureExterior = Toolbox::value(intQuantsEx.fluidState().pressure(phaseIdx));
|
2015-11-12 12:43:57 -06:00
|
|
|
pressureExterior += rhoAvg*(distZ*g);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2016-08-02 06:45:52 -05:00
|
|
|
pressureDifference_[phaseIdx] = pressureExterior - pressureInterior;
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2016-06-14 04:19:32 -05:00
|
|
|
// decide the upstream index for the phase. for this we make sure that the
|
|
|
|
// degree of freedom which is regarded upstream if both pressures are equal
|
|
|
|
// is always the same: if the pressure is equal, the DOF with the lower
|
|
|
|
// global index is regarded to be the upstream one.
|
2016-08-02 06:45:52 -05:00
|
|
|
if (pressureDifference_[phaseIdx] > 0.0) {
|
2016-06-14 04:19:32 -05:00
|
|
|
upIdx_[phaseIdx] = exteriorDofIdx_;
|
|
|
|
dnIdx_[phaseIdx] = interiorDofIdx_;
|
|
|
|
}
|
2016-08-02 06:45:52 -05:00
|
|
|
else if (pressureDifference_[phaseIdx] < 0.0) {
|
2016-06-14 04:19:32 -05:00
|
|
|
upIdx_[phaseIdx] = interiorDofIdx_;
|
|
|
|
dnIdx_[phaseIdx] = exteriorDofIdx_;
|
|
|
|
}
|
2016-08-02 06:45:52 -05:00
|
|
|
else {
|
|
|
|
// if the pressure difference is zero, we chose the DOF which has the
|
|
|
|
// larger volume associated to it as upstream DOF
|
|
|
|
Scalar Vin = elemCtx.dofVolume(interiorDofIdx_, /*timeIdx=*/0);
|
|
|
|
Scalar Vex = elemCtx.dofVolume(exteriorDofIdx_, /*timeIdx=*/0);
|
|
|
|
if (Vin > Vex) {
|
|
|
|
upIdx_[phaseIdx] = interiorDofIdx_;
|
|
|
|
dnIdx_[phaseIdx] = exteriorDofIdx_;
|
|
|
|
}
|
|
|
|
else if (Vin < Vex) {
|
|
|
|
upIdx_[phaseIdx] = exteriorDofIdx_;
|
|
|
|
dnIdx_[phaseIdx] = interiorDofIdx_;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assert(Vin == Vex);
|
|
|
|
// if the volumes are also equal, we pick the DOF which exhibits the
|
|
|
|
// smaller global index
|
|
|
|
if (I < J) {
|
|
|
|
upIdx_[phaseIdx] = interiorDofIdx_;
|
|
|
|
dnIdx_[phaseIdx] = exteriorDofIdx_;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
upIdx_[phaseIdx] = exteriorDofIdx_;
|
|
|
|
dnIdx_[phaseIdx] = interiorDofIdx_;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-06-14 04:19:32 -05:00
|
|
|
|
2016-02-22 11:10:39 -06:00
|
|
|
// apply the threshold pressure for the intersection. note that the concept
|
|
|
|
// of threshold pressure is a quite big hack that only makes sense for ECL
|
2017-05-04 06:21:37 -05:00
|
|
|
// datasets. (and even there, its physical justification is quite
|
2016-02-22 11:10:39 -06:00
|
|
|
// questionable IMO.)
|
2017-05-04 06:23:06 -05:00
|
|
|
if (std::abs(Toolbox::value(pressureDifference_[phaseIdx])) > thpres) {
|
2016-10-25 10:40:32 -05:00
|
|
|
if (pressureDifference_[phaseIdx] < 0.0)
|
2017-05-04 06:23:06 -05:00
|
|
|
pressureDifference_[phaseIdx] += thpres;
|
2016-10-25 10:40:32 -05:00
|
|
|
else
|
2017-05-04 06:23:06 -05:00
|
|
|
pressureDifference_[phaseIdx] -= thpres;
|
2016-10-25 10:40:32 -05:00
|
|
|
}
|
2016-02-22 11:10:39 -06:00
|
|
|
else {
|
2016-08-02 06:45:52 -05:00
|
|
|
pressureDifference_[phaseIdx] = 0.0;
|
2016-02-22 11:10:39 -06:00
|
|
|
volumeFlux_[phaseIdx] = 0.0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
// this is slightly hacky because in the automatic differentiation case, it
|
|
|
|
// only works for the element centered finite volume method. for ebos this
|
|
|
|
// does not matter, though.
|
2015-11-18 04:54:35 -06:00
|
|
|
unsigned upstreamIdx = upstreamIndex_(phaseIdx);
|
2015-05-21 09:18:45 -05:00
|
|
|
const auto& up = elemCtx.intensiveQuantities(upstreamIdx, timeIdx);
|
2019-03-12 09:51:41 -05:00
|
|
|
|
|
|
|
// TODO: should the rock compaction transmissibility multiplier be upstreamed
|
|
|
|
// or averaged? all fluids should see the same compaction?!
|
|
|
|
const Evaluation& transMult =
|
|
|
|
problem.template rockCompTransMultiplier<Evaluation>(up, stencil.globalSpaceIndex(upstreamIdx));
|
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
if (upstreamIdx == interiorDofIdx_)
|
|
|
|
volumeFlux_[phaseIdx] =
|
2019-03-12 09:51:41 -05:00
|
|
|
pressureDifference_[phaseIdx]*up.mobility(phaseIdx)*transMult*(-trans/faceArea);
|
2015-05-21 09:18:45 -05:00
|
|
|
else
|
|
|
|
volumeFlux_[phaseIdx] =
|
2019-03-12 09:51:41 -05:00
|
|
|
pressureDifference_[phaseIdx]*(Toolbox::value(up.mobility(phaseIdx))*Toolbox::value(transMult)*(-trans/faceArea));
|
2014-12-27 08:19:15 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
/*!
|
|
|
|
* \brief Update the required gradients for boundary faces
|
|
|
|
*/
|
|
|
|
template <class FluidState>
|
|
|
|
void calculateBoundaryGradients_(const ElementContext& elemCtx,
|
|
|
|
unsigned scvfIdx,
|
|
|
|
unsigned timeIdx,
|
|
|
|
const FluidState& exFluidState)
|
|
|
|
{
|
2019-02-06 04:18:51 -06:00
|
|
|
const auto& problem = elemCtx.problem();
|
|
|
|
|
2019-03-19 06:31:28 -05:00
|
|
|
bool enableBoundaryMassFlux = problem.nonTrivialBoundaryConditions();
|
2018-01-30 04:46:23 -06:00
|
|
|
if (!enableBoundaryMassFlux)
|
|
|
|
return;
|
|
|
|
|
|
|
|
const auto& stencil = elemCtx.stencil(timeIdx);
|
|
|
|
const auto& scvf = stencil.boundaryFace(scvfIdx);
|
|
|
|
|
|
|
|
interiorDofIdx_ = scvf.interiorIndex();
|
|
|
|
|
|
|
|
Scalar trans = problem.transmissibilityBoundary(elemCtx, scvfIdx);
|
|
|
|
Scalar faceArea = scvf.area();
|
|
|
|
|
|
|
|
// estimate the gravity correction: for performance reasons we use a simplified
|
|
|
|
// approach for this flux module that assumes that gravity is constant and always
|
|
|
|
// acts into the downwards direction. (i.e., no centrifuge experiments, sorry.)
|
|
|
|
Scalar g = elemCtx.problem().gravity()[dimWorld - 1];
|
|
|
|
|
|
|
|
const auto& intQuantsIn = elemCtx.intensiveQuantities(interiorDofIdx_, timeIdx);
|
|
|
|
|
|
|
|
// this is quite hacky because the dune grid interface does not provide a
|
|
|
|
// cellCenterDepth() method (so we ask the problem to provide it). The "good"
|
|
|
|
// solution would be to take the Z coordinate of the element centroids, but since
|
|
|
|
// ECL seems to like to be inconsistent on that front, it needs to be done like
|
|
|
|
// here...
|
|
|
|
Scalar zIn = problem.dofCenterDepth(elemCtx, interiorDofIdx_, timeIdx);
|
|
|
|
Scalar zEx = scvf.integrationPos()[dimWorld - 1];
|
|
|
|
|
|
|
|
// the distances from the DOF's depths. (i.e., the additional depth of the
|
|
|
|
// exterior DOF)
|
|
|
|
Scalar distZ = zIn - zEx;
|
|
|
|
|
|
|
|
for (unsigned phaseIdx=0; phaseIdx < numPhases; phaseIdx++) {
|
|
|
|
if (!FluidSystem::phaseIsActive(phaseIdx))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
// do the gravity correction: compute the hydrostatic pressure for the
|
|
|
|
// integration position
|
|
|
|
const Evaluation& rhoIn = intQuantsIn.fluidState().density(phaseIdx);
|
|
|
|
const auto& rhoEx = exFluidState.density(phaseIdx);
|
|
|
|
Evaluation rhoAvg = (rhoIn + rhoEx)/2;
|
|
|
|
|
|
|
|
const Evaluation& pressureInterior = intQuantsIn.fluidState().pressure(phaseIdx);
|
|
|
|
Evaluation pressureExterior = exFluidState.pressure(phaseIdx);
|
|
|
|
pressureExterior += rhoAvg*(distZ*g);
|
|
|
|
|
|
|
|
pressureDifference_[phaseIdx] = pressureExterior - pressureInterior;
|
|
|
|
|
|
|
|
// decide the upstream index for the phase. for this we make sure that the
|
|
|
|
// degree of freedom which is regarded upstream if both pressures are equal
|
|
|
|
// is always the same: if the pressure is equal, the DOF with the lower
|
|
|
|
// global index is regarded to be the upstream one.
|
|
|
|
if (pressureDifference_[phaseIdx] > 0.0) {
|
|
|
|
upIdx_[phaseIdx] = -1;
|
|
|
|
dnIdx_[phaseIdx] = interiorDofIdx_;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
upIdx_[phaseIdx] = interiorDofIdx_;
|
|
|
|
dnIdx_[phaseIdx] = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// this is slightly hacky because in the automatic differentiation case, it
|
|
|
|
// only works for the element centered finite volume method. for ebos this
|
|
|
|
// does not matter, though.
|
|
|
|
unsigned upstreamIdx = upstreamIndex_(phaseIdx);
|
2019-03-12 09:51:41 -05:00
|
|
|
const auto& up = elemCtx.intensiveQuantities(upstreamIdx, timeIdx);
|
|
|
|
|
|
|
|
Evaluation transModified = trans;
|
|
|
|
if (enableExperiments) {
|
|
|
|
// deal with water induced rock compaction
|
|
|
|
transModified *= problem.template rockCompTransMultiplier<double>(up, stencil.globalSpaceIndex(upstreamIdx));
|
|
|
|
}
|
|
|
|
|
2019-01-31 01:06:15 -06:00
|
|
|
if (upstreamIdx == interiorDofIdx_) {
|
2018-01-30 04:46:23 -06:00
|
|
|
volumeFlux_[phaseIdx] =
|
2019-03-12 09:51:41 -05:00
|
|
|
pressureDifference_[phaseIdx]*up.mobility(phaseIdx)*(-transModified/faceArea);
|
2019-01-31 01:06:15 -06:00
|
|
|
|
2019-03-12 09:51:41 -05:00
|
|
|
if (enableSolvent && phaseIdx == gasPhaseIdx)
|
|
|
|
asImp_().setSolventVolumeFlux( pressureDifference_[phaseIdx]*up.solventMobility()*(-transModified/faceArea));
|
2019-02-01 10:33:30 -06:00
|
|
|
}
|
|
|
|
else {
|
2018-01-30 04:46:23 -06:00
|
|
|
// compute the phase mobility using the material law parameters of the
|
|
|
|
// interior element. TODO: this could probably be done more efficiently
|
|
|
|
const auto& matParams =
|
|
|
|
elemCtx.problem().materialLawParams(elemCtx,
|
|
|
|
interiorDofIdx_,
|
|
|
|
/*timeIdx=*/0);
|
|
|
|
typename FluidState::Scalar kr[numPhases];
|
|
|
|
MaterialLaw::relativePermeabilities(kr, matParams, exFluidState);
|
|
|
|
|
|
|
|
const auto& mob = kr[phaseIdx]/exFluidState.viscosity(phaseIdx);
|
|
|
|
volumeFlux_[phaseIdx] =
|
2019-03-12 09:51:41 -05:00
|
|
|
pressureDifference_[phaseIdx]*mob*(-transModified/faceArea);
|
2019-01-31 01:06:15 -06:00
|
|
|
|
|
|
|
// Solvent inflow is not yet supported
|
2019-03-12 09:51:41 -05:00
|
|
|
if (enableSolvent && phaseIdx == gasPhaseIdx)
|
|
|
|
asImp_().setSolventVolumeFlux(0.0);
|
2018-01-30 04:46:23 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
/*!
|
2015-01-04 12:11:02 -06:00
|
|
|
* \brief Update the volumetric fluxes for all fluid phases on the interior faces of the context
|
2014-12-27 08:19:15 -06:00
|
|
|
*/
|
2017-01-17 06:21:16 -06:00
|
|
|
void calculateFluxes_(const ElementContext& elemCtx OPM_UNUSED, unsigned scvfIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED)
|
2014-12-27 08:19:15 -06:00
|
|
|
{ }
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
void calculateBoundaryFluxes_(const ElementContext& elemCtx OPM_UNUSED, unsigned scvfIdx OPM_UNUSED, unsigned timeIdx OPM_UNUSED)
|
|
|
|
{}
|
|
|
|
|
2017-05-05 03:46:53 -05:00
|
|
|
private:
|
|
|
|
Implementation& asImp_()
|
|
|
|
{ return *static_cast<Implementation*>(this); }
|
|
|
|
|
|
|
|
const Implementation& asImp_() const
|
|
|
|
{ return *static_cast<const Implementation*>(this); }
|
|
|
|
|
2015-05-21 09:18:45 -05:00
|
|
|
// the volumetric flux of all phases [m^3/s]
|
|
|
|
Evaluation volumeFlux_[numPhases];
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2016-08-02 06:45:52 -05:00
|
|
|
// the difference in effective pressure between the exterior and the interior degree
|
|
|
|
// of freedom [Pa]
|
|
|
|
Evaluation pressureDifference_[numPhases];
|
2016-06-14 04:19:32 -05:00
|
|
|
|
|
|
|
// the local indices of the interior and exterior degrees of freedom
|
|
|
|
unsigned short interiorDofIdx_;
|
|
|
|
unsigned short exteriorDofIdx_;
|
|
|
|
unsigned short upIdx_[numPhases];
|
|
|
|
unsigned short dnIdx_[numPhases];
|
2014-12-27 08:19:15 -06:00
|
|
|
};
|
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
} // namespace Opm
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
#endif
|