All Classes Namespaces Files Functions Variables Typedefs Enumerator Pages
SimulatorFullyImplicitBlackoilSolvent_impl.hpp
1 /*
2  Copyright 2015 IRIS AS
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_SIMULATORFULLYIMPLICITBLACKOILSOLVENT_IMPL_HEADER_INCLUDED
21 #define OPM_SIMULATORFULLYIMPLICITBLACKOILSOLVENT_IMPL_HEADER_INCLUDED
22 
23 namespace Opm
24 {
25  template <class GridT>
26  SimulatorFullyImplicitBlackoilSolvent<GridT>::
27  SimulatorFullyImplicitBlackoilSolvent(const ParameterGroup& param,
28  const GridT& grid,
29  DerivedGeology& geo,
30  BlackoilPropsAdFromDeck& props,
31  const SolventPropsAdFromDeck& solvent_props,
32  const RockCompressibility* rock_comp_props,
33  NewtonIterationBlackoilInterface& linsolver,
34  const double* gravity,
35  const bool has_disgas,
36  const bool has_vapoil,
37  std::shared_ptr<EclipseState> eclipse_state,
38  BlackoilOutputWriter& output_writer,
39  std::shared_ptr< Deck > deck,
40  const std::vector<double>& threshold_pressures_by_face,
41  const bool has_solvent)
42  : BaseType(param,
43  grid,
44  geo,
45  props,
46  rock_comp_props,
47  linsolver,
48  gravity,
49  has_disgas,
50  has_vapoil,
51  eclipse_state,
52  output_writer,
53  threshold_pressures_by_face,
54  // names of deactivated wells in parallel run
55  std::unordered_set<std::string>())
56  , has_solvent_(has_solvent)
57  , deck_(deck)
58  , solvent_props_(solvent_props)
59  , is_miscible_(false)
60  {
61  if(deck->hasKeyword("MISCIBLE")) {
62  is_miscible_ = true;
63  }
64  }
65 
66  template <class GridT>
67  auto SimulatorFullyImplicitBlackoilSolvent<GridT>::
68  createSolver(const WellModel& well_model)
69  -> std::unique_ptr<Solver>
70  {
71  typedef typename Traits::Model Model;
72 
73 
74  auto model = std::unique_ptr<Model>(new Model(BaseType::model_param_,
75  BaseType::grid_,
76  BaseType::props_,
77  BaseType::geo_,
78  BaseType::rock_comp_props_,
79  solvent_props_,
80  well_model,
81  BaseType::solver_,
82  BaseType::eclipse_state_,
83  BaseType::has_disgas_,
84  BaseType::has_vapoil_,
85  BaseType::terminal_output_,
86  has_solvent_,
87  is_miscible_));
88 
89  if (!BaseType::threshold_pressures_by_face_.empty()) {
90  model->setThresholdPressures(BaseType::threshold_pressures_by_face_);
91  }
92 
93  return std::unique_ptr<Solver>(new Solver(BaseType::solver_param_, std::move(model)));
94  }
95 
96  template <class GridT>
97  void SimulatorFullyImplicitBlackoilSolvent<GridT>::
98  handleAdditionalWellInflow(SimulatorTimer& timer,
99  WellsManager& /*wells_manager*/,
100  typename BaseType::WellState& well_state,
101  const Wells* wells)
102  {
103  // compute solvent inflow
104  const int nw = wells->number_of_wells;
105  std::vector<double> perfcells_fraction(wells->well_connpos[nw], 0.0);
106 
107  size_t currentStep = timer.currentStepNum();
108  const auto& schedule = BaseType::eclipse_state_->getSchedule();
109 
110  for (const auto& well_solvent : schedule.getWells( currentStep )) {
111  if (well_solvent->getStatus( currentStep ) == WellCommon::SHUT) {
112  continue;
113  }
114 
115  WellInjectionProperties injection = well_solvent->getInjectionProperties(currentStep);
116  if (injection.injectorType == WellInjector::GAS) {
117 
118  double solventFraction = well_solvent->getSolventFraction(currentStep);
119 
120  // Find the solvent well in the well list and add properties to it
121  int wix = 0;
122  for (; wix < nw; ++wix) {
123  if (well_solvent->name() == wells->name[wix]) {
124  break;
125  }
126  }
127  if (wix == wells->number_of_wells) {
128  OPM_THROW(std::runtime_error, "Could not find a match for well "
129  << well_solvent->name()
130  << " from WSOLVENT.");
131  }
132  for (int j = wells->well_connpos[wix]; j < wells->well_connpos[wix+1]; ++j) {
133  perfcells_fraction[j] = solventFraction;
134  }
135  }
136  }
137  well_state.solventFraction() = perfcells_fraction;
138  }
139 
140 } // namespace Opm
141 
142 #endif // OPM_SIMULATORFULLYIMPLICITBLACKOILSOLVENT_IMPL_HEADER_INCLUDED