20#ifndef PAVG_CALCULATOR_HPP
21#define PAVG_CALCULATOR_HPP
29#include <unordered_map>
38class PAvgDynamicSourceData;
65 const double beta ,
const Result& y);
83 return this->wbp_[this->index(type)];
88 static constexpr auto NumModes =
89 static_cast<std::size_t
>(WBPMode::WBP9) + 1;
92 using WBPStore = std::array<double, NumModes>;
102 Result& set(
const WBPMode type,
const double wbp)
104 this->wbp_[this->index(type)] = wbp;
113 constexpr WBPStore::size_type index(
const WBPMode mode)
const
115 return static_cast<WBPStore::size_type
>(mode);
202 const PAvg& controls,
203 const double gravity,
204 const double refDepth);
210 return this->contributingCells_;
232 return this->averagePressures_;
361 std::unique_ptr<Impl> pImpl_;
372 using ContrIndexType = std::vector<std::size_t>::size_type;
378 using SetupMap = std::unordered_map<std::size_t, ContrIndexType>;
381 enum class NeighbourKind
392 struct PAvgConnection
402 PAvgConnection(
const double ctf_arg,
403 const double depth_arg,
404 const ContrIndexType cell_arg)
417 ContrIndexType cell{};
422 std::vector<ContrIndexType> rectNeighbours{};
427 std::vector<ContrIndexType> diagNeighbours{};
432 std::vector<PAvgConnection> connections_{};
435 std::vector<std::vector<PAvgConnection>::size_type> openConns_{};
439 std::vector<std::size_t> contributingCells_{};
444 Result averagePressures_{};
459 void addConnection(
const GridDims& cellIndexMap,
460 const Connection& conn,
461 SetupMap& setupHelperMap);
478 void accumulateLocalContributions(
const Sources& sources,
479 const PAvg& controls,
480 const double gravity,
481 const double refDepth);
490 virtual void collectGlobalContributions();
499 void assignResults(
const PAvg& controls);
517 void addNeighbour(std::optional<std::size_t> neighbour,
518 NeighbourKind neighbourKind,
519 SetupMap& setupHelperMap);
524 std::size_t lastConnsCell()
const;
537 void addNeighbours_X(
const GridDims& grid, SetupMap& setupHelperMap);
550 void addNeighbours_Y(
const GridDims& grid, SetupMap& setupHelperMap);
563 void addNeighbours_Z(
const GridDims& grid, SetupMap& setupHelperMap);
604 template <
typename ConnIndexMap,
typename CTFPressureWeightFunction>
605 void accumulateLocalContributions(
const Sources& sources,
606 const PAvg& controls,
607 const std::vector<double>& connDP,
608 ConnIndexMap connIndex,
609 CTFPressureWeightFunction ctfPressWeight);
642 template <
typename ConnIndexMap>
643 void accumulateLocalContributions(
const Sources& sources,
644 const PAvg& controls,
645 const std::vector<double>& connDP,
646 ConnIndexMap&& connIndex);
659 void accumulateLocalContribOpen(
const Sources& sources,
660 const PAvg& controls,
661 const std::vector<double>& connDP);
674 void accumulateLocalContribAll(
const Sources& sources,
675 const PAvg& controls,
676 const std::vector<double>& connDP);
708 template <
typename ConnIndexMap>
710 connectionPressureOffsetWell(
const std::size_t nconn,
711 const Sources& sources,
712 const double gravity,
713 const double refDepth,
714 ConnIndexMap connIndex)
const;
747 template <
typename ConnIndexMap>
749 connectionPressureOffsetRes(
const std::size_t nconn,
750 const Sources& sources,
751 const double gravity,
752 const double refDepth,
753 ConnIndexMap connIndex)
const;
774 connectionPressureOffset(
const Sources& sources,
775 const PAvg& controls,
776 const double gravity,
777 const double refDepth)
const;
797PAvgCalculator::Result
Definition GridDims.hpp:31
Accumulate weighted running averages of cell contributions to WBP.
Definition PAvgCalculator.hpp:238
LocalRunningAverages getRunningAverages() const
Get buffer of intermediate, local results.
void prepareContribution()
Zero out/clear WBP term buffer.
Accumulator()
Constructor.
Accumulator(const Accumulator &rhs)
Copy constructor.
Accumulator & add(const double weight, const Accumulator &other)
Add contribution from other accumulator.
void prepareAccumulation()
Zero out/clear WBP result buffer.
std::array< double, 8 > LocalRunningAverages
Collection of running averages and their associate weights.
Definition PAvgCalculator.hpp:244
Accumulator & operator=(Accumulator &&rhs)
Move assignment operator.
Accumulator & addDiagonal(const double weight, const double press)
Add contribution from diagonal, level 2 neighbouring cell.
Accumulator(Accumulator &&rhs)
Move constructor.
Accumulator & addCentre(const double weight, const double press)
Add contribution from centre/connecting cell.
void commitContribution(const double innerWeight=-1.0)
Accumulate current source term into result buffer whilst applying any user-prescribed term weighting.
Accumulator & operator=(const Accumulator &rhs)
Assignment operator.
Accumulator & addRectangular(const double weight, const double press)
Add contribution from direct, rectangular, level 1 neighbouring cell.
void assignRunningAverages(const LocalRunningAverages &avg)
Assign coalesced/global contributions.
~Accumulator()
Destructor.
Result getFinalResult() const
Calculate final WBP results from individual contributions.
Result of block-averaging well pressure procedure.
Definition PAvgCalculator.hpp:56
friend Result linearCombination(const double alpha, Result x, const double beta, const Result &y)
Grant internal data member access to combination function.
double value(const WBPMode type) const
Retrieve numerical value of specific block-averaged well pressure.
Definition PAvgCalculator.hpp:81
WBPMode
Kind of block-averaged well pressure.
Definition PAvgCalculator.hpp:70
References to source contributions owned by other party.
Definition PAvgCalculator.hpp:121
const PAvgDynamicSourceData & wellConns() const
Get read-only access to connection-level contributions.
Definition PAvgCalculator.hpp:152
Sources & wellBlocks(const PAvgDynamicSourceData &wbSrc)
Provide reference to cell-level contributions (pressure, pore-volume, mixture density) owned by other...
Definition PAvgCalculator.hpp:128
const PAvgDynamicSourceData & wellBlocks() const
Get read-only access to cell-level contributions.
Definition PAvgCalculator.hpp:146
Sources & wellConns(const PAvgDynamicSourceData &wcSrc)
Provide reference to connection-level contributions (pressure, pore-volume, mixture density) owned by...
Definition PAvgCalculator.hpp:139
Facility for deriving well-level pressure values from selected block-averaging procedures.
Definition PAvgCalculator.hpp:49
const std::vector< std::size_t > & allWBPCells() const
List of all cells, global indices in natural ordering, that contribute to the block-average pressures...
Definition PAvgCalculator.hpp:208
virtual ~PAvgCalculator()
Destructor.
const Result & averagePressures() const
Block-average pressure derived from selection of source cells.
Definition PAvgCalculator.hpp:230
Accumulator accumPV_
Average pressures weighted by pore-volume.
Definition PAvgCalculator.hpp:368
void pruneInactiveWBPCells(const std::vector< bool > &isActive)
Finish construction by pruning inactive cells.
Accumulator accumCTF_
Average pressures weighted by connection transmissibility factor.
Definition PAvgCalculator.hpp:365
PAvgCalculator(const GridDims &cellIndexMap, const WellConnections &connections)
Constructor.
std::vector< std::size_t > allWellConnections() const
List all reservoir connections that potentially contribute to this block-averaging pressure calculati...
void inferBlockAveragePressures(const Sources &sources, const PAvg &controls, const double gravity, const double refDepth)
Compute block-average well-level pressure values from collection of source contributions and user-def...
Dynamic source data for block-average pressure calculations.
Definition PAvgDynamicSourceData.hpp:35
Definition WellConnections.hpp:45
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
PAvgCalculator::Result linearCombination(const double alpha, PAvgCalculator::Result x, const double beta, const PAvgCalculator::Result &y)
Form linear combination of WBP result objects.