FacePropertiesTPSA.hpp
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 Copyright 2025 NORCE AS
5
6 This file is part of the Open Porous Media project (OPM).
7
8 OPM is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 2 of the License, or
11 (at your option) any later version.
12
13 OPM is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with OPM. If not, see <http://www.gnu.org/licenses/>.
20
21 Consult the COPYING file in the top-level source directory of this
22 module for the precise wording of the license and the list of
23 copyright holders.
24*/
25#ifndef TPSA_FACE_PROPERTIES_HPP
26#define TPSA_FACE_PROPERTIES_HPP
27
28#include <dune/common/fvector.hh>
29
30#include <opm/grid/LookUpData.hh>
31
32#include <cstdint>
33#include <map>
34#include <vector>
35#include <utility>
36
37
38namespace Opm {
39
40class EclipseState;
41
47template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
49
50 enum { dimWorld = GridView::dimensionworld };
51
52public:
53 using DimVector = Dune::FieldVector<Scalar, dimWorld>;
54
55 FacePropertiesTPSA(const EclipseState& eclState,
56 const GridView& gridView,
57 const CartesianIndexMapper& cartMapper,
58 const Grid& grid,
59 std::function<std::array<double, dimWorld>(int)> centroids);
60
61 void finishInit();
62
63 void update();
64
65 Scalar weightAverage(unsigned elemIdx1, unsigned elemIdx2) const;
66 Scalar weightAverageBoundary(unsigned elemIdx1, unsigned boundaryFaceIdx) const;
67 Scalar weightProduct(unsigned elemIdx1, unsigned elemIdx2) const;
68 Scalar weightProductBoundary(unsigned elemIdx1, unsigned boundaryFaceIdx) const;
69 Scalar normalDistance(unsigned elemIdx1, unsigned elemIdx2) const;
70 Scalar normalDistanceBoundary(unsigned elemIdx1, unsigned boundaryFaceIdx) const;
71 DimVector cellFaceNormal(unsigned elemIdx1, unsigned elemIdx2);
72 const DimVector& cellFaceNormalBoundary(unsigned elemIdx1, unsigned boundaryFaceIdx) const;
73
77 const Scalar shearModulus(unsigned elemIdx) const
78 { return sModulus_[elemIdx]; }
79
80
81protected:
82 struct FaceInfo
83 {
86 unsigned elemIdx;
87 unsigned cartElemIdx;
88 };
89
90 template <class Intersection>
91 void computeCellProperties(const Intersection& intersection,
92 FaceInfo& inside,
93 FaceInfo& outside,
94 DimVector& faceNormal,
95 /*isCpGrid=*/std::false_type) const;
96
97 template <class Intersection>
98 void computeCellProperties(const Intersection& intersection,
99 FaceInfo& inside,
100 FaceInfo& outside,
101 DimVector& faceNormal,
102 /*isCpGrid=*/std::true_type) const;
103
104 Scalar computeDistance_(const DimVector& distVec, const DimVector& faceNormal);
105
106 Scalar computeWeight_(const Scalar distance, const Scalar smod);
107
108 DimVector distanceVector_(const DimVector& faceCenter, const unsigned& cellIdx) const;
109
110 void extractSModulus_();
111
112 std::vector<Scalar> sModulus_;
113 std::unordered_map<std::uint64_t, Scalar> weightsAvg_;
114 std::unordered_map<std::uint64_t, Scalar> weightsProd_;
115 std::unordered_map<std::uint64_t, Scalar> distance_;
116 std::unordered_map<std::uint64_t, DimVector> faceNormal_;
117
118 std::map<std::pair<unsigned, unsigned>, Scalar> weightsAvgBoundary_;
119 std::map<std::pair<unsigned, unsigned>, Scalar> weightsProdBoundary_;
120 std::map<std::pair<unsigned, unsigned>, Scalar> distanceBoundary_;
121 std::map<std::pair<unsigned, unsigned>, DimVector> faceNormalBoundary_;
122
123 const EclipseState& eclState_;
124 const GridView& gridView_;
125 const CartesianIndexMapper& cartMapper_;
126 const Grid& grid_;
127 std::function<std::array<double, dimWorld>(int)> centroids_;
128 std::vector<std::array<double, dimWorld>> centroids_cache_;
129
132
133}; // FacePropertiesTPSA
134
135namespace details {
136 std::uint64_t isIdTPSA(std::uint32_t elemIdx1, std::uint32_t elemIdx2);
137} // namespace details
138
139} // namespace Opm
140
141#endif
Cell face properties needed in TPSA equation calculations.
Definition: FacePropertiesTPSA.hpp:48
std::vector< Scalar > sModulus_
Definition: FacePropertiesTPSA.hpp:112
void extractSModulus_()
Extract shear modulus from eclState.
Definition: FacePropertiesTPSA_impl.hpp:553
void finishInit()
Compute TPSA face properties.
Definition: FacePropertiesTPSA_impl.hpp:96
std::map< std::pair< unsigned, unsigned >, DimVector > faceNormalBoundary_
Definition: FacePropertiesTPSA.hpp:121
const Scalar shearModulus(unsigned elemIdx) const
Return shear modulus of an element.
Definition: FacePropertiesTPSA.hpp:77
const LookUpData< Grid, GridView > lookUpData_
Definition: FacePropertiesTPSA.hpp:130
void computeCellProperties(const Intersection &intersection, FaceInfo &inside, FaceInfo &outside, DimVector &faceNormal, std::false_type) const
Compute face properties from general DUNE grid.
Definition: FacePropertiesTPSA_impl.hpp:458
const LookUpCartesianData< Grid, GridView > lookUpCartesianData_
Definition: FacePropertiesTPSA.hpp:131
const CartesianIndexMapper & cartMapper_
Definition: FacePropertiesTPSA.hpp:125
std::map< std::pair< unsigned, unsigned >, Scalar > weightsProdBoundary_
Definition: FacePropertiesTPSA.hpp:119
std::map< std::pair< unsigned, unsigned >, Scalar > distanceBoundary_
Definition: FacePropertiesTPSA.hpp:120
Scalar weightProduct(unsigned elemIdx1, unsigned elemIdx2) const
Product of weights at interface between two elements.
Definition: FacePropertiesTPSA_impl.hpp:342
const EclipseState & eclState_
Definition: FacePropertiesTPSA.hpp:123
DimVector cellFaceNormal(unsigned elemIdx1, unsigned elemIdx2)
Cell face normal at interface between two elements.
Definition: FacePropertiesTPSA_impl.hpp:401
Dune::FieldVector< Scalar, dimWorld > DimVector
Definition: FacePropertiesTPSA.hpp:53
Scalar weightAverage(unsigned elemIdx1, unsigned elemIdx2) const
Average (half-)weight at interface between two elements.
Definition: FacePropertiesTPSA_impl.hpp:303
std::vector< std::array< double, dimWorld > > centroids_cache_
Definition: FacePropertiesTPSA.hpp:128
Scalar normalDistanceBoundary(unsigned elemIdx1, unsigned boundaryFaceIdx) const
Distance to boundary interface.
Definition: FacePropertiesTPSA_impl.hpp:384
Scalar weightAverageBoundary(unsigned elemIdx1, unsigned boundaryFaceIdx) const
Average (half-)weight at boundary interface.
Definition: FacePropertiesTPSA_impl.hpp:328
std::unordered_map< std::uint64_t, Scalar > weightsProd_
Definition: FacePropertiesTPSA.hpp:114
std::map< std::pair< unsigned, unsigned >, Scalar > weightsAvgBoundary_
Definition: FacePropertiesTPSA.hpp:118
const DimVector & cellFaceNormalBoundary(unsigned elemIdx1, unsigned boundaryFaceIdx) const
Cell face normal of boundary interface.
Definition: FacePropertiesTPSA_impl.hpp:423
Scalar computeWeight_(const Scalar distance, const Scalar smod)
Compute weight ratio between distance and shear modulus.
Definition: FacePropertiesTPSA_impl.hpp:517
void update()
Compute TPSA face properties.
Definition: FacePropertiesTPSA_impl.hpp:106
Scalar computeDistance_(const DimVector &distVec, const DimVector &faceNormal)
Compute normal distance from cell center to face center.
Definition: FacePropertiesTPSA_impl.hpp:440
const GridView & gridView_
Definition: FacePropertiesTPSA.hpp:124
DimVector distanceVector_(const DimVector &faceCenter, const unsigned &cellIdx) const
Distance vector from cell center to face center.
Definition: FacePropertiesTPSA_impl.hpp:532
const Grid & grid_
Definition: FacePropertiesTPSA.hpp:126
Scalar normalDistance(unsigned elemIdx1, unsigned elemIdx2) const
Distance between two elements.
Definition: FacePropertiesTPSA_impl.hpp:370
std::unordered_map< std::uint64_t, Scalar > weightsAvg_
Definition: FacePropertiesTPSA.hpp:113
std::unordered_map< std::uint64_t, DimVector > faceNormal_
Definition: FacePropertiesTPSA.hpp:116
std::function< std::array< double, dimWorld >(int)> centroids_
Definition: FacePropertiesTPSA.hpp:127
FacePropertiesTPSA(const EclipseState &eclState, const GridView &gridView, const CartesianIndexMapper &cartMapper, const Grid &grid, std::function< std::array< double, dimWorld >(int)> centroids)
Constructor.
Definition: FacePropertiesTPSA_impl.hpp:77
Scalar weightProductBoundary(unsigned elemIdx1, unsigned boundaryFaceIdx) const
Product of weights at boundary interface.
Definition: FacePropertiesTPSA_impl.hpp:356
std::unordered_map< std::uint64_t, Scalar > distance_
Definition: FacePropertiesTPSA.hpp:115
Definition: GenericThresholdPressure.hpp:40
Definition: FlowGenericProblem.hpp:51
std::uint64_t isIdTPSA(std::uint32_t elemIdx1, std::uint32_t elemIdx2)
Definition: FacePropertiesTPSA_impl.hpp:54
Definition: blackoilbioeffectsmodules.hh:45
Definition: FacePropertiesTPSA.hpp:83
int faceIdx
Definition: FacePropertiesTPSA.hpp:85
unsigned cartElemIdx
Definition: FacePropertiesTPSA.hpp:87
unsigned elemIdx
Definition: FacePropertiesTPSA.hpp:86
DimVector faceCenter
Definition: FacePropertiesTPSA.hpp:84