My Project
EulerUpstream.hpp
1 //===========================================================================
2 //
3 // File: EulerUpstream.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_EULERUPSTREAM_HEADER
37 #define OPENRS_EULERUPSTREAM_HEADER
38 
39 #include <opm/porsol/euler/EulerUpstreamResidual.hpp>
40 
41 #include <opm/common/utility/parameters/ParameterGroup.hpp>
42 #include <opm/common/utility/numeric/SparseVector.hpp>
43 
44 
45 namespace Opm {
46 
49  template <class GridInterface, class ReservoirProperties, class BoundaryConditions>
51  {
52  public:
55  EulerUpstream();
59  EulerUpstream(const GridInterface& grid,
60  const ReservoirProperties& resprop,
61  const BoundaryConditions& boundary);
65  void init(const Opm::ParameterGroup& param);
69  void init(const Opm::ParameterGroup& param,
70  const GridInterface& grid,
71  const ReservoirProperties& resprop,
72  const BoundaryConditions& boundary);
76  void initObj(const GridInterface& grid,
77  const ReservoirProperties& resprop,
78  const BoundaryConditions& boundary);
82  void display();
83 
87  void setCourantNumber(double cn);
88 
95  template <class PressureSolution>
96  void transportSolve(std::vector<double>& saturation,
97  const double time,
98  const typename GridInterface::Vector& gravity,
99  const PressureSolution& pressure_sol,
100  const Opm::SparseVector<double>& injection_rates) const;
101 
102  protected:
103  typedef typename GridInterface::CellIterator CIt;
104  typedef typename CIt::FaceIterator FIt;
105  typedef typename FIt::Vector Vector;
106 
107 
108  template <class PressureSolution>
109  double computeCflTime(const std::vector<double>& saturation,
110  const double time,
111  const typename GridInterface::Vector& gravity,
112  const PressureSolution& pressure_sol) const;
113 
114  template <class PressureSolution>
115  void smallTimeStep(std::vector<double>& saturation,
116  const double time,
117  const typename GridInterface::Vector& gravity,
118  const PressureSolution& pressure_sol,
119  const Opm::SparseVector<double>& injection_rates) const;
120 
121  void checkAndPossiblyClampSat(std::vector<double>& s) const;
122 
123 
124  EulerUpstreamResidual<GridInterface,
125  ReservoirProperties,
126  BoundaryConditions> residual_computer_;
127 
128  bool method_viscous_;
129  bool method_gravity_;
130  bool method_capillary_;
131  bool use_cfl_viscous_;
132  bool use_cfl_gravity_;
133  bool use_cfl_capillary_;
134  // The courant_number is the multiplied with the cfl time to get the time step.
135  double courant_number_;
136  int minimum_small_steps_;
137  int maximum_small_steps_;
138  bool check_sat_;
139  bool clamp_sat_;
140  std::vector<double> porevol_;
141 
142  // Storing residual so that we won't have to reallocate it for every step.
143  mutable std::vector<double> residual_;
144  };
145 
146 } // namespace Opm
147 
148 #include "EulerUpstream_impl.hpp"
149 
150 #endif // OPENRS_EULERUPSTREAM_HEADER
Class for doing simple transport by explicit Euler upstream method for general grid.
Definition: EulerUpstreamResidual.hpp:58
Class for doing simple transport by explicit Euler upstream method for general grid.
Definition: EulerUpstream.hpp:51
void 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.
void setCourantNumber(double cn)
Set the Courant number.
Definition: EulerUpstream_impl.hpp:144
void initObj(const GridInterface &grid, const ReservoirProperties &resprop, const BoundaryConditions &boundary)
Definition: EulerUpstream_impl.hpp:120
EulerUpstream()
Definition: EulerUpstream_impl.hpp:60
EulerUpstream(const GridInterface &grid, const ReservoirProperties &resprop, const BoundaryConditions &boundary)
void display()
Definition: EulerUpstream_impl.hpp:132
void init(const Opm::ParameterGroup &param)
Definition: EulerUpstream_impl.hpp:95
void init(const Opm::ParameterGroup &param, const GridInterface &grid, const ReservoirProperties &resprop, const BoundaryConditions &boundary)
Inverting small matrices.
Definition: ImplicitAssembly.hpp:43