https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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{
19public:
21
22 virtual ~FixedPointSolve() = default;
23
26
27 virtual void initialSetup() override;
28
33 virtual bool solve() override;
34
50
58 unsigned int numFixedPointIts() const { return _fixed_point_it + 1; }
59
61 unsigned int numPicardIts() const
62 {
63 mooseDeprecated("numPicards() is deprecated. Please use numFixedPointIts() instead.");
64
65 return _fixed_point_it + 1;
66 }
67
70
72 bool XFEMRepeatStep() const { return _xfem_repeat_step; }
73
79
82
85
88
90 void setMultiAppTransformedVariables(const std::vector<std::string> & vars)
91 {
93 }
94
96 virtual void setMultiAppTransformedPostprocessors(const std::vector<PostprocessorName> & pps)
97 {
99 }
100
109 virtual void allocateStorage(const bool primary) = 0;
110
112 bool autoAdvance() const;
113
115 void failStep() { _fail_step = true; }
116
118 virtual void
120 const std::vector<Real> & timestep_begin_norms,
121 const std::vector<Real> & timestep_end_norms) const = 0;
122
128
129protected:
135 bool performingRelaxation(const bool primary) const;
136
143 virtual void saveVariableValues(const bool primary) = 0;
144
151 virtual void savePostprocessorValues(const bool primary) = 0;
152
161 virtual bool useFixedPointAlgorithmUpdateInsteadOfPicard(const bool primary) = 0;
162
174 virtual bool solveStep(const std::set<dof_id_type> & transformed_dofs);
175
177 virtual void saveAllValues(const bool primary);
178
187 virtual void transformPostprocessors(const bool primary) = 0;
188
198 virtual void transformVariables(const std::set<dof_id_type> & transformed_dofs,
199 const bool primary) = 0;
200
202 bool examineFixedPointConvergence(bool & converged);
203
206
209 void findTransformedSystem(const bool primary);
210
213
215 const Real _relax_factor;
217 std::vector<std::string> _transformed_vars; // TODO: make const once relaxed_variables is removed
219 const std::vector<PostprocessorName> _transformed_pps;
221 std::vector<std::vector<PostprocessorValue>> _transformed_pps_values;
226
230 std::vector<std::string> _secondary_transformed_variables;
232 std::vector<PostprocessorName> _secondary_transformed_pps;
234 std::vector<std::vector<PostprocessorValue>> _secondary_transformed_pps_values;
235
238 unsigned int _fixed_point_it;
244private:
246 const unsigned int _max_xfem_update;
249
251 unsigned int _xfem_update_count;
254
257
260
264
268};
char ** vars
Executioners are objects that do the actual work of solving your problem.
Definition Executioner.h:37
std::set< SystemBase * > _systems_to_copy_previous_solutions_for
All the systems that should save their previous solutions.
virtual void transformVariables(const std::set< dof_id_type > &transformed_dofs, const bool primary)=0
Use the fixed point algorithm to transform the variables.
void failStep()
Mark the current solve as failed due to external conditions.
virtual void initialSetup() override
Method that should be executed once, before any solve calls.
unsigned int _main_fixed_point_it
Current fixed point iteration index for the main app; 0 for the first iteration.
Real _secondary_relaxation_factor
Relaxation factor outside of fixed point iteration (used as a subapp)
const Real _relax_factor
Relaxation factor for fixed point Iteration.
void setFixedPointStatus(MooseFixedPointConvergenceReason status)
Set fixed point status.
virtual bool solveStep(const std::set< dof_id_type > &transformed_dofs)
Perform one fixed point iteration or a full solve.
bool _fail_step
force the current step to fail, triggering are repeat with a cut dt
Real _old_entering_time
Time of previous fixed point solve as a subapp.
bool examineFixedPointConvergence(bool &converged)
Examine the various convergence metrics.
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...
const unsigned int _max_xfem_update
Maximum number of xfem updates per step.
const bool _has_fixed_point_its
Whether or not we activate fixed point iteration.
void setMultiAppRelaxationFactor(Real factor)
Set relaxation factor for the current solve as a SubApp.
static InputParameters validParams()
bool autoAdvance() const
Whether sub-applications are automatically advanced no matter what happens during their solves.
std::vector< std::vector< PostprocessorValue > > _transformed_pps_values
Previous values of the relaxed postprocessors.
unsigned int _xfem_update_count
Counter for number of xfem updates that have been performed in the current step.
unsigned int numPicardIts() const
Deprecated getter for the number of fixed point iterations.
virtual bool useFixedPointAlgorithmUpdateInsteadOfPicard(const bool primary)=0
Use the fixed point algorithm transform instead of simply using the Picard update This routine can be...
void copyPreviousFixedPointSolutionForSystem(SystemBase *sys)
Add to the list of systems that should keep their previous fixed point solutions.
bool _xfem_repeat_step
Whether step should be repeated due to xfem modifying the mesh.
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)
bool XFEMRepeatStep() const
This function checks the _xfem_repeat_step flag set by solve.
virtual void setMultiAppTransformedPostprocessors(const std::vector< PostprocessorName > &pps)
Set relaxation postprocessors for the current solve as a SubApp.
MooseFixedPointConvergenceReason
Enumeration for fixed point convergence reasons.
@ DIVERGED_MAX_ITS
FP converged according to Convergence object.
@ CONVERGED_ABS
Main app nonlinear solve converged, FP unassessed.
@ REACH_MAX_ITS
FP converged by absolute or relative PP tolerance.
@ CONVERGED_PP
FP converged by relative residual tolerance.
@ CONVERGED_RELATIVE
FP converged by absolute residual tolerance.
@ DIVERGED_FAILED_MULTIAPP
Main app nonlinear solve diverged.
@ CONVERGED_OBJECT
FP converged by hitting max iterations and accepting.
@ DIVERGED_NONLINEAR
FP diverged by hitting max iterations.
const bool _update_xfem_at_timestep_begin
Controls whether xfem should update the mesh at the beginning of the time step.
void printFixedPointConvergenceReason()
Print information about the fixed point convergence.
const std::vector< PostprocessorName > _transformed_pps
The postprocessors (transferred or not) that are going to be relaxed.
virtual void saveVariableValues(const bool primary)=0
Saves the current values of the variables, and update the old(er) vectors.
virtual void saveAllValues(const bool primary)
Save both the variable and postprocessor values.
bool performingRelaxation(const bool primary) const
Returns true if there is relaxation.
virtual ~FixedPointSolve()=default
virtual void savePostprocessorValues(const bool primary)=0
Saves the current values of the postprocessors, and update the old(er) vectors.
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 bool _auto_advance_set_by_user
Whether the user has set the auto_advance parameter for handling advancement of sub-applications in m...
virtual bool solve() override
Iteratively solves the FEProblem.
std::vector< std::string > _transformed_vars
The variables (transferred or not) that are going to be relaxed.
virtual void transformPostprocessors(const bool primary)=0
Use the fixed point algorithm to transform the postprocessors.
unsigned int _fixed_point_it
std::vector< std::string > _secondary_transformed_variables
Variables to be relaxed outside of fixed point iteration (used as a subapp)
void findTransformedSystem(const bool primary)
Find the system holding the variables to be transformed (accelerated or relaxed)
SystemBase * _transformed_sys
System holding the transformed variables.
unsigned int numFixedPointIts() const
Get the number of fixed point iterations performed Because this returns the number of fixed point ite...
virtual void allocateStorage(const bool primary)=0
Allocate storage for the fixed point algorithm.
static InputParameters fixedPointDefaultConvergenceParams()
virtual void printFixedPointConvergenceHistory(Real initial_norm, const std::vector< Real > &timestep_begin_norms, const std::vector< Real > &timestep_end_norms) const =0
Print the convergence history of the coupling, at every fixed point iteration.
MooseFixedPointConvergenceReason _fixed_point_status
Status of fixed point solve.
void setMultiAppTransformedVariables(const std::vector< std::string > &vars)
Set relaxation variables for the current solve as a SubApp.
void clearFixedPointStatus()
Clear fixed point status.
bool hasFixedPointIteration()
Whether or not this has fixed point iterations.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void mooseDeprecated(Args &&... args) const
Base class for a system (of equations)
Definition SystemBase.h:87