https://mooseframework.inl.gov
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 {
27 public:
29 
31 
34 
35  virtual void initialSetup() override;
36 
37  enum class NormalizationType
38  {
39  GLOBAL_L2 = 0,
40  LOCAL_L2 = 1,
41  GLOBAL_LINF = 2,
42  LOCAL_LINF = 3
43  };
44 
46  {
47  friend class TaggingInterface;
50  };
51 
54 
55 protected:
56  virtual void nonlinearConvergenceSetup() override;
57 
58  virtual bool checkRelativeConvergence(const unsigned int it,
59  const Real fnorm,
60  const Real the_residual,
61  const Real rtol,
62  const Real abstol,
63  std::ostringstream & oss) override;
64 
77  bool checkConvergenceIndividVars(const Real fnorm,
78  const Real abstol,
79  const Real rtol,
80  const Real initial_residual_before_preset_bcs);
81 
85  std::vector<NonlinearVariableName> _soln_var_names;
86  std::vector<AuxVariableName> _ref_resid_var_names;
88 
92  std::vector<NonlinearVariableName> _group_soln_var_names;
93  std::vector<AuxVariableName> _group_ref_resid_var_names;
95 
98  std::vector<unsigned int> _soln_vars;
99  std::vector<unsigned int> _ref_resid_vars;
101 
107  unsigned int _accept_iters;
109 
112  std::vector<Real> _group_ref_resid;
113  std::vector<Real> _group_resid;
114  std::vector<Real> _group_output_resid;
116 
118  std::vector<unsigned int> _variable_group_num_index;
119 
121  std::vector<Real> _scaling_factors;
122 
125 
127  std::vector<NonlinearVariableName> _converge_on;
129  std::vector<bool> _converge_on_var;
130 
133 
136 
139 
142 
144 };
virtual void nonlinearConvergenceSetup() override
Performs setup necessary for each call to checkConvergence.
Interface class shared between ReferenceResidualProblem and ReferenceResidualConvergence.
unsigned int TagID
Definition: MooseTypes.h:210
bool checkConvergenceIndividVars(const Real fnorm, const Real abstol, const Real rtol, const Real initial_residual_before_preset_bcs)
Check the convergence by comparing the norm of each variable&#39;s residual separately against its refere...
std::vector< NonlinearVariableName > _soln_var_names
ReferenceResidualConvergence(const InputParameters &parameters)
std::vector< bool > _converge_on_var
Flag for each solution variable being in &#39;converge_on&#39;.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual bool checkRelativeConvergence(const unsigned int it, const Real fnorm, const Real the_residual, const Real rtol, const Real abstol, std::ostringstream &oss) override
Check the relative convergence of the nonlinear solution.
std::vector< NonlinearVariableName > _group_soln_var_names
const NumericVector< Number > * _reference_vector
The vector storing the reference residual values.
std::vector< unsigned int > _variable_group_num_index
Group number index for each variable.
void updateReferenceResidual()
Computes the reference residuals for each group.
std::vector< AuxVariableName > _ref_resid_var_names
std::vector< unsigned int > _soln_vars
TagID _reference_vector_tag_id
The reference vector tag id.
TagID referenceVectorTagID(ReferenceVectorTagIDKey) const
Returns the tag ID associated with the reference vector tag ID key.
bool _local_norm
Flag to optionally perform normalization of residual by reference residual before or after L2 norm is...
std::vector< AuxVariableName > _group_ref_resid_var_names
std::vector< unsigned int > _ref_resid_vars
virtual void initialSetup() override
Gets called at the beginning of the simulation before this object is asked to do its job...
Uses a reference residual to define relative convergence criteria.
libMesh::FEMNormType _norm_type
Container for normalization type.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
enum ReferenceResidualConvergence::ZeroReferenceType _zero_ref_type
const InputParameters & parameters() const
Get the parameters of the object.
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< NonlinearVariableName > _converge_on
Variables to use for individual variable convergence checks.
Default nonlinear convergence criteria for FEProblem.
ZeroReferenceType
Container for convergence treatment when the reference residual is zero.