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
|
|
|
|
*
|
2019-09-05 10:04:39 -05:00
|
|
|
* \copydoc Opm::EclTransmissibility
|
2014-12-27 08:19:15 -06:00
|
|
|
*/
|
|
|
|
#ifndef EWOMS_ECL_TRANSMISSIBILITY_HH
|
|
|
|
#define EWOMS_ECL_TRANSMISSIBILITY_HH
|
|
|
|
|
2019-04-26 14:07:22 -05:00
|
|
|
#include <ebos/nncsorter.hpp>
|
|
|
|
|
2019-09-16 03:58:20 -05:00
|
|
|
#include <opm/models/utils/propertysystem.hh>
|
2020-05-15 02:23:01 -05:00
|
|
|
#include <opm/models/common/multiphasebaseproperties.hh>
|
2016-01-17 14:15:27 -06:00
|
|
|
|
|
|
|
#include <opm/parser/eclipse/EclipseState/EclipseState.hpp>
|
2020-01-13 08:46:50 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
|
2016-01-29 12:21:32 -06:00
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/FaceDir.hpp>
|
|
|
|
#include <opm/parser/eclipse/EclipseState/Grid/TransMult.hpp>
|
2018-11-30 02:07:27 -06:00
|
|
|
#include <opm/parser/eclipse/Units/Units.hpp>
|
|
|
|
|
2018-01-08 05:23:57 -06:00
|
|
|
|
2018-02-08 05:20:17 -06:00
|
|
|
#include <opm/grid/CpGrid.hpp>
|
2018-01-08 05:23:57 -06:00
|
|
|
|
2018-02-01 07:40:01 -06:00
|
|
|
#include <opm/material/common/Exceptions.hpp>
|
2018-01-30 04:46:23 -06:00
|
|
|
#include <opm/material/common/ConditionalStorage.hpp>
|
2016-01-17 14:15:27 -06:00
|
|
|
|
2018-01-08 05:23:57 -06:00
|
|
|
#include <dune/grid/common/mcmgmapper.hh>
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
#include <dune/common/version.hh>
|
|
|
|
#include <dune/common/fvector.hh>
|
|
|
|
#include <dune/common/fmatrix.hh>
|
|
|
|
|
|
|
|
#include <array>
|
|
|
|
#include <vector>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
namespace Opm {
|
2016-01-17 14:15:27 -06:00
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
/*!
|
|
|
|
* \ingroup EclBlackOilSimulator
|
|
|
|
*
|
|
|
|
* \brief This class calculates the transmissibilites for grid faces according to the
|
|
|
|
* Eclipse Technical Description.
|
|
|
|
*/
|
|
|
|
template <class TypeTag>
|
|
|
|
class EclTransmissibility
|
|
|
|
{
|
2020-08-26 03:49:52 -05:00
|
|
|
using Grid = GetPropType<TypeTag, Properties::Grid>;
|
|
|
|
using GridView = GetPropType<TypeTag, Properties::GridView>;
|
|
|
|
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
|
|
|
|
using Vanguard = GetPropType<TypeTag, Properties::Vanguard>;
|
|
|
|
using ElementMapper = GetPropType<TypeTag, Properties::ElementMapper>;
|
|
|
|
using Intersection = typename GridView::Intersection;
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2020-08-27 02:13:30 -05:00
|
|
|
static const bool enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>();
|
2018-01-30 04:46:23 -06:00
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
// Grid and world dimension
|
|
|
|
enum { dimWorld = GridView::dimensionworld };
|
|
|
|
|
|
|
|
typedef Dune::FieldMatrix<Scalar, dimWorld, dimWorld> DimMatrix;
|
|
|
|
typedef Dune::FieldVector<Scalar, dimWorld> DimVector;
|
|
|
|
|
2018-12-11 08:13:05 -06:00
|
|
|
static const unsigned elemIdxShift = 32; // bits
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
public:
|
2018-12-09 16:41:31 -06:00
|
|
|
|
2018-02-01 09:26:58 -06:00
|
|
|
EclTransmissibility(const Vanguard& vanguard)
|
|
|
|
: vanguard_(vanguard)
|
2018-11-30 02:07:27 -06:00
|
|
|
{
|
2020-01-17 07:56:40 -06:00
|
|
|
const Opm::UnitSystem& unitSystem = vanguard_.eclState().getDeckUnitSystem();
|
2019-02-01 10:33:30 -06:00
|
|
|
transmissibilityThreshold_ = unitSystem.parse("Transmissibility").getSIScaling() * 1e-6;
|
2018-11-30 02:07:27 -06:00
|
|
|
}
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Actually compute the transmissibilty over a face as a pre-compute step.
|
|
|
|
*
|
|
|
|
* This code actually uses the direction specific "centroids" of
|
|
|
|
* each element. These "centroids" are _not_ the identical
|
|
|
|
* barycenter of the element, but the middle of the centers of the
|
|
|
|
* faces of the logical Cartesian cells, i.e., the centers of the
|
|
|
|
* faces of the reference elements. We do things this way because
|
|
|
|
* the barycenter of the element can be located outside of the
|
|
|
|
* element for sufficiently "ugly" (i.e., thin and "non-flat")
|
|
|
|
* elements which in turn leads to quite wrong
|
|
|
|
* permeabilities. This approach is probably not always correct
|
|
|
|
* either but at least it seems to be much better.
|
|
|
|
*/
|
|
|
|
void finishInit()
|
2020-01-15 07:36:52 -06:00
|
|
|
{ update(true); }
|
2016-10-17 07:02:09 -05:00
|
|
|
|
2017-06-22 08:55:01 -05:00
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
/*!
|
|
|
|
* \brief Compute all transmissibilities
|
|
|
|
*
|
2020-01-15 07:36:52 -06:00
|
|
|
* \param global If true, update is called on all processes
|
2018-01-30 04:46:23 -06:00
|
|
|
* Also, this updates the "thermal half transmissibilities" if energy is enabled.
|
|
|
|
*/
|
2020-01-15 07:36:52 -06:00
|
|
|
void update(bool global)
|
2014-12-27 08:19:15 -06:00
|
|
|
{
|
2018-02-01 09:26:58 -06:00
|
|
|
const auto& gridView = vanguard_.gridView();
|
|
|
|
const auto& cartMapper = vanguard_.cartesianIndexMapper();
|
|
|
|
const auto& eclState = vanguard_.eclState();
|
2018-12-20 03:17:13 -06:00
|
|
|
const auto& cartDims = cartMapper.cartesianDimensions();
|
2016-12-05 12:49:58 -06:00
|
|
|
auto& transMult = eclState.getTransMult();
|
2020-01-15 07:36:52 -06:00
|
|
|
const auto& comm = vanguard_.gridView().comm();
|
2018-01-08 05:23:57 -06:00
|
|
|
ElementMapper elemMapper(gridView, Dune::mcmgElementLayout());
|
2016-07-15 08:19:46 -05:00
|
|
|
|
2017-05-15 02:56:17 -05:00
|
|
|
// get the ntg values, the ntg values are modified for the cells merged with minpv
|
2020-01-28 03:50:06 -06:00
|
|
|
const std::vector<double>& ntg = eclState.fieldProps().get_double("NTG");
|
2017-05-12 05:39:03 -05:00
|
|
|
|
2016-12-05 12:49:58 -06:00
|
|
|
unsigned numElements = elemMapper.size();
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2016-12-30 03:05:11 -06:00
|
|
|
extractPermeability_();
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
// calculate the axis specific centroids of all elements
|
|
|
|
std::array<std::vector<DimVector>, dimWorld> axisCentroids;
|
|
|
|
|
2015-11-18 04:54:35 -06:00
|
|
|
for (unsigned dimIdx = 0; dimIdx < dimWorld; ++dimIdx)
|
2014-12-27 08:19:15 -06:00
|
|
|
axisCentroids[dimIdx].resize(numElements);
|
|
|
|
|
2020-03-04 14:06:21 -06:00
|
|
|
const std::vector<double>& centroids = vanguard_.cellCentroids();
|
2020-01-15 07:36:52 -06:00
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
auto elemIt = gridView.template begin</*codim=*/ 0>();
|
|
|
|
const auto& elemEndIt = gridView.template end</*codim=*/ 0>();
|
2020-01-15 07:36:52 -06:00
|
|
|
size_t centroidIdx = 0;
|
|
|
|
for (; elemIt != elemEndIt; ++elemIt, ++centroidIdx) {
|
2015-01-21 08:15:40 -06:00
|
|
|
const auto& elem = *elemIt;
|
2016-12-05 12:49:58 -06:00
|
|
|
unsigned elemIdx = elemMapper.index(elem);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2016-07-15 08:19:46 -05:00
|
|
|
// compute the axis specific "centroids" used for the transmissibilities. for
|
|
|
|
// consistency with the flow simulator, we use the element centers as
|
|
|
|
// computed by opm-parser's Opm::EclipseGrid class for all axes.
|
2020-03-19 04:03:44 -05:00
|
|
|
std::array<double, 3> centroid;
|
2020-01-15 07:36:52 -06:00
|
|
|
if (vanguard_.gridView().comm().rank() == 0) {
|
|
|
|
const auto& eclGrid = eclState.getInputGrid();
|
|
|
|
unsigned cartesianCellIdx = cartMapper.cartesianIndex(elemIdx);
|
2020-03-19 04:03:44 -05:00
|
|
|
centroid = eclGrid.getCellCenter(cartesianCellIdx);
|
2020-01-15 07:36:52 -06:00
|
|
|
} else
|
2020-03-19 04:03:44 -05:00
|
|
|
std::copy(centroids.begin() + centroidIdx * dimWorld,
|
|
|
|
centroids.begin() + (centroidIdx + 1) * dimWorld,
|
|
|
|
centroid.begin());
|
2020-01-15 07:36:52 -06:00
|
|
|
|
2016-07-15 08:19:46 -05:00
|
|
|
for (unsigned axisIdx = 0; axisIdx < dimWorld; ++axisIdx)
|
|
|
|
for (unsigned dimIdx = 0; dimIdx < dimWorld; ++dimIdx)
|
|
|
|
axisCentroids[axisIdx][elemIdx][dimIdx] = centroid[dimIdx];
|
2014-12-27 08:19:15 -06:00
|
|
|
}
|
|
|
|
|
2015-01-06 05:40:30 -06:00
|
|
|
// reserving some space in the hashmap upfront saves quite a bit of time because
|
|
|
|
// resizes are costly for hashmaps and there would be quite a few of them if we
|
|
|
|
// would not have a rough idea of how large the final map will be (the rough idea
|
2016-07-15 08:59:45 -05:00
|
|
|
// is a conforming Cartesian grid).
|
2016-10-17 07:02:09 -05:00
|
|
|
trans_.clear();
|
2014-12-27 08:19:15 -06:00
|
|
|
trans_.reserve(numElements*3*1.05);
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
transBoundary_.clear();
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
// if energy is enabled, let's do the same for the "thermal half transmissibilities"
|
|
|
|
if (enableEnergy) {
|
|
|
|
thermalHalfTrans_->clear();
|
2018-03-26 03:53:43 -05:00
|
|
|
thermalHalfTrans_->reserve(numElements*6*1.05);
|
2018-01-30 04:46:23 -06:00
|
|
|
|
|
|
|
thermalHalfTransBoundary_.clear();
|
2018-01-30 04:46:23 -06:00
|
|
|
}
|
|
|
|
|
2020-01-15 07:36:52 -06:00
|
|
|
// The MULTZ needs special case if the option is ALL
|
|
|
|
// Then the smallest multiplier is applied.
|
|
|
|
// Default is to apply the top and bottom multiplier
|
|
|
|
bool useSmallestMultiplier;
|
|
|
|
if (comm.rank() == 0) {
|
|
|
|
const auto& eclGrid = eclState.getInputGrid();
|
|
|
|
useSmallestMultiplier = eclGrid.getMultzOption() == Opm::PinchMode::ModeEnum::ALL;
|
|
|
|
}
|
|
|
|
if (global && comm.size() > 1) {
|
|
|
|
comm.broadcast(&useSmallestMultiplier, 1, 0);
|
|
|
|
}
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
// compute the transmissibilities for all intersections
|
|
|
|
elemIt = gridView.template begin</*codim=*/ 0>();
|
|
|
|
for (; elemIt != elemEndIt; ++elemIt) {
|
2015-01-21 08:15:40 -06:00
|
|
|
const auto& elem = *elemIt;
|
2018-01-30 04:46:23 -06:00
|
|
|
unsigned elemIdx = elemMapper.index(elem);
|
|
|
|
|
2015-01-21 08:15:40 -06:00
|
|
|
auto isIt = gridView.ibegin(elem);
|
|
|
|
const auto& isEndIt = gridView.iend(elem);
|
2018-01-30 04:46:23 -06:00
|
|
|
unsigned boundaryIsIdx = 0;
|
2014-12-27 08:19:15 -06:00
|
|
|
for (; isIt != isEndIt; ++ isIt) {
|
2015-01-19 09:22:34 -06:00
|
|
|
// store intersection, this might be costly
|
|
|
|
const auto& intersection = *isIt;
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
// deal with grid boundaries
|
2018-03-26 03:53:43 -05:00
|
|
|
if (intersection.boundary()) {
|
2018-01-30 04:46:23 -06:00
|
|
|
// compute the transmissibilty for the boundary intersection
|
|
|
|
const auto& geometry = intersection.geometry();
|
|
|
|
const auto& faceCenterInside = geometry.center();
|
|
|
|
|
|
|
|
auto faceAreaNormal = intersection.centerUnitOuterNormal();
|
|
|
|
faceAreaNormal *= geometry.volume();
|
|
|
|
|
|
|
|
Scalar transBoundaryIs;
|
|
|
|
computeHalfTrans_(transBoundaryIs,
|
|
|
|
faceAreaNormal,
|
|
|
|
intersection.indexInInside(),
|
|
|
|
distanceVector_(faceCenterInside,
|
|
|
|
intersection.indexInInside(),
|
|
|
|
elemIdx,
|
|
|
|
axisCentroids),
|
|
|
|
permeability_[elemIdx]);
|
|
|
|
|
|
|
|
// normally there would be two half-transmissibilities that would be
|
|
|
|
// averaged. on the grid boundary there only is the half
|
|
|
|
// transmissibility of the interior element.
|
|
|
|
transBoundary_[std::make_pair(elemIdx, boundaryIsIdx)] = transBoundaryIs;
|
|
|
|
|
|
|
|
// for boundary intersections we also need to compute the thermal
|
|
|
|
// half transmissibilities
|
|
|
|
if (enableEnergy) {
|
|
|
|
const auto& n = intersection.centerUnitOuterNormal();
|
|
|
|
const auto& inPos = elem.geometry().center();
|
|
|
|
const auto& outPos = intersection.geometry().center();
|
|
|
|
const auto& d = outPos - inPos;
|
|
|
|
|
2018-03-26 03:53:43 -05:00
|
|
|
// eWoms expects fluxes to be area specific, i.e. we must *not*
|
|
|
|
// the transmissibility with the face area here
|
|
|
|
Scalar thermalHalfTrans = std::abs(n*d)/(d*d);
|
2018-01-30 04:46:23 -06:00
|
|
|
|
2018-03-26 03:53:43 -05:00
|
|
|
thermalHalfTransBoundary_[std::make_pair(elemIdx, boundaryIsIdx)] =
|
|
|
|
thermalHalfTrans;
|
2018-01-30 04:46:23 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
++ boundaryIsIdx;
|
2014-12-27 08:19:15 -06:00
|
|
|
continue;
|
2018-01-30 04:46:23 -06:00
|
|
|
}
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2018-03-26 03:53:43 -05:00
|
|
|
if (!intersection.neighbor())
|
|
|
|
// elements can be on process boundaries, i.e. they are not on the
|
|
|
|
// domain boundary yet they don't have neighbors.
|
|
|
|
continue;
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
const auto& outsideElem = intersection.outside();
|
|
|
|
unsigned outsideElemIdx = elemMapper.index(outsideElem);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
// update the "thermal half transmissibility" for the intersection
|
|
|
|
if (enableEnergy) {
|
|
|
|
const auto& n = intersection.centerUnitOuterNormal();
|
|
|
|
Scalar A = intersection.geometry().volume();
|
|
|
|
|
|
|
|
const auto& inPos = elem.geometry().center();
|
2018-03-26 03:53:43 -05:00
|
|
|
const auto& outPos = intersection.geometry().center();
|
2018-01-30 04:46:23 -06:00
|
|
|
const auto& d = outPos - inPos;
|
|
|
|
|
2018-03-26 03:53:43 -05:00
|
|
|
(*thermalHalfTrans_)[directionalIsId_(elemIdx, outsideElemIdx)] =
|
|
|
|
A * (n*d)/(d*d);
|
2018-01-30 04:46:23 -06:00
|
|
|
}
|
|
|
|
|
2020-09-07 09:44:17 -05:00
|
|
|
unsigned insideCartElemIdx = cartMapper.cartesianIndex(elemIdx);
|
|
|
|
unsigned outsideCartElemIdx = cartMapper.cartesianIndex(outsideElemIdx);
|
|
|
|
|
2018-03-26 03:53:43 -05:00
|
|
|
// we only need to calculate a face's transmissibility
|
|
|
|
// once...
|
2020-09-07 09:44:17 -05:00
|
|
|
if (insideCartElemIdx > outsideCartElemIdx)
|
2018-03-26 03:53:43 -05:00
|
|
|
continue;
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
// local indices of the faces of the inside and
|
|
|
|
// outside elements which contain the intersection
|
2019-02-05 16:23:48 -06:00
|
|
|
int insideFaceIdx = intersection.indexInInside();
|
|
|
|
int outsideFaceIdx = intersection.indexInOutside();
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2019-01-28 06:09:19 -06:00
|
|
|
if (insideFaceIdx == -1) {
|
|
|
|
// NNC. Set zero transmissibility, as it will be
|
|
|
|
// *added to* by applyNncToGridTrans_() later.
|
|
|
|
assert(outsideFaceIdx == -1);
|
|
|
|
trans_[isId_(elemIdx, outsideElemIdx)] = 0.0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2017-06-22 08:55:01 -05:00
|
|
|
DimVector faceCenterInside;
|
|
|
|
DimVector faceCenterOutside;
|
|
|
|
DimVector faceAreaNormal;
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
typename std::is_same<Grid, Dune::CpGrid>::type isCpGrid;
|
|
|
|
computeFaceProperties(intersection,
|
|
|
|
elemIdx,
|
|
|
|
insideFaceIdx,
|
|
|
|
outsideElemIdx,
|
|
|
|
outsideFaceIdx,
|
|
|
|
faceCenterInside,
|
|
|
|
faceCenterOutside,
|
|
|
|
faceAreaNormal,
|
|
|
|
isCpGrid);
|
2017-01-19 01:57:44 -06:00
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
Scalar halfTrans1;
|
|
|
|
Scalar halfTrans2;
|
|
|
|
|
|
|
|
computeHalfTrans_(halfTrans1,
|
2017-01-19 01:57:44 -06:00
|
|
|
faceAreaNormal,
|
2014-12-27 08:19:15 -06:00
|
|
|
insideFaceIdx,
|
2017-01-19 01:57:44 -06:00
|
|
|
distanceVector_(faceCenterInside,
|
2015-01-19 09:22:34 -06:00
|
|
|
intersection.indexInInside(),
|
2018-01-30 04:46:23 -06:00
|
|
|
elemIdx,
|
2014-12-27 08:19:15 -06:00
|
|
|
axisCentroids),
|
2018-01-30 04:46:23 -06:00
|
|
|
permeability_[elemIdx]);
|
2014-12-27 08:19:15 -06:00
|
|
|
computeHalfTrans_(halfTrans2,
|
2017-01-19 01:57:44 -06:00
|
|
|
faceAreaNormal,
|
2014-12-27 08:19:15 -06:00
|
|
|
outsideFaceIdx,
|
2017-01-19 01:57:44 -06:00
|
|
|
distanceVector_(faceCenterOutside,
|
2015-01-19 09:22:34 -06:00
|
|
|
intersection.indexInOutside(),
|
2014-12-27 08:19:15 -06:00
|
|
|
outsideElemIdx,
|
|
|
|
axisCentroids),
|
2016-12-05 12:49:58 -06:00
|
|
|
permeability_[outsideElemIdx]);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2020-01-28 03:50:06 -06:00
|
|
|
applyNtg_(halfTrans1, insideFaceIdx, elemIdx, ntg);
|
|
|
|
applyNtg_(halfTrans2, outsideFaceIdx, outsideElemIdx, ntg);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
// convert half transmissibilities to full face
|
|
|
|
// transmissibilities using the harmonic mean
|
2016-02-25 05:49:14 -06:00
|
|
|
Scalar trans;
|
2016-08-02 10:15:02 -05:00
|
|
|
if (std::abs(halfTrans1) < 1e-30 || std::abs(halfTrans2) < 1e-30)
|
2016-02-25 05:49:14 -06:00
|
|
|
// avoid division by zero
|
|
|
|
trans = 0.0;
|
|
|
|
else
|
|
|
|
trans = 1.0 / (1.0/halfTrans1 + 1.0/halfTrans2);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
|
|
|
// apply the full face transmissibility multipliers
|
|
|
|
// for the inside ...
|
2018-12-20 03:17:13 -06:00
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
if (useSmallestMultiplier)
|
2018-12-20 03:17:13 -06:00
|
|
|
applyAllZMultipliers_(trans, insideFaceIdx, insideCartElemIdx, outsideCartElemIdx, transMult, cartDims);
|
2019-02-01 10:33:30 -06:00
|
|
|
else
|
2018-12-20 03:17:13 -06:00
|
|
|
applyMultipliers_(trans, insideFaceIdx, insideCartElemIdx, transMult);
|
2014-12-27 08:19:15 -06:00
|
|
|
// ... and outside elements
|
2016-08-09 01:33:06 -05:00
|
|
|
applyMultipliers_(trans, outsideFaceIdx, outsideCartElemIdx, transMult);
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2015-01-27 06:17:01 -06:00
|
|
|
// apply the region multipliers (cf. the MULTREGT keyword)
|
|
|
|
Opm::FaceDir::DirEnum faceDir;
|
|
|
|
switch (insideFaceIdx) {
|
|
|
|
case 0:
|
|
|
|
case 1:
|
|
|
|
faceDir = Opm::FaceDir::XPlus;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
case 3:
|
|
|
|
faceDir = Opm::FaceDir::YPlus;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4:
|
|
|
|
case 5:
|
|
|
|
faceDir = Opm::FaceDir::ZPlus;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-02-01 07:40:01 -06:00
|
|
|
throw std::logic_error("Could not determine a face direction");
|
2015-01-27 06:17:01 -06:00
|
|
|
}
|
|
|
|
|
2016-08-09 01:33:06 -05:00
|
|
|
trans *= transMult.getRegionMultiplier(insideCartElemIdx,
|
|
|
|
outsideCartElemIdx,
|
|
|
|
faceDir);
|
2015-01-27 06:17:01 -06:00
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
trans_[isId_(elemIdx, outsideElemIdx)] = trans;
|
2014-12-27 08:19:15 -06:00
|
|
|
}
|
|
|
|
}
|
2018-10-15 02:44:42 -05:00
|
|
|
|
|
|
|
// potentially overwrite and/or modify transmissibilities based on input from deck
|
|
|
|
updateFromEclState_();
|
2018-12-09 16:41:31 -06:00
|
|
|
|
|
|
|
// Create mapping from global to local index
|
|
|
|
const size_t cartesianSize = cartMapper.cartesianSize();
|
|
|
|
// reserve memory
|
|
|
|
std::vector<int> globalToLocal(cartesianSize, -1);
|
|
|
|
|
|
|
|
// loop over all elements (global grid) and store Cartesian index
|
|
|
|
elemIt = vanguard_.grid().leafGridView().template begin<0>();
|
|
|
|
|
|
|
|
for (; elemIt != elemEndIt; ++elemIt) {
|
|
|
|
int elemIdx = elemMapper.index(*elemIt);
|
|
|
|
int cartElemIdx = vanguard_.cartesianIndexMapper().cartesianIndex(elemIdx);
|
|
|
|
globalToLocal[cartElemIdx] = elemIdx;
|
|
|
|
}
|
2019-04-24 10:18:44 -05:00
|
|
|
applyEditNncToGridTrans_(globalToLocal);
|
2019-01-16 05:21:07 -06:00
|
|
|
applyNncToGridTrans_(globalToLocal);
|
2018-12-11 08:13:05 -06:00
|
|
|
|
|
|
|
//remove very small non-neighbouring transmissibilities
|
|
|
|
removeSmallNonCartesianTransmissibilities_();
|
2014-12-27 08:19:15 -06:00
|
|
|
}
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
/*!
|
|
|
|
* \brief Return the permeability for an element.
|
|
|
|
*/
|
2016-12-05 12:49:58 -06:00
|
|
|
const DimMatrix& permeability(unsigned elemIdx) const
|
|
|
|
{ return permeability_[elemIdx]; }
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
/*!
|
|
|
|
* \brief Return the transmissibility for the intersection between two elements.
|
|
|
|
*/
|
2015-11-18 04:54:35 -06:00
|
|
|
Scalar transmissibility(unsigned elemIdx1, unsigned elemIdx2) const
|
2014-12-27 08:19:15 -06:00
|
|
|
{ return trans_.at(isId_(elemIdx1, elemIdx2)); }
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
/*!
|
|
|
|
* \brief Return the transmissibility for a given boundary segment.
|
|
|
|
*/
|
|
|
|
Scalar transmissibilityBoundary(unsigned elemIdx, unsigned boundaryFaceIdx) const
|
|
|
|
{ return transBoundary_.at(std::make_pair(elemIdx, boundaryFaceIdx)); }
|
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
/*!
|
|
|
|
* \brief Return the thermal "half transmissibility" for the intersection between two
|
|
|
|
* elements.
|
|
|
|
*
|
|
|
|
* The "half transmissibility" features all sub-expressions of the "thermal
|
2018-03-26 03:53:43 -05:00
|
|
|
* transmissibility" which can be precomputed, i.e. they are not dependent on the
|
|
|
|
* current solution:
|
2018-01-30 04:46:23 -06:00
|
|
|
*
|
2018-03-26 03:53:43 -05:00
|
|
|
* H_t = A * (n*d)/(d*d);
|
2018-01-30 04:46:23 -06:00
|
|
|
*
|
|
|
|
* where A is the area of the intersection between the inside and outside elements, n
|
2018-03-26 03:53:43 -05:00
|
|
|
* is the outer unit normal, and d is the distance between the center of the inside
|
|
|
|
* cell and the center of the intersection.
|
2018-01-30 04:46:23 -06:00
|
|
|
*/
|
|
|
|
Scalar thermalHalfTrans(unsigned insideElemIdx, unsigned outsideElemIdx) const
|
2018-03-26 03:53:43 -05:00
|
|
|
{ return thermalHalfTrans_->at(directionalIsId_(insideElemIdx, outsideElemIdx)); }
|
2018-01-30 04:46:23 -06:00
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
Scalar thermalHalfTransBoundary(unsigned insideElemIdx, unsigned boundaryFaceIdx) const
|
|
|
|
{ return thermalHalfTransBoundary_.at(std::make_pair(insideElemIdx, boundaryFaceIdx)); }
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
private:
|
2018-10-15 02:44:42 -05:00
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
void removeSmallNonCartesianTransmissibilities_()
|
|
|
|
{
|
2018-12-11 08:13:05 -06:00
|
|
|
const auto& cartMapper = vanguard_.cartesianIndexMapper();
|
|
|
|
const auto& cartDims = cartMapper.cartesianDimensions();
|
2019-02-01 10:33:30 -06:00
|
|
|
for (auto&& trans: trans_) {
|
|
|
|
if (trans.second < transmissibilityThreshold_) {
|
2018-12-11 08:13:05 -06:00
|
|
|
const auto& id = trans.first;
|
|
|
|
const auto& elements = isIdReverse_(id);
|
|
|
|
int gc1 = std::min(cartMapper.cartesianIndex(elements.first), cartMapper.cartesianIndex(elements.second));
|
|
|
|
int gc2 = std::max(cartMapper.cartesianIndex(elements.first), cartMapper.cartesianIndex(elements.second));
|
|
|
|
|
|
|
|
// only adjust the NNCs
|
2019-02-01 10:33:30 -06:00
|
|
|
if (gc2 - gc1 == 1 || gc2 - gc1 == cartDims[0] || gc2 - gc1 == cartDims[0]*cartDims[1])
|
2018-12-11 08:13:05 -06:00
|
|
|
continue;
|
|
|
|
|
|
|
|
//remove transmissibilities less than the threshold (by default 1e-6 in the deck's unit system)
|
|
|
|
trans.second = 0.0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
void applyAllZMultipliers_(Scalar& trans,
|
|
|
|
unsigned insideFaceIdx,
|
|
|
|
unsigned insideCartElemIdx,
|
|
|
|
unsigned outsideCartElemIdx,
|
|
|
|
const Opm::TransMult& transMult,
|
|
|
|
const std::array<int, dimWorld>& cartDims)
|
|
|
|
{
|
|
|
|
if (insideFaceIdx > 3) { // top or or bottom
|
2018-12-20 03:17:13 -06:00
|
|
|
Scalar mult = 1e20;
|
|
|
|
unsigned cartElemIdx = insideCartElemIdx;
|
2020-09-07 09:54:14 -05:00
|
|
|
assert(insideFaceIdx==5); // as insideCartElemIdx < outsideCartElemIdx holds for the Z column
|
|
|
|
// pick the smallest multiplier for Z+ while looking down the pillar untill reaching the other end of the connection
|
|
|
|
// While Z- is not all used here. There is a call after this function that does
|
|
|
|
// applyMultipliers_(trans, outsideFaceIdx, outsideCartElemIdx, transMult)
|
|
|
|
// and hence treats the other direction
|
2018-12-20 03:17:13 -06:00
|
|
|
while (cartElemIdx != outsideCartElemIdx) {
|
2020-09-07 09:54:14 -05:00
|
|
|
mult = std::min(mult, transMult.getMultiplier(cartElemIdx, Opm::FaceDir::ZPlus));
|
2018-12-20 03:17:13 -06:00
|
|
|
cartElemIdx += cartDims[0]*cartDims[1];
|
|
|
|
}
|
|
|
|
trans *= mult;
|
|
|
|
}
|
2019-02-01 10:33:30 -06:00
|
|
|
else
|
|
|
|
applyMultipliers_(trans, insideFaceIdx, insideCartElemIdx, transMult);
|
2018-12-20 03:17:13 -06:00
|
|
|
}
|
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
void updateFromEclState_()
|
|
|
|
{
|
2018-10-15 02:44:42 -05:00
|
|
|
const auto& gridView = vanguard_.gridView();
|
|
|
|
const auto& cartMapper = vanguard_.cartesianIndexMapper();
|
|
|
|
const auto& cartDims = cartMapper.cartesianDimensions();
|
|
|
|
ElementMapper elemMapper(gridView, Dune::mcmgElementLayout());
|
|
|
|
|
2020-01-13 08:46:50 -06:00
|
|
|
const auto& fp = vanguard_.eclState().fieldProps();
|
2020-02-25 07:29:45 -06:00
|
|
|
const auto& inputTranxData = fp.get_double("TRANX");
|
|
|
|
const auto& inputTranyData = fp.get_double("TRANY");
|
|
|
|
const auto& inputTranzData = fp.get_double("TRANZ");
|
2020-01-13 08:46:50 -06:00
|
|
|
bool tranx_deckAssigned = false; // Ohh my ....
|
|
|
|
bool trany_deckAssigned = false;
|
|
|
|
bool tranz_deckAssigned = false;
|
2018-10-15 02:44:42 -05:00
|
|
|
// compute the transmissibilities for all intersections
|
|
|
|
auto elemIt = gridView.template begin</*codim=*/ 0>();
|
|
|
|
const auto& elemEndIt = gridView.template end</*codim=*/ 0>();
|
|
|
|
|
|
|
|
for (; elemIt != elemEndIt; ++elemIt) {
|
|
|
|
const auto& elem = *elemIt;
|
|
|
|
auto isIt = gridView.ibegin(elem);
|
|
|
|
const auto& isEndIt = gridView.iend(elem);
|
|
|
|
for (; isIt != isEndIt; ++ isIt) {
|
|
|
|
// store intersection, this might be costly
|
|
|
|
const auto& intersection = *isIt;
|
|
|
|
if (!intersection.neighbor())
|
|
|
|
continue; // intersection is on the domain boundary
|
|
|
|
|
|
|
|
unsigned c1 = elemMapper.index(intersection.inside());
|
|
|
|
unsigned c2 = elemMapper.index(intersection.outside());
|
|
|
|
|
|
|
|
if (c1 > c2)
|
|
|
|
continue; // we only need to handle each connection once, thank you.
|
|
|
|
|
|
|
|
auto isId = isId_(c1, c2);
|
|
|
|
|
|
|
|
int gc1 = std::min(cartMapper.cartesianIndex(c1), cartMapper.cartesianIndex(c2));
|
|
|
|
int gc2 = std::max(cartMapper.cartesianIndex(c1), cartMapper.cartesianIndex(c2));
|
|
|
|
|
2020-06-15 03:40:26 -05:00
|
|
|
if (gc2 - gc1 == 1 && cartDims[0] > 1) {
|
2020-01-13 08:46:50 -06:00
|
|
|
if (tranx_deckAssigned)
|
2018-10-15 02:44:42 -05:00
|
|
|
// set simulator internal transmissibilities to values from inputTranx
|
2020-02-25 07:29:45 -06:00
|
|
|
trans_[isId] = inputTranxData[c1];
|
2019-02-01 10:33:30 -06:00
|
|
|
else
|
2018-10-15 02:44:42 -05:00
|
|
|
// Scale transmissibilities with scale factor from inputTranx
|
2020-02-25 07:29:45 -06:00
|
|
|
trans_[isId] *= inputTranxData[c1];
|
2018-10-15 02:44:42 -05:00
|
|
|
}
|
2020-06-15 03:40:26 -05:00
|
|
|
else if (gc2 - gc1 == cartDims[0] && cartDims[1] > 1) {
|
2020-01-13 08:46:50 -06:00
|
|
|
if (trany_deckAssigned)
|
2018-10-15 02:44:42 -05:00
|
|
|
// set simulator internal transmissibilities to values from inputTrany
|
2020-02-25 07:29:45 -06:00
|
|
|
trans_[isId] = inputTranyData[c1];
|
2019-02-01 10:33:30 -06:00
|
|
|
else
|
2018-10-15 02:44:42 -05:00
|
|
|
// Scale transmissibilities with scale factor from inputTrany
|
2020-02-25 07:29:45 -06:00
|
|
|
trans_[isId] *= inputTranyData[c1];
|
2018-10-15 02:44:42 -05:00
|
|
|
}
|
|
|
|
else if (gc2 - gc1 == cartDims[0]*cartDims[1]) {
|
2020-01-13 08:46:50 -06:00
|
|
|
if (tranz_deckAssigned)
|
2018-10-15 02:44:42 -05:00
|
|
|
// set simulator internal transmissibilities to values from inputTranz
|
2020-02-25 07:29:45 -06:00
|
|
|
trans_[isId] = inputTranzData[c1];
|
2019-02-01 10:33:30 -06:00
|
|
|
else
|
2018-10-15 02:44:42 -05:00
|
|
|
// Scale transmissibilities with scale factor from inputTranz
|
2020-02-25 07:29:45 -06:00
|
|
|
trans_[isId] *= inputTranzData[c1];
|
2018-10-15 02:44:42 -05:00
|
|
|
}
|
|
|
|
//else.. We don't support modification of NNC at the moment.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-06-22 08:55:01 -05:00
|
|
|
template <class Intersection>
|
2019-02-01 10:33:30 -06:00
|
|
|
void computeFaceProperties(const Intersection& intersection,
|
2019-07-08 05:14:24 -05:00
|
|
|
const int insideElemIdx OPM_UNUSED,
|
|
|
|
const int insideFaceIdx OPM_UNUSED,
|
|
|
|
const int outsideElemIdx OPM_UNUSED,
|
|
|
|
const int outsideFaceIdx OPM_UNUSED,
|
2019-02-01 10:33:30 -06:00
|
|
|
DimVector& faceCenterInside,
|
|
|
|
DimVector& faceCenterOutside,
|
|
|
|
DimVector& faceAreaNormal,
|
|
|
|
/*isCpGrid=*/std::false_type) const
|
2017-06-22 08:55:01 -05:00
|
|
|
{
|
|
|
|
// default implementation for DUNE grids
|
|
|
|
const auto& geometry = intersection.geometry();
|
|
|
|
faceCenterInside = geometry.center();
|
|
|
|
faceCenterOutside = faceCenterInside;
|
|
|
|
|
|
|
|
faceAreaNormal = intersection.centerUnitOuterNormal();
|
|
|
|
faceAreaNormal *= geometry.volume();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Intersection>
|
2019-02-01 10:33:30 -06:00
|
|
|
void computeFaceProperties(const Intersection& intersection,
|
|
|
|
const int insideElemIdx,
|
|
|
|
const int insideFaceIdx,
|
|
|
|
const int outsideElemIdx,
|
|
|
|
const int outsideFaceIdx,
|
|
|
|
DimVector& faceCenterInside,
|
|
|
|
DimVector& faceCenterOutside,
|
|
|
|
DimVector& faceAreaNormal,
|
|
|
|
/*isCpGrid=*/std::true_type) const
|
2017-06-22 08:55:01 -05:00
|
|
|
{
|
|
|
|
int faceIdx = intersection.id();
|
2019-02-01 10:33:30 -06:00
|
|
|
faceCenterInside = vanguard_.grid().faceCenterEcl(insideElemIdx, insideFaceIdx);
|
|
|
|
faceCenterOutside = vanguard_.grid().faceCenterEcl(outsideElemIdx, outsideFaceIdx);
|
2018-02-01 09:26:58 -06:00
|
|
|
faceAreaNormal = vanguard_.grid().faceAreaNormalEcl(faceIdx);
|
2017-06-22 08:55:01 -05:00
|
|
|
}
|
|
|
|
|
2019-01-16 05:56:08 -06:00
|
|
|
/*
|
|
|
|
* \brief Applies additional transmissibilities specified via NNC keyword.
|
|
|
|
*
|
|
|
|
* Applies only those NNC that are actually represented by the grid. These may
|
|
|
|
* NNCs due to faults or NNCs that are actually neighbours. In both cases that
|
|
|
|
* specified transmissibilities (scaled by EDITNNC) will be added to the already
|
|
|
|
* existing models.
|
|
|
|
*
|
|
|
|
* \param cartesianToCompressed Vector containing the compressed index (or -1 for inactive
|
|
|
|
* cells) as the element at the cartesian index.
|
|
|
|
* \return Two vector of NNCs (scaled by EDITNNC). The first one are the NNCs that have been applied
|
|
|
|
* and the second the NNCs not resembled by faces of the grid. NNCs specified for
|
|
|
|
* inactive cells are omitted in these vectors.
|
|
|
|
*/
|
2019-02-01 10:33:30 -06:00
|
|
|
std::tuple<std::vector<Opm::NNCdata>, std::vector<Opm::NNCdata> >
|
2019-01-16 05:21:07 -06:00
|
|
|
applyNncToGridTrans_(const std::vector<int>& cartesianToCompressed)
|
2018-11-09 03:25:05 -06:00
|
|
|
{
|
2018-12-09 16:41:31 -06:00
|
|
|
// First scale NNCs with EDITNNC.
|
2019-02-01 10:33:30 -06:00
|
|
|
std::vector<Opm::NNCdata> unprocessedNnc;
|
|
|
|
std::vector<Opm::NNCdata> processedNnc;
|
2018-12-09 16:41:31 -06:00
|
|
|
const auto& nnc = vanguard_.eclState().getInputNNC();
|
2019-02-01 10:33:30 -06:00
|
|
|
if (!nnc.hasNNC())
|
2019-01-16 05:21:07 -06:00
|
|
|
return make_tuple(processedNnc, unprocessedNnc);
|
2019-02-01 10:33:30 -06:00
|
|
|
|
2019-11-26 06:29:40 -06:00
|
|
|
auto nncData = sortNncAndApplyEditnnc(nnc.data(), vanguard_.eclState().getInputEDITNNC().data());
|
2018-11-09 03:25:05 -06:00
|
|
|
|
2019-04-26 14:25:59 -05:00
|
|
|
for (const auto& nncEntry : nncData) {
|
2019-01-16 06:07:52 -06:00
|
|
|
auto c1 = nncEntry.cell1;
|
|
|
|
auto c2 = nncEntry.cell2;
|
|
|
|
auto low = cartesianToCompressed[c1];
|
|
|
|
auto high = cartesianToCompressed[c2];
|
2018-11-09 03:25:05 -06:00
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
if (low > high)
|
2018-12-09 16:41:31 -06:00
|
|
|
std::swap(low, high);
|
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
if (low == -1 && high == -1)
|
2018-12-09 16:41:31 -06:00
|
|
|
// Silently discard as it is not between active cells
|
|
|
|
continue;
|
|
|
|
|
2019-03-04 05:32:13 -06:00
|
|
|
if (low == -1 || high == -1) {
|
|
|
|
// Discard the NNC if it is between active cell and inactive cell
|
|
|
|
std::ostringstream sstr;
|
|
|
|
sstr << "NNC between active and inactive cells ("
|
|
|
|
<< low << " -> " << high << ")";
|
|
|
|
Opm::OpmLog::warning(sstr.str());
|
|
|
|
continue;
|
|
|
|
}
|
2018-12-09 16:41:31 -06:00
|
|
|
|
|
|
|
auto candidate = trans_.find(isId_(low, high));
|
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
if (candidate == trans_.end())
|
2018-12-09 16:41:31 -06:00
|
|
|
// This NNC is not resembled by the grid. Save it for later
|
|
|
|
// processing with local cell values
|
2019-01-16 05:21:07 -06:00
|
|
|
unprocessedNnc.push_back({c1, c2, nncEntry.trans});
|
2019-02-01 10:33:30 -06:00
|
|
|
else {
|
2018-12-09 16:41:31 -06:00
|
|
|
// NNC is represented by the grid and might be a neighboring connection
|
|
|
|
// In this case the transmissibilty is added to the value already
|
|
|
|
// set or computed.
|
2019-01-16 05:21:07 -06:00
|
|
|
candidate->second += nncEntry.trans;
|
|
|
|
processedNnc.push_back({c1, c2, nncEntry.trans});
|
2018-12-09 16:41:31 -06:00
|
|
|
}
|
|
|
|
}
|
2019-01-16 05:21:07 -06:00
|
|
|
return make_tuple(processedNnc, unprocessedNnc);
|
2018-12-09 16:41:31 -06:00
|
|
|
}
|
|
|
|
|
2018-12-10 04:34:23 -06:00
|
|
|
/// \brief Multiplies the grid transmissibilities according to EDITNNC.
|
2019-04-24 10:18:44 -05:00
|
|
|
void applyEditNncToGridTrans_(const std::vector<int>& globalToLocal)
|
2018-12-09 16:41:31 -06:00
|
|
|
{
|
2019-02-01 10:33:30 -06:00
|
|
|
const auto& editNnc = vanguard_.eclState().getInputEDITNNC();
|
|
|
|
if (editNnc.empty())
|
2018-12-09 16:41:31 -06:00
|
|
|
return;
|
2018-11-09 03:25:05 -06:00
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
// editNnc is supposed to only reference non-neighboring connections and not
|
2018-11-09 03:25:05 -06:00
|
|
|
// neighboring connections. Use all entries for scaling if there is an NNC.
|
2018-12-05 03:15:42 -06:00
|
|
|
// variable nnc incremented in loop body.
|
2019-02-01 10:33:30 -06:00
|
|
|
auto nnc = editNnc.data().begin();
|
|
|
|
auto end = editNnc.data().end();
|
|
|
|
while (nnc != end) {
|
|
|
|
auto c1 = nnc->cell1;
|
|
|
|
auto c2 = nnc->cell2;
|
|
|
|
auto low = globalToLocal[c1];
|
|
|
|
auto high = globalToLocal[c2];
|
|
|
|
if (low > high)
|
2018-11-09 03:25:05 -06:00
|
|
|
std::swap(low, high);
|
2018-12-05 03:15:42 -06:00
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
auto candidate = trans_.find(isId_(low, high));
|
|
|
|
if (candidate == trans_.end()) {
|
2018-12-05 03:15:42 -06:00
|
|
|
std::ostringstream sstr;
|
2018-12-20 04:44:46 -06:00
|
|
|
sstr << "Cannot edit NNC from " << c1 << " to " << c2
|
2018-12-05 03:15:42 -06:00
|
|
|
<< " as it does not exist";
|
|
|
|
Opm::OpmLog::warning(sstr.str());
|
2018-12-20 04:44:46 -06:00
|
|
|
++nnc;
|
2018-12-05 03:15:42 -06:00
|
|
|
}
|
2019-02-01 10:33:30 -06:00
|
|
|
else {
|
2018-12-05 03:15:42 -06:00
|
|
|
// NNC exists
|
2019-02-01 10:33:30 -06:00
|
|
|
while (nnc!= end && c1==nnc->cell1 && c2==nnc->cell2) {
|
2018-11-09 03:25:05 -06:00
|
|
|
candidate->second *= nnc->trans;
|
2018-12-05 03:15:42 -06:00
|
|
|
++nnc;
|
2018-11-09 03:25:05 -06:00
|
|
|
}
|
2018-12-05 03:15:42 -06:00
|
|
|
}
|
2018-11-09 03:25:05 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-30 03:05:11 -06:00
|
|
|
void extractPermeability_()
|
2016-12-05 12:49:58 -06:00
|
|
|
{
|
2018-02-01 09:26:58 -06:00
|
|
|
unsigned numElem = vanguard_.gridView().size(/*codim=*/0);
|
2016-12-05 12:49:58 -06:00
|
|
|
permeability_.resize(numElem);
|
|
|
|
|
|
|
|
// read the intrinsic permeabilities from the eclState. Note that all arrays
|
|
|
|
// provided by eclState are one-per-cell of "uncompressed" grid, whereas the
|
|
|
|
// simulation grid might remove a few elements. (e.g. because it is distributed
|
|
|
|
// over several processes.)
|
2020-01-13 08:46:50 -06:00
|
|
|
const auto& fp = vanguard_.eclState().fieldProps();
|
|
|
|
if (fp.has_double("PERMX")) {
|
2020-02-25 07:32:12 -06:00
|
|
|
const std::vector<double>& permxData = fp.get_double("PERMX");
|
2020-01-13 08:46:50 -06:00
|
|
|
|
2020-02-25 07:32:12 -06:00
|
|
|
std::vector<double> permyData;
|
2020-01-13 08:46:50 -06:00
|
|
|
if (fp.has_double("PERMY"))
|
2020-02-25 07:32:12 -06:00
|
|
|
permyData = fp.get_double("PERMY");
|
|
|
|
else
|
|
|
|
permyData = permxData;
|
2020-01-13 08:46:50 -06:00
|
|
|
|
2020-02-25 07:32:12 -06:00
|
|
|
std::vector<double> permzData;
|
2020-01-13 08:46:50 -06:00
|
|
|
if (fp.has_double("PERMZ"))
|
2020-02-25 07:32:12 -06:00
|
|
|
permzData = fp.get_double("PERMZ");
|
|
|
|
else
|
|
|
|
permzData = permxData;
|
2016-12-05 12:49:58 -06:00
|
|
|
|
|
|
|
for (size_t dofIdx = 0; dofIdx < numElem; ++ dofIdx) {
|
|
|
|
permeability_[dofIdx] = 0.0;
|
2020-02-25 07:32:12 -06:00
|
|
|
permeability_[dofIdx][0][0] = permxData[dofIdx];
|
|
|
|
permeability_[dofIdx][1][1] = permyData[dofIdx];
|
|
|
|
permeability_[dofIdx][2][2] = permzData[dofIdx];
|
2016-12-05 12:49:58 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// for now we don't care about non-diagonal entries
|
2020-01-13 08:46:50 -06:00
|
|
|
|
2016-12-05 12:49:58 -06:00
|
|
|
}
|
|
|
|
else
|
2018-02-01 07:40:01 -06:00
|
|
|
throw std::logic_error("Can't read the intrinsic permeability from the ecl state. "
|
|
|
|
"(The PERM{X,Y,Z} keywords are missing)");
|
2016-12-05 12:49:58 -06:00
|
|
|
}
|
|
|
|
|
2018-12-11 08:13:05 -06:00
|
|
|
std::uint64_t isId_(std::uint32_t elemIdx1, std::uint32_t elemIdx2) const
|
2014-12-27 08:19:15 -06:00
|
|
|
{
|
2018-12-11 08:13:05 -06:00
|
|
|
std::uint32_t elemAIdx = std::min(elemIdx1, elemIdx2);
|
2014-12-27 08:19:15 -06:00
|
|
|
std::uint64_t elemBIdx = std::max(elemIdx1, elemIdx2);
|
|
|
|
|
|
|
|
return (elemBIdx<<elemIdxShift) + elemAIdx;
|
|
|
|
}
|
|
|
|
|
2018-12-11 08:13:05 -06:00
|
|
|
std::pair<std::uint32_t, std::uint32_t> isIdReverse_(const std::uint64_t& id) const
|
2018-03-26 03:53:43 -05:00
|
|
|
{
|
2018-12-11 08:13:05 -06:00
|
|
|
// Assigning an unsigned integer to a narrower type discards the most significant bits.
|
|
|
|
// See "The C programming language", section A.6.2.
|
|
|
|
// NOTE that the ordering of element A and B may have changed
|
|
|
|
std::uint32_t elemAIdx = id;
|
|
|
|
std::uint32_t elemBIdx = (id - elemAIdx) >> elemIdxShift;
|
|
|
|
|
|
|
|
return std::make_pair(elemAIdx, elemBIdx);
|
|
|
|
}
|
2018-03-26 03:53:43 -05:00
|
|
|
|
2018-12-11 08:13:05 -06:00
|
|
|
std::uint64_t directionalIsId_(std::uint32_t elemIdx1, std::uint32_t elemIdx2) const
|
|
|
|
{
|
2018-03-26 03:53:43 -05:00
|
|
|
return (std::uint64_t(elemIdx1)<<elemIdxShift) + elemIdx2;
|
|
|
|
}
|
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
void computeHalfTrans_(Scalar& halfTrans,
|
2017-01-19 01:57:44 -06:00
|
|
|
const DimVector& areaNormal,
|
2019-02-05 16:23:48 -06:00
|
|
|
int faceIdx, // in the reference element that contains the intersection
|
2014-12-27 08:19:15 -06:00
|
|
|
const DimVector& distance,
|
|
|
|
const DimMatrix& perm) const
|
|
|
|
{
|
2019-02-05 16:23:48 -06:00
|
|
|
assert(faceIdx >= 0);
|
2015-11-18 04:54:35 -06:00
|
|
|
unsigned dimIdx = faceIdx/2;
|
2014-12-27 08:19:15 -06:00
|
|
|
assert(dimIdx < dimWorld);
|
|
|
|
halfTrans = perm[dimIdx][dimIdx];
|
2015-05-21 09:18:45 -05:00
|
|
|
|
|
|
|
Scalar val = 0;
|
2017-01-19 01:57:44 -06:00
|
|
|
for (unsigned i = 0; i < areaNormal.size(); ++i)
|
|
|
|
val += areaNormal[i]*distance[i];
|
2015-05-21 09:18:45 -05:00
|
|
|
|
2017-02-07 04:33:57 -06:00
|
|
|
halfTrans *= std::abs(val);
|
2016-03-02 06:25:38 -06:00
|
|
|
halfTrans /= distance.two_norm2();
|
2014-12-27 08:19:15 -06:00
|
|
|
}
|
|
|
|
|
2017-01-19 01:57:44 -06:00
|
|
|
DimVector distanceVector_(const DimVector& center,
|
2019-02-05 16:23:48 -06:00
|
|
|
int faceIdx, // in the reference element that contains the intersection
|
2015-11-18 04:54:35 -06:00
|
|
|
unsigned elemIdx,
|
2014-12-27 08:19:15 -06:00
|
|
|
const std::array<std::vector<DimVector>, dimWorld>& axisCentroids) const
|
|
|
|
{
|
2019-02-05 16:23:48 -06:00
|
|
|
assert(faceIdx >= 0);
|
2015-11-18 04:54:35 -06:00
|
|
|
unsigned dimIdx = faceIdx/2;
|
2014-12-27 08:19:15 -06:00
|
|
|
assert(dimIdx < dimWorld);
|
2017-01-19 01:57:44 -06:00
|
|
|
DimVector x = center;
|
2014-12-27 08:19:15 -06:00
|
|
|
x -= axisCentroids[dimIdx][elemIdx];
|
|
|
|
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
void applyMultipliers_(Scalar& trans,
|
|
|
|
unsigned faceIdx,
|
|
|
|
unsigned cartElemIdx,
|
2016-02-25 04:19:55 -06:00
|
|
|
const Opm::TransMult& transMult) const
|
2014-12-27 08:19:15 -06:00
|
|
|
{
|
|
|
|
// apply multiplyer for the transmissibility of the face. (the
|
|
|
|
// face index is the index of the reference-element face which
|
|
|
|
// contains the intersection of interest.)
|
|
|
|
switch (faceIdx) {
|
|
|
|
case 0: // left
|
2016-02-25 04:19:55 -06:00
|
|
|
trans *= transMult.getMultiplier(cartElemIdx, Opm::FaceDir::XMinus);
|
2014-12-27 08:19:15 -06:00
|
|
|
break;
|
|
|
|
case 1: // right
|
2016-02-25 04:19:55 -06:00
|
|
|
trans *= transMult.getMultiplier(cartElemIdx, Opm::FaceDir::XPlus);
|
2014-12-27 08:19:15 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // front
|
2016-02-25 04:19:55 -06:00
|
|
|
trans *= transMult.getMultiplier(cartElemIdx, Opm::FaceDir::YMinus);
|
2014-12-27 08:19:15 -06:00
|
|
|
break;
|
|
|
|
case 3: // back
|
2016-02-25 04:19:55 -06:00
|
|
|
trans *= transMult.getMultiplier(cartElemIdx, Opm::FaceDir::YPlus);
|
2014-12-27 08:19:15 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: // bottom
|
2016-02-25 04:19:55 -06:00
|
|
|
trans *= transMult.getMultiplier(cartElemIdx, Opm::FaceDir::ZMinus);
|
2014-12-27 08:19:15 -06:00
|
|
|
break;
|
|
|
|
case 5: // top
|
2016-02-25 04:19:55 -06:00
|
|
|
trans *= transMult.getMultiplier(cartElemIdx, Opm::FaceDir::ZPlus);
|
2014-12-27 08:19:15 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
void applyNtg_(Scalar& trans,
|
|
|
|
unsigned faceIdx,
|
2020-01-28 03:50:06 -06:00
|
|
|
unsigned elemIdx,
|
2016-02-25 04:19:55 -06:00
|
|
|
const std::vector<double>& ntg) const
|
2014-12-27 08:19:15 -06:00
|
|
|
{
|
|
|
|
// apply multiplyer for the transmissibility of the face. (the
|
|
|
|
// face index is the index of the reference-element face which
|
|
|
|
// contains the intersection of interest.)
|
|
|
|
switch (faceIdx) {
|
|
|
|
case 0: // left
|
2020-01-28 03:50:06 -06:00
|
|
|
trans *= ntg[elemIdx];
|
2014-12-27 08:19:15 -06:00
|
|
|
break;
|
|
|
|
case 1: // right
|
2020-01-28 03:50:06 -06:00
|
|
|
trans *= ntg[elemIdx];
|
2014-12-27 08:19:15 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // front
|
2020-01-28 03:50:06 -06:00
|
|
|
trans *= ntg[elemIdx];
|
2014-12-27 08:19:15 -06:00
|
|
|
break;
|
|
|
|
case 3: // back
|
2020-01-28 03:50:06 -06:00
|
|
|
trans *= ntg[elemIdx];
|
2014-12-27 08:19:15 -06:00
|
|
|
break;
|
|
|
|
|
|
|
|
// NTG does not apply to top and bottom faces
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-01 09:26:58 -06:00
|
|
|
const Vanguard& vanguard_;
|
2019-02-01 10:33:30 -06:00
|
|
|
Scalar transmissibilityThreshold_;
|
2016-12-05 12:49:58 -06:00
|
|
|
std::vector<DimMatrix> permeability_;
|
2014-12-27 08:19:15 -06:00
|
|
|
std::unordered_map<std::uint64_t, Scalar> trans_;
|
2018-01-30 04:46:23 -06:00
|
|
|
std::map<std::pair<unsigned, unsigned>, Scalar> transBoundary_;
|
|
|
|
std::map<std::pair<unsigned, unsigned>, Scalar> thermalHalfTransBoundary_;
|
2018-01-30 04:46:23 -06:00
|
|
|
Opm::ConditionalStorage<enableEnergy,
|
|
|
|
std::unordered_map<std::uint64_t, Scalar> > thermalHalfTrans_;
|
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
|