Transmissibility_impl.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 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
23#ifndef OPM_TRANSMISSIBILITY_IMPL_HPP
24#define OPM_TRANSMISSIBILITY_IMPL_HPP
25
26#ifndef OPM_TRANSMISSIBILITY_HPP
27#include <config.h>
29#endif
30
31#include <dune/common/version.hh>
32#include <dune/grid/common/mcmgmapper.hh>
33
34#include <opm/common/OpmLog/KeywordLocation.hpp>
35#include <opm/common/utility/ThreadSafeMapBuilder.hpp>
36
37#include <opm/grid/CpGrid.hpp>
38#include <opm/grid/utility/ElementChunks.hpp>
39
40#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
41#include <opm/input/eclipse/EclipseState/Grid/FaceDir.hpp>
42#include <opm/input/eclipse/EclipseState/Grid/FieldPropsManager.hpp>
43#include <opm/input/eclipse/EclipseState/Grid/TransMult.hpp>
44#include <opm/input/eclipse/Units/Units.hpp>
45
47
48#include <algorithm>
49#include <array>
50#include <cassert>
51#include <cmath>
52#include <cstddef>
53#include <cstdint>
54#include <functional>
55#include <initializer_list>
56#include <sstream>
57#include <stdexcept>
58#include <string>
59#include <string_view>
60#include <type_traits>
61#include <utility>
62#include <vector>
63
64#include <fmt/format.h>
65
66namespace Opm {
67
68namespace details {
69
70 constexpr unsigned elemIdxShift = 32; // bits
71
72 std::uint64_t isId(std::uint32_t elemIdx1, std::uint32_t elemIdx2)
73 {
74 const std::uint32_t elemAIdx = std::min(elemIdx1, elemIdx2);
75 const std::uint64_t elemBIdx = std::max(elemIdx1, elemIdx2);
76
77 return (elemBIdx << elemIdxShift) + elemAIdx;
78 }
79
80 std::pair<std::uint32_t, std::uint32_t> isIdReverse(const std::uint64_t& id)
81 {
82 // Assigning an unsigned integer to a narrower type discards the most significant bits.
83 // See "The C programming language", section A.6.2.
84 // NOTE that the ordering of element A and B may have changed
85 const std::uint32_t elemAIdx = static_cast<uint32_t>(id);
86 const std::uint32_t elemBIdx = (id - elemAIdx) >> elemIdxShift;
87
88 return std::make_pair(elemAIdx, elemBIdx);
89 }
90
91 std::uint64_t directionalIsId(std::uint32_t elemIdx1, std::uint32_t elemIdx2)
92 {
93 return (std::uint64_t(elemIdx1) << elemIdxShift) + elemIdx2;
94 }
95}
96
97template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
99Transmissibility(const EclipseState& eclState,
100 const GridView& gridView,
101 const CartesianIndexMapper& cartMapper,
102 const Grid& grid,
103 std::function<std::array<double,dimWorld>(int)> centroids,
104 bool enableEnergy,
105 bool enableDiffusivity,
106 bool enableDispersivity)
107 : eclState_(eclState)
108 , gridView_(gridView)
109 , cartMapper_(cartMapper)
110 , grid_(grid)
111 , centroids_(centroids)
112 , enableEnergy_(enableEnergy)
113 , enableDiffusivity_(enableDiffusivity)
114 , enableDispersivity_(enableDispersivity)
115 , lookUpData_(gridView)
116 , lookUpCartesianData_(gridView, cartMapper)
117{
118 const UnitSystem& unitSystem = eclState_.getDeckUnitSystem();
119 transmissibilityThreshold_ = unitSystem.parse("Transmissibility").getSIScaling() * 1e-6;
120}
121
122template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
124gridJoins_(unsigned elemIdx1, unsigned elemIdx2) const
125{
126 using Ix = typename ElementMapper::Index;
127
128 ElementMapper elemMapper(gridView_, Dune::mcmgElementLayout());
129
130 for (const auto& elem : elements(gridView_)) {
131 if (elemMapper.index(elem) != static_cast<Ix>(elemIdx1)) {
132 continue;
133 }
134
135 for (const auto& intersection : intersections(gridView_, elem)) {
136 if (intersection.neighbor() &&
137 (elemMapper.index(intersection.outside()) == static_cast<Ix>(elemIdx2)))
138 {
139 return true;
140 }
141 }
142
143 return false;
144 }
145
146 return false;
147}
148
149template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
151describeCell_(unsigned elemIdx) const
152{
153 auto text = fmt::format("cell {}", elemIdx);
154
155 if (elemIdx >= static_cast<unsigned>(gridView_.size(/*codim=*/0))) {
156 return text + " (out of range)";
157 }
158
159 const auto cartIdx = cartMapper_.cartesianIndex(elemIdx);
160 std::array<int,dimWorld> ijk{};
161 cartMapper_.cartesianCoordinate(elemIdx, ijk);
162
163 text += fmt::format(" (Cartesian {} = [{},{},{}]", cartIdx, ijk[0], ijk[1], ijk[2]);
164
165 if constexpr (requires { grid_.maxLevel(); }) {
166 if (grid_.maxLevel() > 0) {
167 using Ix = typename ElementMapper::Index;
168
169 // Which grid the cell belongs to is the first thing worth knowing:
170 // a pair spanning a refinement boundary, or two cells refining one
171 // coarse cell, is where these lookups go wrong. Found through the
172 // mapper -- iteration order is not index order.
173 ElementMapper elemMapper(gridView_, Dune::mcmgElementLayout());
174 for (const auto& elem : elements(gridView_)) {
175 if (elemMapper.index(elem) == static_cast<Ix>(elemIdx)) {
176 text += fmt::format(", level {}", elem.level());
177 break;
178 }
179 }
180 }
181 }
182
183 return text + ")";
184}
185
186template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
188lookupTrans_(const std::unordered_map<std::uint64_t, Scalar>& map,
189 unsigned elemIdx1, unsigned elemIdx2, std::string_view what) const
190{
191 const auto entry = map.find(details::isId(elemIdx1, elemIdx2));
192 if (entry == map.end()) {
193 // "unordered_map::at: key not found" on its own says nothing about
194 // which connection the model asked for.
195 // Whether the pair is Cartesian-adjacent says which kind of connection
196 // went missing: a face the grid should have, or a non-neighbour one.
197 const auto& cartDims = cartMapper_.cartesianDimensions();
198 const auto gc1 = cartMapper_.cartesianIndex(std::min(elemIdx1, elemIdx2));
199 const auto gc2 = cartMapper_.cartesianIndex(std::max(elemIdx1, elemIdx2));
200 const auto delta = gc2 - gc1;
201 const auto kind =
202 (delta == 0) ? "same coarse cell (refined siblings)" :
203 (delta == 1) ? "neighbours in I" :
204 (delta == cartDims[0]) ? "neighbours in J" :
205 (delta == cartDims[0]*cartDims[1]) ? "neighbours in K" :
206 ((delta % (cartDims[0]*cartDims[1])) == 0) ? "same column, several layers apart (a pinch-out or vertical NNC)"
207 : "not Cartesian neighbours (a non-neighbour connection)";
208
209 // Does the grid actually join these two cells? That separates a caller
210 // asking about a connection that does not exist from this calculation
211 // having missed one that does.
212 const auto joined = this->gridJoins_(elemIdx1, elemIdx2);
213
214 OPM_THROW(std::out_of_range,
215 fmt::format("No {} between {} and {}: {}. {}",
216 what, this->describeCell_(elemIdx1), this->describeCell_(elemIdx2), kind,
217 joined
218 ? "The grid does join them, so the transmissibility "
219 "calculation skipped a face it should have computed."
220 : "The grid does not join them either, so the caller asked "
221 "about a connection that does not exist -- the cell "
222 "indices it used are not the ones this grid knows."));
223 }
224
225 return entry->second;
226}
227
228template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
230transmissibility(unsigned elemIdx1, unsigned elemIdx2) const
231{
232 return this->lookupTrans_(trans_, elemIdx1, elemIdx2, "transmissibility");
233}
234
235template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
237transmissibilityBoundary(unsigned elemIdx, unsigned boundaryFaceIdx) const
238{
239 return transBoundary_.at(std::make_pair(elemIdx, boundaryFaceIdx));
240}
241
242template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
244thermalHalfTrans(unsigned insideElemIdx, unsigned outsideElemIdx) const
245{
246 return thermalHalfTrans_.at(details::directionalIsId(insideElemIdx, outsideElemIdx));
247}
248
249template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
251halfTransmissibility(unsigned insideElemIdx, unsigned outsideElemIdx) const
252{
253 if (!storeHalfTrans_) {
254 // Without this the caller gets a bare std::out_of_range from the empty
255 // map. One branch on a bool, and this is not a hot path: only the
256 // adjoint code asks for these today.
257 OPM_THROW(std::logic_error,
258 "One-sided half transmissibilities were not stored. "
259 "Call setStoreHalfTrans(true) before update() to have them "
260 "computed; they are off by default because only the adjoint "
261 "code needs them.");
262 }
263
264 return halfTrans_.at(details::directionalIsId(insideElemIdx, outsideElemIdx));
265}
266
267template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
269thermalHalfTransBoundary(unsigned insideElemIdx, unsigned boundaryFaceIdx) const
270{
271 return thermalHalfTransBoundary_.at(std::make_pair(insideElemIdx, boundaryFaceIdx));
272}
273
274template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
275const std::map<std::pair<unsigned, unsigned>, Scalar>& Transmissibility<Grid,GridView,ElementMapper,CartesianIndexMapper,Scalar>::
277{
278 return thermalHalfTransBoundary_;
279}
280
281template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
283diffusivity(unsigned elemIdx1, unsigned elemIdx2) const
284{
285 if (diffusivity_.empty())
286 return 0.0;
287
288 return this->lookupTrans_(diffusivity_, elemIdx1, elemIdx2, "diffusivity");
289}
290
291template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
293dispersivity(unsigned elemIdx1, unsigned elemIdx2) const
294{
295 if (dispersivity_.empty())
296 return 0.0;
297
298 return this->lookupTrans_(dispersivity_, elemIdx1, elemIdx2, "dispersivity");
299}
300
301template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
303update(bool global, const TransUpdateQuantities update_quantities,
304 const std::function<unsigned int(unsigned int)>& map, const bool applyNncMultregT)
305{
306 // whether only update the permeability related transmissibility
307 const bool onlyTrans = (update_quantities == TransUpdateQuantities::Trans);
308 const auto& cartDims = cartMapper_.cartesianDimensions();
309 const auto& transMult = eclState_.getTransMult();
310 const auto& comm = gridView_.comm();
311 ElementMapper elemMapper(gridView_, Dune::mcmgElementLayout());
312
313 unsigned numElements = elemMapper.size();
314 // get the ntg values, the ntg values are modified for the cells merged with minpv
315 const std::vector<double>& ntg = this->lookUpData_.assignFieldPropsDoubleOnLeaf(eclState_.fieldProps(), "NTG");
316 const bool updateDiffusivity = eclState_.getSimulationConfig().isDiffusive();
317 const bool updateDispersivity = eclState_.getSimulationConfig().rock_config().dispersion();
318
319 const bool disableNNC = eclState_.getSimulationConfig().useNONNC();
320
321 if (map) {
322 extractPermeability_(map);
323 }
324 else {
325 extractPermeability_();
326 }
327
328 const int num_threads = ThreadManager::maxThreads();
329
330 // reserving some space in the hashmap upfront saves quite a bit of time because
331 // resizes are costly for hashmaps and there would be quite a few of them if we
332 // would not have a rough idea of how large the final map will be (the rough idea
333 // is a conforming Cartesian grid).
334 trans_.clear();
335 if (num_threads == 1) {
336 trans_.reserve(numElements*3*1.05);
337 }
338
339 transBoundary_.clear();
340
341 if (storeHalfTrans_) {
342 halfTrans_.clear();
343 if (num_threads == 1) {
344 halfTrans_.reserve(numElements*6*1.05);
345 }
346 }
347
348 // if energy is enabled, let's do the same for the "thermal half transmissibilities"
349 if ( enableEnergy_ && !onlyTrans) {
350 thermalHalfTrans_.clear();
351 if (num_threads == 1) {
352 thermalHalfTrans_.reserve(numElements*6*1.05);
353 }
354
355 thermalHalfTransBoundary_.clear();
356 }
357
358 // if diffusion is enabled, let's do the same for the "diffusivity"
359 if (updateDiffusivity && !onlyTrans) {
360 diffusivity_.clear();
361 if (num_threads == 1) {
362 diffusivity_.reserve(numElements*3*1.05);
363 }
364 extractPorosity_();
365 }
366
367 // if dispersion is enabled, let's do the same for the "dispersivity"
368 if (updateDispersivity && !onlyTrans) {
369 dispersivity_.clear();
370 if (num_threads == 1) {
371 dispersivity_.reserve(numElements*3*1.05);
372 }
373 extractDispersion_();
374 }
375
376 // The MULTZ needs special case if the option is ALL
377 // Then the smallest multiplier is applied.
378 // Default is to apply the top and bottom multiplier
379 bool useSmallestMultiplier;
380 bool pinchOption4ALL;
381 bool pinchActive;
382 if (comm.rank() == 0) {
383 const auto& eclGrid = eclState_.getInputGrid();
384 pinchActive = eclGrid.isPinchActive();
385 auto pinchTransCalcMode = eclGrid.getPinchOption();
386 useSmallestMultiplier = eclGrid.getMultzOption() == PinchMode::ALL;
387 pinchOption4ALL = (pinchTransCalcMode == PinchMode::ALL);
388 if (pinchOption4ALL) {
389 useSmallestMultiplier = false;
390 }
391 }
392 if (global && comm.size() > 1) {
393 comm.broadcast(&useSmallestMultiplier, 1, 0);
394 comm.broadcast(&pinchOption4ALL, 1, 0);
395 comm.broadcast(&pinchActive, 1, 0);
396 }
397
398 // fill the centroids cache to avoid repeated calculations in loops below
399 centroids_cache_.resize(gridView_.size(0));
400 for (const auto& elem : elements(gridView_)) {
401 const unsigned elemIdx = elemMapper.index(elem);
402 centroids_cache_[elemIdx] = centroids_(elemIdx);
403 }
404
405 auto harmonicMean = [](const Scalar x1, const Scalar x2)
406 {
407 return (std::abs(x1) < 1e-30 || std::abs(x2) < 1e-30)
408 ? 0.0
409 : 1.0 / (1.0 / x1 + 1.0 / x2);
410 };
411
412 auto faceIdToDir = [](int insideFaceIdx)
413 {
414 switch (insideFaceIdx) {
415 case 0:
416 case 1:
417 return FaceDir::XPlus;
418 case 2:
419 case 3:
420 return FaceDir::YPlus;
421 break;
422 case 4:
423 case 5:
424 return FaceDir::ZPlus;
425 default:
426 throw std::logic_error("Could not determine a face direction");
427 }
428 };
429
430 auto halfDiff = [](const DimVector& faceAreaNormal,
431 const unsigned,
432 const DimVector& distVector,
433 const Scalar prop)
434 {
435 return computeHalfDiffusivity_(faceAreaNormal,
436 distVector,
437 prop);
438 };
439
440 ThreadSafeMapBuilder transBoundary(transBoundary_, num_threads,
441 MapBuilderInsertionMode::Insert_Or_Assign);
442 ThreadSafeMapBuilder transMap(trans_, num_threads,
443 MapBuilderInsertionMode::Insert_Or_Assign);
444 ThreadSafeMapBuilder thermalHalfTransBoundary(thermalHalfTransBoundary_, num_threads,
445 MapBuilderInsertionMode::Insert_Or_Assign);
446 ThreadSafeMapBuilder thermalHalfTrans(thermalHalfTrans_, num_threads,
447 MapBuilderInsertionMode::Insert_Or_Assign);
448 ThreadSafeMapBuilder halfTransMap(halfTrans_, num_threads,
449 MapBuilderInsertionMode::Insert_Or_Assign);
450 ThreadSafeMapBuilder diffusivity(diffusivity_, num_threads,
451 MapBuilderInsertionMode::Insert_Or_Assign);
452 ThreadSafeMapBuilder dispersivity(dispersivity_, num_threads,
453 MapBuilderInsertionMode::Insert_Or_Assign);
454
455 const auto& nnc_input = eclState_.getInputNNC().input();
456
457 const auto element_chunks = ElementChunks(gridView_, Dune::Partitions::all, num_threads);
458#ifdef _OPENMP
459#pragma omp parallel for
460#endif
461 for (std::size_t ci = 0; ci < element_chunks.size(); ++ci) {
462 const auto& chunk = element_chunks[ci];
463 for (const auto& elem : chunk) {
464 FaceInfo inside;
465 FaceInfo outside;
466 DimVector faceAreaNormal;
467
468 inside.elemIdx = elemMapper.index(elem);
469 // Get the Cartesian index of the origin cells (parent or equivalent cell on level zero),
470 // for CpGrid with LGRs. For general grids and no LGRs, get the usual Cartesian Index.
471 inside.cartElemIdx = this->lookUpCartesianData_.
472 template getFieldPropCartesianIdx<Grid>(inside.elemIdx);
473
474 auto computeHalf = [this, &faceAreaNormal, &inside, &outside]
475 (const auto& halfComputer,
476 const auto& prop1, const auto& prop2) -> std::array<Scalar,2>
477 {
478 return {
479 halfComputer(faceAreaNormal,
480 inside.faceIdx,
481 distanceVector_(inside.faceCenter, inside.elemIdx),
482 prop1),
483 halfComputer(faceAreaNormal,
484 outside.faceIdx,
485 distanceVector_(outside.faceCenter, outside.elemIdx),
486 prop2)
487 };
488 };
489
490 auto computeHalfMean = [&inside, &outside, &computeHalf, &ntg, &harmonicMean]
491 (const auto& halfComputer, const auto& prop)
492 {
493 auto onesided = computeHalf(halfComputer, prop[inside.elemIdx], prop[outside.elemIdx]);
494 applyNtg_(onesided[0], inside, ntg);
495 applyNtg_(onesided[1], outside, ntg);
496
497 //TODO Add support for multipliers
498 return harmonicMean(onesided[0], onesided[1]);
499 };
500
501 unsigned boundaryIsIdx = 0;
502 for (const auto& intersection : intersections(gridView_, elem)) {
503 // deal with grid boundaries
504 if (intersection.boundary()) {
505 // compute the transmissibilty for the boundary intersection
506 const auto& geometry = intersection.geometry();
507 inside.faceCenter = geometry.center();
508
509 faceAreaNormal = intersection.centerUnitOuterNormal();
510 faceAreaNormal *= geometry.volume();
511
512 Scalar transBoundaryIs =
513 computeHalfTrans_(faceAreaNormal,
514 intersection.indexInInside(),
515 distanceVector_(inside.faceCenter, inside.elemIdx),
516 permeability_[inside.elemIdx]);
517
518 // normally there would be two half-transmissibilities that would be
519 // averaged. on the grid boundary there only is the half
520 // transmissibility of the interior element.
521 applyMultipliers_(transBoundaryIs, intersection.indexInInside(), inside.cartElemIdx, transMult);
522 transBoundary.insert_or_assign(std::make_pair(inside.elemIdx, boundaryIsIdx), transBoundaryIs);
523
524 // for boundary intersections we also need to compute the thermal
525 // half transmissibilities
526 if (enableEnergy_ && !onlyTrans) {
527 Scalar transBoundaryEnergyIs =
528 computeHalfDiffusivity_(faceAreaNormal,
529 distanceVector_(inside.faceCenter, inside.elemIdx),
530 1.0);
531 thermalHalfTransBoundary.insert_or_assign(std::make_pair(inside.elemIdx, boundaryIsIdx),
532 transBoundaryEnergyIs);
533 }
534
535 ++boundaryIsIdx;
536 continue;
537 }
538
539 if (!intersection.neighbor()) {
540 // elements can be on process boundaries, i.e. they are not on the
541 // domain boundary yet they don't have neighbors.
542 ++boundaryIsIdx;
543 continue;
544 }
545
546 const auto& outsideElem = intersection.outside();
547 outside.elemIdx = elemMapper.index(outsideElem);
548
549 // Get the Cartesian index of the origin cells (parent or equivalent cell on level zero),
550 // for CpGrid with LGRs. For general grids and no LGRs, get the usual Cartesian Index.
551 outside.cartElemIdx = this->lookUpCartesianData_.
552 template getFieldPropCartesianIdx<Grid>(outside.elemIdx);
553
554 // we only need to calculate a face's transmissibility
555 // once...
556 // In a parallel run inside.cartElemIdx > outside.cartElemIdx does not imply inside.elemIdx > outside.elemIdx for
557 // ghost cells and we need to use the cartesian index as this will be used when applying Z multipliers
558 // To cover the case where both cells are part of an LGR and as a consequence might have
559 // the same cartesian index, we tie their Cartesian indices and the ones on the leaf grid view.
560 if (std::tie(inside.cartElemIdx, inside.elemIdx) > std::tie(outside.cartElemIdx, outside.elemIdx)) {
561 continue;
562 }
563
564 // local indices of the faces of the inside and
565 // outside elements which contain the intersection
566 inside.faceIdx = intersection.indexInInside();
567 outside.faceIdx = intersection.indexInOutside();
568
569 if (inside.faceIdx == -1) {
570 // NNC. Set zero transmissibility, as it will be
571 // *added to* by applyNncToGridTrans_() later.
572 assert(outside.faceIdx == -1);
573 transMap.insert_or_assign(details::isId(inside.elemIdx, outside.elemIdx), 0.0);
574 if (enableEnergy_ && !onlyTrans) {
575 thermalHalfTrans.insert_or_assign(details::directionalIsId(inside.elemIdx, outside.elemIdx), 0.0);
576 thermalHalfTrans.insert_or_assign(details::directionalIsId(outside.elemIdx, inside.elemIdx), 0.0);
577 }
578
579 if (updateDiffusivity && !onlyTrans) {
580 diffusivity.insert_or_assign(details::isId(inside.elemIdx, outside.elemIdx), 0.0);
581 }
582 if (updateDispersivity && !onlyTrans) {
583 dispersivity.insert_or_assign(details::isId(inside.elemIdx, outside.elemIdx), 0.0);
584 }
585 continue;
586 }
587
588 typename std::is_same<Grid, Dune::CpGrid>::type isCpGrid;
589 computeFaceProperties(intersection,
590 inside,
591 outside,
592 faceAreaNormal,
593 isCpGrid);
594
595 Scalar trans = computeHalfMean(computeHalfTrans_, permeability_);
596
597 if (storeHalfTrans_) {
598 // one-sided half transmissibilities (NTG applied),
599 // for the adjoint permeability chain rule
600 auto onesided = computeHalf(computeHalfTrans_,
601 permeability_[inside.elemIdx],
602 permeability_[outside.elemIdx]);
603 applyNtg_(onesided[0], inside, ntg);
604 applyNtg_(onesided[1], outside, ntg);
605 halfTransMap.insert_or_assign(
607 onesided[0]);
608 halfTransMap.insert_or_assign(
610 onesided[1]);
611 }
612
613 // apply the full face transmissibility multipliers
614 // for the inside ...
615 if (!pinchActive) {
616 if (inside.faceIdx > 3) { // top or bottom
617 auto find_layer = [&cartDims](std::size_t cell) {
618 cell /= cartDims[0];
619 auto k = cell / cartDims[1];
620 return k;
621 };
622 int kup = find_layer(inside.cartElemIdx);
623 int kdown = find_layer(outside.cartElemIdx);
624 // When a grid is a CpGrid with LGRs, insideCartElemIdx coincides with outsideCartElemIdx
625 // for cells on the leaf with the same parent cell on level zero.
626 assert((kup != kdown) || (inside.cartElemIdx == outside.cartElemIdx));
627 if (std::abs(kup -kdown) > 1) {
628 trans = 0.0;
629 }
630 }
631 }
632
633 if (useSmallestMultiplier) {
634 // PINCH(4) == TOPBOT is assumed here as we set useSmallestMultipliers
635 // to false if PINCH(4) == ALL holds
636 // In contrast to the name this will also apply
637 applyAllZMultipliers_(trans, inside, outside, transMult, cartDims);
638 }
639 else {
640 applyMultipliers_(trans, inside.faceIdx, inside.cartElemIdx, transMult);
641 // ... and outside elements
642 applyMultipliers_(trans, outside.faceIdx, outside.cartElemIdx, transMult);
643 }
644
645 bool foundInputNNC = false;
646 if (! nnc_input.empty()) {
647 // Skip region multipliers for overlapping input NNCs (they are handled later)
648 auto it = std::lower_bound(nnc_input.begin(), nnc_input.end(),
649 NNCdata { inside.cartElemIdx, outside.cartElemIdx, 0.0 });
650 foundInputNNC = it != nnc_input.end() && it->cell1 == inside.cartElemIdx && it->cell2 == outside.cartElemIdx;
651 }
652 if (! foundInputNNC) {
653 // apply the region multipliers (cf. the MULTREGT keyword)
654 trans *= transMult.getRegionMultiplier(inside.cartElemIdx,
655 outside.cartElemIdx,
656 faceIdToDir(inside.faceIdx));
657 }
658
659 transMap.insert_or_assign(details::isId(inside.elemIdx, outside.elemIdx), trans);
660
661 // update the "thermal half transmissibility" for the intersection
662 if (enableEnergy_ && !onlyTrans) {
663 const auto half = computeHalf(halfDiff, 1.0, 1.0);
664 // TODO Add support for multipliers
665 thermalHalfTrans.insert_or_assign(details::directionalIsId(inside.elemIdx, outside.elemIdx),
666 half[0]);
667 thermalHalfTrans.insert_or_assign(details::directionalIsId(outside.elemIdx, inside.elemIdx),
668 half[1]);
669 }
670
671 // update the "diffusive half transmissibility" for the intersection
672 if (updateDiffusivity && !onlyTrans) {
673 diffusivity.insert_or_assign(details::isId(inside.elemIdx, outside.elemIdx),
674 computeHalfMean(halfDiff, porosity_));
675 }
676
677 // update the "dispersivity half transmissibility" for the intersection
678 if (updateDispersivity && !onlyTrans) {
679 dispersivity.insert_or_assign(details::isId(inside.elemIdx, outside.elemIdx),
680 computeHalfMean(halfDiff, dispersion_));
681 }
682 }
683 }
684 }
685 centroids_cache_.clear();
686
687#ifdef _OPENMP
688#pragma omp parallel sections
689#endif
690 {
691#ifdef _OPENMP
692#pragma omp section
693#endif
694 transMap.finalize();
695#ifdef _OPENMP
696#pragma omp section
697#endif
698 transBoundary.finalize();
699#ifdef _OPENMP
700#pragma omp section
701#endif
702 thermalHalfTransBoundary.finalize();
703#ifdef _OPENMP
704#pragma omp section
705#endif
706 thermalHalfTrans.finalize();
707#ifdef _OPENMP
708#pragma omp section
709#endif
710 diffusivity.finalize();
711#ifdef _OPENMP
712#pragma omp section
713#endif
714 dispersivity.finalize();
715#ifdef _OPENMP
716#pragma omp section
717#endif
718 halfTransMap.finalize();
719 }
720
721 // Potentially overwrite and/or modify transmissibilities based on input from deck
722 this->updateFromEclState_(global);
723
724 // Create mapping from global to local index
725 std::unordered_map<std::size_t,int> globalToLocal;
726
727 // Loop over all elements (global grid) and store Cartesian index
728 for (const auto& elem : elements(grid_.leafGridView())) {
729 int elemIdx = elemMapper.index(elem);
730 int cartElemIdx = cartMapper_.cartesianIndex(elemIdx);
731 globalToLocal[cartElemIdx] = elemIdx;
732 }
733
734 if (!disableNNC) {
735 // For EDITNNC and EDITNNCR we warn only once
736 // If transmissibility is used for load balancing this will be done
737 // when computing the gobal transmissibilities and all warnings will
738 // be seen in a parallel. Unfortunately, when we do not use transmissibilities
739 // we will only see warnings for the partition of process 0 and also false positives.
740 this->applyPinchNncToGridTrans_(globalToLocal, applyNncMultregT);
741 this->applyNncToGridTrans_(globalToLocal);
742 this->applyEditNncToGridTrans_(globalToLocal);
743 this->applyEditNncrToGridTrans_(globalToLocal);
744 if (applyNncMultregT) {
745 this->applyNncMultreg_(globalToLocal);
746 }
747 warnEditNNC_ = false;
748 }
749
750 // If disableNNC == true, remove all non-neighbouring transmissibilities.
751 // If disableNNC == false, remove very small non-neighbouring transmissibilities.
752 this->removeNonCartesianTransmissibilities_(disableNNC);
753}
754
755template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
758{
759 unsigned numElem = gridView_.size(/*codim=*/0);
760 permeability_.resize(numElem);
761
762 // read the intrinsic permeabilities from the eclState. Note that all arrays
763 // provided by eclState are one-per-cell of "uncompressed" grid, whereas the
764 // simulation grid might remove a few elements. (e.g. because it is distributed
765 // over several processes.)
766 const auto& fp = eclState_.fieldProps();
767 if (fp.has_double("PERMX")) {
768 const std::vector<double>& permxData = this-> lookUpData_.assignFieldPropsDoubleOnLeaf(fp, "PERMX");
769
770 std::vector<double> permyData;
771 if (fp.has_double("PERMY"))
772 permyData = this-> lookUpData_.assignFieldPropsDoubleOnLeaf(fp,"PERMY");
773 else
774 permyData = permxData;
775
776 std::vector<double> permzData;
777 if (fp.has_double("PERMZ"))
778 permzData = this-> lookUpData_.assignFieldPropsDoubleOnLeaf(fp,"PERMZ");
779 else
780 permzData = permxData;
781
782 for (std::size_t dofIdx = 0; dofIdx < numElem; ++ dofIdx) {
783 permeability_[dofIdx] = 0.0;
784 permeability_[dofIdx][0][0] = permxData[dofIdx];
785 permeability_[dofIdx][1][1] = permyData[dofIdx];
786 permeability_[dofIdx][2][2] = permzData[dofIdx];
787 }
788
789 // for now we don't care about non-diagonal entries
790
791 }
792 else
793 throw std::logic_error("Can't read the intrinsic permeability from the ecl state. "
794 "(The PERM{X,Y,Z} keywords are missing)");
795}
796
797template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
799extractPermeability_(const std::function<unsigned int(unsigned int)>& map)
800{
801 unsigned numElem = gridView_.size(/*codim=*/0);
802 permeability_.resize(numElem);
803
804 // read the intrinsic permeabilities from the eclState. Note that all arrays
805 // provided by eclState are one-per-cell of "uncompressed" grid, whereas the
806 // simulation grid might remove a few elements. (e.g. because it is distributed
807 // over several processes.)
808 const auto& fp = eclState_.fieldProps();
809 if (fp.has_double("PERMX")) {
810 const std::vector<double>& permxData =
811 this->lookUpData_.assignFieldPropsDoubleOnLeaf(fp,"PERMX");
812
813 std::vector<double> permyData;
814 if (fp.has_double("PERMY")){
815 permyData = this->lookUpData_.assignFieldPropsDoubleOnLeaf(fp,"PERMY");
816 }
817 else {
818 permyData = permxData;
819 }
820
821 std::vector<double> permzData;
822 if (fp.has_double("PERMZ")) {
823 permzData = this->lookUpData_.assignFieldPropsDoubleOnLeaf(fp,"PERMZ");
824 }
825 else {
826 permzData = permxData;
827 }
828
829 for (std::size_t dofIdx = 0; dofIdx < numElem; ++ dofIdx) {
830 permeability_[dofIdx] = 0.0;
831 std::size_t inputDofIdx = map(dofIdx);
832 permeability_[dofIdx][0][0] = permxData[inputDofIdx];
833 permeability_[dofIdx][1][1] = permyData[inputDofIdx];
834 permeability_[dofIdx][2][2] = permzData[inputDofIdx];
835 }
836
837 // for now we don't care about non-diagonal entries
838 }
839 else {
840 throw std::logic_error("Can't read the intrinsic permeability from the ecl state. "
841 "(The PERM{X,Y,Z} keywords are missing)");
842 }
843}
844
845template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
848{
849 // read the intrinsic porosity from the eclState. Note that all arrays
850 // provided by eclState are one-per-cell of "uncompressed" grid, whereas the
851 // simulation grid might remove a few elements. (e.g. because it is distributed
852 // over several processes.)
853 const auto& fp = eclState_.fieldProps();
854 if (fp.has_double("PORO")) {
855 if constexpr (std::is_same_v<Scalar,double>) {
856 porosity_ = this->lookUpData_.assignFieldPropsDoubleOnLeaf(fp,"PORO");
857 }
858 else {
859 const auto por = this->lookUpData_.assignFieldPropsDoubleOnLeaf(fp,"PORO");
860 porosity_.resize(por.size());
861 std::ranges::copy(por, porosity_.begin());
862 }
863 }
864 else {
865 throw std::logic_error("Can't read the porosity from the ecl state. "
866 "(The PORO keywords are missing)");
867 }
868}
869
870template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
873{
874 if (!enableDispersivity_) {
875 throw std::runtime_error("Dispersion disabled at compile time, but the deck "
876 "contains the DISPERC keyword.");
877 }
878 const auto& fp = eclState_.fieldProps();
879 if constexpr (std::is_same_v<Scalar,double>) {
880 dispersion_ = this->lookUpData_.assignFieldPropsDoubleOnLeaf(fp,"DISPERC");
881 }
882 else {
883 const auto disp = this->lookUpData_.assignFieldPropsDoubleOnLeaf(fp,"DISPERC");
884 dispersion_.resize(disp.size());
885 std::ranges::copy(disp, dispersion_.begin());
886 }
887}
888
889template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
892{
893 const auto& cartDims = cartMapper_.cartesianDimensions();
894 for (auto&& trans: trans_) {
895 //either remove all NNC transmissibilities or those less than the threshold (by default 1e-6 in the deck's unit system)
896 if (removeAll || trans.second < transmissibilityThreshold_) {
897 const auto& id = trans.first;
898 const auto& elements = details::isIdReverse(id);
899 int gc1 = std::min(cartMapper_.cartesianIndex(elements.first), cartMapper_.cartesianIndex(elements.second));
900 int gc2 = std::max(cartMapper_.cartesianIndex(elements.first), cartMapper_.cartesianIndex(elements.second));
901
902 // only adjust the NNCs
903 // When LGRs, all neighbors in the LGR are cartesian neighbours on the level grid representing the LGR.
904 // When elements on the leaf grid view have the same parent cell, gc1 and gc2 coincide.
905 if (gc2 - gc1 == 1 || gc2 - gc1 == cartDims[0] || gc2 - gc1 == cartDims[0]*cartDims[1] || gc2 - gc1 == 0) {
906 continue;
907 }
908
909 trans.second = 0.0;
910 }
911 }
912}
913
914template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
916applyAllZMultipliers_(Scalar& trans,
917 const FaceInfo& inside,
918 const FaceInfo& outside,
919 const TransMult& transMult,
920 const std::array<int, dimWorld>& cartDims)
921{
922 if (grid_.maxLevel() > 0) {
923 OPM_THROW(std::invalid_argument, "MULTZ not support with LGRS, yet.");
924 }
925 if (inside.faceIdx > 3) { // top or or bottom
926 assert(inside.faceIdx == 5); // as insideCartElemIdx < outsideCartElemIdx holds for the Z column
927 // For CpGrid with LGRs, insideCartElemIdx == outsideCartElemIdx when cells on the leaf have the same parent cell on level zero.
928 assert(outside.cartElemIdx >= inside.cartElemIdx);
929 unsigned lastCartElemIdx;
930 if (outside.cartElemIdx == inside.cartElemIdx) {
931 lastCartElemIdx = outside.cartElemIdx;
932 }
933 else {
934 lastCartElemIdx = outside.cartElemIdx - cartDims[0]*cartDims[1];
935 }
936 // Last multiplier using (Z+)*(Z-)
937 Scalar mult = transMult.getMultiplier(lastCartElemIdx , FaceDir::ZPlus) *
938 transMult.getMultiplier(outside.cartElemIdx , FaceDir::ZMinus);
939
940 // pick the smallest multiplier using (Z+)*(Z-) while looking down
941 // the pillar until reaching the other end of the connection
942 for (auto cartElemIdx = inside.cartElemIdx; cartElemIdx < lastCartElemIdx;) {
943 auto multiplier = transMult.getMultiplier(cartElemIdx, FaceDir::ZPlus);
944 cartElemIdx += cartDims[0]*cartDims[1];
945 multiplier *= transMult.getMultiplier(cartElemIdx, FaceDir::ZMinus);
946 mult = std::min(mult, static_cast<Scalar>(multiplier));
947 }
948
949 trans *= mult;
950 }
951 else {
952 applyMultipliers_(trans, inside.faceIdx, inside.cartElemIdx, transMult);
953 applyMultipliers_(trans, outside.faceIdx, outside.cartElemIdx, transMult);
954 }
955}
956
957template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
959updateFromEclState_(bool global)
960{
961 const FieldPropsManager* fp =
962 (global) ? &(eclState_.fieldProps()) :
963 &(eclState_.globalFieldProps());
964
965 std::array<bool,3> is_tran {fp->tran_active("TRANX"),
966 fp->tran_active("TRANY"),
967 fp->tran_active("TRANZ")};
968
969 if (!(is_tran[0] || is_tran[1] || is_tran[2])) {
970 // Skip unneeded expensive traversals
971 return;
972 }
973
974 std::array<std::string, 3> keywords {"TRANX", "TRANY", "TRANZ"};
975 std::array<std::vector<double>,3> trans = createTransmissibilityArrays_(is_tran);
976 auto key = keywords.begin();
977 auto perform = is_tran.begin();
978
979 for (auto it = trans.begin(); it != trans.end(); ++it, ++key, ++perform) {
980 if (*perform) {
981 if (grid_.maxLevel() > 0) {
982 OPM_THROW(std::invalid_argument, "Calculations on TRANX/TRANY/TRANZ arrays are not support with LGRS, yet.");
983 }
984 fp->apply_tran(*key, *it);
985 }
986 }
987
988 resetTransmissibilityFromArrays_(is_tran, trans);
989}
990
991template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
992std::array<std::vector<double>,3>
994createTransmissibilityArrays_(const std::array<bool,3>& is_tran)
995{
996 const auto& cartDims = cartMapper_.cartesianDimensions();
997 ElementMapper elemMapper(gridView_, Dune::mcmgElementLayout());
998
999 auto numElem = gridView_.size(/*codim=*/0);
1000 std::array<std::vector<double>,3> trans = {
1001 std::vector<double>(is_tran[0] ? numElem : 0, 0),
1002 std::vector<double>(is_tran[1] ? numElem : 0, 0),
1003 std::vector<double>(is_tran[2] ? numElem : 0, 0)
1004 };
1005
1006 // compute the transmissibilities for all intersections
1007 for (const auto& elem : elements(gridView_)) {
1008 for (const auto& intersection : intersections(gridView_, elem)) {
1009 // store intersection, this might be costly
1010 if (!intersection.neighbor()) {
1011 continue; // intersection is on the domain boundary
1012 }
1013
1014 // In the EclState TRANX[c1] is transmissibility in X+
1015 // direction. we only store transmissibilities in the +
1016 // direction. Same for Y and Z. Ordering of compressed (c1,c2) and cartesian index
1017 // (gc1, gc2) is coherent (c1 < c2 <=> gc1 < gc2) only in a serial run.
1018 // In a parallel run this only holds in the interior as elements in the
1019 // ghost overlap region might be ordered after the others. Hence we need
1020 // to use the cartesian index to select the compressed index where to store
1021 // the transmissibility value.
1022 // c1 < c2 <=> gc1 < gc2 is no longer true (even in serial) when the grid is a
1023 // CpGrid with LGRs. When cells c1 and c2 have the same parent
1024 // cell on level zero, then gc1 == gc2.
1025 unsigned c1 = elemMapper.index(intersection.inside());
1026 unsigned c2 = elemMapper.index(intersection.outside());
1027 int gc1 = cartMapper_.cartesianIndex(c1);
1028 int gc2 = cartMapper_.cartesianIndex(c2);
1029 if (std::tie(gc1, c1) > std::tie(gc2, c2)) {
1030 // we only need to handle each connection once, thank you.
1031 // We do this when gc1 is smaller than the other to find the
1032 // correct place to store in parallel when ghost/overlap elements
1033 // are ordered last
1034 continue;
1035 }
1036
1037 auto isID = details::isId(c1, c2);
1038
1039 // For CpGrid with LGRs, when leaf grid view cells with indices c1 and c2
1040 // have the same parent cell on level zero, then gc2 - gc1 == 0. In that case,
1041 // 'intersection.indexInSIde()' needed to be checked to determine the direction, i.e.
1042 // add in the if/else-if 'gc2 == gc1 && intersection.indexInInside() == ... '
1043 if ((gc2 - gc1 == 1 || (gc2 == gc1 && (intersection.indexInInside() == 0 || intersection.indexInInside() == 1)))
1044 && cartDims[0] > 1)
1045 {
1046 if (is_tran[0]) {
1047 // set simulator internal transmissibilities to values from inputTranx
1048 trans[0][c1] = trans_[isID];
1049 }
1050 }
1051 else if ((gc2 - gc1 == cartDims[0] || (gc2 == gc1 && (intersection.indexInInside() == 2 || intersection.indexInInside() == 3)))
1052 && cartDims[1] > 1)
1053 {
1054 if (is_tran[1]) {
1055 // set simulator internal transmissibilities to values from inputTrany
1056 trans[1][c1] = trans_[isID];
1057 }
1058 }
1059 else if (gc2 - gc1 == cartDims[0]*cartDims[1] ||
1060 (gc2 == gc1 && (intersection.indexInInside() == 4 || intersection.indexInInside() == 5)))
1061 {
1062 if (is_tran[2]) {
1063 // set simulator internal transmissibilities to values from inputTranz
1064 trans[2][c1] = trans_[isID];
1065 }
1066 }
1067 // else.. We don't support modification of NNC at the moment.
1068 }
1069 }
1070
1071 return trans;
1072}
1073
1074template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1076resetTransmissibilityFromArrays_(const std::array<bool,3>& is_tran,
1077 const std::array<std::vector<double>,3>& trans)
1078{
1079 const auto& cartDims = cartMapper_.cartesianDimensions();
1080 ElementMapper elemMapper(gridView_, Dune::mcmgElementLayout());
1081
1082 // compute the transmissibilities for all intersections
1083 for (const auto& elem : elements(gridView_)) {
1084 for (const auto& intersection : intersections(gridView_, elem)) {
1085 if (!intersection.neighbor()) {
1086 continue; // intersection is on the domain boundary
1087 }
1088
1089 // In the EclState TRANX[c1] is transmissibility in X+
1090 // direction. we only store transmissibilities in the +
1091 // direction. Same for Y and Z. Ordering of compressed (c1,c2) and cartesian index
1092 // (gc1, gc2) is coherent (c1 < c2 <=> gc1 < gc2) only in a serial run.
1093 // In a parallel run this only holds in the interior as elements in the
1094 // ghost overlap region might be ordered after the others. Hence we need
1095 // to use the cartesian index to select the compressed index where to store
1096 // the transmissibility value.
1097 // c1 < c2 <=> gc1 < gc2 is no longer true (even in serial) when the grid is a
1098 // CpGrid with LGRs. When cells c1 and c2 have the same parent
1099 // cell on level zero, then gc1 == gc2.
1100 unsigned c1 = elemMapper.index(intersection.inside());
1101 unsigned c2 = elemMapper.index(intersection.outside());
1102 int gc1 = cartMapper_.cartesianIndex(c1);
1103 int gc2 = cartMapper_.cartesianIndex(c2);
1104 if (std::tie(gc1, c1) > std::tie(gc2, c2)) {
1105 // we only need to handle each connection once, thank you.
1106 // We do this when gc1 is smaller than the other to find the
1107 // correct place to read in parallel when ghost/overlap elements
1108 // are ordered last
1109 continue;
1110 }
1111
1112 auto isID = details::isId(c1, c2);
1113
1114 // For CpGrid with LGRs, when leaf grid view cells with indices c1 and c2
1115 // have the same parent cell on level zero, then gc2 - gc1 == 0. In that case,
1116 // 'intersection.indexInSIde()' needed to be checked to determine the direction, i.e.
1117 // add in the if/else-if 'gc2 == gc1 && intersection.indexInInside() == ... '
1118 if ((gc2 - gc1 == 1 || (gc2 == gc1 && (intersection.indexInInside() == 0 || intersection.indexInInside() == 1)))
1119 && cartDims[0] > 1)
1120 {
1121 if (is_tran[0]) {
1122 // set simulator internal transmissibilities to values from inputTranx
1123 trans_[isID] = trans[0][c1];
1124 }
1125 }
1126 else if ((gc2 - gc1 == cartDims[0] || (gc2 == gc1 && (intersection.indexInInside() == 2|| intersection.indexInInside() == 3)))
1127 && cartDims[1] > 1)
1128 {
1129 if (is_tran[1]) {
1130 // set simulator internal transmissibilities to values from inputTrany
1131 trans_[isID] = trans[1][c1];
1132 }
1133 }
1134 else if (gc2 - gc1 == cartDims[0]*cartDims[1] ||
1135 (gc2 == gc1 && (intersection.indexInInside() == 4 || intersection.indexInInside() == 5)))
1136 {
1137 if (is_tran[2]) {
1138 // set simulator internal transmissibilities to values from inputTranz
1139 trans_[isID] = trans[2][c1];
1140 }
1141 }
1142
1143 // else.. We don't support modification of NNC at the moment.
1144 }
1145 }
1146}
1147
1148template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1149template<class Intersection>
1151computeFaceProperties(const Intersection& intersection,
1152 FaceInfo& inside,
1153 FaceInfo& outside,
1154 DimVector& faceAreaNormal,
1155 /*isCpGrid=*/std::false_type) const
1156{
1157 if constexpr (requires(const Grid& g) { g.faceAreaNormalEcl(0); }) {
1158 // The grid gives the face center and the area normal as the CpGrid defines them: the face center is the
1159 // center of the side of each cell, and the area normal is computed from the nodes of the face. For faces
1160 // that are not plane or at faults, this is different from the geometry of the face, and gives the
1161 // transmissibilities of the CpGrid.
1162 inside.faceCenter = grid_.faceCenterEcl(inside.elemIdx, inside.faceIdx);
1163 outside.faceCenter = grid_.faceCenterEcl(outside.elemIdx, outside.faceIdx);
1164
1165 if constexpr (requires { intersection.id(); }) {
1166 faceAreaNormal = grid_.faceAreaNormalEcl(intersection.id());
1167 }
1168 else {
1169 faceAreaNormal = grid_.faceAreaNormalEcl(intersection.impl().id());
1170 }
1171 }
1172 else {
1173 // default implementation for DUNE grids
1174 const auto& geometry = intersection.geometry();
1175 outside.faceCenter = inside.faceCenter = geometry.center();
1176
1177 faceAreaNormal = intersection.centerUnitOuterNormal();
1178 faceAreaNormal *= geometry.volume();
1179 }
1180}
1181
1182template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1183template<class Intersection>
1185computeFaceProperties(const Intersection& intersection,
1186 FaceInfo& inside,
1187 FaceInfo& outside,
1188 DimVector& faceAreaNormal,
1189 /*isCpGrid=*/std::true_type) const
1190{
1191 int faceIdx = intersection.id();
1192
1193 if (grid_.maxLevel() == 0) {
1194 inside.faceCenter = grid_.faceCenterEcl(inside.elemIdx, inside.faceIdx, intersection);
1195 outside.faceCenter = grid_.faceCenterEcl(outside.elemIdx, outside.faceIdx, intersection);
1196 faceAreaNormal = grid_.faceAreaNormalEcl(faceIdx);
1197 }
1198 else {
1199 if ((intersection.inside().level() != intersection.outside().level())) {
1200 // For CpGrid with LGRs, intersection laying on the boundary of an LGR, having two neighboring cells:
1201 // one coarse neighboring cell and one refined neighboring cell, we get the corresponding parent
1202 // intersection (from level 0), and use the center of the parent intersection for the coarse
1203 // neighboring cell.
1204
1205 // Get parent intersection and its geometry
1206 const auto& parentIntersection =
1207 grid_.getParentIntersectionFromLgrBoundaryFace(intersection);
1208 const auto& parentIntersectionGeometry = parentIntersection.geometry();
1209
1210 // For the coarse neighboring cell, take the center of the parent intersection.
1211 // For the refined neighboring cell, take the 'usual' center.
1212 inside.faceCenter = (intersection.inside().level() == 0)
1213 ? parentIntersectionGeometry.center()
1214 : grid_.faceCenterEcl(inside.elemIdx, inside.faceIdx, intersection);
1215 outside.faceCenter = (intersection.outside().level() == 0)
1216 ? parentIntersectionGeometry.center()
1217 : grid_.faceCenterEcl(outside.elemIdx, outside.faceIdx, intersection);
1218
1219 // For some computations, it seems to be benefitial to replace the actual area of the refined face, by
1220 // the area of its parent face.
1221 // faceAreaNormal = parentIntersection.centerUnitOuterNormal();
1222 // faceAreaNormal *= parentIntersectionGeometry.volume();
1223
1225 faceAreaNormal = intersection.centerUnitOuterNormal();
1226 faceAreaNormal *= intersection.geometry().volume();
1227 }
1228 else {
1229 assert(intersection.inside().level() == intersection.outside().level());
1230
1231 inside.faceCenter = grid_.faceCenterEcl(inside.elemIdx, inside.faceIdx, intersection);
1232 outside.faceCenter = grid_.faceCenterEcl(outside.elemIdx, outside.faceIdx, intersection);
1233
1234 // When the CpGrid has LGRs, we compute the face area normal differently.
1235 if (intersection.inside().level() > 0) { // remove intersection.inside().level() > 0
1236 faceAreaNormal = intersection.centerUnitOuterNormal();
1237 faceAreaNormal *= intersection.geometry().volume();
1238 }
1239 else {
1240 faceAreaNormal = grid_.faceAreaNormalEcl(faceIdx);
1241 }
1242 }
1243 }
1244}
1245
1246template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1247void
1249applyPinchNncToGridTrans_(const std::unordered_map<std::size_t,int>& cartesianToCompressed,
1250 const bool applyNncMultregT)
1251{
1252 const auto& pinchNnc = eclState_.getPinchNNC();
1253 const auto& transMult = this->eclState_.getTransMult();
1254
1255 for (const auto& nncEntry : pinchNnc) {
1256 auto c1 = nncEntry.cell1;
1257 auto c2 = nncEntry.cell2;
1258 auto lowIt = cartesianToCompressed.find(c1);
1259 auto highIt = cartesianToCompressed.find(c2);
1260 int low = (lowIt == cartesianToCompressed.end())? -1 : lowIt->second;
1261 int high = (highIt == cartesianToCompressed.end())? -1 : highIt->second;
1262
1263 if (low > high) {
1264 std::swap(low, high);
1265 }
1266
1267 if (low == -1 && high == -1) {
1268 // Silently discard as it is not between active cells
1269 continue;
1270 }
1271
1272 if (low == -1 || high == -1) {
1273 // We can end up here if one of the cells is overlap/ghost, because those
1274 // are lacking connections to other cells in the ghost/overlap.
1275 // Hence discard the NNC if it is between active cell and inactive cell
1276 continue;
1277 }
1278
1279 {
1280 auto candidate = trans_.find(details::isId(low, high));
1281 if (candidate != trans_.end()) {
1282 // the correctly calculated transmissibility is stored in
1283 // the NNC. Overwrite previous value with it.
1284 // taking the region multiplier into account.
1285 candidate->second = nncEntry.trans;
1286 if (applyNncMultregT) {
1287 const auto mult = transMult.getRegionMultiplierNNC(c1, c2);
1288 candidate->second *= mult;
1289 }
1290 }
1291 }
1292 }
1293}
1294
1295template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1296void
1298applyNncToGridTrans_(const std::unordered_map<std::size_t,int>& cartesianToCompressed)
1299{
1300 // First scale NNCs with EDITNNC.
1301 const auto& nnc_input = eclState_.getInputNNC().input();
1302
1303 for (const auto& nncEntry : nnc_input) {
1304 auto c1 = nncEntry.cell1;
1305 auto c2 = nncEntry.cell2;
1306 auto lowIt = cartesianToCompressed.find(c1);
1307 auto highIt = cartesianToCompressed.find(c2);
1308 int low = (lowIt == cartesianToCompressed.end())? -1 : lowIt->second;
1309 int high = (highIt == cartesianToCompressed.end())? -1 : highIt->second;
1310
1311 if (low > high) {
1312 std::swap(low, high);
1313 }
1314
1315 if (low == -1 && high == -1) {
1316 // Silently discard as it is not between active cells
1317 continue;
1318 }
1319
1320 if (low == -1 || high == -1) {
1321 // Discard the NNC if it is between active cell and inactive cell
1322 std::ostringstream sstr;
1323 sstr << "NNC between active and inactive cells ("
1324 << low << " -> " << high << ") with globalcell is (" << c1 << "->" << c2 <<")";
1325 OpmLog::warning(sstr.str());
1326 continue;
1327 }
1328
1329 if (auto candidate = trans_.find(details::isId(low, high)); candidate != trans_.end()) {
1330 // NNC is represented by the grid and might be a neighboring connection
1331 // In this case the transmissibilty is added to the value already
1332 // set or computed.
1333 candidate->second += nncEntry.trans;
1334 }
1335 // if (enableEnergy_) {
1336 // auto candidate = thermalHalfTrans_.find(details::directionalIsId(low, high));
1337 // if (candidate != trans_.end()) {
1338 // // NNC is represented by the grid and might be a neighboring connection
1339 // // In this case the transmissibilty is added to the value already
1340 // // set or computed.
1341 // candidate->second += nncEntry.transEnergy1;
1342 // }
1343 // auto candidate = thermalHalfTrans_.find(details::directionalIsId(high, low));
1344 // if (candidate != trans_.end()) {
1345 // // NNC is represented by the grid and might be a neighboring connection
1346 // // In this case the transmissibilty is added to the value already
1347 // // set or computed.
1348 // candidate->second += nncEntry.transEnergy2;
1349 // }
1350 // }
1351 // if (enableDiffusivity_) {
1352 // auto candidate = diffusivity_.find(details::isId(low, high));
1353 // if (candidate != trans_.end()) {
1354 // // NNC is represented by the grid and might be a neighboring connection
1355 // // In this case the transmissibilty is added to the value already
1356 // // set or computed.
1357 // candidate->second += nncEntry.transDiffusion;
1358 // }
1359 // }
1360 }
1361}
1362
1363template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1365applyEditNncToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal)
1366{
1367 const auto& input = eclState_.getInputNNC();
1368 applyEditNncToGridTransHelper_(globalToLocal, "EDITNNC",
1369 input.edit(),
1370 [&input](const NNCdata& nnc){
1371 return input.edit_location(nnc);},
1372 // Multiply transmissibility with EDITNNC value
1373 [](Scalar& trans, const Scalar& rhs){ trans *= rhs;});
1374}
1375
1376template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1378applyEditNncrToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal)
1379{
1380 const auto& input = eclState_.getInputNNC();
1381 applyEditNncToGridTransHelper_(globalToLocal, "EDITNNCR",
1382 input.editr(),
1383 [&input](const NNCdata& nnc){
1384 return input.editr_location(nnc);},
1385 // Replace Transmissibility with EDITNNCR value
1386 [](Scalar& trans, const Scalar& rhs){ trans = rhs;});
1387}
1388
1389template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1391applyEditNncToGridTransHelper_(const std::unordered_map<std::size_t,int>& globalToLocal,
1392 const std::string& keyword,
1393 const std::vector<NNCdata>& nncs,
1394 const std::function<KeywordLocation(const NNCdata&)>& getLocation,
1395 const std::function<void(Scalar&, const Scalar&)>& apply)
1396{
1397 if (nncs.empty()) {
1398 return;
1399 }
1400 const auto& cartDims = cartMapper_.cartesianDimensions();
1401
1402 auto format_ijk = [&cartDims](std::size_t cell) -> std::string
1403 {
1404 auto i = cell % cartDims[0]; cell /= cartDims[0];
1405 auto j = cell % cartDims[1];
1406 auto k = cell / cartDims[1];
1407
1408 return fmt::format("({},{},{})", i + 1,j + 1,k + 1);
1409 };
1410
1411 auto print_warning = [&format_ijk, &getLocation, &keyword] (const NNCdata& nnc)
1412 {
1413 const auto& location = getLocation( nnc );
1414 auto warning = fmt::format("Problem with {} keyword\n"
1415 "In {} line {} \n"
1416 "No NNC defined for connection {} -> {}", keyword, location.filename,
1417 location.lineno, format_ijk(nnc.cell1), format_ijk(nnc.cell2));
1418 OpmLog::warning(keyword, warning);
1419 };
1420
1421 // editNnc is supposed to only reference non-neighboring connections and not
1422 // neighboring connections. Use all entries for scaling if there is an NNC.
1423 // variable nnc incremented in loop body.
1424 auto nnc = nncs.begin();
1425 auto end = nncs.end();
1426 std::size_t warning_count = 0;
1427 while (nnc != end) {
1428 auto c1 = nnc->cell1;
1429 auto c2 = nnc->cell2;
1430 auto lowIt = globalToLocal.find(c1);
1431 auto highIt = globalToLocal.find(c2);
1432
1433 if (lowIt == globalToLocal.end() || highIt == globalToLocal.end()) {
1434 // Prevent warnings for NNCs stored on other processes in parallel (both cells inactive)
1435 if (lowIt != highIt && warnEditNNC_) {
1436 print_warning(*nnc);
1437 warning_count++;
1438 }
1439 ++nnc;
1440 continue;
1441 }
1442
1443 auto low = lowIt->second, high = highIt->second;
1444
1445 if (low > high) {
1446 std::swap(low, high);
1447 }
1448
1449 auto candidate = trans_.find(details::isId(low, high));
1450 if (candidate == trans_.end() && warnEditNNC_) {
1451 print_warning(*nnc);
1452 ++nnc;
1453 warning_count++;
1454 }
1455 else {
1456 // NNC exists
1457 while (nnc != end && c1 == nnc->cell1 && c2 == nnc->cell2) {
1458 apply(candidate->second, nnc->trans);
1459 ++nnc;
1460 }
1461 }
1462 }
1463
1464 if (warning_count > 0) {
1465 auto warning = fmt::format("Problems with {} keyword\n"
1466 "A total of {} connections not defined in grid", keyword, warning_count);
1467 OpmLog::warning(warning);
1468 }
1469}
1470
1471template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1472void
1474applyNncMultreg_(const std::unordered_map<std::size_t,int>& cartesianToCompressed)
1475{
1476 const auto& inputNNC = this->eclState_.getInputNNC();
1477 const auto& transMult = this->eclState_.getTransMult();
1478
1479 auto compressedIdx = [&cartesianToCompressed](const std::size_t globIdx)
1480 {
1481 auto ixPos = cartesianToCompressed.find(globIdx);
1482 return (ixPos == cartesianToCompressed.end()) ? -1 : ixPos->second;
1483 };
1484
1485 // Apply region-based transmissibility multipliers (i.e., the MULTREGT
1486 // keyword) to those transmissibilities that are directly assigned from
1487 // the input.
1488 //
1489 // * NNC::input() covers the NNC keyword and any numerical aquifers
1490 // * NNC::editr() covers the EDITNNCR keyword
1491 //
1492 // Note: We do not apply MULTREGT to the entries in NNC::edit() since
1493 // those act as regular multipliers and have already been fully
1494 // accounted for in the multiplier part of the main loop of update() and
1495 // the applyEditNncToGridTrans_() member function.
1496 for (const auto& nncList : {&NNC::input, &NNC::editr}) {
1497 for (const auto& nncEntry : (inputNNC.*nncList)()) {
1498 const auto c1 = nncEntry.cell1;
1499 const auto c2 = nncEntry.cell2;
1500
1501 auto low = compressedIdx(c1);
1502 auto high = compressedIdx(c2);
1503
1504 if ((low == -1) || (high == -1)) {
1505 continue;
1506 }
1507
1508 if (low > high) {
1509 std::swap(low, high);
1510 }
1511
1512 auto candidate = this->trans_.find(details::isId(low, high));
1513 if (candidate != this->trans_.end()) {
1514 candidate->second *= transMult.getRegionMultiplierNNC(c1, c2);
1515 }
1516 }
1517 }
1518}
1519
1520template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1521Scalar
1523computeHalfTrans_(const DimVector& areaNormal,
1524 int faceIdx, // in the reference element that contains the intersection
1525 const DimVector& distance,
1526 const DimMatrix& perm)
1527{
1528 assert(faceIdx >= 0);
1529 unsigned dimIdx = faceIdx / 2;
1530 assert(dimIdx < dimWorld);
1531 Scalar halfTrans = perm[dimIdx][dimIdx];
1532 halfTrans *= std::abs(Dune::dot(areaNormal, distance));
1533 halfTrans /= distance.two_norm2();
1534
1535 return halfTrans;
1536}
1537
1538template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1539Scalar
1541computeHalfDiffusivity_(const DimVector& areaNormal,
1542 const DimVector& distance,
1543 const Scalar poro)
1544{
1545 Scalar halfDiff = poro;
1546 halfDiff *= std::abs(Dune::dot(areaNormal, distance));
1547 halfDiff /= distance.two_norm2();
1548
1549 return halfDiff;
1550}
1551
1552template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1555distanceVector_(const DimVector& faceCenter,
1556 const unsigned& cellIdx) const
1557{
1558 const auto& cellCenter = centroids_cache_.empty() ? centroids_(cellIdx)
1559 : centroids_cache_[cellIdx];
1560 DimVector x = faceCenter;
1561 for (unsigned dimIdx = 0; dimIdx < dimWorld; ++dimIdx) {
1562 x[dimIdx] -= cellCenter[dimIdx];
1563 }
1564
1565 return x;
1566}
1567
1568template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1570applyMultipliers_(Scalar& trans,
1571 unsigned faceIdx,
1572 unsigned cartElemIdx,
1573 const TransMult& transMult) const
1574{
1575 // apply multiplier for the transmissibility of the face. (the
1576 // face index is the index of the reference-element face which
1577 // contains the intersection of interest.)
1578 trans *= transMult.getMultiplier(cartElemIdx,
1579 FaceDir::FromIntersectionIndex(faceIdx));
1580}
1581
1582template<class Grid, class GridView, class ElementMapper, class CartesianIndexMapper, class Scalar>
1584applyNtg_(Scalar& trans,
1585 const FaceInfo& face,
1586 const std::vector<double>& ntg)
1587{
1588 // apply multiplier for the transmissibility of the face. (the
1589 // face index is the index of the reference-element face which
1590 // contains the intersection of interest.)
1591 // NTG does not apply to top and bottom faces
1592 if (face.faceIdx >= 0 && face.faceIdx <= 3) {
1593 trans *= ntg[face.elemIdx];
1594 }
1595}
1596
1597} // namespace Opm
1598
1599#endif // OPM_TRANSMISSIBILITY_IMPL_HPP
static unsigned maxThreads()
Return the maximum number of threads of the current process.
Definition: threadmanager.hpp:66
void applyMultipliers_(Scalar &trans, unsigned faceIdx, unsigned cartElemIdx, const TransMult &transMult) const
Definition: Transmissibility_impl.hpp:1570
Scalar diffusivity(unsigned elemIdx1, unsigned elemIdx2) const
Return the diffusivity for the intersection between two elements.
Definition: Transmissibility_impl.hpp:283
void applyEditNncToGridTrans_(const std::unordered_map< std::size_t, int > &globalToLocal)
Multiplies the grid transmissibilities according to EDITNNC.
Definition: Transmissibility_impl.hpp:1365
void computeFaceProperties(const Intersection &intersection, FaceInfo &inside, FaceInfo &outside, DimVector &faceAreaNormal, std::false_type) const
Definition: Transmissibility_impl.hpp:1151
Dune::FieldMatrix< Scalar, dimWorld, dimWorld > DimMatrix
Definition: Transmissibility.hpp:60
void update(bool global, TransUpdateQuantities update_quantities=TransUpdateQuantities::All, const std::function< unsigned int(unsigned int)> &map={}, bool applyNncMultRegT=false)
Definition: Transmissibility_impl.hpp:303
DimVector distanceVector_(const DimVector &faceCenter, const unsigned &cellIdx) const
Definition: Transmissibility_impl.hpp:1555
void applyNncMultreg_(const std::unordered_map< std::size_t, int > &globalToLocal)
Definition: Transmissibility_impl.hpp:1474
void applyEditNncrToGridTrans_(const std::unordered_map< std::size_t, int > &globalToLocal)
Resets the grid transmissibilities according to EDITNNCR.
Definition: Transmissibility_impl.hpp:1378
void extractDispersion_()
Definition: Transmissibility_impl.hpp:872
const std::map< std::pair< unsigned, unsigned >, Scalar > & getThermalHalfTransBoundary() const
Definition: Transmissibility_impl.hpp:276
Scalar thermalHalfTrans(unsigned insideElemIdx, unsigned outsideElemIdx) const
Return the thermal "half transmissibility" for the intersection between two elements.
Definition: Transmissibility_impl.hpp:244
Scalar transmissibilityBoundary(unsigned elemIdx, unsigned boundaryFaceIdx) const
Return the transmissibility for a given boundary segment.
Definition: Transmissibility_impl.hpp:237
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:994
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)
Definition: Transmissibility_impl.hpp:1391
void updateFromEclState_(bool global)
Definition: Transmissibility_impl.hpp:959
void extractPermeability_()
Definition: Transmissibility_impl.hpp:757
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:916
Scalar lookupTrans_(const std::unordered_map< std::uint64_t, Scalar > &map, unsigned elemIdx1, unsigned elemIdx2, std::string_view what) const
Definition: Transmissibility_impl.hpp:188
TransUpdateQuantities
Compute all transmissibilities.
Definition: Transmissibility.hpp:178
void resetTransmissibilityFromArrays_(const std::array< bool, 3 > &is_tran, const std::array< std::vector< double >, 3 > &trans)
overwrites calculated transmissibilities
Definition: Transmissibility_impl.hpp:1076
Dune::FieldVector< Scalar, dimWorld > DimVector
Definition: Transmissibility.hpp:61
static Scalar computeHalfDiffusivity_(const DimVector &areaNormal, const DimVector &distance, const Scalar poro)
Definition: Transmissibility_impl.hpp:1541
Scalar transmissibilityThreshold_
Definition: Transmissibility.hpp:322
Scalar transmissibility(unsigned elemIdx1, unsigned elemIdx2) const
Return the transmissibility for the intersection between two elements.
Definition: Transmissibility_impl.hpp:230
std::string describeCell_(unsigned elemIdx) const
Cell index, its Cartesian index, and on a refined grid its level.
Definition: Transmissibility_impl.hpp:151
static void applyNtg_(Scalar &trans, const FaceInfo &face, const std::vector< double > &ntg)
Definition: Transmissibility_impl.hpp:1584
const EclipseState & eclState_
Definition: Transmissibility.hpp:316
Scalar dispersivity(unsigned elemIdx1, unsigned elemIdx2) const
Return the dispersivity for the intersection between two elements.
Definition: Transmissibility_impl.hpp:293
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)
Definition: Transmissibility_impl.hpp:99
void applyNncToGridTrans_(const std::unordered_map< std::size_t, int > &cartesianToCompressed)
Definition: Transmissibility_impl.hpp:1298
Scalar halfTransmissibility(unsigned insideElemIdx, unsigned outsideElemIdx) const
One-sided (half) transmissibility of the face between two cells, seen from the inside cell (NTG appli...
Definition: Transmissibility_impl.hpp:251
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:1249
bool gridJoins_(unsigned elemIdx1, unsigned elemIdx2) const
Whether the grid has an intersection between the two cells.
Definition: Transmissibility_impl.hpp:124
void extractPorosity_()
Definition: Transmissibility_impl.hpp:847
void removeNonCartesianTransmissibilities_(bool removeAll)
Definition: Transmissibility_impl.hpp:891
static Scalar computeHalfTrans_(const DimVector &areaNormal, int faceIdx, const DimVector &distance, const DimMatrix &perm)
Definition: Transmissibility_impl.hpp:1523
Scalar thermalHalfTransBoundary(unsigned insideElemIdx, unsigned boundaryFaceIdx) const
Definition: Transmissibility_impl.hpp:269
if(!linsolver_)
Definition: FlexibleSolver_impl.hpp:338
int Index
The type of an index of a degree of freedom.
Definition: overlaptypes.hh:44
constexpr unsigned elemIdxShift
Definition: FacePropertiesTPSA_impl.hpp:52
std::pair< std::uint32_t, std::uint32_t > isIdReverse(const std::uint64_t &id)
Definition: Transmissibility_impl.hpp:80
std::uint64_t directionalIsId(std::uint32_t elemIdx1, std::uint32_t elemIdx2)
Definition: Transmissibility_impl.hpp:91
std::uint64_t isId(std::uint32_t elemIdx1, std::uint32_t elemIdx2)
Definition: Transmissibility_impl.hpp:72
Definition: blackoilbioeffectsmodules.hh:45
Definition: Transmissibility.hpp:188
unsigned cartElemIdx
Definition: Transmissibility.hpp:192
DimVector faceCenter
Definition: Transmissibility.hpp:189
unsigned elemIdx
Definition: Transmissibility.hpp:191
int faceIdx
Definition: Transmissibility.hpp:190