Line data Source code
1 : //* This file is part of the MOOSE framework 2 : //* https://mooseframework.inl.gov 3 : //* 4 : //* All rights reserved, see COPYRIGHT for full restrictions 5 : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT 6 : //* 7 : //* Licensed under LGPL 2.1, please see LICENSE for details 8 : //* https://www.gnu.org/licenses/lgpl-2.1.html 9 : 10 : #include "ReferenceResidualInterface.h" 11 : #include "MooseObject.h" 12 : #include "MooseEnum.h" 13 : 14 : InputParameters 15 7477 : ReferenceResidualInterface::validParams() 16 : { 17 7477 : InputParameters params = emptyInputParameters(); 18 : 19 29908 : params.addParam<SolverSystemName>( 20 : "solver_sys", "nl0", "Solver system for which this object applies."); 21 29908 : params.addParam<TagName>( 22 : "residual_vector", 23 : "The tag name of the custom vector tag to use in place of the residual vector. This can be " 24 : "used to provide greater control over which variable is used in absolute and relative " 25 : "tolerancing. If not provided, the full residual vector will be used."); 26 29908 : params.addParam<TagName>("reference_vector", "The tag name of the reference residual vector."); 27 22431 : params.addParam<Real>("acceptable_multiplier", 28 14954 : 1.0, 29 : "Multiplier applied to relative tolerance for acceptable limit"); 30 22431 : params.addParam<unsigned int>( 31 : "acceptable_iterations", 32 14954 : 0, 33 : "Iterations after which convergence to acceptable limits is accepted"); 34 29908 : params.addParam<std::vector<std::vector<NonlinearVariableName>>>( 35 : "group_variables", 36 : "Name of variables that are grouped together to check convergence. (Multiple groups can be " 37 : "provided, separated by semicolon)"); 38 29908 : params.addParam<std::vector<NonlinearVariableName>>( 39 : "converge_on", 40 : {}, 41 : "If supplied, use only these variables in the individual variable convergence check"); 42 22431 : params.addParam<bool>("unscale_the_residual", 43 14954 : false, 44 : "If set to true, utilize the variable specific residual scalar to unscale " 45 : "the residual before comparing against the absolute tolerance. This will " 46 : "also print the un-scaled residual to console. This will not change the " 47 : "relative tolerance check except for console output"); 48 29908 : MooseEnum Lnorm("global_L2 local_L2 global_Linf local_Linf", "global_L2"); 49 29908 : params.addParam<MooseEnum>( 50 : "normalization_type", 51 : Lnorm, 52 : "The normalization type used to compare the reference and actual residuals."); 53 29908 : Lnorm.addDocumentation("global_L2", 54 : "Compare the L2 norm of the residual vector to the L2 norm of the " 55 : "absolute reference vector to determine relative convergence"); 56 29908 : Lnorm.addDocumentation( 57 : "local_L2", 58 : "Compute the L2 norm of the residual vector divided component-wise by the absolute reference " 59 : "vector to the L2 norm of the absolute reference vector to determine relative convergence"); 60 29908 : Lnorm.addDocumentation( 61 : "global_Linf", 62 : "Compare the L-infinity norm of the residual vector to the L-infinity norm of the " 63 : "absolute reference vector to determine relative convergence"); 64 29908 : Lnorm.addDocumentation( 65 : "local_Linf", 66 : "Compute the L-infinity norm of the residual vector divided component-wise " 67 : "by the absolute reference " 68 : "vector to the L-infinity norm of the absolute reference vector to " 69 : "determine relative convergence"); 70 : 71 29908 : MooseEnum zero_ref_res("zero_tolerance relative_tolerance", "relative_tolerance"); 72 29908 : params.addParam<MooseEnum>("zero_reference_residual_treatment", 73 : zero_ref_res, 74 : "Determine behavior if a reference residual value of zero is present " 75 : "for a particular variable."); 76 29908 : zero_ref_res.addDocumentation("zero_tolerance", 77 : "Solve is treated as converged if the residual is zero"); 78 29908 : zero_ref_res.addDocumentation( 79 : "relative_tolerance", 80 : "Solve is treated as converged if the residual is below the relative tolerance"); 81 : 82 29908 : params.addParamNamesToGroup("acceptable_iterations acceptable_multiplier", 83 : "Acceptable convergence"); 84 29908 : params.addParamNamesToGroup("reference_vector", "Reference residual"); 85 22431 : params.addParamNamesToGroup("group_variables", "Variables to check for convergence"); 86 : 87 14954 : return params; 88 7477 : } 89 : 90 707 : ReferenceResidualInterface::ReferenceResidualInterface(const MooseObject * moose_object) 91 707 : : _use_group_variables(false) 92 : { 93 2121 : if (moose_object->isParamValid("group_variables")) 94 : { 95 : _group_variables = 96 82 : moose_object->getParam<std::vector<std::vector<NonlinearVariableName>>>("group_variables"); 97 41 : _use_group_variables = true; 98 : } 99 707 : }