TransportSolverTwophasePolymer.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2012 SINTEF ICT, Applied Mathematics.
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_TRANSPORTSOLVERTWOPHASEPOLYMER_HEADER_INCLUDED
21 #define OPM_TRANSPORTSOLVERTWOPHASEPOLYMER_HEADER_INCLUDED
22 
24 #include <opm/core/transport/reorder/ReorderSolverInterface.hpp>
25 #include <opm/core/utility/linearInterpolation.hpp>
26 #include <vector>
27 #include <list>
28 
29 struct UnstructuredGrid;
30 
31 namespace Opm
32 {
33 
34  class IncompPropertiesInterface;
35 
39  class TransportSolverTwophasePolymer : public ReorderSolverInterface
40  {
41  public:
42 
44  enum GradientMethod { Analytic, FinDif }; // Analytic is chosen (hard-coded)
45 
56  TransportSolverTwophasePolymer(const UnstructuredGrid& grid,
57  const IncompPropertiesInterface& props,
58  const PolymerProperties& polyprops,
59  const SingleCellMethod method,
60  const double tol,
61  const int maxit);
62 
65 
80  void solve(const double* darcyflux,
81  const double* porevolume,
82  const double* source,
83  const double* polymer_inflow_c,
84  const double dt,
85  std::vector<double>& saturation,
86  std::vector<double>& concentration,
87  std::vector<double>& cmax);
88 
100  void solveGravity(const std::vector<std::vector<int> >& columns,
101  const double* porevolume,
102  const double dt,
103  std::vector<double>& saturation,
104  std::vector<double>& concentration,
105  std::vector<double>& cmax);
106 
107  public: // But should be made private...
108  virtual void solveSingleCell(const int cell);
109  virtual void solveMultiCell(const int num_cells, const int* cells);
110  void solveSingleCellBracketing(int cell);
111  void solveSingleCellNewton(int cell);
112  void solveSingleCellGradient(int cell);
113  void solveSingleCellNewtonSimple(int cell,bool use_sc);
114  class ResidualEquation;
115 
116  void initGravity(const double* grav);
117  void solveSingleCellGravity(const std::vector<int>& cells,
118  const int pos,
119  const double* gravflux);
120  int solveGravityColumn(const std::vector<int>& cells);
121  void scToc(const double* x, double* x_c) const;
122 
123  #ifdef PROFILING
124  class Newton_Iter {
125  public:
126  bool res_s;
127  int cell;
128  double s;
129  double c;
130 
131  Newton_Iter(bool res_s_val, int cell_val, double s_val, double c_val) {
132  res_s = res_s_val;
133  cell = cell_val;
134  s = s_val;
135  c = c_val;
136  }
137  };
138 
139  std::list<Newton_Iter> res_counts;
140  #endif
141 
142 
143  private:
144  const UnstructuredGrid& grid_;
145  const double* porosity_;
146  const double* porevolume_; // one volume per cell
147  const IncompPropertiesInterface& props_;
148  const PolymerProperties& polyprops_;
149  std::vector<double> smin_;
150  std::vector<double> smax_;
151  double tol_;
152  double maxit_;
153 
154  const double* darcyflux_; // one flux per grid face
155  const double* source_; // one source per cell
156  const double* polymer_inflow_c_;
157  double dt_;
158  std::vector<double> saturation_; // one per cell, only water saturation!
159  double* concentration_;
160  double* cmax_;
161  std::vector<double> fractionalflow_; // one per cell
162  std::vector<double> mc_; // one per cell
163  const double* visc_;
164  SingleCellMethod method_;
165  double adhoc_safety_;
166 
167  // For gravity segregation.
168  std::vector<double> gravflux_;
169  std::vector<double> mob_;
170  std::vector<double> cmax0_;
171  // For gravity segregation, column variables
172  std::vector<double> s0_;
173  std::vector<double> c0_;
174 
175  struct ResidualC;
176  struct ResidualS;
177 
178  class ResidualCGrav;
179  class ResidualSGrav;
180 
181 
182  void fracFlow(double s, double c, double cmax, int cell, double& ff) const;
183  void fracFlowWithDer(double s, double c, double cmax, int cell, double& ff,
184  double* dff_dsdc) const;
185  void fracFlowBoth(double s, double c, double cmax, int cell, double& ff,
186  double* dff_dsdc, bool if_with_der) const;
187  void computeMc(double c, double& mc) const;
188  void computeMcWithDer(double c, double& mc, double& dmc_dc) const;
189  void mobility(double s, double c, int cell, double* mob) const;
190  };
191 
192 } // namespace Opm
193 
194 #endif // OPM_TRANSPORTSOLVERTWOPHASEPOLYMER_HEADER_INCLUDED
Definition: TransportSolverTwophasePolymer.hpp:44
Definition: TransportSolverTwophasePolymer.hpp:43
void solveSingleCellNewtonSimple(int cell, bool use_sc)
void scToc(const double *x, double *x_c) const
Definition: CompressibleTpfaPolymer.hpp:32
std::vector< double > & cmax
Definition: GravityColumnSolverPolymer_impl.hpp:78
void solveSingleCellGravity(const std::vector< int > &cells, const int pos, const double *gravflux)
Definition: TransportSolverTwophasePolymer.hpp:39
SingleCellMethod
Definition: TransportSolverTwophasePolymer.hpp:43
Definition: TransportSolverTwophasePolymer.hpp:43
Definition: TransportSolverTwophasePolymer.hpp:43
void solveGravity(const std::vector< std::vector< int > > &columns, const double *porevolume, const double dt, std::vector< double > &saturation, std::vector< double > &concentration, std::vector< double > &cmax)
Definition: PolymerProperties.hpp:34
Definition: TransportSolverTwophasePolymer.hpp:44
int solveGravityColumn(const std::vector< int > &cells)
GradientMethod
Definition: TransportSolverTwophasePolymer.hpp:44
Definition: TransportSolverTwophasePolymer.hpp:43
void setPreferredMethod(SingleCellMethod method)
Set the preferred method, Bracketing or Newton.
void solve(const double *darcyflux, const double *porevolume, const double *source, const double *polymer_inflow_c, const double dt, std::vector< double > &saturation, std::vector< double > &concentration, std::vector< double > &cmax)
void initGravity(const double *grav)
virtual void solveMultiCell(const int num_cells, const int *cells)
virtual void solveSingleCell(const int cell)
Definition: TransportSolverTwophasePolymer.hpp:43
TransportSolverTwophasePolymer(const UnstructuredGrid &grid, const IncompPropertiesInterface &props, const PolymerProperties &polyprops, const SingleCellMethod method, const double tol, const int maxit)