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);
77 if (!dynamic_cast<DefaultMultiAppFixedPointConvergence *>(&convergence))
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;
std::vector< std::vector< PostprocessorValue > > _transformed_pps_values
Previous values of the relaxed postprocessors.
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.
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)...
FEProblemBase & _problem
Reference to FEProblem.
SteffensenSolve(Executioner &ex)
NumericVector< Number > & solution()
void setPostprocessorValueByName(const PostprocessorName &name, const PostprocessorValue &value, std::size_t t_index=0)
Set the value of a PostprocessorValue.
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
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 transformVariables(const std::set< dof_id_type > &transformed_dofs, const bool primary) override final
Use the fixed point algorithm to transform the variables.
std::vector< PostprocessorName > _secondary_transformed_pps
Postprocessors to be relaxed outside of fixed point iteration (used as a subapp)
auto max(const L &left, const R &right)
const std::vector< PostprocessorName > _transformed_pps
The postprocessors (transferred or not) that are going to be relaxed.
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
Adds a solution length vector to the system.
TagID _fxn_m1_tagid
Vector tag id for the most recent solution variable, pre-Steffensen transform, as a main app...
TagID _xn_m1_tagid
Vector tag id for the solution variable before the latest solve, as a main app.
void update()
Update the system (doing libMesh magic)
const Real _relax_factor
Relaxation factor for fixed point Iteration.
virtual Convergence & getConvergence(const std::string &name, const THREAD_ID tid=0) const
Gets a Convergence object.
virtual bool useFixedPointAlgorithmUpdateInsteadOfPicard(const bool primary) override final
Use the fixed point algorithm transform instead of simply using the Picard update.
const ConvergenceName & getMultiAppFixedPointConvergenceName() const
Gets the MultiApp fixed point convergence object name.
TagID _secondary_xn_m1_tagid
Vector tag id for the solution variable before the latest solve, as a sub app.
Executioners are objects that do the actual work of solving your problem.
virtual void saveVariableValues(const bool primary) override final
Saves the current values of the variables, and update the old(er) vectors.
Real _secondary_relaxation_factor
Relaxation factor outside of fixed point iteration (used as a subapp)
virtual void allocateStorage(const bool primary) override final
Allocate storage for the fixed point algorithm.
std::string stringify(const T &t)
conversion to string
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name) const
Retrieve the value of the Postprocessor.
unsigned int _fixed_point_it
static InputParameters validParams()
TagID _secondary_fxn_m1_tagid
Vector tag id for the most recent solution variable, pre-Steffensen transform, as a sub app...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void initialSetup() override
Method that should be executed once, before any solve calls.
static std::string outputNorm(const Real &old_norm, const Real &norm, const unsigned int precision=6)
A helper function for outputting norms in color.
const TagID INVALID_TAG_ID
SystemBase * _transformed_sys
System holding the transformed variables.
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...
virtual void set(const numeric_index_type i, const Number value)=0
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
virtual void initialSetup() override
Method that should be executed once, before any solve calls.
void findTransformedSystem(const bool primary)
Find the system holding the variables to be transformed (accelerated or relaxed)
virtual NumericVector< Number > & getVector(const std::string &name)
Get a raw NumericVector by name.
static InputParameters validParams()
unsigned int _main_fixed_point_it
fixed point iteration counter for the main app