EulerUpstreamResidual.hpp
Go to the documentation of this file.
1 //===========================================================================
2 //
3 // File: EulerUpstreamResidual.hpp
4 //
5 // Created: Thu May 6 11:14:23 2010
6 //
7 // Author(s): Atgeirr F Rasmussen <atgeirr@sintef.no>
8 // Jostein R Natvig <jostein.r.natvig@sintef.no>
9 //
10 // $Date$
11 //
12 // $Revision$
13 //
14 //===========================================================================
15 
16 /*
17  Copyright 2010 SINTEF ICT, Applied Mathematics.
18  Copyright 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_EULERUPSTREAMRESIDUAL_HEADER
37 #define OPENRS_EULERUPSTREAMRESIDUAL_HEADER
38 
39 
40 
41 #include <boost/unordered_map.hpp>
42 
43 #include <opm/core/utility/parameters/ParameterGroup.hpp>
44 #include <opm/core/utility/SparseVector.hpp>
45 
46 
47 namespace Opm {
48 
49  namespace EulerUpstreamResidualDetails {
50  // Forward declaration for friendship purposes.
51  template <class UpstreamSolver, class PressureSolution>
52  struct UpdateForCell;
53  }
54 
55 
58  template <class GridInterface, class ReservoirProperties, class BoundaryConditions>
60  {
61  public:
62  template <class S, class P>
64  typedef typename GridInterface::CellIterator CIt;
65  typedef typename CIt::FaceIterator FIt;
66  typedef typename FIt::Vector Vector;
67  typedef ReservoirProperties RP;
68 
75  EulerUpstreamResidual(const GridInterface& grid,
76  const ReservoirProperties& resprop,
77  const BoundaryConditions& boundary);
78 
79  void initObj(const GridInterface& grid,
80  const ReservoirProperties& resprop,
81  const BoundaryConditions& boundary);
82 
83 
84  template <class FlowSolution>
85  void computeResidual(const std::vector<double>& saturation,
86  const typename GridInterface::Vector& gravity,
87  const FlowSolution& flow_sol,
88  const Opm::SparseVector<double>& injection_rates,
89  const bool method_viscous,
90  const bool method_gravity,
91  const bool method_capillary,
92  std::vector<double>& sat_delta) const;
93 
94  void computeCapPressures(const std::vector<double>& saturation) const;
95 
96  const GridInterface& grid() const;
97  const ReservoirProperties& reservoirProperties() const;
98  const BoundaryConditions& boundaryConditions() const;
99 
100  private:
101  void initFinal();
102 
103  typename GridInterface::Vector
104  estimateCapPressureGradient(const FIt& f, const FIt& nbf, const std::vector<double>& saturation) const;
105 
106  const GridInterface* pgrid_;
107  const ReservoirProperties* preservoir_properties_;
108  const BoundaryConditions* pboundary_;
109 
110  // Boundary id to face iterator mapping. May be mostly or completely empty.
111  // Obviously requires unique-face-per-bid grids.
112  std::vector<FIt> bid_to_face_;
113 
114  // Storing some cell iterators, so that we may use tbb for parallelizing.
115  std::vector<CIt> cell_iters_;
116 
117  // Precomputing the capillary pressures of cells saves a little time.
118  mutable std::vector<double> cap_pressures_;
119  mutable const Opm::SparseVector<double>* pinjection_rates_;
120  mutable bool method_viscous_;
121  mutable bool method_gravity_;
122  mutable bool method_capillary_;
123  };
124 
125 } // namespace Opm
126 
128 
129 
130 #endif // OPENRS_EULERUPSTREAMRESIDUAL_HEADER
void computeCapPressures(const std::vector< double > &saturation) const
Definition: EulerUpstreamResidual_impl.hpp:460
const BoundaryConditions & boundaryConditions() const
Definition: EulerUpstreamResidual_impl.hpp:452
void computeResidual(const std::vector< double > &saturation, const typename GridInterface::Vector &gravity, const FlowSolution &flow_sol, const Opm::SparseVector< double > &injection_rates, const bool method_viscous, const bool method_gravity, const bool method_capillary, std::vector< double > &sat_delta) const
Definition: BlackoilFluid.hpp:31
const GridInterface & grid() const
Definition: EulerUpstreamResidual_impl.hpp:437
GridInterface::CellIterator CIt
Definition: EulerUpstreamResidual.hpp:64
CIt::FaceIterator FIt
Definition: EulerUpstreamResidual.hpp:65
Definition: EulerUpstreamResidual.hpp:59
EulerUpstreamResidual()
Definition: EulerUpstreamResidual_impl.hpp:371
const ReservoirProperties & reservoirProperties() const
Definition: EulerUpstreamResidual_impl.hpp:445
ReservoirProperties RP
Definition: EulerUpstreamResidual.hpp:67
void initObj(const GridInterface &grid, const ReservoirProperties &resprop, const BoundaryConditions &boundary)
Definition: EulerUpstreamResidual_impl.hpp:391
Definition: EulerUpstreamResidual.hpp:52
FIt::Vector Vector
Definition: EulerUpstreamResidual.hpp:66