My Project
FlowLinearSolverParameters.hpp
1/*
2 Copyright 2015, 2020 SINTEF Digital, Mathematics and Cybernetics.
3 Copyright 2015 IRIS AS
4 Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
5 Copyright 2015 NTNU
6 Copyright 2015 Statoil AS
7
8 This file is part of the Open Porous Media project (OPM).
9
10 OPM is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation, either version 3 of the License, or
13 (at your option) any later version.
14
15 OPM is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with OPM. If not, see <http://www.gnu.org/licenses/>.
22*/
23
24#ifndef OPM_FLOWLINEARSOLVERPARAMETERS_HEADER_INCLUDED
25#define OPM_FLOWLINEARSOLVERPARAMETERS_HEADER_INCLUDED
26
27#include <opm/simulators/linalg/MILU.hpp>
28
29#include <opm/simulators/linalg/linalgproperties.hh>
30#include <opm/models/utils/parametersystem.hh>
31
32namespace Opm {
33template <class TypeTag>
34class ISTLSolverEbos;
35}
36
37
38namespace Opm::Properties {
39
40namespace TTag {
42}
43
44template<class TypeTag, class MyTypeTag>
46 using type = UndefinedProperty;
47};
48template<class TypeTag, class MyTypeTag>
50 using type = UndefinedProperty;
51};
52template<class TypeTag, class MyTypeTag>
54 using type = UndefinedProperty;
55};
56template<class TypeTag, class MyTypeTag>
58 using type = UndefinedProperty;
59};
60//
61// LinearSolverVerbosity defined in opm-models
62//
63template<class TypeTag, class MyTypeTag>
65 using type = UndefinedProperty;
66};
67template<class TypeTag, class MyTypeTag>
69 using type = UndefinedProperty;
70};
71template<class TypeTag, class MyTypeTag>
73 using type = UndefinedProperty;
74};
75template<class TypeTag, class MyTypeTag>
77 using type = UndefinedProperty;
78};
79template<class TypeTag, class MyTypeTag>
80struct UseGmres {
81 using type = UndefinedProperty;
82};
83template<class TypeTag, class MyTypeTag>
85 using type = UndefinedProperty;
86};
87template<class TypeTag, class MyTypeTag>
89 using type = UndefinedProperty;
90};
91template<class TypeTag, class MyTypeTag>
93 using type = UndefinedProperty;
94};
95template<class TypeTag, class MyTypeTag>
97 using type = UndefinedProperty;
98};
99template<class TypeTag, class MyTypeTag>
101 using type = UndefinedProperty;
102};
103template<class TypeTag, class MyTypeTag>
105 using type = UndefinedProperty;
106};
107template<class TypeTag, class MyTypeTag>
109 using type = UndefinedProperty;
110};
111template<class TypeTag, class MyTypeTag>
113 using type = UndefinedProperty;
114};
115template<class TypeTag, class MyTypeTag>
117 using type = UndefinedProperty;
118};
119template<class TypeTag, class MyTypeTag>
121 using type = UndefinedProperty;
122};
123template<class TypeTag, class MyTypeTag>
125 using type = UndefinedProperty;
126};
127template<class TypeTag, class MyTypeTag>
129 using type = UndefinedProperty;
130};
131template<class TypeTag, class MyTypeTag>
133 using type = UndefinedProperty;
134};
135template<class TypeTag, class MyTypeTag>
137 using type = UndefinedProperty;
138};
139template<class TypeTag>
140struct LinearSolverReduction<TypeTag, TTag::FlowIstlSolverParams> {
141 using type = GetPropType<TypeTag, Scalar>;
142 static constexpr type value = 1e-2;
143};
144template<class TypeTag>
145struct IluRelaxation<TypeTag, TTag::FlowIstlSolverParams> {
146 using type = GetPropType<TypeTag, Scalar>;
147 static constexpr type value = 0.9;
148};
149template<class TypeTag>
150struct LinearSolverMaxIter<TypeTag, TTag::FlowIstlSolverParams> {
151 static constexpr int value = 200;
152};
153template<class TypeTag>
154struct LinearSolverRestart<TypeTag, TTag::FlowIstlSolverParams> {
155 static constexpr int value = 40;
156};
157template<class TypeTag>
158struct LinearSolverVerbosity<TypeTag, TTag::FlowIstlSolverParams> {
159 static constexpr int value = 0;
160};
161template<class TypeTag>
162struct IluFillinLevel<TypeTag, TTag::FlowIstlSolverParams> {
163 static constexpr int value = 0;
164};
165template<class TypeTag>
166struct MiluVariant<TypeTag, TTag::FlowIstlSolverParams> {
167 static constexpr auto value = "ILU";
168};
169template<class TypeTag>
170struct IluRedblack<TypeTag, TTag::FlowIstlSolverParams> {
171 static constexpr bool value = false;
172};
173template<class TypeTag>
174struct IluReorderSpheres<TypeTag, TTag::FlowIstlSolverParams> {
175 static constexpr bool value = false;
176};
177template<class TypeTag>
178struct UseGmres<TypeTag, TTag::FlowIstlSolverParams> {
179 static constexpr bool value = false;
180};
181template<class TypeTag>
182struct LinearSolverRequireFullSparsityPattern<TypeTag, TTag::FlowIstlSolverParams> {
183 static constexpr bool value = false;
184};
185template<class TypeTag>
186struct LinearSolverIgnoreConvergenceFailure<TypeTag, TTag::FlowIstlSolverParams> {
187 static constexpr bool value = false;
188};
189template<class TypeTag>
190struct LinearSolverBackend<TypeTag, TTag::FlowIstlSolverParams> {
192};
193template<class TypeTag>
194struct PreconditionerAddWellContributions<TypeTag, TTag::FlowIstlSolverParams> {
195 static constexpr bool value = false;
196};
197template<class TypeTag>
198struct ScaleLinearSystem<TypeTag, TTag::FlowIstlSolverParams> {
199 static constexpr bool value = false;
200};
201template<class TypeTag>
202struct CprMaxEllIter<TypeTag, TTag::FlowIstlSolverParams> {
203 static constexpr int value = 20;
204};
205template<class TypeTag>
206struct CprEllSolvetype<TypeTag, TTag::FlowIstlSolverParams> {
207 static constexpr int value = 0;
208};
209template<class TypeTag>
210struct CprReuseSetup<TypeTag, TTag::FlowIstlSolverParams> {
211 static constexpr int value = 3;
212};
213template<class TypeTag>
214struct CprReuseInterval<TypeTag, TTag::FlowIstlSolverParams> {
215 static constexpr int value = 10;
216};
217template<class TypeTag>
218struct LinearSolver<TypeTag, TTag::FlowIstlSolverParams> {
219 static constexpr auto value = "ilu0";
220};
221template<class TypeTag>
222struct AcceleratorMode<TypeTag, TTag::FlowIstlSolverParams> {
223 static constexpr auto value = "none";
224};
225template<class TypeTag>
226struct BdaDeviceId<TypeTag, TTag::FlowIstlSolverParams> {
227 static constexpr int value = 0;
228};
229template<class TypeTag>
230struct OpenclPlatformId<TypeTag, TTag::FlowIstlSolverParams> {
231 static constexpr int value = 0;
232};
233template<class TypeTag>
234struct OpenclIluReorder<TypeTag, TTag::FlowIstlSolverParams> {
235 static constexpr auto value = ""; // note: default value is chosen depending on the solver used
236};
237template<class TypeTag>
238struct FpgaBitstream<TypeTag, TTag::FlowIstlSolverParams> {
239 static constexpr auto value = "";
240};
241
242} // namespace Opm::Properties
243
244namespace Opm
245{
246
247
250 {
251 double linear_solver_reduction_;
252 double ilu_relaxation_;
253 int linear_solver_maxiter_;
254 int linear_solver_restart_;
255 int linear_solver_verbosity_;
256 int ilu_fillin_level_;
257 MILU_VARIANT ilu_milu_;
258 bool ilu_redblack_;
259 bool ilu_reorder_sphere_;
260 bool newton_use_gmres_;
261 bool require_full_sparsity_pattern_;
262 bool ignoreConvergenceFailure_;
263 bool scale_linear_system_;
264 std::string linsolver_;
265 std::string accelerator_mode_;
266 int bda_device_id_;
267 int opencl_platform_id_;
268 int cpr_max_ell_iter_;
269 int cpr_reuse_setup_;
270 int cpr_reuse_interval_;
271 std::string opencl_ilu_reorder_;
272 std::string fpga_bitstream_;
273
274 template <class TypeTag>
275 void init()
276 {
277 // TODO: these parameters have undocumented non-trivial dependencies
278 linear_solver_reduction_ = EWOMS_GET_PARAM(TypeTag, double, LinearSolverReduction);
279 ilu_relaxation_ = EWOMS_GET_PARAM(TypeTag, double, IluRelaxation);
280 linear_solver_maxiter_ = EWOMS_GET_PARAM(TypeTag, int, LinearSolverMaxIter);
281 linear_solver_restart_ = EWOMS_GET_PARAM(TypeTag, int, LinearSolverRestart);
282 linear_solver_verbosity_ = EWOMS_GET_PARAM(TypeTag, int, LinearSolverVerbosity);
283 ilu_fillin_level_ = EWOMS_GET_PARAM(TypeTag, int, IluFillinLevel);
284 ilu_milu_ = convertString2Milu(EWOMS_GET_PARAM(TypeTag, std::string, MiluVariant));
285 ilu_redblack_ = EWOMS_GET_PARAM(TypeTag, bool, IluRedblack);
286 ilu_reorder_sphere_ = EWOMS_GET_PARAM(TypeTag, bool, IluReorderSpheres);
287 newton_use_gmres_ = EWOMS_GET_PARAM(TypeTag, bool, UseGmres);
288 require_full_sparsity_pattern_ = EWOMS_GET_PARAM(TypeTag, bool, LinearSolverRequireFullSparsityPattern);
289 ignoreConvergenceFailure_ = EWOMS_GET_PARAM(TypeTag, bool, LinearSolverIgnoreConvergenceFailure);
290 scale_linear_system_ = EWOMS_GET_PARAM(TypeTag, bool, ScaleLinearSystem);
291 cpr_max_ell_iter_ = EWOMS_GET_PARAM(TypeTag, int, CprMaxEllIter);
292 cpr_reuse_setup_ = EWOMS_GET_PARAM(TypeTag, int, CprReuseSetup);
293 cpr_reuse_interval_ = EWOMS_GET_PARAM(TypeTag, int, CprReuseInterval);
294 linsolver_ = EWOMS_GET_PARAM(TypeTag, std::string, LinearSolver);
295 accelerator_mode_ = EWOMS_GET_PARAM(TypeTag, std::string, AcceleratorMode);
296 bda_device_id_ = EWOMS_GET_PARAM(TypeTag, int, BdaDeviceId);
297 opencl_platform_id_ = EWOMS_GET_PARAM(TypeTag, int, OpenclPlatformId);
298 opencl_ilu_reorder_ = EWOMS_GET_PARAM(TypeTag, std::string, OpenclIluReorder);
299 fpga_bitstream_ = EWOMS_GET_PARAM(TypeTag, std::string, FpgaBitstream);
300 }
301
302 template <class TypeTag>
303 static void registerParameters()
304 {
305 EWOMS_REGISTER_PARAM(TypeTag, double, LinearSolverReduction, "The minimum reduction of the residual which the linear solver must achieve");
306 EWOMS_REGISTER_PARAM(TypeTag, double, IluRelaxation, "The relaxation factor of the linear solver's ILU preconditioner");
307 EWOMS_REGISTER_PARAM(TypeTag, int, LinearSolverMaxIter, "The maximum number of iterations of the linear solver");
308 EWOMS_REGISTER_PARAM(TypeTag, int, LinearSolverRestart, "The number of iterations after which GMRES is restarted");
309 EWOMS_REGISTER_PARAM(TypeTag, int, LinearSolverVerbosity, "The verbosity level of the linear solver (0: off, 2: all)");
310 EWOMS_REGISTER_PARAM(TypeTag, int, IluFillinLevel, "The fill-in level of the linear solver's ILU preconditioner");
311 EWOMS_REGISTER_PARAM(TypeTag, std::string, MiluVariant, "Specify which variant of the modified-ILU preconditioner ought to be used. Possible variants are: ILU (default, plain ILU), MILU_1 (lump diagonal with dropped row entries), MILU_2 (lump diagonal with the sum of the absolute values of the dropped row entries), MILU_3 (if diagonal is positive add sum of dropped row entrires. Otherwise subtract them), MILU_4 (if diagonal is positive add sum of dropped row entrires. Otherwise do nothing");
312 EWOMS_REGISTER_PARAM(TypeTag, bool, IluRedblack, "Use red-black partitioning for the ILU preconditioner");
313 EWOMS_REGISTER_PARAM(TypeTag, bool, IluReorderSpheres, "Whether to reorder the entries of the matrix in the red-black ILU preconditioner in spheres starting at an edge. If false the original ordering is preserved in each color. Otherwise why try to ensure D4 ordering (in a 2D structured grid, the diagonal elements are consecutive).");
314 EWOMS_REGISTER_PARAM(TypeTag, bool, UseGmres, "Use GMRES as the linear solver");
315 EWOMS_REGISTER_PARAM(TypeTag, bool, LinearSolverRequireFullSparsityPattern, "Produce the full sparsity pattern for the linear solver");
316 EWOMS_REGISTER_PARAM(TypeTag, bool, LinearSolverIgnoreConvergenceFailure, "Continue with the simulation like nothing happened after the linear solver did not converge");
317 EWOMS_REGISTER_PARAM(TypeTag, bool, ScaleLinearSystem, "Scale linear system according to equation scale and primary variable types");
318 EWOMS_REGISTER_PARAM(TypeTag, int, CprMaxEllIter, "MaxIterations of the elliptic pressure part of the cpr solver");
319 EWOMS_REGISTER_PARAM(TypeTag, int, CprReuseSetup, "Reuse preconditioner setup. Valid options are 0: recreate the preconditioner for every linear solve, 1: recreate once every timestep, 2: recreate if last linear solve took more than 10 iterations, 3: never recreate, 4: recreated every CprReuseInterval");
320 EWOMS_REGISTER_PARAM(TypeTag, int, CprReuseInterval, "Reuse preconditioner interval. Used when CprReuseSetup is set to 4, then the preconditioner will be fully recreated instead of reused every N linear solve, where N is this parameter.");
321 EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolver, "Configuration of solver. Valid options are: ilu0 (default), cpr (an alias for cpr_trueimpes), cpr_quasiimpes, cpr_trueimpes or amg. Alternatively, you can request a configuration to be read from a JSON file by giving the filename here, ending with '.json.'");
322 EWOMS_REGISTER_PARAM(TypeTag, std::string, AcceleratorMode, "Use GPU (cusparseSolver or openclSolver) or FPGA (fpgaSolver) as the linear solver, usage: '--accelerator-mode=[none|cusparse|opencl|fpga|amgcl]'");
323 EWOMS_REGISTER_PARAM(TypeTag, int, BdaDeviceId, "Choose device ID for cusparseSolver or openclSolver, use 'nvidia-smi' or 'clinfo' to determine valid IDs");
324 EWOMS_REGISTER_PARAM(TypeTag, int, OpenclPlatformId, "Choose platform ID for openclSolver, use 'clinfo' to determine valid platform IDs");
325 EWOMS_REGISTER_PARAM(TypeTag, std::string, OpenclIluReorder, "Choose the reordering strategy for ILU for openclSolver and fpgaSolver, usage: '--opencl-ilu-reorder=[level_scheduling|graph_coloring], level_scheduling behaves like Dune and cusparse, graph_coloring is more aggressive and likely to be faster, but is random-based and generally increases the number of linear solves and linear iterations significantly.");
326 EWOMS_REGISTER_PARAM(TypeTag, std::string, FpgaBitstream, "Specify the bitstream file for fpgaSolver (including path), usage: '--fpga-bitstream=<filename>'");
327 }
328
329 FlowLinearSolverParameters() { reset(); }
330
331 // set default values
332 void reset()
333 {
334 newton_use_gmres_ = false;
335 linear_solver_reduction_ = 1e-2;
336 linear_solver_maxiter_ = 150;
337 linear_solver_restart_ = 40;
338 linear_solver_verbosity_ = 0;
339 require_full_sparsity_pattern_ = false;
340 ignoreConvergenceFailure_ = false;
341 ilu_fillin_level_ = 0;
342 ilu_relaxation_ = 0.9;
343 ilu_milu_ = MILU_VARIANT::ILU;
344 ilu_redblack_ = false;
345 ilu_reorder_sphere_ = true;
346 accelerator_mode_ = "none";
347 bda_device_id_ = 0;
348 opencl_platform_id_ = 0;
349 opencl_ilu_reorder_ = ""; // note: the default value is chosen depending on the solver used
350 fpga_bitstream_ = "";
351 }
352 };
353
354
355} // namespace Opm
356
357
358
359
360#endif // OPM_FLOWLINEARSOLVERPARAMETERS_HEADER_INCLUDED
This class solves the fully implicit black-oil system by solving the reduced system (after eliminatin...
Definition: ISTLSolverEbos.hpp:197
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27
MILU_VARIANT
Definition: MILU.hpp:34
@ ILU
Do not perform modified ILU.
This class carries all parameters for the NewtonIterationBlackoilInterleaved class.
Definition: FlowLinearSolverParameters.hpp:250
Definition: FlowLinearSolverParameters.hpp:120
Definition: FlowLinearSolverParameters.hpp:124
Definition: FlowLinearSolverParameters.hpp:104
Definition: FlowLinearSolverParameters.hpp:100
Definition: FlowLinearSolverParameters.hpp:112
Definition: FlowLinearSolverParameters.hpp:108
Definition: FlowLinearSolverParameters.hpp:136
Definition: FlowLinearSolverParameters.hpp:64
Definition: FlowLinearSolverParameters.hpp:72
Definition: FlowLinearSolverParameters.hpp:49
Definition: FlowLinearSolverParameters.hpp:76
Definition: FlowLinearSolverParameters.hpp:88
Definition: FlowLinearSolverParameters.hpp:53
Definition: FlowLinearSolverParameters.hpp:45
Definition: FlowLinearSolverParameters.hpp:84
Definition: FlowLinearSolverParameters.hpp:57
Definition: FlowLinearSolverParameters.hpp:116
Definition: FlowLinearSolverParameters.hpp:68
Definition: FlowLinearSolverParameters.hpp:132
Definition: FlowLinearSolverParameters.hpp:128
Definition: FlowLinearSolverParameters.hpp:92
Definition: FlowLinearSolverParameters.hpp:96
Definition: FlowLinearSolverParameters.hpp:41
Definition: FlowLinearSolverParameters.hpp:80