Loading...
Searching...
No Matches
Transmissibility.hpp
Go to the documentation of this file.
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
// vi: set et ts=4 sw=4 sts=4:
/*
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/>.
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.
*/
#ifndef OPM_TRANSMISSIBILITY_HPP
#define OPM_TRANSMISSIBILITY_HPP
#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
#include <opm/grid/common/CartesianIndexMapper.hpp>
#include <opm/grid/LookUpData.hh>
#include <array>
#include <functional>
#include <map>
#include <cstdint>
#include <unordered_map>
#include <vector>
namespace Opm {
class KeywordLocation;
class EclipseState;
struct NNCdata;
class TransMult;
template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
class Transmissibility {
// Grid and world dimension
enum { dimWorld = GridView::dimensionworld };
public:
using DimMatrix = Dune::FieldMatrix<Scalar, dimWorld, dimWorld>;
using DimVector = Dune::FieldVector<Scalar, dimWorld>;
Transmissibility(const EclipseState& eclState,
const GridView& gridView,
const CartesianIndexMapper& cartMapper,
const Grid& grid,
std::function<std::array<double,dimWorld>(int)> centroids,
bool enableEnergy,
bool enableDiffusivity,
bool enableDispersivity);
const DimMatrix& permeability(unsigned elemIdx) const
{ return permeability_[elemIdx]; }
Scalar transmissibility(unsigned elemIdx1, unsigned elemIdx2) const;
Scalar transmissibilityBoundary(unsigned elemIdx, unsigned boundaryFaceIdx) const;
Scalar thermalHalfTrans(unsigned insideElemIdx, unsigned outsideElemIdx) const;
Scalar thermalHalfTransBoundary(unsigned insideElemIdx, unsigned boundaryFaceIdx) const;
Scalar diffusivity(unsigned elemIdx1, unsigned elemIdx2) const;
Scalar dispersivity(unsigned elemIdx1, unsigned elemIdx2) const;
void finishInit(const std::function<unsigned int(unsigned int)>& map = {})
{
this->update(true, TransUpdateQuantities::All, map, /*applyNncMultRegT = */ true);
}
enum class TransUpdateQuantities { Trans, All };
void update(bool global, TransUpdateQuantities update_quantities = TransUpdateQuantities::All,
const std::function<unsigned int(unsigned int)>& map = {}, bool applyNncMultRegT = false);
protected:
void updateFromEclState_(bool global);
void removeNonCartesianTransmissibilities_(bool removeAll);
struct FaceInfo
{
DimVector faceCenter;
int faceIdx;
unsigned elemIdx;
unsigned cartElemIdx;
};
void applyAllZMultipliers_(Scalar& trans,
const FaceInfo& inside,
const FaceInfo& outside,
const TransMult& transMult,
const std::array<int, dimWorld>& cartDims);
std::array<std::vector<double>,3>
createTransmissibilityArrays_(const std::array<bool,3>& is_tran);
void resetTransmissibilityFromArrays_(const std::array<bool,3>& is_tran,
const std::array<std::vector<double>,3>& trans);
template <class Intersection>
void computeFaceProperties(const Intersection& intersection,
FaceInfo& inside,
FaceInfo& outside,
DimVector& faceAreaNormal,
/*isCpGrid=*/std::false_type) const;
template <class Intersection>
void computeFaceProperties(const Intersection& intersection,
FaceInfo& inside,
FaceInfo& outside,
DimVector& faceAreaNormal,
/*isCpGrid=*/std::true_type) const;
/*
* \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 Nothing.
*/
void applyNncToGridTrans_(const std::unordered_map<std::size_t,int>& cartesianToCompressed);
void applyPinchNncToGridTrans_(const std::unordered_map<std::size_t,int>& cartesianToCompressed,
bool applyNncMultregT);
void applyEditNncToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal);
void applyEditNncrToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal);
void applyNncMultreg_(const std::unordered_map<std::size_t,int>& globalToLocal);
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(Scalar&, const Scalar&)>& apply);
void extractPermeability_();
void extractPermeability_(const std::function<unsigned int(unsigned int)>& map);
void extractPorosity_();
void extractDispersion_();
static Scalar computeHalfTrans_(const DimVector& areaNormal,
int faceIdx, // in the reference element that contains the intersection
const DimVector& distance,
const DimMatrix& perm);
static Scalar computeHalfDiffusivity_(const DimVector& areaNormal,
const DimVector& distance,
const Scalar poro);
DimVector distanceVector_(const DimVector& faceCenter,
const unsigned& cellIdx) const;
void applyMultipliers_(Scalar& trans,
unsigned faceIdx,
unsigned cartElemIdx,
const TransMult& transMult) const;
static void applyNtg_(Scalar& trans,
const FaceInfo& face,
const std::vector<double>& ntg);
std::vector<DimMatrix> permeability_;
std::vector<Scalar> porosity_;
std::vector<Scalar> dispersion_;
std::unordered_map<std::uint64_t, Scalar> trans_;
const EclipseState& eclState_;
const GridView& gridView_;
const CartesianIndexMapper& cartMapper_;
const Grid& grid_;
std::function<std::array<double,dimWorld>(int)> centroids_;
std::vector<std::array<double,dimWorld>> centroids_cache_;
Scalar transmissibilityThreshold_;
std::map<std::pair<unsigned, unsigned>, Scalar> transBoundary_;
std::map<std::pair<unsigned, unsigned>, Scalar> thermalHalfTransBoundary_;
bool enableEnergy_;
bool enableDiffusivity_;
bool enableDispersivity_;
bool warnEditNNC_ = true;
std::unordered_map<std::uint64_t, Scalar> thermalHalfTrans_; //NB this is based on direction map size is ca 2*trans_ (diffusivity_)
std::unordered_map<std::uint64_t, Scalar> diffusivity_;
std::unordered_map<std::uint64_t, Scalar> dispersivity_;
const LookUpData<Grid,GridView> lookUpData_;
const LookUpCartesianData<Grid,GridView> lookUpCartesianData_;
};
namespace details {
std::uint64_t isId(std::uint32_t elemIdx1, std::uint32_t elemIdx2);
std::pair<std::uint32_t, std::uint32_t> isIdReverse(const std::uint64_t& id);
std::uint64_t directionalIsId(std::uint32_t elemIdx1, std::uint32_t elemIdx2);
}
} // namespace Opm
#endif // OPM_TRANSMISSIBILITY_HPP
Opm::LookUpCartesianData
Definition GenericThresholdPressure.hpp:40
Opm::LookUpData
Definition FlowGenericProblem.hpp:51
Opm::Transmissibility::diffusivity
Scalar diffusivity(unsigned elemIdx1, unsigned elemIdx2) const
Return the diffusivity for the intersection between two elements.
Definition Transmissibility_impl.hpp:150
Opm::Transmissibility::applyEditNncToGridTrans_
void applyEditNncToGridTrans_(const std::unordered_map< std::size_t, int > &globalToLocal)
Multiplies the grid transmissibilities according to EDITNNC.
Definition Transmissibility_impl.hpp:1173
Opm::Transmissibility::applyEditNncrToGridTrans_
void applyEditNncrToGridTrans_(const std::unordered_map< std::size_t, int > &globalToLocal)
Resets the grid transmissibilities according to EDITNNCR.
Definition Transmissibility_impl.hpp:1186
Opm::Transmissibility::thermalHalfTrans
Scalar thermalHalfTrans(unsigned insideElemIdx, unsigned outsideElemIdx) const
Return the thermal "half transmissibility" for the intersection between two elements.
Definition Transmissibility_impl.hpp:136
Opm::Transmissibility::finishInit
void finishInit(const std::function< unsigned int(unsigned int)> &map={})
Actually compute the transmissibility over a face as a pre-compute step.
Definition Transmissibility.hpp:129
Opm::Transmissibility::transmissibilityBoundary
Scalar transmissibilityBoundary(unsigned elemIdx, unsigned boundaryFaceIdx) const
Return the transmissibility for a given boundary segment.
Definition Transmissibility_impl.hpp:129
Opm::Transmissibility::createTransmissibilityArrays_
std::array< std::vector< double >, 3 > createTransmissibilityArrays_(const std::array< bool, 3 > &is_tran)
Creates TRANS{XYZ} arrays for modification by FieldProps data.
Definition Transmissibility_impl.hpp:819
Opm::Transmissibility::applyAllZMultipliers_
void applyAllZMultipliers_(Scalar &trans, const FaceInfo &inside, const FaceInfo &outside, const TransMult &transMult, const std::array< int, dimWorld > &cartDims)
Apply the Multipliers for the case PINCH(4)==TOPBOT.
Definition Transmissibility_impl.hpp:741
Opm::Transmissibility::TransUpdateQuantities
TransUpdateQuantities
Compute all transmissibilities.
Definition Transmissibility.hpp:157
Opm::Transmissibility::resetTransmissibilityFromArrays_
void resetTransmissibilityFromArrays_(const std::array< bool, 3 > &is_tran, const std::array< std::vector< double >, 3 > &trans)
overwrites calculated transmissibilities
Definition Transmissibility_impl.hpp:901
Opm::Transmissibility::permeability
const DimMatrix & permeability(unsigned elemIdx) const
Return the permeability for an element.
Definition Transmissibility.hpp:74
Opm::Transmissibility::transmissibility
Scalar transmissibility(unsigned elemIdx1, unsigned elemIdx2) const
Return the transmissibility for the intersection between two elements.
Definition Transmissibility_impl.hpp:122
Opm::Transmissibility::dispersivity
Scalar dispersivity(unsigned elemIdx1, unsigned elemIdx2) const
Return the dispersivity for the intersection between two elements.
Definition Transmissibility_impl.hpp:160
Opm::Transmissibility::applyPinchNncToGridTrans_
void applyPinchNncToGridTrans_(const std::unordered_map< std::size_t, int > &cartesianToCompressed, bool applyNncMultregT)
Applies the previous calculate transmissibilities to the NNCs created via PINCH.
Definition Transmissibility_impl.hpp:1057
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43
Opm::Transmissibility::FaceInfo
Definition Transmissibility.hpp:167