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
|
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
#include <opm/grid/common/CartesianIndexMapper.hpp>
|
2018-01-08 05:23:57 -06:00
|
|
|
|
2014-12-27 08:19:15 -06:00
|
|
|
#include <dune/common/fvector.hh>
|
|
|
|
#include <dune/common/fmatrix.hh>
|
|
|
|
|
|
|
|
#include <array>
|
2021-05-05 05:13:25 -05:00
|
|
|
#include <map>
|
|
|
|
#include <tuple>
|
2014-12-27 08:19:15 -06:00
|
|
|
#include <vector>
|
|
|
|
#include <unordered_map>
|
2021-09-30 04:50:22 -05:00
|
|
|
#include <functional>
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2019-09-05 10:04:39 -05:00
|
|
|
namespace Opm {
|
2016-01-17 14:15:27 -06:00
|
|
|
|
2023-03-31 13:11:12 -05:00
|
|
|
class KeywordLocation;
|
2021-05-05 05:13:25 -05:00
|
|
|
class EclipseState;
|
|
|
|
struct NNCdata;
|
|
|
|
class TransMult;
|
2018-01-30 04:46:23 -06:00
|
|
|
|
2021-12-01 07:00:21 -06:00
|
|
|
template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
|
2021-05-05 05:13:25 -05:00
|
|
|
class EclTransmissibility {
|
2014-12-27 08:19:15 -06:00
|
|
|
// Grid and world dimension
|
|
|
|
enum { dimWorld = GridView::dimensionworld };
|
|
|
|
public:
|
2018-12-09 16:41:31 -06:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
|
|
|
|
using DimVector = Dune::FieldVector<Scalar, dimWorld>;
|
2018-12-09 16:41:31 -06:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
EclTransmissibility(const EclipseState& eclState,
|
|
|
|
const GridView& gridView,
|
2021-12-01 07:00:21 -06:00
|
|
|
const CartesianIndexMapper& cartMapper,
|
2021-05-05 05:13:25 -05:00
|
|
|
const Grid& grid,
|
2021-09-30 04:50:22 -05:00
|
|
|
std::function<std::array<double,dimWorld>(int)> centroids,
|
2021-05-15 06:35:21 -05:00
|
|
|
bool enableEnergy,
|
|
|
|
bool enableDiffusivity);
|
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.
|
|
|
|
*/
|
2021-05-05 05:13:25 -05:00
|
|
|
Scalar transmissibility(unsigned elemIdx1, unsigned elemIdx2) const;
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2018-01-30 04:46:23 -06:00
|
|
|
/*!
|
|
|
|
* \brief Return the transmissibility for a given boundary segment.
|
|
|
|
*/
|
2021-05-05 05:13:25 -05:00
|
|
|
Scalar transmissibilityBoundary(unsigned elemIdx, unsigned boundaryFaceIdx) const;
|
2018-01-30 04:46:23 -06:00
|
|
|
|
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
|
|
|
*/
|
2021-05-05 05:13:25 -05:00
|
|
|
Scalar thermalHalfTrans(unsigned insideElemIdx, unsigned outsideElemIdx) const;
|
2018-01-30 04:46:23 -06:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
Scalar thermalHalfTransBoundary(unsigned insideElemIdx, unsigned boundaryFaceIdx) const;
|
2018-01-30 04:46:23 -06:00
|
|
|
|
2021-01-14 08:33:28 -06:00
|
|
|
/*!
|
|
|
|
* \brief Return the diffusivity for the intersection between two elements.
|
|
|
|
*/
|
2021-05-05 05:13:25 -05:00
|
|
|
Scalar diffusivity(unsigned elemIdx1, unsigned elemIdx2) const;
|
2021-01-14 08:33:28 -06:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
/*!
|
|
|
|
* \brief Actually compute the transmissibility 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.
|
|
|
|
*/
|
2021-12-01 07:00:21 -06:00
|
|
|
void finishInit(const std::function<unsigned int(unsigned int)>& map = {})
|
|
|
|
{ update(true,map); }
|
2018-10-15 02:44:42 -05:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
/*!
|
|
|
|
* \brief Compute all transmissibilities
|
|
|
|
*
|
|
|
|
* \param global If true, update is called on all processes
|
|
|
|
* Also, this updates the "thermal half transmissibilities" if energy is enabled.
|
|
|
|
*/
|
2021-12-01 07:00:21 -06:00
|
|
|
void update(bool global, const std::function<unsigned int(unsigned int)>& map = {});
|
2018-12-11 08:13:05 -06:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
protected:
|
|
|
|
void updateFromEclState_(bool global);
|
2018-12-11 08:13:05 -06:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
void removeSmallNonCartesianTransmissibilities_();
|
2018-12-11 08:13:05 -06:00
|
|
|
|
2020-09-08 03:59:41 -05:00
|
|
|
/// \brief Apply the Multipliers for the case PINCH(4)==TOPBOT
|
|
|
|
///
|
|
|
|
/// \param pinchTop Whether PINCH(5) is TOP, otherwise ALL is assumed.
|
2019-02-01 10:33:30 -06:00
|
|
|
void applyAllZMultipliers_(Scalar& trans,
|
|
|
|
unsigned insideFaceIdx,
|
2020-09-08 03:59:41 -05:00
|
|
|
unsigned outsideFaceIdx,
|
2019-02-01 10:33:30 -06:00
|
|
|
unsigned insideCartElemIdx,
|
|
|
|
unsigned outsideCartElemIdx,
|
2021-05-05 05:13:25 -05:00
|
|
|
const TransMult& transMult,
|
2020-09-08 03:59:41 -05:00
|
|
|
const std::array<int, dimWorld>& cartDims,
|
2021-05-05 05:13:25 -05:00
|
|
|
bool pinchTop);
|
2020-09-17 05:18:07 -05:00
|
|
|
|
|
|
|
/// \brief Creates TRANS{XYZ} arrays for modification by FieldProps data
|
|
|
|
///
|
|
|
|
/// \param is_tran Whether TRAN{XYZ} will be modified. If entry is false the array will be empty
|
|
|
|
/// \returns an array of vector (TRANX, TRANY, TRANZ}
|
|
|
|
std::array<std::vector<double>,3>
|
2021-05-05 05:13:25 -05:00
|
|
|
createTransmissibilityArrays_(const std::array<bool,3>& is_tran);
|
2018-10-15 02:44:42 -05:00
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
/// \brief overwrites calculated transmissibilities
|
|
|
|
///
|
|
|
|
/// \param is_tran Whether TRAN{XYZ} have been modified.
|
|
|
|
/// \param trans Arrays with modified transmissibilities TRAN{XYZ}
|
|
|
|
void resetTransmissibilityFromArrays_(const std::array<bool,3>& is_tran,
|
|
|
|
const std::array<std::vector<double>,3>& trans);
|
2018-10-15 02:44:42 -05:00
|
|
|
|
2017-06-22 08:55:01 -05:00
|
|
|
template <class Intersection>
|
2019-02-01 10:33:30 -06:00
|
|
|
void computeFaceProperties(const Intersection& intersection,
|
2021-05-05 05:13:25 -05:00
|
|
|
const int,
|
|
|
|
const int,
|
|
|
|
const int,
|
|
|
|
const int,
|
2019-02-01 10:33:30 -06:00
|
|
|
DimVector& faceCenterInside,
|
|
|
|
DimVector& faceCenterOutside,
|
|
|
|
DimVector& faceAreaNormal,
|
2021-05-05 05:13:25 -05:00
|
|
|
/*isCpGrid=*/std::false_type) const;
|
2017-06-22 08:55:01 -05:00
|
|
|
|
|
|
|
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,
|
2021-05-05 05:13:25 -05:00
|
|
|
/*isCpGrid=*/std::true_type) const;
|
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.
|
|
|
|
*/
|
2021-05-05 05:13:25 -05:00
|
|
|
std::tuple<std::vector<NNCdata>, std::vector<NNCdata>>
|
2021-09-22 02:22:25 -05:00
|
|
|
applyNncToGridTrans_(const std::unordered_map<std::size_t,int>& cartesianToCompressed);
|
2020-11-10 03:48:53 -06:00
|
|
|
|
2018-12-10 04:34:23 -06:00
|
|
|
/// \brief Multiplies the grid transmissibilities according to EDITNNC.
|
2021-09-22 02:22:25 -05:00
|
|
|
void applyEditNncToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal);
|
2020-11-10 03:48:53 -06:00
|
|
|
|
2023-03-31 13:51:39 -05:00
|
|
|
/// \brief Resets the grid transmissibilities according to EDITNNCR.
|
|
|
|
void applyEditNncrToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal);
|
|
|
|
|
2023-03-31 13:11:12 -05:00
|
|
|
void applyEditNncToGridTransHelper_(const std::unordered_map<std::size_t,int>& globalToLocal,
|
|
|
|
const std::string& keyword, const std::vector<NNCdata>& nncs,
|
|
|
|
const std::function<KeywordLocation(const NNCdata&)>& getLocation,
|
|
|
|
const std::function<void(double&, const double&)>& apply);
|
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
void extractPermeability_();
|
2021-12-01 07:00:21 -06:00
|
|
|
|
|
|
|
void extractPermeability_(const std::function<unsigned int(unsigned int)>& map);
|
|
|
|
|
2021-05-05 05:13:25 -05:00
|
|
|
void extractPorosity_();
|
2018-03-26 03:53:43 -05:00
|
|
|
|
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,
|
2021-05-05 05:13:25 -05:00
|
|
|
const DimMatrix& perm) const;
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2021-01-14 08:33:28 -06:00
|
|
|
void computeHalfDiffusivity_(Scalar& halfDiff,
|
|
|
|
const DimVector& areaNormal,
|
|
|
|
const DimVector& distance,
|
2021-05-05 05:13:25 -05:00
|
|
|
const Scalar& poro) const;
|
2021-01-14 08:33:28 -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,
|
2021-05-05 05:13:25 -05:00
|
|
|
const std::array<std::vector<DimVector>, dimWorld>& axisCentroids) const;
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
void applyMultipliers_(Scalar& trans,
|
|
|
|
unsigned faceIdx,
|
|
|
|
unsigned cartElemIdx,
|
2021-05-05 05:13:25 -05:00
|
|
|
const TransMult& transMult) const;
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2019-02-01 10:33:30 -06:00
|
|
|
void applyNtg_(Scalar& trans,
|
|
|
|
unsigned faceIdx,
|
2020-01-28 03:50:06 -06:00
|
|
|
unsigned elemIdx,
|
2021-05-05 05:13:25 -05:00
|
|
|
const std::vector<double>& ntg) const;
|
2014-12-27 08:19:15 -06:00
|
|
|
|
2016-12-05 12:49:58 -06:00
|
|
|
std::vector<DimMatrix> permeability_;
|
2021-01-14 08:33:28 -06:00
|
|
|
std::vector<Scalar> porosity_;
|
2014-12-27 08:19:15 -06:00
|
|
|
std::unordered_map<std::uint64_t, Scalar> trans_;
|
2021-05-05 05:13:25 -05:00
|
|
|
const EclipseState& eclState_;
|
|
|
|
const GridView& gridView_;
|
2021-12-01 07:00:21 -06:00
|
|
|
const CartesianIndexMapper& cartMapper_;
|
2021-05-05 05:13:25 -05:00
|
|
|
const Grid& grid_;
|
2021-09-30 04:50:22 -05:00
|
|
|
std::function<std::array<double,dimWorld>(int)> centroids_;
|
2021-05-05 05:13:25 -05:00
|
|
|
Scalar transmissibilityThreshold_;
|
2018-01-30 04:46:23 -06:00
|
|
|
std::map<std::pair<unsigned, unsigned>, Scalar> transBoundary_;
|
|
|
|
std::map<std::pair<unsigned, unsigned>, Scalar> thermalHalfTransBoundary_;
|
2021-05-15 06:35:21 -05:00
|
|
|
bool enableEnergy_;
|
|
|
|
bool enableDiffusivity_;
|
|
|
|
std::unordered_map<std::uint64_t, Scalar> thermalHalfTrans_;
|
|
|
|
std::unordered_map<std::uint64_t, Scalar> diffusivity_;
|
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
|