SimulatorFullyImplicitBlackoilSolvent_impl.hpp
Go to the documentation of this file.
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>
27  SimulatorFullyImplicitBlackoilSolvent(const parameter::ParameterGroup& param,
28  const GridT& grid,
29  const DerivedGeology& geo,
31  const SolventPropsAdFromDeck& solvent_props,
32  const RockCompressibility* rock_comp_props,
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  Opm::DeckConstPtr& 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  , has_solvent_(has_solvent)
55  , deck_(deck)
56  , solvent_props_(solvent_props)
57  {
58  if(deck->hasKeyword("MISCIBLE")) {
59  std::cerr << "MISICIBLE keyword is present. Mixing is not currently supported" << std::endl;
60  }
61  }
62 
63  template <class GridT>
65  createSolver(const Wells* wells)
66  -> std::unique_ptr<Solver>
67  {
68  typedef typename Traits::Model Model;
69 
70 
71  auto model = std::unique_ptr<Model>(new Model(BaseType::model_param_,
72  BaseType::grid_,
73  BaseType::props_,
74  BaseType::geo_,
75  BaseType::rock_comp_props_,
76  solvent_props_,
77  wells,
78  BaseType::solver_,
79  BaseType::eclipse_state_,
80  BaseType::has_disgas_,
81  BaseType::has_vapoil_,
82  BaseType::terminal_output_,
83  has_solvent_));
84 
85  if (!BaseType::threshold_pressures_by_face_.empty()) {
86  model->setThresholdPressures(BaseType::threshold_pressures_by_face_);
87  }
88 
89  return std::unique_ptr<Solver>(new Solver(BaseType::solver_param_, std::move(model)));
90  }
91 
92  template <class GridT>
94  handleAdditionalWellInflow(SimulatorTimer& timer,
95  WellsManager& /*wells_manager*/,
96  typename BaseType::WellState& well_state,
97  const Wells* wells)
98  {
99  // compute solvent inflow
100  const int nw = wells->number_of_wells;
101  std::vector<double> perfcells_fraction(wells->well_connpos[nw], 0.0);
102 
103  if (deck_->hasKeyword("WSOLVENT")) {
104 
105  size_t currentStep = timer.currentStepNum();
106  ScheduleConstPtr schedule = BaseType::eclipse_state_->getSchedule();
107  Opm::DeckKeywordConstPtr keyword = deck_->getKeyword("WSOLVENT");
108  const int num_keywords = keyword->size();
109 
110  for (int recordNr = 0; recordNr < num_keywords; ++recordNr) {
111  DeckRecordConstPtr record = keyword->getRecord(recordNr);
112  const std::string& wellNamesPattern = record->getItem("WELL")->getTrimmedString(0);
113  std::vector<WellPtr> wells_solvent = schedule->getWells(wellNamesPattern);
114  for (auto wellIter = wells_solvent.begin(); wellIter != wells_solvent.end(); ++wellIter) {
115  WellPtr well_solvent = *wellIter;
116  WellInjectionProperties injection = well_solvent->getInjectionProperties(currentStep);
117  if (injection.injectorType == WellInjector::GAS) {
118  double solventFraction = well_solvent->getSolventFraction(currentStep);
119  // Find the solvent well in the well list and add properties to it
120  int wix = 0;
121  for (; wix < nw; ++wix) {
122  if (wellNamesPattern == wells->name[wix]) {
123  break;
124  }
125  }
126  if (wix == wells->number_of_wells) {
127  OPM_THROW(std::runtime_error, "Could not find a match for well "
128  << wellNamesPattern
129  << " from WSOLVENT.");
130  }
131  for (int j = wells->well_connpos[wix]; j < wells->well_connpos[wix+1]; ++j) {
132  perfcells_fraction[j] = solventFraction;
133  }
134  } else {
135  OPM_THROW(std::logic_error, "For solvent injector you must have a gas injector");
136  }
137  }
138  }
139  }
140  well_state.solventFraction() = perfcells_fraction;
141  }
142 
143 } // namespace Opm
144 
145 #endif // OPM_SIMULATORFULLYIMPLICITBLACKOILSOLVENT_IMPL_HEADER_INCLUDED
Definition: GeoProps.hpp:53
Definition: BlackoilPropsAdInterface.hpp:38
Definition: AdditionalObjectDeleter.hpp:22
void handleAdditionalWellInflow(SimulatorTimer &timer, WellsManager &wells_manager, typename BaseType::WellState &well_state, const Wells *wells)
Definition: SimulatorFullyImplicitBlackoilSolvent_impl.hpp:94
void setThresholdPressures(const std::vector< double > &threshold_pressures_by_face)
Set threshold pressures that prevent or reduce flow. This prevents flow across faces if the potential...
Definition: BlackoilModelBase_impl.hpp:317
Class collecting all necessary components for a two-phase simulation.
Definition: SimulatorBase.hpp:84
Definition: BlackoilSolventModel.hpp:38
std::unique_ptr< Solver > createSolver(const Wells *wells)
Definition: SimulatorFullyImplicitBlackoilSolvent_impl.hpp:65
Interface class for (linear) solvers for the fully implicit black-oil system.
Definition: NewtonIterationBlackoilInterface.hpp:31
SimulatorFullyImplicitBlackoilSolvent(const parameter::ParameterGroup &param, const GridT &grid, const DerivedGeology &geo, BlackoilPropsAdInterface &props, const SolventPropsAdFromDeck &solvent_props, const RockCompressibility *rock_comp_props, NewtonIterationBlackoilInterface &linsolver, const double *gravity, const bool disgas, const bool vapoil, std::shared_ptr< EclipseState > eclipse_state, BlackoilOutputWriter &output_writer, Opm::DeckConstPtr &deck, const std::vector< double > &threshold_pressures_by_face, const bool solvent)
Definition: SimulatorFullyImplicitBlackoilSolvent_impl.hpp:27
Definition: SolventPropsAdFromDeck.hpp:38
Wrapper class for VTK, Matlab, and ECL output.
Definition: SimulatorFullyImplicitBlackoilOutput.hpp:195
Traits::WellState WellState
Definition: SimulatorBase.hpp:90