36 const std::vector<PostprocessorName> * transformed_pps;
37 std::vector<std::vector<PostprocessorValue>> * transformed_pps_values;
66 (*transformed_pps_values).resize((*transformed_pps).size());
67 for (
size_t i = 0; i < (*transformed_pps).size(); i++)
68 (*transformed_pps_values)[i].resize(2);
79 "Only DefaultMultiAppFixedPointConvergence objects may be used for "
80 "'multiapp_fixed_point_convergence' when using the Steffensen fixed point algorithm.");
86 unsigned int iteration;
104 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
106 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
114 if (iteration % 2 == 1)
123 unsigned int iteration;
124 const std::vector<PostprocessorName> * transformed_pps;
125 std::vector<std::vector<PostprocessorValue>> * transformed_pps_values;
140 for (
size_t i = 0; i < (*transformed_pps).size(); i++)
142 if (iteration % 2 == 0)
163 Real relaxation_factor;
164 const std::vector<PostprocessorName> * transformed_pps;
165 std::vector<std::vector<PostprocessorValue>> * transformed_pps_values;
180 for (
size_t i = 0; i < (*transformed_pps).size(); i++)
184 const Real fxn_m1 = (*transformed_pps_values)[i][0];
185 const Real xn_m1 = (*transformed_pps_values)[i][1];
188 Real new_value = current_value;
189 if (!MooseUtils::absoluteFuzzyEqual(current_value + xn_m1 - 2 * fxn_m1, 0))
191 xn_m1 - (fxn_m1 - xn_m1) * (fxn_m1 - xn_m1) / (current_value + xn_m1 - 2 * fxn_m1);
194 new_value = relaxation_factor * new_value + (1 - relaxation_factor) * fxn_m1;
204 Real relaxation_factor;
224 for (
const auto & dof : transformed_dofs)
227 Real new_value = solution(dof);
228 if (!MooseUtils::absoluteFuzzyEqual(solution(dof) + xn_m1(dof) - 2 * fxn_m1(dof), 0))
229 new_value = xn_m1(dof) - (fxn_m1(dof) - xn_m1(dof)) * (fxn_m1(dof) - xn_m1(dof)) /
230 (solution(dof) + xn_m1(dof) - 2 * fxn_m1(dof));
233 new_value = relaxation_factor * new_value + (1 - relaxation_factor) * fxn_m1(dof);
235 solution.set(dof, new_value);
243 const Real initial_norm,
244 const std::vector<Real> & timestep_begin_norms,
245 const std::vector<Real> & timestep_end_norms)
const
247 _console <<
"\n 0 Steffensen initialization |R| = "
250 Real max_norm_old = initial_norm;
253 Real max_norm = std::max(timestep_begin_norms[i], timestep_end_norms[i]);
254 std::stringstream steffensen_prefix;
256 steffensen_prefix <<
" Steffensen initialization |R| = ";
258 steffensen_prefix <<
" Steffensen half-step |R| = ";
260 steffensen_prefix <<
" Steffensen step |R| = ";
262 _console << std::setw(2) << i + 1 << steffensen_prefix.str()
265 max_norm_old = max_norm;
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
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.
Default fixed point convergence criteria.
Executioners are objects that do the actual work of solving your problem.
virtual Convergence & getConvergence(const std::string &name, const THREAD_ID tid=0) const
Gets a Convergence object.
void setPostprocessorValueByName(const PostprocessorName &name, const PostprocessorValue &value, std::size_t t_index=0)
Set the value of a PostprocessorValue.
const ConvergenceName & getMultiAppFixedPointConvergenceName() const
Gets the MultiApp fixed point convergence object name.
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.
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.
FEProblemBase & _problem
Reference to FEProblem.
virtual void transformPostprocessors(const bool primary) override final
Use the fixed point algorithm to transform the postprocessors.
virtual void savePostprocessorValues(const bool primary) override final
Saves the current values of the postprocessors, and update the old(er) vectors.
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 _fxn_m1_tagid
Vector tag id for the most recent solution variable, pre-Steffensen transform, as a main app.
TagID _secondary_xn_m1_tagid
Vector tag id for the solution variable before the latest solve, as a sub app.
TagID _secondary_fxn_m1_tagid
Vector tag id for the most recent solution variable, pre-Steffensen 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.
TagID _xn_m1_tagid
Vector tag id for the solution variable before the latest solve, as a main app.
SteffensenSolve(Executioner &ex)
virtual bool useFixedPointAlgorithmUpdateInsteadOfPicard(const bool primary) override final
Use the fixed point algorithm transform instead of simply using the Picard update.
virtual void allocateStorage(const bool primary) override final
Allocate storage for the fixed point algorithm.
static InputParameters validParams()
virtual void initialSetup() override
Method that should be executed once, before any solve calls.
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.
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
std::string stringify(const T &t)
conversion to string