98 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
100 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
102 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
104 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
133 const std::vector<PostprocessorName> * transformed_pps;
134 std::vector<std::vector<PostprocessorValue>> * transformed_pps_values;
148 for (
size_t i = 0; i < (*transformed_pps).size(); i++)
151 (*transformed_pps_values)[i][3] = (*transformed_pps_values)[i][1];
163 (*transformed_pps_values)[i][2] = (*transformed_pps_values)[i][1];
166 (*transformed_pps_values)[i][2] = (*transformed_pps_values)[i][0];
186 Real relaxation_factor;
187 const std::vector<PostprocessorName> * transformed_pps;
188 std::vector<std::vector<PostprocessorValue>> * transformed_pps_values;
203 for (
size_t i = 0; i < (*transformed_pps).size(); i++)
207 const Real xn_m1 = (*transformed_pps_values)[i][1];
208 const Real fxn_m2 = (*transformed_pps_values)[i][2];
209 const Real xn_m2 = (*transformed_pps_values)[i][3];
212 (*transformed_pps_values)[i][0] = fxn_m1;
215 Real new_value = fxn_m1;
216 if (!MooseUtils::absoluteFuzzyEqual(fxn_m1 - xn_m1 - fxn_m2 + xn_m2, 0))
217 new_value = xn_m1 - (fxn_m1 - xn_m1) * (xn_m1 - xn_m2) / (fxn_m1 - xn_m1 - fxn_m2 + xn_m2);
220 new_value = relaxation_factor * new_value + (1 - relaxation_factor) * xn_m1;
229 Real relaxation_factor;
260 for (
const auto & dof : target_dofs)
263 Real new_value = fxn_m1(dof);
264 if (!MooseUtils::absoluteFuzzyEqual(solution(dof) - xn_m1(dof) - fxn_m2(dof) + xn_m2(dof), 0))
265 new_value = xn_m1(dof) - (solution(dof) - xn_m1(dof)) * (xn_m1(dof) - xn_m2(dof)) /
266 (solution(dof) - xn_m1(dof) - fxn_m2(dof) + xn_m2(dof));
269 new_value = relaxation_factor * new_value + (1 - relaxation_factor) * xn_m1(dof);
271 solution.set(dof, new_value);
279 const std::vector<Real> & timestep_begin_norms,
280 const std::vector<Real> & timestep_end_norms)
const
282 _console <<
"\n 0 Secant initialization |R| = "
285 Real max_norm_old = initial_norm;
288 Real max_norm = std::max(timestep_begin_norms[i], timestep_end_norms[i]);
289 std::stringstream secant_prefix;
291 secant_prefix <<
" Secant initialization |R| = ";
293 secant_prefix <<
" Secant step |R| = ";
295 _console << std::setw(2) << i + 1 << secant_prefix.str()
297 max_norm_old = max_norm;
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
static std::string outputNorm(const Real &old_norm, const Real &norm, const unsigned int precision=6)
A helper function for outputting norms in color.
Executioners are objects that do the actual work of solving your problem.
void setPostprocessorValueByName(const PostprocessorName &name, const PostprocessorValue &value, std::size_t t_index=0)
Set the value of a PostprocessorValue.
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.
static InputParameters validParams()
std::vector< std::vector< PostprocessorValue > > _transformed_pps_values
Previous values of the relaxed postprocessors.
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)
const std::vector< PostprocessorName > _transformed_pps
The postprocessors (transferred or not) that are going to be relaxed.
std::vector< PostprocessorName > _secondary_transformed_pps
Postprocessors to be relaxed outside of fixed point iteration (used as a subapp)
unsigned int _fixed_point_it
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 const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name) const
Retrieve the value of the Postprocessor.
virtual void savePostprocessorValues(const bool primary) override final
Saves the current values of the postprocessors, and update the old(er) vectors.
TagID _xn_m1_tagid
Vector tag id for the solution variable before the latest solve, as a main app.
TagID _secondary_xn_m1_tagid
Vector tag id for the solution variable before the latest solve, as a sub app.
virtual void transformPostprocessors(const bool primary) override final
Use the fixed point algorithm to transform the postprocessors.
TagID _xn_m2_tagid
Vector tag id for the solution variable two solves ago, as a main app.
virtual void allocateStorage(const bool primary) override final
Allocate storage for the fixed point algorithm.
TagID _secondary_fxn_m1_tagid
Vector tag id for the most recent solution variable, pre-Secant transform, as a sub app.
virtual void transformVariables(const std::set< dof_id_type > &transformed_dofs, const bool primary) override final
Use the fixed point algorithm to transform the variables.
virtual bool useFixedPointAlgorithmUpdateInsteadOfPicard(const bool primary) override final
Use the fixed point algorithm transform instead of simply using the Picard update.
TagID _fxn_m1_tagid
Vector tag id for the most recent solution variable, pre-Secant transform, as a main app.
static InputParameters validParams()
TagID _secondary_xn_m2_tagid
Vector tag id for the solution variable two primary solves ago, as a sub app.
SecantSolve(Executioner &ex)
TagID _fxn_m2_tagid
Vector tag id for the result of the last but one solve, as a main app.
virtual void printFixedPointConvergenceHistory(Real initial_norm, const std::vector< Real > ×tep_begin_norms, const std::vector< Real > ×tep_end_norms) const override final
Print the convergence history of the coupling, at every fixed point iteration.
virtual void saveVariableValues(const bool primary) override final
Saves the current values of the variables, and update the old(er) vectors.
TagID _secondary_fxn_m2_tagid
Vector tag id for the result of the last but one secondary solve, as a sub app.
FEProblemBase & _problem
Reference to FEProblem.
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
virtual void needSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time, libMesh::ParallelType parallel_type=GHOSTED)
Registers that the solution state state is needed.
NumericVector< Number > & solution()
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
void update()
Update the system (doing libMesh magic)
const TagID INVALID_TAG_ID
const TagName PREVIOUS_MULTIAPP_FP_SOLUTION_TAG
std::string stringify(const T &t)
conversion to string