20#ifndef OPM_AQUIFERCONSTANTFLUX_HPP
21#define OPM_AQUIFERCONSTANTFLUX_HPP
25#include <opm/input/eclipse/EclipseState/Aquifer/Aquancon.hpp>
26#include <opm/input/eclipse/EclipseState/Aquifer/AquiferFlux.hpp>
28#include <opm/material/common/MathToolbox.hpp>
29#include <opm/material/densead/Evaluation.hpp>
37template<
typename TypeTag>
48 static constexpr int numEq = BlackoilIndices::numEq;
53 const SingleAquiferFlux& aquifer)
55 , connections_ (connections)
56 , aquifer_data_ (aquifer)
57 , connection_flux_ (connections_.size(),
Eval{0})
59 this->total_face_area_ = this->initializeConnections();
65 result.cumulative_flux_ = 1.0;
74 assert (total_face_area.size() >=
static_cast<typename std::vector<Scalar>::size_type
>(this->aquiferID()));
82 return this->total_face_area_;
87 aquifer_data_ = aquifer;
92 auto xaqPos = aquiferSoln.find(this->
aquiferID());
93 if (xaqPos == aquiferSoln.end()) {
97 this->cumulative_flux_ = this->area_fraction_ * xaqPos->second.volume;
108 this->flux_rate_ = this->totalFluxRate();
109 this->cumulative_flux_ +=
110 this->flux_rate_ * this->
simulator_.timeStepSize();
115 data::AquiferData data;
117 data.aquiferID = this->aquifer_data_.id;
121 data.fluxRate = this->totalFluxRate();
123 data.volume = this->cumulative_flux_;
126 data.initPressure = 0.0;
132 const unsigned cellIdx,
133 [[maybe_unused]]
const unsigned timeIdx)
override
135 const int idx = this->cellToConnectionIdx_[cellIdx];
142 const auto fw = this->aquifer_data_.flux;
144 this->connection_flux_[idx] = fw * this->connections_[idx].effective_facearea;
146 rates[BlackoilIndices::conti0EqIdx + compIdx_()]
147 += this->connection_flux_[idx] / model.dofTotalVolume(cellIdx);
150 template<
class Serializer>
153 serializer(cumulative_flux_);
158 return this->cumulative_flux_ == rhs.cumulative_flux_;
162 const std::vector<Aquancon::AquancCell>& connections_;
164 SingleAquiferFlux aquifer_data_;
165 std::vector<Eval> connection_flux_{};
166 std::vector<int> cellToConnectionIdx_{};
168 Scalar cumulative_flux_{};
169 Scalar total_face_area_{0.0};
170 Scalar area_fraction_{1.0};
172 Scalar initializeConnections()
174 auto connected_face_area = 0.0;
176 this->cellToConnectionIdx_
177 .resize(this->
simulator_.gridView().size(0), -1);
179 for (std::size_t idx = 0; idx < this->connections_.size(); ++idx) {
180 const auto global_index = this->connections_[idx].global_index;
181 const int cell_index = this->
simulator_.vanguard()
182 .compressedIndexForInterior(global_index);
184 if (cell_index < 0) {
188 this->cellToConnectionIdx_[cell_index] = idx;
190 connected_face_area += this->connections_[idx].effective_facearea;
197 return connected_face_area;
202 const auto tot_face_area = this->
simulator_.vanguard()
203 .grid().comm().sum(connected_face_area);
205 return (tot_face_area > 0.0)
206 ? connected_face_area / tot_face_area
214 return FluidSystem::oilCompIdx;
216 return FluidSystem::waterCompIdx;
219 Scalar totalFluxRate()
const
221 return std::accumulate(this->connection_flux_.begin(),
222 this->connection_flux_.end(), 0.0,
223 [](
const Scalar rate,
const auto& q)
225 return rate + getValue(q);
Definition: AquiferConstantFlux.hpp:39
DenseAd::Evaluation< Scalar, numEq > Eval
Definition: AquiferConstantFlux.hpp:49
GetPropType< TypeTag, Properties::RateVector > RateVector
Definition: AquiferConstantFlux.hpp:41
void initFromRestart(const data::Aquifers &aquiferSoln) override
Definition: AquiferConstantFlux.hpp:90
void endTimeStep() override
Definition: AquiferConstantFlux.hpp:106
void computeFaceAreaFraction(const std::vector< Scalar > &total_face_area) override
Definition: AquiferConstantFlux.hpp:72
AquiferConstantFlux(const std::vector< Aquancon::AquancCell > &connections, const Simulator &simulator, const SingleAquiferFlux &aquifer)
Definition: AquiferConstantFlux.hpp:51
GetPropType< TypeTag, Properties::FluidSystem > FluidSystem
Definition: AquiferConstantFlux.hpp:44
GetPropType< TypeTag, Properties::Indices > BlackoilIndices
Definition: AquiferConstantFlux.hpp:45
Scalar totalFaceArea() const override
Definition: AquiferConstantFlux.hpp:80
data::AquiferData aquiferData() const override
Definition: AquiferConstantFlux.hpp:113
GetPropType< TypeTag, Properties::ElementMapper > ElementMapper
Definition: AquiferConstantFlux.hpp:43
void updateAquifer(const SingleAquiferFlux &aquifer)
Definition: AquiferConstantFlux.hpp:85
static constexpr int numEq
Definition: AquiferConstantFlux.hpp:48
bool operator==(const AquiferConstantFlux &rhs) const
Definition: AquiferConstantFlux.hpp:156
void addToSource(RateVector &rates, const unsigned cellIdx, const unsigned timeIdx) override
Definition: AquiferConstantFlux.hpp:131
virtual ~AquiferConstantFlux()=default
void beginTimeStep() override
Definition: AquiferConstantFlux.hpp:103
GetPropType< TypeTag, Properties::Scalar > Scalar
Definition: AquiferConstantFlux.hpp:46
GetPropType< TypeTag, Properties::Simulator > Simulator
Definition: AquiferConstantFlux.hpp:42
static AquiferConstantFlux serializationTestObject(const Simulator &simulator)
Definition: AquiferConstantFlux.hpp:62
void initialSolutionApplied() override
Definition: AquiferConstantFlux.hpp:100
void serializeOp(Serializer &serializer)
Definition: AquiferConstantFlux.hpp:151
Definition: AquiferInterface.hpp:35
const Simulator & simulator_
Definition: AquiferInterface.hpp:98
bool co2store_or_h2store_() const
Definition: AquiferInterface.hpp:82
int aquiferID() const
Definition: AquiferInterface.hpp:79
Definition: blackoilboundaryratevector.hh:37
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:235