Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
FixedPointSolve.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 
12 #include "SolveObject.h"
13 
14 // System includes
15 #include <string>
16 
18 {
19 public:
21 
22  virtual ~FixedPointSolve() = default;
23 
25 
30  virtual bool solve() override;
31 
34  {
35  UNSOLVED = 0,
37  CONVERGED_ABS = 2,
39  CONVERGED_CUSTOM = 4,
40  REACH_MAX_ITS = 5,
41  DIVERGED_MAX_ITS = -1,
42  DIVERGED_NONLINEAR = -2,
44  };
45 
49  unsigned int minFixedPointIts() const { return _min_fixed_point_its; }
50 
54  unsigned int maxFixedPointIts() const { return _max_fixed_point_its; }
55 
63  unsigned int numFixedPointIts() const { return _fixed_point_it + 1; }
64 
66  unsigned int numPicardIts() const
67  {
68  mooseDeprecated("numPicards() is deprecated. Please use numFixedPointIts() instead.");
69 
70  return _fixed_point_it + 1;
71  }
72 
75 
77  bool XFEMRepeatStep() const { return _xfem_repeat_step; }
78 
81 
84 
87 
89  void setMultiAppTransformedVariables(const std::vector<std::string> & vars)
90  {
92  }
93 
95  virtual void setMultiAppTransformedPostprocessors(const std::vector<PostprocessorName> & pps)
96  {
98  }
99 
108  virtual void allocateStorage(const bool primary) = 0;
109 
111  bool autoAdvance() const;
112 
114  void failStep() { _fail_step = true; }
115 
116 protected:
123  virtual void saveVariableValues(const bool primary) = 0;
124 
131  virtual void savePostprocessorValues(const bool primary) = 0;
132 
141  virtual bool useFixedPointAlgorithmUpdateInsteadOfPicard(const bool primary) = 0;
142 
156  virtual bool
157  solveStep(Real & begin_norm, Real & end_norm, const std::set<dof_id_type> & transformed_dofs);
158 
160  virtual void saveAllValues(const bool primary);
161 
170  virtual void transformPostprocessors(const bool primary) = 0;
171 
181  virtual void transformVariables(const std::set<dof_id_type> & transformed_dofs,
182  const bool primary) = 0;
183 
185  virtual void printFixedPointConvergenceHistory() = 0;
186 
189 
191  bool examineFixedPointConvergence(bool & converged);
192 
195 
197  unsigned int _min_fixed_point_its;
199  unsigned int _max_fixed_point_its;
201  bool _has_fixed_point_its; // TODO: make const once picard parameters are removed
203  bool _accept_max_it; // TODO: make const once picard parameters are removed
205  bool _has_fixed_point_norm; // TODO: make const once picard parameters are removed
207  Real _fixed_point_rel_tol; // TODO: make const once picard parameters are removed
209  Real _fixed_point_abs_tol; // TODO: make const once picard parameters are removed
211  bool _fixed_point_force_norms; // TODO: make const once picard parameters are removed
212 
214  const PostprocessorValue *
215  _fixed_point_custom_pp; // FIXME Make const and private once picard_custom_pp is gone
216 
220  std::vector<std::string> _transformed_vars; // TODO: make const once relaxed_variables is removed
222  const std::vector<PostprocessorName> _transformed_pps;
224  std::vector<std::vector<PostprocessorValue>> _transformed_pps_values;
225 
229  std::vector<std::string> _secondary_transformed_variables;
231  std::vector<PostprocessorName> _secondary_transformed_pps;
233  std::vector<std::vector<PostprocessorValue>> _secondary_transformed_pps_values;
234 
237  unsigned int _fixed_point_it;
239  unsigned int _main_fixed_point_it;
249 private:
261  std::ostringstream _pp_history;
262 
264  const unsigned int _max_xfem_update;
267 
269  unsigned int _xfem_update_count;
272 
275 
278 
282 
286 };
std::vector< std::vector< PostprocessorValue > > _transformed_pps_values
Previous values of the relaxed postprocessors.
unsigned int maxFixedPointIts() const
Get the maximum number of fixed point iterations.
std::vector< std::vector< PostprocessorValue > > _secondary_transformed_pps_values
Previous values of the postprocessors relaxed outside of the fixed point iteration (used as a subapp)...
unsigned int minFixedPointIts() const
Get the minimum number of fixed point iterations.
FixedPointSolve(Executioner &ex)
virtual void saveVariableValues(const bool primary)=0
Saves the current values of the variables, and update the old(er) vectors.
void mooseDeprecated(Args &&... args) const
Real _fixed_point_initial_norm
Initial residual norm.
bool examineFixedPointConvergence(bool &converged)
Examine the various convergence metrics.
bool _has_fixed_point_its
Whether or not we activate fixed point iteration.
bool _fixed_point_force_norms
Whether or not we force evaluation of residual norms even without multiapps.
std::vector< Real > _fixed_point_timestep_end_norm
Full history of residual norm after evaluation of timestep_end.
virtual void allocateStorage(const bool primary)=0
Allocate storage for the fixed point algorithm.
char ** vars
void failStep()
Mark the current solve as failed due to external conditions.
unsigned int _min_fixed_point_its
Minimum fixed point iterations.
virtual bool solve() override
Iteratively solves the FEProblem.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
bool _has_fixed_point_norm
Whether or not to use residual norm to check the fixed point convergence.
void setMultiAppRelaxationFactor(Real factor)
Set relaxation factor for the current solve as a SubApp.
const PostprocessorValue * _fixed_point_custom_pp
Postprocessor value for user-defined fixed point convergence check.
void clearFixedPointStatus()
Clear fixed point status.
MooseFixedPointConvergenceReason
Enumeration for fixed point convergence reasons.
unsigned int numPicardIts() const
Deprecated getter for the number of fixed point iterations.
virtual void saveAllValues(const bool primary)
Save both the variable and postprocessor values.
unsigned int numFixedPointIts() const
Get the number of fixed point iterations performed Because this returns the number of fixed point ite...
bool _fail_step
force the current step to fail, triggering are repeat with a cut dt
virtual void transformPostprocessors(const bool primary)=0
Use the fixed point algorithm to transform the postprocessors.
MooseFixedPointConvergenceReason checkConvergence() const
Check the solver status.
std::vector< PostprocessorName > _secondary_transformed_pps
Postprocessors to be relaxed outside of fixed point iteration (used as a subapp)
const std::vector< PostprocessorName > _transformed_pps
The postprocessors (transferred or not) that are going to be relaxed.
Real _fixed_point_rel_tol
Relative tolerance on residual norm.
virtual void savePostprocessorValues(const bool primary)=0
Saves the current values of the postprocessors, and update the old(er) vectors.
virtual ~FixedPointSolve()=default
unsigned int _xfem_update_count
Counter for number of xfem updates that have been performed in the current step.
std::vector< Real > _fixed_point_timestep_begin_norm
Full history of residual norm after evaluation of timestep_begin.
const Real _relax_factor
Relaxation factor for fixed point Iteration.
std::ostringstream _pp_history
Convergence history of the custom convergence check postprocessor.
MooseFixedPointConvergenceReason _fixed_point_status
Status of fixed point solve.
Real _pp_scaling
Scaling of custom convergence check postprocessor (its initial value)
Real _pp_new
Current value of the custom convergence check postprocessor.
Real PostprocessorValue
various MOOSE typedefs
Definition: MooseTypes.h:202
virtual void transformVariables(const std::set< dof_id_type > &transformed_dofs, const bool primary)=0
Use the fixed point algorithm to transform the variables.
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:30
unsigned int _max_fixed_point_its
Maximum fixed point iterations.
Real _secondary_relaxation_factor
Relaxation factor outside of fixed point iteration (used as a subapp)
virtual void setMultiAppTransformedPostprocessors(const std::vector< PostprocessorName > &pps)
Set relaxation postprocessors for the current solve as a SubApp.
bool XFEMRepeatStep() const
This function checks the _xfem_repeat_step flag set by solve.
virtual bool solveStep(Real &begin_norm, Real &end_norm, const std::set< dof_id_type > &transformed_dofs)
Perform one fixed point iteration or a full solve.
unsigned int _fixed_point_it
static InputParameters validParams()
virtual bool useFixedPointAlgorithmUpdateInsteadOfPicard(const bool primary)=0
Use the fixed point algorithm transform instead of simply using the Picard update This routine can be...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
const bool _auto_advance_set_by_user
Whether the user has set the auto_advance parameter for handling advancement of sub-applications in m...
std::vector< std::string > _secondary_transformed_variables
Variables to be relaxed outside of fixed point iteration (used as a subapp)
bool autoAdvance() const
Whether sub-applications are automatically advanced no matter what happens during their solves...
Real _pp_old
Old value of the custom convergence check postprocessor.
bool _xfem_repeat_step
Whether step should be repeated due to xfem modifying the mesh.
void setMultiAppTransformedVariables(const std::vector< std::string > &vars)
Set relaxation variables for the current solve as a SubApp.
const Real _custom_abs_tol
Absolute tolerance on postprocessor value.
Real _old_entering_time
Time of previous fixed point solve as a subapp.
const unsigned int _max_xfem_update
Maximum number of xfem updates per step.
Real _fixed_point_abs_tol
Absolute tolerance on residual norm.
void printFixedPointConvergenceReason()
Print information about the fixed point convergence.
bool hasFixedPointIteration()
Whether or not this has fixed point iterations.
virtual void printFixedPointConvergenceHistory()=0
Print the convergence history of the coupling, at every fixed point iteration.
bool _accept_max_it
Whether or not to treat reaching maximum number of fixed point iteration as converged.
const bool _auto_advance_user_value
The value of auto_advance set by the user for handling advancement of sub-applications in multi-app c...
unsigned int _main_fixed_point_it
fixed point iteration counter for the main app
void computeCustomConvergencePostprocessor()
Computes and prints the user-specified postprocessor assessing convergence.
const bool _update_xfem_at_timestep_begin
Controls whether xfem should update the mesh at the beginning of the time step.
const Real _custom_rel_tol
Relative tolerance on postprocessor value.
std::vector< std::string > _transformed_vars
The variables (transferred or not) that are going to be relaxed.