97 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
99 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
101 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
103 "allocateStorage has not been called with primary = " +
Moose::stringify(primary));
132 const std::vector<PostprocessorName> * transformed_pps;
133 std::vector<std::vector<PostprocessorValue>> * transformed_pps_values;
147 for (
size_t i = 0; i < (*transformed_pps).size(); i++)
150 (*transformed_pps_values)[i][3] = (*transformed_pps_values)[i][1];
162 (*transformed_pps_values)[i][2] = (*transformed_pps_values)[i][1];
165 (*transformed_pps_values)[i][2] = (*transformed_pps_values)[i][0];
185 Real relaxation_factor;
186 const std::vector<PostprocessorName> * transformed_pps;
187 std::vector<std::vector<PostprocessorValue>> * transformed_pps_values;
202 for (
size_t i = 0; i < (*transformed_pps).size(); i++)
206 const Real xn_m1 = (*transformed_pps_values)[i][1];
207 const Real fxn_m2 = (*transformed_pps_values)[i][2];
208 const Real xn_m2 = (*transformed_pps_values)[i][3];
211 (*transformed_pps_values)[i][0] = fxn_m1;
214 Real new_value = fxn_m1;
215 if (!MooseUtils::absoluteFuzzyEqual(fxn_m1 - xn_m1 - fxn_m2 + xn_m2, 0))
216 new_value = xn_m1 - (fxn_m1 - xn_m1) * (xn_m1 - xn_m2) / (fxn_m1 - xn_m1 - fxn_m2 + xn_m2);
219 new_value = relaxation_factor * new_value + (1 - relaxation_factor) * xn_m1;
228 Real relaxation_factor;
259 for (
const auto & dof : target_dofs)
262 Real new_value = fxn_m1(dof);
263 if (!MooseUtils::absoluteFuzzyEqual(solution(dof) - xn_m1(dof) - fxn_m2(dof) + xn_m2(dof), 0))
264 new_value = xn_m1(dof) - (solution(dof) - xn_m1(dof)) * (xn_m1(dof) - xn_m2(dof)) /
265 (solution(dof) - xn_m1(dof) - fxn_m2(dof) + xn_m2(dof));
268 new_value = relaxation_factor * new_value + (1 - relaxation_factor) * xn_m1(dof);
270 solution.
set(dof, new_value);
278 const std::vector<Real> & timestep_begin_norms,
279 const std::vector<Real> & timestep_end_norms)
const 281 _console <<
"\n 0 Secant initialization |R| = " 284 Real max_norm_old = initial_norm;
287 Real max_norm =
std::max(timestep_begin_norms[i], timestep_end_norms[i]);
288 std::stringstream secant_prefix;
290 secant_prefix <<
" Secant initialization |R| = ";
292 secant_prefix <<
" Secant step |R| = ";
294 _console << std::setw(2) << i + 1 << secant_prefix.str()
296 max_norm_old = max_norm;
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)...
FEProblemBase & _problem
Reference to FEProblem.
TagID _secondary_xn_m1_tagid
Vector tag id for the solution variable before the latest solve, as a sub app.
NumericVector< Number > & solution()
TagID _secondary_fxn_m2_tagid
Vector tag id for the result of the last but one secondary solve, as a sub app.
static InputParameters validParams()
void setPostprocessorValueByName(const PostprocessorName &name, const PostprocessorValue &value, std::size_t t_index=0)
Set the value of a PostprocessorValue.
TagID _secondary_xn_m2_tagid
Vector tag id for the solution variable two primary solves ago, as a sub app.
virtual void saveVariableValues(const bool primary) override final
Saves the current values of the variables, and update the old(er) vectors.
virtual TagID addVectorTag(const TagName &tag_name, const Moose::VectorTagType type=Moose::VECTOR_TAG_RESIDUAL)
Create a Tag.
TagID _xn_m2_tagid
Vector tag id for the solution variable two solves ago, as a main app.
TagID _fxn_m1_tagid
Vector tag id for the most recent solution variable, pre-Secant transform, as a main app...
const TagName PREVIOUS_FP_SOLUTION_TAG
std::vector< PostprocessorName > _secondary_transformed_pps
Postprocessors to be relaxed outside of fixed point iteration (used as a subapp)
virtual void transformPostprocessors(const bool primary) override final
Use the fixed point algorithm to transform the postprocessors.
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.
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.
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)
TagID _secondary_fxn_m1_tagid
Vector tag id for the most recent solution variable, pre-Secant transform, as a sub app...
const Real _relax_factor
Relaxation factor for fixed point Iteration.
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.
Executioners are objects that do the actual work of solving your problem.
Real _secondary_relaxation_factor
Relaxation factor outside of fixed point iteration (used as a subapp)
virtual void savePostprocessorValues(const bool primary) override final
Saves the current values of the postprocessors, and update the old(er) vectors.
std::string stringify(const T &t)
conversion to string
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.
TagID _fxn_m2_tagid
Vector tag id for the result of the last but one solve, as a main app.
virtual const PostprocessorValue & getPostprocessorValueByName(const PostprocessorName &name) const
Retrieve the value of the Postprocessor.
unsigned int _fixed_point_it
TagID _xn_m1_tagid
Vector tag id for the solution variable before the latest solve, as a main app.
static InputParameters validParams()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
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.
virtual void allocateStorage(const bool primary) override final
Allocate storage for the fixed point algorithm.
virtual bool useFixedPointAlgorithmUpdateInsteadOfPicard(const bool primary) override final
Use the fixed point algorithm transform instead of simply using the Picard update.
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.
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.
SecantSolve(Executioner &ex)
unsigned int _main_fixed_point_it
fixed point iteration counter for the main app