34 const std::vector<PostprocessorName> * transformed_pps;
35 std::vector<std::vector<PostprocessorValue>> * transformed_pps_values;
60 (*transformed_pps_values).resize((*transformed_pps).size());
61 for (
size_t i = 0; i < (*transformed_pps).size(); i++)
62 (*transformed_pps_values)[i].resize(2);
71 if (!dynamic_cast<DefaultMultiAppFixedPointConvergence *>(&convergence))
73 "Only DefaultMultiAppFixedPointConvergence objects may be used for " 74 "'multiapp_fixed_point_convergence' when using the Steffensen fixed point algorithm.");
80 unsigned int iteration;
98 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
100 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
108 if (iteration % 2 == 1)
117 unsigned int iteration;
118 const std::vector<PostprocessorName> * transformed_pps;
119 std::vector<std::vector<PostprocessorValue>> * transformed_pps_values;
134 for (
size_t i = 0; i < (*transformed_pps).size(); i++)
136 if (iteration % 2 == 0)
157 Real relaxation_factor;
158 const std::vector<PostprocessorName> * transformed_pps;
159 std::vector<std::vector<PostprocessorValue>> * transformed_pps_values;
174 for (
size_t i = 0; i < (*transformed_pps).size(); i++)
178 const Real fxn_m1 = (*transformed_pps_values)[i][0];
179 const Real xn_m1 = (*transformed_pps_values)[i][1];
182 Real new_value = current_value;
185 xn_m1 - (fxn_m1 - xn_m1) * (fxn_m1 - xn_m1) / (current_value + xn_m1 - 2 * fxn_m1);
188 new_value = relaxation_factor * new_value + (1 - relaxation_factor) * fxn_m1;
198 Real relaxation_factor;
218 for (
const auto & dof : transformed_dofs)
221 Real new_value = solution(dof);
223 new_value = xn_m1(dof) - (fxn_m1(dof) - xn_m1(dof)) * (fxn_m1(dof) - xn_m1(dof)) /
224 (solution(dof) + xn_m1(dof) - 2 * fxn_m1(dof));
227 new_value = relaxation_factor * new_value + (1 - relaxation_factor) * fxn_m1(dof);
229 solution.
set(dof, new_value);
237 const Real initial_norm,
238 const std::vector<Real> & timestep_begin_norms,
239 const std::vector<Real> & timestep_end_norms)
const 241 _console <<
"\n 0 Steffensen initialization |R| = " 244 Real max_norm_old = initial_norm;
247 Real max_norm =
std::max(timestep_begin_norms[i], timestep_end_norms[i]);
248 std::stringstream steffensen_prefix;
250 steffensen_prefix <<
" Steffensen initialization |R| = ";
252 steffensen_prefix <<
" Steffensen half-step |R| = ";
254 steffensen_prefix <<
" Steffensen step |R| = ";
256 _console << std::setw(2) << i + 1 << steffensen_prefix.str()
259 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)
bool absoluteFuzzyEqual(const T &var1, const T2 &var2, const T3 &tol=libMesh::TOLERANCE *libMesh::TOLERANCE)
Function to check whether two variables are equal within an absolute tolerance.
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
SystemBase & _solver_sys
Reference to a system for creating vectors as needed for the solve, etc.
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
void mooseError(Args &&... args) const
Emits an error prefixed with object name and type.
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.
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