238 double linear_solver_reduction_;
239 double relaxed_linear_solver_reduction_;
240 int linear_solver_maxiter_;
241 int linear_solver_restart_;
242 int linear_solver_verbosity_;
243 double ilu_relaxation_;
244 int ilu_fillin_level_;
247 bool ilu_reorder_sphere_;
248 bool newton_use_gmres_;
249 bool ignoreConvergenceFailure_;
250 bool scale_linear_system_;
251 std::string linsolver_;
252 bool linear_solver_print_json_definition_;
253 int cpr_reuse_setup_;
254 int cpr_reuse_interval_;
255 std::string accelerator_mode_;
257 int opencl_platform_id_;
258 bool opencl_ilu_parallel_;
260 template <
class TypeTag>
261 void init(
bool cprRequestedInDataFile)
264 linear_solver_reduction_ = Parameters::get<TypeTag, Properties::LinearSolverReduction>();
265 relaxed_linear_solver_reduction_ = Parameters::get<TypeTag, Properties::RelaxedLinearSolverReduction>();
266 linear_solver_maxiter_ = Parameters::get<TypeTag, Properties::LinearSolverMaxIter>();
267 linear_solver_restart_ = Parameters::get<TypeTag, Properties::LinearSolverRestart>();
268 linear_solver_verbosity_ = Parameters::get<TypeTag, Properties::LinearSolverVerbosity>();
269 ilu_relaxation_ = Parameters::get<TypeTag, Properties::IluRelaxation>();
270 ilu_fillin_level_ = Parameters::get<TypeTag, Properties::IluFillinLevel>();
271 ilu_milu_ = convertString2Milu(Parameters::get<TypeTag, Properties::MiluVariant>());
272 ilu_redblack_ = Parameters::get<TypeTag, Properties::IluRedblack>();
273 ilu_reorder_sphere_ = Parameters::get<TypeTag, Properties::IluReorderSpheres>();
274 newton_use_gmres_ = Parameters::get<TypeTag, Properties::UseGmres>();
275 ignoreConvergenceFailure_ = Parameters::get<TypeTag, Properties::LinearSolverIgnoreConvergenceFailure>();
276 scale_linear_system_ = Parameters::get<TypeTag, Properties::ScaleLinearSystem>();
277 linsolver_ = Parameters::get<TypeTag, Properties::LinearSolver>();
278 linear_solver_print_json_definition_ = Parameters::get<TypeTag, Properties::LinearSolverPrintJsonDefinition>();
279 cpr_reuse_setup_ = Parameters::get<TypeTag, Properties::CprReuseSetup>();
280 cpr_reuse_interval_ = Parameters::get<TypeTag, Properties::CprReuseInterval>();
282 if (!Parameters::isSet<TypeTag, Properties::LinearSolver>() && cprRequestedInDataFile) {
285 linsolver_ = Parameters::get<TypeTag, Properties::LinearSolver>();
288 accelerator_mode_ = Parameters::get<TypeTag, Properties::AcceleratorMode>();
289 bda_device_id_ = Parameters::get<TypeTag, Properties::BdaDeviceId>();
290 opencl_platform_id_ = Parameters::get<TypeTag, Properties::OpenclPlatformId>();
291 opencl_ilu_parallel_ = Parameters::get<TypeTag, Properties::OpenclIluParallel>();
294 template <
class TypeTag>
295 static void registerParameters()
297 Parameters::registerParam<TypeTag, Properties::LinearSolverReduction>
298 (
"The minimum reduction of the residual which the linear solver must achieve");
299 Parameters::registerParam<TypeTag, Properties::RelaxedLinearSolverReduction>
300 (
"The minimum reduction of the residual which the linear solver need to "
301 "achieve for the solution to be accepted");
302 Parameters::registerParam<TypeTag, Properties::LinearSolverMaxIter>
303 (
"The maximum number of iterations of the linear solver");
304 Parameters::registerParam<TypeTag, Properties::LinearSolverRestart>
305 (
"The number of iterations after which GMRES is restarted");
306 Parameters::registerParam<TypeTag, Properties::LinearSolverVerbosity>
307 (
"The verbosity level of the linear solver (0: off, 2: all)");
308 Parameters::registerParam<TypeTag, Properties::IluRelaxation>
309 (
"The relaxation factor of the linear solver's ILU preconditioner");
310 Parameters::registerParam<TypeTag, Properties::IluFillinLevel>
311 (
"The fill-in level of the linear solver's ILU preconditioner");
312 Parameters::registerParam<TypeTag, Properties::MiluVariant>
313 (
"Specify which variant of the modified-ILU preconditioner ought to be used. "
314 "Possible variants are: ILU (default, plain ILU), "
315 "MILU_1 (lump diagonal with dropped row entries), "
316 "MILU_2 (lump diagonal with the sum of the absolute values of the dropped row entries), "
317 "MILU_3 (if diagonal is positive add sum of dropped row entries, otherwise subtract them), "
318 "MILU_4 (if diagonal is positive add sum of dropped row entries, otherwise do nothing");
319 Parameters::registerParam<TypeTag, Properties::IluRedblack>
320 (
"Use red-black partitioning for the ILU preconditioner");
321 Parameters::registerParam<TypeTag, Properties::IluReorderSpheres>
322 (
"Whether to reorder the entries of the matrix in the red-black "
323 "ILU preconditioner in spheres starting at an edge. "
324 "If false the original ordering is preserved in each color. "
325 "Otherwise why try to ensure D4 ordering (in a 2D structured grid, "
326 "the diagonal elements are consecutive).");
327 Parameters::registerParam<TypeTag, Properties::UseGmres>
328 (
"Use GMRES as the linear solver");
329 Parameters::registerParam<TypeTag, Properties::LinearSolverIgnoreConvergenceFailure>
330 (
"Continue with the simulation like nothing happened "
331 "after the linear solver did not converge");
332 Parameters::registerParam<TypeTag, Properties::ScaleLinearSystem>
333 (
"Scale linear system according to equation scale and primary variable types");
334 Parameters::registerParam<TypeTag, Properties::LinearSolver>
335 (
"Configuration of solver. Valid options are: ilu0 (default), "
336 "dilu, cprw, cpr (an alias for cprw), cpr_quasiimpes, "
337 "cpr_trueimpes, cpr_trueimpesanalytic, amg or hybrid (experimental). "
338 "Alternatively, you can request a configuration to be read from a "
339 "JSON file by giving the filename here, ending with '.json.'");
340 Parameters::registerParam<TypeTag, Properties::LinearSolverPrintJsonDefinition>
341 (
"Write the JSON definition of the linear solver setup to the DBG file.");
342 Parameters::registerParam<TypeTag, Properties::CprReuseSetup>
343 (
"Reuse preconditioner setup. Valid options are "
344 "0: recreate the preconditioner for every linear solve, "
345 "1: recreate once every timestep, "
346 "2: recreate if last linear solve took more than 10 iterations, "
347 "3: never recreate, "
348 "4: recreated every CprReuseInterval");
349 Parameters::registerParam<TypeTag, Properties::CprReuseInterval>
350 (
"Reuse preconditioner interval. Used when CprReuseSetup is set to 4, "
351 "then the preconditioner will be fully recreated instead of reused "
352 "every N linear solve, where N is this parameter.");
353 Parameters::registerParam<TypeTag, Properties::AcceleratorMode>
354 (
"Choose a linear solver, usage: "
355 "'--accelerator-mode=[none|cusparse|opencl|amgcl|rocalution|rocsparse]'");
356 Parameters::registerParam<TypeTag, Properties::BdaDeviceId>
357 (
"Choose device ID for cusparseSolver or openclSolver, "
358 "use 'nvidia-smi' or 'clinfo' to determine valid IDs");
359 Parameters::registerParam<TypeTag, Properties::OpenclPlatformId>
360 (
"Choose platform ID for openclSolver, use 'clinfo' "
361 "to determine valid platform IDs");
362 Parameters::registerParam<TypeTag, Properties::OpenclIluParallel>
363 (
"Parallelize ILU decomposition and application on GPU");
371 relaxed_linear_solver_reduction_ = 1e-2;
372 linear_solver_reduction_ = 1e-2;
373 linear_solver_maxiter_ = 200;
374 linear_solver_restart_ = 40;
375 linear_solver_verbosity_ = 0;
376 ilu_relaxation_ = 0.9;
377 ilu_fillin_level_ = 0;
379 ilu_redblack_ =
false;
380 ilu_reorder_sphere_ =
false;
381 newton_use_gmres_ =
false;
382 ignoreConvergenceFailure_ =
false;
383 scale_linear_system_ =
false;
385 linear_solver_print_json_definition_ =
true;
386 cpr_reuse_setup_ = 4;
387 cpr_reuse_interval_ = 30;
388 accelerator_mode_ =
"none";
390 opencl_platform_id_ = 0;
391 opencl_ilu_parallel_ =
true;