30 "fixed_point_min_its", 1,
"Specifies the minimum number of fixed point iterations.");
32 "fixed_point_max_its", 1,
"Specifies the maximum number of fixed point iterations.");
33 params.
addParam<
bool>(
"disable_fixed_point_residual_norm_check",
35 "Disable the residual norm evaluation thus the three parameters "
36 "fixed_point_rel_tol, fixed_point_abs_tol and fixed_point_force_norms.");
38 "fixed_point_force_norms",
40 "Force the evaluation of both the TIMESTEP_BEGIN and TIMESTEP_END norms regardless of the "
41 "existence of active MultiApps with those execute_on flags, default: false.");
43 "accept_on_max_fixed_point_iteration",
45 "True to treat reaching the maximum number of fixed point iterations as converged.");
48 "fixed_point_rel_tol>0",
49 "The relative nonlinear residual drop to shoot for "
50 "during fixed point iterations. This check is "
51 "performed based on the main app's nonlinear "
55 "fixed_point_abs_tol>0",
56 "The absolute nonlinear residual to shoot for "
57 "during fixed point iterations. This check is "
58 "performed based on the main app's nonlinear "
61 params.
addParam<PostprocessorName>(
"custom_pp",
62 "Postprocessor for custom fixed point convergence check.");
63 params.
addParam<
bool>(
"direct_pp_value",
65 "True to use direct postprocessor value "
66 "(scaled by value on first iteration). "
67 "False (default) to use difference in postprocessor "
68 "value between fixed point iterations.");
72 "The relative nonlinear residual drop to shoot for "
73 "during fixed point iterations. This check is "
74 "performed based on the postprocessor defined by "
75 "custom_pp residual.");
79 "The absolute nonlinear residual to shoot for "
80 "during fixed point iterations. This check is "
81 "performed based on postprocessor defined by "
82 "the custom_pp residual.");
85 "fixed_point_min_its fixed_point_max_its disable_fixed_point_residual_norm_check "
86 "accept_on_max_fixed_point_iteration fixed_point_rel_tol fixed_point_abs_tol "
87 "fixed_point_force_norms custom_pp direct_pp_value custom_abs_tol custom_rel_tol",
88 "MultiApp fixed point iterations");
100 "multiapp_fixed_point_convergence",
101 "Name of the Convergence object to use to assess convergence of the "
102 "MultiApp fixed point solve. If not provided, a default Convergence "
103 "will be constructed internally from the executioner parameters.");
108 "relaxation_factor>0 & relaxation_factor<2",
109 "Fraction of newly computed value to keep."
110 "Set between 0 and 2.");
111 params.
addParam<std::vector<std::string>>(
112 "transformed_variables",
113 std::vector<std::string>(),
114 "List of main app variables to transform during fixed point iterations");
115 params.
addParam<std::vector<PostprocessorName>>(
116 "transformed_postprocessors",
117 std::vector<PostprocessorName>(),
118 "List of main app postprocessors to transform during fixed point iterations");
121 std::vector<std::string>(),
122 "List of main app variables to relax during fixed point iterations",
123 "Relaxed variables is deprecated, use transformed_variables instead.");
125 params.
addParam<
bool>(
"auto_advance",
126 "Whether to automatically advance sub-applications regardless of whether "
127 "their solve converges, for transient executioners only.");
130 "multiapp_fixed_point_convergence "
131 "relaxation_factor transformed_variables transformed_postprocessors auto_advance",
132 "Fixed point iterations");
136 std::numeric_limits<unsigned int>::max(),
137 "Maximum number of times to update XFEM crack topology in a step due to evolving cracks");
138 params.
addParam<
bool>(
"update_xfem_at_timestep_begin",
140 "Should XFEM update the mesh at the beginning of the timestep");
143 "XFEM fixed point iterations");
150 _has_fixed_point_its(getParam<unsigned
int>(
"fixed_point_max_its") > 1 ||
151 getParam<unsigned
int>(
"fixed_point_min_its") > 1 ||
152 isParamSetByUser(
"multiapp_fixed_point_convergence")),
153 _relax_factor(getParam<Real>(
"relaxation_factor")),
154 _transformed_vars(getParam<
std::vector<
std::string>>(
"transformed_variables")),
155 _transformed_pps(getParam<
std::vector<PostprocessorName>>(
"transformed_postprocessors")),
156 _transformed_sys(nullptr),
158 _secondary_relaxation_factor(1.0),
161 _max_xfem_update(getParam<unsigned
int>(
"max_xfem_update")),
162 _update_xfem_at_timestep_begin(getParam<bool>(
"update_xfem_at_timestep_begin")),
163 _xfem_update_count(0),
164 _xfem_repeat_step(false),
165 _old_entering_time(_problem.time() - 1),
167 _auto_advance_set_by_user(isParamValid(
"auto_advance")),
168 _auto_advance_user_value(_auto_advance_set_by_user ? getParam<bool>(
"auto_advance") : true)
171 if (!
parameters().isParamSetByAddParam(
"relaxed_variables"))
176 "Both variable and postprocessor transformation are active. If the two share dofs, the "
177 "transformation will not be correct.");
180 "Relaxation factor must act on at least one 'transformed_variables' or one "
181 "'transformed_postprocessors'");
185 (getParam<Real>(
"relaxation_factor") != 1 ||
186 getParam<std::vector<std::string>>(
"transformed_variables").size() ||
187 getParam<std::vector<PostprocessorName>>(
"transformed_postprocessors").size()))
189 std::string(
"Parameter(s) ") +
190 ((getParam<Real>(
"relaxation_factor") != 1) ?
"'relaxation_factor', " :
"") +
191 (
getParam<std::vector<std::string>>(
"transformed_variables").size()
192 ?
"'transformed_variables', "
194 (
getParam<std::vector<std::string>>(
"transformed_postprocessors").size()
195 ?
"'transformed_postprocessors', "
197 " were passed to the Executioner for multiapp fixed point iterations, but fixed "
198 "point iterations are only activiated if 'fixed_point_min_its', "
199 "'fixed_point_max_its' or 'multiapp_fixed_point_convergence' are passed");
210 "Secondary relaxation factor, specified in the MultiApps block, must act on at least one "
211 "'secondary_transformed_variables' or one 'secondary_transformed_postprocessors'. "
212 "See parent application MultiApp parameters");
217 getParam<ConvergenceName>(
"multiapp_fixed_point_convergence"));
246 TIME_SECTION(
"PicardSolve", 1);
250 bool converged =
true;
260 std::set<dof_id_type> transformed_dofs;
272 std::set<dof_id_type> secondary_transformed_dofs;
319 << COLOR_DEFAULT << std::endl
324 const bool solve_converged =
solveStep(transformed_dofs);
481 _console << COLOR_MAGENTA <<
"\nMain app solve:" << COLOR_DEFAULT << std::endl;
502 _console <<
"\nRepeating step due to XFEM mesh modification" << std::endl;
552 const auto status = convergence.checkConvergence(n_iter);
572 _console <<
"Fixed point convergence reason: ";
588 _console <<
"CONVERGED_OBJECT (see Convergence object)";
597 _console <<
"DIVERGED_FAILED_MULTIAPP";
600 _console <<
"DIVERGED_OBJECT (see Convergence object)";
605 mooseError(
"Internal error: wrong fixed point status!");
639 if (!transformed_vars.empty())
647 for (
const auto & var_name : transformed_vars)
652 "Transformed variables must all belong to the same system. Auxiliary and each "
653 "solver system cannot be mixed");
655 mooseError(
"Secondary transformed variables must all belong to the same system. Auxiliary "
656 "and each solver system cannot be mixed");
660 mooseInfo(
"Transformation of auxiliary variables is only supported for auxiliary variables "
661 "that are only transferred from the child application");
const ExecFlagType EXEC_MULTIAPP_FIXED_POINT_END
const ExecFlagType EXEC_MULTIAPP_FIXED_POINT_CONVERGENCE
const ExecFlagType EXEC_TIMESTEP_END
const ExecFlagType EXEC_TIMESTEP_BEGIN
const ExecFlagType EXEC_MULTIAPP_FIXED_POINT_ITERATION_END
const ExecFlagType EXEC_MULTIAPP_FIXED_POINT_BEGIN
const ExecFlagType EXEC_FAILED
void ErrorVector unsigned int
Grab all the (possibly semi)local dof indices for the variables passed in, in the system passed in.
const std::set< dof_id_type > & getDofIndices() const
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
virtual void initialize()
Method that gets called before each iteration loop.
virtual void preExecute()
Method that gets called in each iteration before the solve.
virtual void checkIterationType(IterationType) const
Perform checks related to the iteration type.
This class provides reusable routines for eigenvalue executioners.
Executioners are objects that do the actual work of solving your problem.
virtual void postSolve()
Override this for actions that should take place after execution, called by FixedPointSolve.
virtual void preSolve()
Override this for actions that should take place before execution, called by FixedPointSolve.
virtual void onTimestepEnd() override
void needsPreviousMultiAppFixedPointIterationAuxiliary(bool state)
Set a flag that indicated that user required values for the previous multiapp fixed point iterate for...
virtual bool updateMeshXFEM()
Update the mesh due to changing XFEM cuts.
void execTransfers(ExecFlagType type)
Execute the Transfers associated with the ExecFlagType.
bool haveXFEM()
Find out whether the current analysis is using XFEM.
virtual std::size_t numSolverSystems() const override
virtual void updateActiveObjects()
Update the active objects in the warehouses.
virtual Real & dt() const
virtual Convergence & getConvergence(const std::string &name, const THREAD_ID tid=0) const
Gets a Convergence object.
void setMultiAppFixedPointConvergenceName(const ConvergenceName &convergence_name)
Sets the MultiApp fixed point convergence object name if there is one.
void restoreMultiApps(ExecFlagType type, bool force=false)
Restore the MultiApps associated with the ExecFlagType.
void needsPreviousMultiAppFixedPointIterationSolution(bool needed, const unsigned int solver_sys_num)
Set a flag that indicated that user required values for the previous multiapp fixed point iterate for...
bool execMultiApps(ExecFlagType type, bool auto_advance=true)
Execute the MultiApps associated with the ExecFlagType.
virtual MooseMesh & mesh() override
SolverSystem & getSolverSystem(unsigned int sys_num)
Get non-constant reference to a solver system.
void backupMultiApps(ExecFlagType type)
Backup the MultiApps associated with the ExecFlagType.
void setNeedToAddDefaultMultiAppFixedPointConvergence()
Sets _need_to_add_default_multiapp_fixed_point_convergence to true.
virtual void execute(const ExecFlagType &exec_type)
Convenience function for performing execution of MOOSE systems.
virtual Real & time() const
virtual int & timeStep() const
virtual bool isTransient() const override
const ConvergenceName & getMultiAppFixedPointConvergenceName() const
Gets the MultiApp fixed point convergence object name.
virtual void outputStep(ExecFlagType type)
Output the current step.
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.
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.
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.
static InputParameters validParams()
bool autoAdvance() const
Whether sub-applications are automatically advanced no matter what happens during their solves.
unsigned int _xfem_update_count
Counter for number of xfem updates that have been performed in the current step.
virtual bool useFixedPointAlgorithmUpdateInsteadOfPicard(const bool primary)=0
Use the fixed point algorithm transform instead of simply using the Picard update This routine can be...
bool _xfem_repeat_step
Whether step should be repeated due to xfem modifying the mesh.
MooseFixedPointConvergenceReason
Enumeration for fixed point convergence reasons.
@ DIVERGED_OBJECT
Multiapp solve diverged.
@ 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.
@ CONVERGED_NONLINEAR
Not solved yet.
@ 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 void savePostprocessorValues(const bool primary)=0
Saves the current values of the postprocessors, and update the old(er) vectors.
FixedPointSolve(Executioner &ex)
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.
virtual void allocateStorage(const bool primary)=0
Allocate storage for the fixed point algorithm.
static InputParameters fixedPointDefaultConvergenceParams()
MooseFixedPointConvergenceReason _fixed_point_status
Status of fixed point solve.
FixedPointConfig & fixedPointConfig()
This info is stored here because we need a "globalish" place to put it in order to allow communicatio...
bool isUltimateMaster() const
Whether or not this app is the ultimate master app.
SolutionInvalidity & solutionInvalidity()
Get the SolutionInvalidity for this app.
const InputParameters & parameters() const
Get the parameters of the object.
void paramError(const std::string ¶m, Args... args) const
Emits an error prefixed with the file and line number of the given param (from the input file) along ...
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type and optionally a file path to the top-level block p...
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
void mooseInfo(Args &&... args) const
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
const libMesh::ConstElemRange * getActiveLocalElementRange()
Return pointers to range objects for various types of ranges (local nodes, boundary elems,...
MooseApp & _app
The MOOSE application this is associated with.
void mooseWarning(Args &&... args) const
void accumulateIterationIntoTimeStepOccurences()
Pass the number of solution invalid occurrences from current iteration to cumulative counters.
void resetTimeStepOccurences()
Reset the number of solution invalid occurrences back to zero for the current time step.
void resetIterationOccurences()
Reset the number of solution invalid occurrences back to zero.
void accumulateTimeStepIntoTotalOccurences(const unsigned int timestep_index)
Pass the number of solution invalid occurrences from current timestep to cumulative timestep counter ...
void syncIteration()
Sync iteration counts to main processor Sum across all processors.
SystemBase & _solver_sys
Reference to a system for creating vectors as needed for the solve, etc.
FEProblemBase & _problem
Reference to FEProblem.
SolveObject * _inner_solve
SolveObject wrapped by this solve object.
virtual void initialSetup()
Method that should be executed once, before any solve calls.
Executioner & _executioner
Executioner used to construct this.
AuxiliarySystem & _aux
Reference to auxiliary system for faster access.
virtual bool solve()=0
Solve routine provided by this object.
virtual bool hasAuxiliaryVariable(const std::string &var_name) const
Whether or not this problem has this auxiliary variable.
virtual bool hasVariable(const std::string &var_name) const
Query a system for a variable.
const auto MULTIAPP_FIXED_POINT
void parallel_reduce(const Range &range, Body &body, unsigned int n_threads=libMesh::n_threads())
std::vector< std::string > sub_transformed_vars
The names of variables to transform for fixed point solve algorithms (e.g. secant,...
std::vector< PostprocessorName > sub_transformed_pps
The names of postprocessors to transform for fixed point solve algorithms (e.g. secant,...
Real sub_relaxation_factor
relaxation factor to be used for a MultiApp's subapps.