TofDiscGalReorder.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_TOFDISCGALREORDER_HEADER_INCLUDED
21#define OPM_TOFDISCGALREORDER_HEADER_INCLUDED
22
24#include <memory>
25#include <vector>
26#include <map>
27#include <ostream>
28
29struct UnstructuredGrid;
30
31namespace Opm
32{
33
34 class IncompPropertiesInterface;
35 class ParameterGroup;
36 class VelocityInterpolationInterface;
37 class DGBasisInterface;
38 template <typename T> class SparseTable;
39
50 {
51 public:
74 TofDiscGalReorder(const UnstructuredGrid& grid,
75 const ParameterGroup& param);
76
77
90 void solveTof(const double* darcyflux,
91 const double* porevolume,
92 const double* source,
93 std::vector<double>& tof_coeff);
94
113 void solveTofTracer(const double* darcyflux,
114 const double* porevolume,
115 const double* source,
116 const SparseTable<int>& tracerheads,
117 std::vector<double>& tof_coeff,
118 std::vector<double>& tracer_coeff);
119
120 private:
121 virtual void solveSingleCell(const int cell);
122 virtual void solveMultiCell(const int num_cells, const int* cells);
123
124 void cellContribs(const int cell);
125 void faceContribs(const int cell);
126 void solveLinearSystem(const int cell);
127
128 private:
129 // Disable copying and assignment.
131 TofDiscGalReorder& operator=(const TofDiscGalReorder&);
132
133 // Data members
134 const UnstructuredGrid& grid_;
135 std::shared_ptr<VelocityInterpolationInterface> velocity_interpolation_;
136 bool use_cvi_;
137 bool use_limiter_;
138 double limiter_relative_flux_threshold_;
139 enum LimiterMethod { MinUpwindFace, MinUpwindAverage };
140 LimiterMethod limiter_method_;
141 enum LimiterUsage { DuringComputations, AsPostProcess, AsSimultaneousPostProcess };
142 LimiterUsage limiter_usage_;
143 const double* darcyflux_; // one flux per grid face
144 const double* porevolume_; // one volume per cell
145 const double* source_; // one volumetric source term per cell
146 std::shared_ptr<DGBasisInterface> basis_func_;
147 double* tof_coeff_;
148 // For tracers.
149 double* tracer_coeff_;
150 int num_tracers_;
151 enum { NoTracerHead = -1 };
152 std::vector<int> tracerhead_by_cell_;
153 bool tracers_ensure_unity_;
154 // Used by solveSingleCell().
155 std::vector<double> rhs_; // single-cell right-hand-sides
156 std::vector<double> jac_; // single-cell jacobian
157 std::vector<double> orig_rhs_; // single-cell right-hand-sides (copy)
158 std::vector<double> orig_jac_; // single-cell jacobian (copy)
159 std::vector<double> coord_;
160 mutable std::vector<double> basis_;
161 mutable std::vector<double> basis_nb_;
162 std::vector<double> grad_basis_;
163 std::vector<double> velocity_;
164 int num_singlesolves_;
165 // Used by solveMultiCell():
166 double gauss_seidel_tol_;
167 int num_multicell_;
168 int max_size_multicell_;
169 int max_iter_multicell_;
170
171 // Private methods
172
173 // Apply some limiter, writing to array tof
174 // (will read data from tof_coeff_, it is ok to call
175 // with tof_coeff as tof argument.
176 void applyLimiter(const int cell, double* tof);
177 void applyMinUpwindLimiter(const int cell, const bool face_min, double* tof);
178 void applyLimiterAsPostProcess();
179 void applyLimiterAsSimultaneousPostProcess();
180 double totalFlux(const int cell) const;
181 double minCornerVal(const int cell, const int face) const;
182
183 // Apply a simple (restrict to [0,1]) limiter.
184 // Intended for tracers.
185 void applyTracerLimiter(const int cell, double* local_coeff);
186 };
187
188} // namespace Opm
189
190#endif // OPM_TRANSPORTMODELTRACERTOFDISCGAL_HEADER_INCLUDED
Definition: ReorderSolverInterface.hpp:39
Definition: TofDiscGalReorder.hpp:38
Definition: TofDiscGalReorder.hpp:50
void solveTof(const double *darcyflux, const double *porevolume, const double *source, std::vector< double > &tof_coeff)
TofDiscGalReorder(const UnstructuredGrid &grid, const ParameterGroup &param)
void solveTofTracer(const double *darcyflux, const double *porevolume, const double *source, const SparseTable< int > &tracerheads, std::vector< double > &tof_coeff, std::vector< double > &tracer_coeff)
Definition: AnisotropicEikonal.hpp:44