https://mooseframework.inl.gov
Loading...
Searching...
No Matches
ReferenceResidualConvergence.h
Go to the documentation of this file.
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#pragma once
11
14
15// PETSc includes
16#include <petsc.h>
17#include <petscmat.h>
18
19#include "libmesh/enum_norm_type.h"
20
26{
27public:
29
31
34
35 virtual void initialSetup() override;
36
43
46
47protected:
48 virtual NonlinearSystemBase & nonlinearSystem() override;
49
50 virtual void nonlinearConvergenceSetup() override;
51
52 virtual bool checkResidualConvergence(const unsigned int n_iter,
53 const Real fnorm,
54 const Real ref_norm,
55 const Real rel_tol,
56 const Real abs_tol,
57 std::ostringstream & oss) override;
58
71 bool checkConvergenceIndividVars(const Real fnorm,
72 const Real abs_tol,
73 const Real rel_tol,
74 const Real initial_residual_before_preset_bcs);
75
78
82 std::vector<NonlinearVariableName> _soln_var_names;
83 std::vector<AuxVariableName> _ref_resid_var_names;
85
88 std::vector<NonlinearVariableName> _group_names;
90
93 std::vector<unsigned int> _soln_vars;
94 std::vector<unsigned int> _ref_resid_vars;
96
101 const Real _accept_mult;
102 const unsigned int _accept_iters;
104
106 const unsigned int _nl_sys_num;
107
110 std::vector<Real> _group_ref_resid;
111 std::vector<Real> _group_resid;
113
115 std::vector<bool> _is_var_grouped;
116
118 std::vector<unsigned int> _group_index;
119
121 std::vector<Real> _scaling_factors;
122
124 const NumericVector<Number> * _residual_vector;
125
127 const NumericVector<Number> * _reference_vector;
128
130 std::vector<bool> _converge_on_var;
131 std::vector<bool> _converge_on_group;
132
135
138
141
144
147};
unsigned int TagID
Definition MooseTypes.h:238
Default nonlinear convergence criteria for FEProblem.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
const InputParameters & parameters() const
Get the parameters of the object.
Definition MooseBase.h:131
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition MooseEnum.h:55
Nonlinear system to be solved.
Uses a reference residual to define relative convergence criteria.
virtual void nonlinearConvergenceSetup() override
Performs setup necessary for each call to checkConvergence.
bool checkConvergenceIndividVars(const Real fnorm, const Real abs_tol, const Real rel_tol, const Real initial_residual_before_preset_bcs)
Check the convergence by comparing the norm of each variable's residual separately against its refere...
ZeroReferenceType
Container for convergence treatment when the reference residual is zero.
virtual bool checkResidualConvergence(const unsigned int n_iter, const Real fnorm, const Real ref_norm, const Real rel_tol, const Real abs_tol, std::ostringstream &oss) override
Check the absolute and relative convergence of the nonlinear solution.
std::vector< AuxVariableName > _ref_resid_var_names
enum ReferenceResidualConvergence::ZeroReferenceType _zero_ref_type
std::vector< bool > _is_var_grouped
Vector of bools to signify if variable is in a group.
const NumericVector< Number > * _reference_vector
The vector storing the reference residual values.
std::vector< unsigned int > _soln_vars
const bool _unscale_the_residual
Bool to unscale the residual before convergence checks and screen output.
const MooseEnum _norm_type_enum
Enum holding the normalization type.
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job.
void updateReferenceResidual()
Computes the reference residuals for each group.
const unsigned int _nl_sys_num
Nonlinear system to which this convergence object applies.
virtual NonlinearSystemBase & nonlinearSystem() override
Nonlinear system whose convergence state should be checked.
TagID referenceVectorTagID(ReferenceVectorTagIDKey) const
Returns the tag ID associated with the reference vector tag ID key.
libMesh::FEMNormType _norm_type
Container for normalization type.
std::vector< NonlinearVariableName > _group_names
std::vector< unsigned int > _group_index
Group number index for each variable.
std::vector< Real > _scaling_factors
Local storage for the scaling factors applied to each of the variables to apply to _ref_resid_vars.
std::vector< unsigned int > _ref_resid_vars
std::vector< bool > _converge_on_var
Flag for each solution variable or group being in 'converge_on'.
const NumericVector< Number > * _residual_vector
The optional vector storing the reference residual values.
TagID _reference_vector_tag_id
The reference vector tag id.
bool _local_norm
Flag to optionally perform normalization of residual by reference residual before or after L2 norm is...
std::vector< NonlinearVariableName > _soln_var_names
Interface class shared between ReferenceResidualProblem and ReferenceResidualConvergence.