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 7439 : ReferenceResidualInterface::validParams() 16 : { 17 7439 : InputParameters params = emptyInputParameters(); 18 : 19 29756 : params.addParam<TagName>( 20 : "residual_vector", 21 : "The tag name of the custom vector tag to use in place of the residual vector. This can be " 22 : "used to provide greater control over which variable is used in absolute and relative " 23 : "tolerancing. If not provided, the full residual vector will be used."); 24 29756 : params.addParam<TagName>("reference_vector", "The tag name of the reference residual vector."); 25 22317 : params.addParam<Real>("acceptable_multiplier", 26 14878 : 1.0, 27 : "Multiplier applied to relative tolerance for acceptable limit"); 28 22317 : params.addParam<unsigned int>( 29 : "acceptable_iterations", 30 14878 : 0, 31 : "Iterations after which convergence to acceptable limits is accepted"); 32 29756 : params.addParam<std::vector<std::vector<NonlinearVariableName>>>( 33 : "group_variables", 34 : "Name of variables that are grouped together to check convergence. (Multiple groups can be " 35 : "provided, separated by semicolon)"); 36 29756 : params.addParam<std::vector<NonlinearVariableName>>( 37 : "converge_on", 38 : {}, 39 : "If supplied, use only these variables in the individual variable convergence check"); 40 22317 : params.addParam<bool>("unscale_the_residual", 41 14878 : false, 42 : "If set to true, utilize the variable specific residual scalar to unscale " 43 : "the residual before comparing against the absolute tolerance. This will " 44 : "also print the un-scaled residual to console. This will not change the " 45 : "relative tolerance check except for console output"); 46 29756 : MooseEnum Lnorm("global_L2 local_L2 global_Linf local_Linf", "global_L2"); 47 29756 : params.addParam<MooseEnum>( 48 : "normalization_type", 49 : Lnorm, 50 : "The normalization type used to compare the reference and actual residuals."); 51 29756 : Lnorm.addDocumentation("global_L2", 52 : "Compare the L2 norm of the residual vector to the L2 norm of the " 53 : "absolute reference vector to determine relative convergence"); 54 29756 : Lnorm.addDocumentation( 55 : "local_L2", 56 : "Compute the L2 norm of the residual vector divided component-wise by the absolute reference " 57 : "vector to the L2 norm of the absolute reference vector to determine relative convergence"); 58 29756 : Lnorm.addDocumentation( 59 : "global_Linf", 60 : "Compare the L-infinity norm of the residual vector to the L-infinity norm of the " 61 : "absolute reference vector to determine relative convergence"); 62 29756 : Lnorm.addDocumentation( 63 : "local_Linf", 64 : "Compute the L-infinity norm of the residual vector divided component-wise " 65 : "by the absolute reference " 66 : "vector to the L-infinity norm of the absolute reference vector to " 67 : "determine relative convergence"); 68 : 69 29756 : MooseEnum zero_ref_res("zero_tolerance relative_tolerance", "relative_tolerance"); 70 29756 : params.addParam<MooseEnum>("zero_reference_residual_treatment", 71 : zero_ref_res, 72 : "Determine behavior if a reference residual value of zero is present " 73 : "for a particular variable."); 74 29756 : zero_ref_res.addDocumentation("zero_tolerance", 75 : "Solve is treated as converged if the residual is zero"); 76 29756 : zero_ref_res.addDocumentation( 77 : "relative_tolerance", 78 : "Solve is treated as converged if the residual is below the relative tolerance"); 79 : 80 29756 : params.addParamNamesToGroup("acceptable_iterations acceptable_multiplier", 81 : "Acceptable convergence"); 82 29756 : params.addParamNamesToGroup("reference_vector", "Reference residual"); 83 22317 : params.addParamNamesToGroup("group_variables", "Variables to check for convergence"); 84 : 85 14878 : return params; 86 7439 : } 87 : 88 687 : ReferenceResidualInterface::ReferenceResidualInterface(const MooseObject * moose_object) 89 687 : : _use_group_variables(false) 90 : { 91 2061 : if (moose_object->isParamValid("group_variables")) 92 : { 93 : _group_variables = 94 62 : moose_object->getParam<std::vector<std::vector<NonlinearVariableName>>>("group_variables"); 95 31 : _use_group_variables = true; 96 : } 97 687 : }