All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
EulerUpstreamImplicit.hpp
1 //===========================================================================
2 //
3 // File: EulerUpstreamImplicit.hpp
4 //
5 // Created: Tue Jun 16 14:07:53 2009
6 //
7 // Author(s): Atgeirr F Rasmussen <atgeirr@sintef.no>
8 // B�rd Skaflestad <bard.skaflestad@sintef.no>
9 //
10 // $Date$
11 //
12 // $Revision$
13 //
14 //===========================================================================
15 
16 /*
17 Copyright 2009, 2010 SINTEF ICT, Applied Mathematics.
18 Copyright 2009, 2010 Statoil ASA.
19 
20 This file is part of The Open Reservoir Simulator Project (OpenRS).
21 
22 OpenRS is free software: you can redistribute it and/or modify
23 it under the terms of the GNU General Public License as published by
24 the Free Software Foundation, either version 3 of the License, or
25 (at your option) any later version.
26 
27 OpenRS is distributed in the hope that it will be useful,
28 but WITHOUT ANY WARRANTY; without even the implied warranty of
29 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30 GNU General Public License for more details.
31 
32 You should have received a copy of the GNU General Public License
33 along with OpenRS. If not, see <http://www.gnu.org/licenses/>.
34 */
35 
36 #ifndef OPENRS_EULERUPSTREAMIMPLICIT_HEADER
37 #define OPENRS_EULERUPSTREAMIMPLICIT_HEADER
38 
39 #include <boost/unordered_map.hpp>
40 
41 #include <opm/core/utility/SparseVector.hpp>
42 #include <opm/core/utility/parameters/ParameterGroup.hpp>
43 
44 #include <opm/porsol/common/ImplicitTransportDefs.hpp>
45 #include <opm/porsol/common/BCRSMatrixBlockAssembler.hpp>
46 
47 #include <dune/grid/common/GridAdapter.hpp>
48 
49 #include <opm/core/transport/implicit/ImplicitAssembly.hpp>
50 #include <opm/core/transport/implicit/ImplicitTransport.hpp>
51 #include <opm/core/transport/implicit/JacobianSystem.hpp>
52 #include <opm/core/transport/implicit/SinglePointUpwindTwoPhase.hpp>
53 
54 
55 namespace Opm {
56 
59  template <class GridInterface, class ReservoirProperties, class BoundaryConditions>
61  {
62  public:
69  EulerUpstreamImplicit (const GridInterface& grid,
70  const ReservoirProperties& resprop,
71  const BoundaryConditions& boundary);
75  void init(const Opm::ParameterGroup& param);
79  void init(const Opm::ParameterGroup& param,
80  const GridInterface& grid,
81  const ReservoirProperties& resprop,
82  const BoundaryConditions& boundary);
86  void initObj(const GridInterface& grid,
87  const ReservoirProperties& resprop,
88  const BoundaryConditions& boundary);
92  void display();
93 
98  template <class PressureSolution>
99  bool transportSolve(std::vector<double>& saturation,
100  const double time,
101  const typename GridInterface::Vector& gravity,
102  const PressureSolution& pressure_sol,
103  const Opm::SparseVector<double>& injection_rates) const;
104 
105  protected:
106  // typedef typename GridInterface::CellIterator CIt;
107  // typedef typename CIt::FaceIterator FIt;
108  // typedef typename FIt::Vector Vector;
109 
110  template <class PressureSolution>
111  void smallTimeStep(std::vector<double>& saturation,
112  const double time,
113  const typename GridInterface::Vector& gravity,
114  const PressureSolution& pressure_sol,
115  const Opm::SparseVector<double>& injection_rates) const;
116 
117  void checkAndPossiblyClampSat(std::vector<double>& s) const;
118 
119 
120 
121  // Interface to implicit solver
123  typedef Opm::SinglePointUpwindTwoPhase<TwophaseFluid> TransportModel;
124 # if 0
125  typedef Opm::ImplicitTransportDefault::NewtonVectorCollection< ::std::vector<double> > NVecColl;
126  typedef Opm::ImplicitTransportDefault::JacobianSystem < struct CSRMatrix, NVecColl > JacSys;
127  typedef Opm::ImplicitTransportLinAlgSupport::CSRMatrixUmfpackSolver LinearSolver;
128 # else
129  typedef Dune::FieldVector<double, 1> ScalarVectorBlockType;
130  typedef Dune::FieldMatrix<double, 1, 1> ScalarMatrixBlockType;
131 
132  typedef Dune::BlockVector<ScalarVectorBlockType> ScalarBlockVector;
133  typedef Dune::BCRSMatrix <ScalarMatrixBlockType> ScalarBCRSMatrix;
134 
135  typedef Opm::ImplicitTransportDefault::NewtonVectorCollection< ScalarBlockVector > NVecColl;
136  typedef Opm::ImplicitTransportDefault::JacobianSystem < ScalarBCRSMatrix, NVecColl > JacSys;
137 
139 # endif
140  typedef Opm::ImplicitTransport<TransportModel ,
141  JacSys ,
143  Opm::ImplicitTransportDefault::VectorNegater,
144  Opm::ImplicitTransportDefault::VectorZero ,
145  Opm::ImplicitTransportDefault::MatrixZero ,
146  Opm::ImplicitTransportDefault::VectorAssign > TransportSolver;
147 
148  // should be initialized by param
149 
150  //TransportModel model_;
151  //TransportSolver tsolver_;
152  GridAdapter mygrid_;
153  ReservoirProperties myrp_;
154 
155  //Opm::SimpleFluid2pWrapper< ReservoirProperties > myfluid_;
156  //TwophaseFluid myfluid_;
157 
158  bool check_sat_;
159  bool clamp_sat_;
160  int max_repeats_;
161  std::vector<double> porevol_;
162 
163  std::vector<int> periodic_cells_;
164  std::vector<int> periodic_faces_;
165  std::vector<int> periodic_nbfaces_;
166  std::vector<int> periodic_hfaces_;
167  std::vector<int> direclet_cells_;
168  std::vector<double> direclet_sat_;
169  std::vector<double> direclet_hfaces_;
170  //std::vector< double > trans_;
171  std::vector<double> htrans_;
172  Opm::ImplicitTransportDetails::NRControl ctrl_;
173  // Storing residual so that we won't have to reallocate it for every step.
174  //mutable std::vector<double> residual_;
175  };
176 
177 } // namespace Opm
178 
179 #include "EulerUpstreamImplicit_impl.hpp"
180 
181 #endif // OPENRS_EULERUPSTREAM_HEADER
void display()
Definition: EulerUpstreamImplicit_impl.hpp:219
Definition: ImplicitTransportDefs.hpp:168
Definition: ImplicitTransportDefs.hpp:121
void initObj(const GridInterface &grid, const ReservoirProperties &resprop, const BoundaryConditions &boundary)
Definition: EulerUpstreamImplicit_impl.hpp:98
Class for doing simple transport by implicit Euler upstream method for general grid.
Definition: EulerUpstreamImplicit.hpp:60
void init(const Opm::ParameterGroup &param)
Definition: EulerUpstreamImplicit_impl.hpp:74
Definition: ImplicitTransportDefs.hpp:49
EulerUpstreamImplicit()
Definition: EulerUpstreamImplicit_impl.hpp:60
bool transportSolve(std::vector< double > &saturation, const double time, const typename GridInterface::Vector &gravity, const PressureSolution &pressure_sol, const Opm::SparseVector< double > &injection_rates) const
Solve transport equation, evolving.