WellFractureFlowSplit.hpp
Go to the documentation of this file.
1/*
2 Copyright 2026 SINTEF Digital, Mathematics and Cybernetics.
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 3 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
20#ifndef OPM_WELL_FRACTURE_FLOW_SPLIT_HPP_INCLUDED
21#define OPM_WELL_FRACTURE_FLOW_SPLIT_HPP_INCLUDED
22
23#include <opm/material/common/MathToolbox.hpp>
25
26#include <algorithm>
27#include <cassert>
28
29namespace Opm {
30
43template <class FluidSystem, class Scalar, class Simulator,
44 class WellContainer, class WellState>
46 const WellContainer& well_container,
47 WellState& well_state,
48 const WellState& nupcol_well_state)
49{
50 using IndexTraits = typename FluidSystem::IndexTraitsType;
51
52 for (const auto& well : well_container) {
53 auto& single_wellstate = well_state.well(well->indexOfWell());
54 auto& perf_data = single_wellstate.perf_data;
55 auto& filtrate_data = perf_data.filtrate_data;
56 auto& fracture_data = perf_data.fracture_data;
57
58 // fracture_data is only sized once a fracture model claims the well.
59 std::ranges::fill(fracture_data.injected_rate, Scalar{0});
60 std::ranges::fill(filtrate_data.flow_factor, Scalar{1});
61 fracture_data.injected_phase = -1;
62
63 if (!well->isInjector()) {
64 continue;
65 }
66
67 // Set even without fractured connections on this rank: the owner
68 // reports the total of a distributed well under this phase.
69 const auto inj_type = well->wellEcl().injectorType();
70 const auto inj_phase = injectedActivePhaseIdx(well->phaseUsage(), inj_type);
71 if (!inj_phase.has_value()) {
72 continue; // MULTI injector or injected phase not active
73 }
74 fracture_data.injected_phase =
75 static_cast<int>(*injectedCanonicalPhaseIdx<IndexTraits>(inj_type));
76
77 const auto& fracture_indices = well->wellIndexFracture();
78 if (fracture_indices.empty()) {
79 continue; // no fracture crosses this well's local connections
80 }
81
82 const auto& wellstate_nupcol = nupcol_well_state.well(well->indexOfWell());
83
84 const int nperf = static_cast<int>(well->wellIndex().size());
85 assert(static_cast<int>(fracture_indices.size()) == nperf);
86
87 const int np = well_state.numPhases();
88
89 auto obtain = [](const auto& value) { return getValue(value); };
90
91 for (int perf = 0; perf < nperf; ++perf) {
92 const auto cell_idx = well->perforationData()[perf].cell_index;
93 const auto& intQuants =
94 simulator.model().intensiveQuantities(cell_idx, /*timeIdx=*/0);
95 const auto trans_mult = simulator.problem()
96 .template wellTransMultiplier<Scalar>(intQuants, cell_idx, obtain);
97
98 const Scalar matrix_wi = well->wellIndex()[perf] * trans_mult;
99 const Scalar perf_pressure = wellstate_nupcol.perf_data.pressure[perf];
100 const Scalar fracture_wi = fracture_indices[perf].wellIndex(perf_pressure);
101 const Scalar effective_wi = matrix_wi + fracture_wi;
102
103 auto& fracture_rate = fracture_data.injected_rate[perf];
104 if (effective_wi > 0.0) {
105 const Scalar matrix_frac = matrix_wi / effective_wi;
106 filtrate_data.flow_factor[perf] = matrix_frac;
107 fracture_rate = (1.0 - matrix_frac)
108 * perf_data.phase_rates[perf*np + *inj_phase];
109 }
110 else {
111 filtrate_data.flow_factor[perf] = 0.0;
112 fracture_rate = 0.0;
113 }
114 }
115 }
116}
117
118} // namespace Opm
119
120#endif // OPM_WELL_FRACTURE_FLOW_SPLIT_HPP_INCLUDED
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:87
Problem & problem()
Return the object which specifies the pysical setup of the simulation.
Definition: simulator.hh:273
Model & model()
Return the physical model used in the simulation.
Definition: simulator.hh:260
Definition: WellContainer.hpp:46
Definition: WellState.hpp:68
constexpr int numPhases() const
The number of phases present.
Definition: WellState.hpp:274
const SingleWellState< Scalar, IndexTraits > & well(std::size_t well_index) const
Definition: WellState.hpp:315
Definition: blackoilbioeffectsmodules.hh:45
void updateWellFractureFlowSplit(const Simulator &simulator, const WellContainer &well_container, WellState &well_state, const WellState &nupcol_well_state)
Definition: WellFractureFlowSplit.hpp:45
std::optional< int > injectedActivePhaseIdx(const PhaseUsageInfo< IndexTraits > &pu, const InjectorType type)
Definition: InjectedPhase.hpp:50