https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
SecantInversionControl Class Reference

Control that adjusts a scalar parameter (held in a postprocessor) once per fixed-point iteration using the secant method, so that a sub-app output postprocessor matches a target function of time. More...

#include <SecantInversionControl.h>

Inheritance diagram for SecantInversionControl:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 SecantInversionControl (const InputParameters &parameters)
 
virtual void execute () override final
 Template method: reads the current (parameter, output) sample, delegates the scheme-specific decision to computeUpdate(), and applies it (publish, residual, next parameter).
 
std::vector< std::string > & getDependencies ()
 
virtual bool enabled () const
 
std::shared_ptr< MooseObject > getSharedPtr ()
 
std::shared_ptr< const MooseObject > getSharedPtr () const
 
bool isKokkosObject () const
 
MooseApp & getMooseApp () const
 
const std::string & type () const
 
const std::string & name () const
 
std::string typeAndName () const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
MooseObjectName uniqueName () const
 
const InputParameters & parameters () const
 
const hit::Node * getHitNode () const
 
bool hasBase () const
 
const std::string & getBase () const
 
const T & getParam (const std::string &name) const
 
std::vector< std::pair< T1, T2 > > getParam (const std::string &param1, const std::string &param2) const
 
const T * queryParam (const std::string &name) const
 
const T & getRenamedParam (const std::string &old_name, const std::string &new_name) const
 
T getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &name) const
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void paramError (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramWarning (const std::string &param, Args... args) const
 
void paramInfo (const std::string &param, Args... args) const
 
std::string messagePrefix (const bool hit_prefix=true) const
 
std::string errorPrefix (const std::string &) const
 
void mooseError (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseDeprecatedNoTrace (Args &&... args) const
 
void mooseInfo (Args &&... args) const
 
void callMooseError (std::string msg, const bool with_prefix, const hit::Node *node=nullptr, const bool show_trace=true) const
 
std::string getDataFileName (const std::string &param) const
 
std::string getDataFileNameByName (const std::string &relative_path) const
 
std::string getDataFilePath (const std::string &relative_path) const
 
bool isImplicit ()
 
Moose::StateArg determineState () const
 
virtual void initialSetup ()
 
virtual void timestepSetup ()
 
virtual void jacobianSetup ()
 
virtual void residualSetup ()
 
virtual void subdomainSetup ()
 
virtual void customSetup (const ExecFlagType &)
 
const ExecFlagEnum & getExecuteOnEnum () const
 
const Function & getFunction (const std::string &name) const
 
const Function & getFunctionByName (const FunctionName &name) const
 
bool hasFunction (const std::string &param_name) const
 
bool hasFunctionByName (const FunctionName &name) const
 
Moose::Kokkos::Function getKokkosFunction (const std::string &name) const
 
const T & getKokkosFunction (const std::string &name) const
 
Moose::Kokkos::Function getKokkosFunctionByName (const FunctionName &name) const
 
const T & getKokkosFunctionByName (const FunctionName &name) const
 
bool hasKokkosFunction (const std::string &param_name) const
 
bool hasKokkosFunctionByName (const FunctionName &name) const
 
UserObjectName getUserObjectName (const std::string &param_name) const
 
const T & getUserObject (const std::string &param_name, bool is_dependency=true) const
 
const T & getUserObjectByName (const UserObjectName &object_name, bool is_dependency=true) const
 
const UserObjectBase & getUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectBase & getUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObject (const std::string &param_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
bool hasUserObjectByName (const UserObjectName &object_name) const
 
PerfGraph & perfGraph ()
 
bool isDefaultPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessor (const std::string &param_name, const unsigned int index=0) const
 
bool hasPostprocessorByName (const PostprocessorName &name) const
 
std::size_t coupledPostprocessors (const std::string &param_name) const
 
const PostprocessorName & getPostprocessorName (const std::string &param_name, const unsigned int index=0) const
 
const VectorPostprocessorValue & getVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValue & getVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name, bool needs_broadcast) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const VectorPostprocessorValue & getVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name, bool needs_broadcast) const
 
const ScatterVectorPostprocessorValue & getScatterVectorPostprocessorValue (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValue & getScatterVectorPostprocessorValueByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValue & getScatterVectorPostprocessorValueOld (const std::string &param_name, const std::string &vector_name) const
 
const ScatterVectorPostprocessorValue & getScatterVectorPostprocessorValueOldByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
bool hasVectorPostprocessor (const std::string &param_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool hasVectorPostprocessorByName (const VectorPostprocessorName &name) const
 
const VectorPostprocessorName & getVectorPostprocessorName (const std::string &param_name) const
 
const PostprocessorValue & getPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValue & getPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
virtual const PostprocessorValue & getPostprocessorValueByName (const PostprocessorName &name) const
 
virtual const PostprocessorValue & getPostprocessorValueByName (const PostprocessorName &name) const
 
const PostprocessorValue & getPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValue & getPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValue & getPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const PostprocessorValue & getPostprocessorValueOlderByName (const PostprocessorName &name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributed (const std::string &param_name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
bool isVectorPostprocessorDistributedByName (const VectorPostprocessorName &name) const
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Static Public Member Functions

static InputParameters validParams ()
 
static void callMooseError (MooseApp *const app, const InputParameters &params, std::string msg, const bool with_prefix, const hit::Node *node, const bool show_trace=true)
 
static MultiMooseEnum getExecuteOptions ()
 

Public Attributes

 usingCombinedWarningSolutionWarnings
 
const ConsoleStream _console
 

Static Public Attributes

static const std::string type_param
 
static const std::string name_param
 
static const std::string unique_name_param
 
static const std::string app_param
 
static const std::string moose_base_param
 
static const std::string kokkos_object_param
 

Protected Member Functions

virtual IterationUpdate computeUpdate (unsigned int it, Real p_used, Real y, Real y_target) override
 Compute this iteration's update from the current sample: the 1-based fixed-point iteration it and the (parameter, output) pair (p_used, y) that produced it, against target y_target.
 
unsigned int fixedPointIteration () const
 1-based fixed-point iteration (1 on the first iteration of each fixed-point solve, including restep)
 
Real targetValue () const
 Target output value at the current time.
 
void publishConvergedParameter (Real p)
 Publish a parameter value to the optional converged-parameter postprocessor (no-op if unset)
 
void setParameter (Real p)
 Write the next parameter guess to the parameter postprocessor.
 
Real linearRootUpdate (Real p_a, Real y_a, Real p_b, Real y_b, Real y_target)
 One guarded linear-model root update from two (parameter, output) samples – a secant step shared by the secant and finite-difference Newton schemes: returns p_b - (y_b - y_target) * (p_b - p_a) / (y_b - y_a).
 
Real normalizedResidual (Real y) const
 Normalized convergence residual for output value y: |y - targetValue()| / max(absolute_tolerance, relative_tolerance*|targetValue()|).
 
void setResidual (Real value)
 Write a value to the residual postprocessor that the Convergence object compares against 1.
 
bool hasControllableParameterByName (const std::string &name) const
 
void flagInvalidSolutionInternal (const InvalidSolutionID invalid_solution_id) const
 
InvalidSolutionID registerInvalidSolutionInternal (const std::string &message, const bool warning) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level) const
 
PerfID registerTimedSection (const std::string &section_name, const unsigned int level, const std::string &live_message, const bool print_dots=true) const
 
std::string timedSectionName (const std::string &section_name) const
 
virtual void addUserObjectDependencyHelper (const UserObjectBase &) const
 
T & declareRestartableData (const std::string &data_name, Args &&... args)
 
ManagedValue< T > declareManagedRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
const T & getRestartableData (const std::string &data_name) const
 
T & declareRestartableDataWithContext (const std::string &data_name, void *context, Args &&... args)
 
T & declareRecoverableData (const std::string &data_name, Args &&... args)
 
T & declareRestartableDataWithObjectName (const std::string &data_name, const std::string &object_name, Args &&... args)
 
T & declareRestartableDataWithObjectNameWithContext (const std::string &data_name, const std::string &object_name, void *context, Args &&... args)
 
std::string restartableName (const std::string &data_name) const
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &) const
 
virtual void addVectorPostprocessorDependencyHelper (const VectorPostprocessorName &) const
 
const ReporterContextBase & getReporterContextBaseByName (const ReporterName &reporter_name) const
 
const ReporterName & getReporterName (const std::string &param_name) const
 
virtual void addReporterDependencyHelper (const ReporterName &)
 
ControllableParameter getControllableParameter (const std::string &param_name)
 
ControllableParameter getControllableParameter (const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const std::string &tag, const std::string &object_name, const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const MooseObjectName &object_name, const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const MooseObjectParameterName &param_name)
 
ControllableParameter getControllableParameterByName (const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const std::string &tag, const std::string &object_name, const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const MooseObjectName &object_name, const std::string &param_name)
 
ControllableParameter getControllableParameterByName (const MooseObjectParameterName &param_name)
 
T getControllableValue (const std::string &name, bool warn_when_values_differ=true)
 
T getControllableValue (const std::string &name, bool warn_when_values_differ=true)
 
T getControllableValueByName (const std::string &name, bool warn_when_values_differ=true)
 
T getControllableValueByName (const std::string &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
T getControllableValueByName (const MooseObjectName &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
T getControllableValueByName (const std::string &tag, const std::string &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
T getControllableValueByName (const MooseObjectParameterName &desired, bool warn_when_values_differ=true)
 
T getControllableValueByName (const std::string &name, bool warn_when_values_differ=true)
 
T getControllableValueByName (const std::string &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
T getControllableValueByName (const MooseObjectName &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
T getControllableValueByName (const std::string &tag, const std::string &object_name, const std::string &param_name, bool warn_when_values_differ=true)
 
T getControllableValueByName (const MooseObjectParameterName &desired, bool warn_when_values_differ=true)
 
void setControllableValue (const std::string &name, const T &value)
 
void setControllableValue (const std::string &name, const T &value)
 
void setControllableValueByName (const std::string &name, const T &value)
 
void setControllableValueByName (const std::string &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const MooseObjectName &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const std::string &tag, const std::string &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const MooseObjectParameterName &name, const T &value)
 
void setControllableValueByName (const std::string &name, const T &value)
 
void setControllableValueByName (const std::string &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const MooseObjectName &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const std::string &tag, const std::string &object_name, const std::string &param_name, const T &value)
 
void setControllableValueByName (const MooseObjectParameterName &name, const T &value)
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, const std::size_t time_index=0)
 
const T & getReporterValue (const std::string &param_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, const std::size_t time_index=0)
 
const T & getReporterValueByName (const ReporterName &reporter_name, ReporterMode mode, const std::size_t time_index=0)
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValue (const std::string &param_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 
bool hasReporterValueByName (const ReporterName &reporter_name) const
 

Protected Attributes

const PostprocessorValue & _output
 Sub-app output value transferred back to the main app (compared against the target)
 
const PostprocessorValue & _param
 Parameter value consumed by the most recent sub-app solve (read in place)
 
const PostprocessorName _param_name
 Name of the parameter postprocessor to update with the next guess.
 
const std::optional< PostprocessorName > _converged_param_name
 Optional postprocessor to publish the parameter value that produced the current output.
 
const Function & _target_function
 Target output as a function of time.
 
const PostprocessorName _residual_name
 Name of the postprocessor the control writes with the normalized convergence residual.
 
const Real _abs_tol
 Absolute tolerance on |output - target|.
 
const Real _rel_tol
 Relative tolerance on |output - target|, relative to |target|.
 
FEProblemBase & _fe_problem
 
std::vector< std::string > _depends_on
 
const bool & _enabled
 
MooseApp & _app
 
Factory & _factory
 
ActionFactory & _action_factory
 
const std::string & _type
 
const std::string & _name
 
const InputParameters & _pars
 
MooseApp & _pg_moose_app
 
const std::string _prefix
 
const InputParameters & _ti_params
 
FEProblemBase & _ti_feproblem
 
bool _is_implicit
 
Real & _t
 
const Real & _t_old
 
int & _t_step
 
Real & _dt
 
Real & _dt_old
 
bool _is_transient
 
const ExecFlagEnum & _execute_enum
 
const ExecFlagType & _current_execute_flag
 
MooseApp & _restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
const Parallel::Communicator & _communicator
 

Private Member Functions

const Moose::FunctionBase * getKokkosFunctionByNameHelper (const FunctionName &name) const
 
const UserObjectBase & getUserObjectFromFEProblem (const UserObjectName &object_name, const THREAD_ID tid=0) const
 
const T & castUserObject (const UserObjectBase &uo_base, const std::string &param_name="") const
 
void mooseObjectError (const std::string &param_name, std::stringstream &oss) const
 
const std::string & userObjectType (const UserObjectBase &uo) const
 
const std::string & userObjectName (const UserObjectBase &uo) const
 
RestartableDataValue & registerRestartableDataOnApp (std::unique_ptr< RestartableDataValue > data, THREAD_ID tid) const
 
void registerRestartableNameWithFilterOnApp (const std::string &name, Moose::RESTARTABLE_FILTER filter)
 
RestartableData< T > & declareRestartableDataHelper (const std::string &data_name, void *context, Args &&... args) const
 
const PostprocessorName & getPostprocessorNameInternal (const std::string &param_name, const unsigned int index, const bool allow_default_value=true) const
 
bool isDefaultPostprocessorValueByName (const PostprocessorName &name) const
 
PostprocessorValue getDefaultPostprocessorValueByName (const PostprocessorName &name) const
 
void checkParam (const std::string &param_name, const unsigned int index=std::numeric_limits< unsigned int >::max()) const
 
bool postprocessorsAdded () const
 
const VectorPostprocessorValue & getVectorPostprocessorByNameHelper (const VectorPostprocessorName &name, const std::string &vector_name, bool broadcast, std::size_t t_index) const
 
const VectorPostprocessorContext< VectorPostprocessorValue > & getVectorPostprocessorContextByNameHelper (const VectorPostprocessorName &name, const std::string &vector_name) const
 
bool vectorPostprocessorsAdded () const
 
bool reportersAdded () const
 
void possiblyCheckHasReporter (const ReporterName &reporter_name, const std::string &param_name="") const
 
const PostprocessorValue & getPostprocessorValueInternal (const std::string &param_name, unsigned int index, std::size_t t_index) const
 
const PostprocessorValue & getPostprocessorValueInternal (const std::string &param_name, unsigned int index, std::size_t t_index) const
 
const PostprocessorValue & getPostprocessorValueByNameInternal (const PostprocessorName &name, std::size_t t_index) const
 
const PostprocessorValue & getPostprocessorValueByNameInternal (const PostprocessorName &name, std::size_t t_index) const
 
void possiblyCheckHasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessor (const std::string &param_name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 
void possiblyCheckHasVectorPostprocessorByName (const VectorPostprocessorName &name, const std::string &vector_name) const
 

Static Private Member Functions

static const hit::Node * getHitNode (const InputParameters &params)
 
static std::string messagePrefix (const InputParameters &params, const bool hit_prefix)
 

Private Attributes

const Real _initial_delta
 Perturbation applied on the first iteration of each fixed-point solve to seed the secant method.
 
Real _p_prev
 Previous iteration's parameter value (secant point); refreshed each fixed-point solve.
 
Real _y_prev
 Previous iteration's output value (secant point); refreshed each fixed-point solve.
 
InputParameterWarehouse & _input_parameter_warehouse
 
const ParallelParamObject & _parent
 
const MooseBase & _si_moose_base
 
const FEProblemBase * _si_problem
 
const std::string _ti_name
 
ExecFlagEnum _empty_execute_enum
 
const MooseObject & _fni_object
 
const InputParameters & _fni_params
 
FEProblemBase & _fni_feproblem
 
const THREAD_ID _fni_tid
 
const MooseObject & _uoi_moose_object
 
const FEProblemBase & _uoi_feproblem
 
const THREAD_ID _uoi_tid
 
const RestartableDataMapName _metaname
 
std::string _restartable_name
 
const MooseObject & _ppi_moose_object
 
const InputParameters & _ppi_params
 
const FEProblemBase & _ppi_feproblem
 
std::map< PostprocessorName, std::unique_ptr< PostprocessorValue > > _default_values
 
const bool _broadcast_by_default
 
const MooseObject & _vpi_moose_object
 
const FEProblemBase & _vpi_feproblem
 
const THREAD_ID _vpi_tid
 
const InputParameters & _ri_params
 
FEProblemBase & _ri_fe_problem_base
 
const ReporterData & _ri_reporter_data
 
const MooseObject & _ri_moose_object
 

Detailed Description

Control that adjusts a scalar parameter (held in a postprocessor) once per fixed-point iteration using the secant method, so that a sub-app output postprocessor matches a target function of time.

The outer iteration, convergence, and time-step cutting are owned by the executioner and the Convergence system; this object only performs the secant update.

Definition at line 20 of file SecantInversionControl.h.

Constructor & Destructor Documentation

◆ SecantInversionControl()

SecantInversionControl::SecantInversionControl ( const InputParameters &  parameters)

Definition at line 32 of file SecantInversionControl.C.

34 _initial_delta(getParam<Real>("initial_delta")),
35 _p_prev(0.0),
36 _y_prev(0.0)
37{
38}
Base class for controls that adjust a single scalar parameter (held in a postprocessor) once per fixe...
const InputParameters & parameters() const
const Real _initial_delta
Perturbation applied on the first iteration of each fixed-point solve to seed the secant method.
Real _y_prev
Previous iteration's output value (secant point); refreshed each fixed-point solve.
Real _p_prev
Previous iteration's parameter value (secant point); refreshed each fixed-point solve.

Member Function Documentation

◆ computeUpdate()

InversionControlBase::IterationUpdate SecantInversionControl::computeUpdate ( unsigned int  it,
Real  p_used,
Real  y,
Real  y_target 
)
overrideprotectedvirtual

Compute this iteration's update from the current sample: the 1-based fixed-point iteration it and the (parameter, output) pair (p_used, y) that produced it, against target y_target.

Implements InversionControlBase.

Definition at line 41 of file SecantInversionControl.C.

42{
43 Real p_next;
44 if (it == 1)
45 // Only one (p, y) pair known: seed the secant method with a perturbation.
46 p_next = p_used + _initial_delta;
47 else
48 p_next = linearRootUpdate(_p_prev, _y_prev, p_used, y, y_target);
49
50 // _p_prev/_y_prev are plain members, not restartable: they are re-seeded on the first iteration
51 // of every fixed-point solve (it == 1), so a recover at a step boundary loses nothing.
52 _p_prev = p_used;
53 _y_prev = y;
54
55 // Every secant iteration reports the normalized residual and publishes its evaluated parameter.
56 return {p_next, normalizedResidual(y), true};
57}
const std::vector< double > y
Real normalizedResidual(Real y) const
Normalized convergence residual for output value y: |y - targetValue()| / max(absolute_tolerance,...
Real linearRootUpdate(Real p_a, Real y_a, Real p_b, Real y_b, Real y_target)
One guarded linear-model root update from two (parameter, output) samples – a secant step shared by t...
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ execute()

void InversionControlBase::execute ( )
finaloverridevirtualinherited

Template method: reads the current (parameter, output) sample, delegates the scheme-specific decision to computeUpdate(), and applies it (publish, residual, next parameter).

Derived classes implement computeUpdate(), not this.

Implements Control.

Definition at line 102 of file InversionControlBase.C.

103{
104 const unsigned int it = fixedPointIteration();
105 const Real p_used = _param;
106 const Real y = _output;
107 const Real y_target = targetValue();
108
109 const IterationUpdate update = computeUpdate(it, p_used, y, y_target);
110
111 // Publish the parameter that produced the current output (the solution at convergence).
112 if (update.publish)
114 // Report the convergence residual the fixed-point Convergence object compares against 1.
115 setResidual(update.residual);
116 // Write the next guess back to the working parameter postprocessor.
117 setParameter(update.next_parameter);
118}
virtual IterationUpdate computeUpdate(unsigned int it, Real p_used, Real y, Real y_target)=0
Compute this iteration's update from the current sample: the 1-based fixed-point iteration it and the...
void setResidual(Real value)
Write a value to the residual postprocessor that the Convergence object compares against 1.
unsigned int fixedPointIteration() const
1-based fixed-point iteration (1 on the first iteration of each fixed-point solve,...
const PostprocessorValue & _param
Parameter value consumed by the most recent sub-app solve (read in place)
void publishConvergedParameter(Real p)
Publish a parameter value to the optional converged-parameter postprocessor (no-op if unset)
void setParameter(Real p)
Write the next parameter guess to the parameter postprocessor.
const PostprocessorValue & _output
Sub-app output value transferred back to the main app (compared against the target)
Real targetValue() const
Target output value at the current time.

◆ fixedPointIteration()

unsigned int InversionControlBase::fixedPointIteration ( ) const
protectedinherited

1-based fixed-point iteration (1 on the first iteration of each fixed-point solve, including restep)

Definition at line 76 of file InversionControlBase.C.

77{
78 Executioner * const executioner = _app.getExecutioner();
79 // hasSolveObject<FixedPointSolve>() guards the null (executor-style executioners never build
80 // one); hasFixedPointIteration() then checks that fixed-point iteration is actually enabled.
81 // Without the second check a standard executioner with no fixed-point settings still owns a
82 // FixedPointSolve, so the control would silently drift the parameter once per time step instead
83 // of iterating.
84 if (!executioner || !executioner->hasSolveObject<FixedPointSolve>() ||
87 "requires an executioner configured to perform fixed-point (MultiApp) iterations; set "
88 "'fixed_point_max_its' greater than 1 (or otherwise enable fixed-point iteration) on "
89 "the executioner.");
90 // numFixedPointIts() returns _fixed_point_it + 1, i.e. 1 on the first iteration of each fresh
91 // fixed-point solve (including a restep retry).
92 return executioner->fixedPointSolve().numFixedPointIts();
93}
bool hasSolveObject() const
FixedPointSolve & fixedPointSolve()
unsigned int numFixedPointIts() const
bool hasFixedPointIteration()
Executioner * getExecutioner() const
void mooseError(Args &&... args) const
MooseApp & _app

Referenced by InversionControlBase::execute().

◆ linearRootUpdate()

Real InversionControlBase::linearRootUpdate ( Real  p_a,
Real  y_a,
Real  p_b,
Real  y_b,
Real  y_target 
)
protectedinherited

One guarded linear-model root update from two (parameter, output) samples – a secant step shared by the secant and finite-difference Newton schemes: returns p_b - (y_b - y_target) * (p_b - p_a) / (y_b - y_a).

If the denominator or slope is too small to divide by, emits a warning and returns p_b unchanged.

Definition at line 134 of file InversionControlBase.C.

135{
136 const Real dp = p_b - p_a;
137 const Real dy = y_b - y_a;
138 // Guard a vanishing or non-finite denominator/slope before dividing. The magnitude-scaled
139 // threshold is a pragmatic "dy too small" heuristic, not a principled relative tolerance; the
140 // finiteness check also traps a NaN/Inf sample from a diverging forward solve, which the "<"
141 // comparisons alone would let through (every comparison with NaN is false).
142 if (!std::isfinite(dp) || !std::isfinite(dy) || std::abs(dp) < 1e-15 ||
143 std::abs(dy) < 1e-15 * (std::abs(y_b) + std::abs(y_a) + 1.0))
144 {
145 mooseWarning("The parameter update at t = ",
146 _t,
147 " has a vanishing or non-finite denominator or slope; leaving the parameter "
148 "unchanged.");
149 return p_b;
150 }
151 return p_b - (y_b - y_target) * dp / dy;
152}
void mooseWarning(Args &&... args) const
Real & _t

Referenced by NewtonInversionControl::computeUpdate(), and computeUpdate().

◆ normalizedResidual()

Real InversionControlBase::normalizedResidual ( Real  y) const
protectedinherited

Normalized convergence residual for output value y: |y - targetValue()| / max(absolute_tolerance, relative_tolerance*|targetValue()|).

A value <= 1 means the absolute OR relative criterion is satisfied. The denominator is always positive because absolute_tolerance is range-checked > 0, so no divide guard is needed. When targetValue() is 0 the relative term vanishes and the criterion collapses to the purely absolute test |y| <= absolute_tolerance; choose absolute_tolerance accordingly for targets that cross or sit at zero, where a relative tolerance carries no meaning.

Definition at line 155 of file InversionControlBase.C.

156{
157 const Real target = targetValue();
158 return std::abs(y - target) / std::max(_abs_tol, _rel_tol * std::abs(target));
159}
const Real _rel_tol
Relative tolerance on |output - target|, relative to |target|.
const Real _abs_tol
Absolute tolerance on |output - target|.

Referenced by NewtonInversionControl::computeUpdate(), and computeUpdate().

◆ publishConvergedParameter()

void InversionControlBase::publishConvergedParameter ( Real  p)
protectedinherited

Publish a parameter value to the optional converged-parameter postprocessor (no-op if unset)

Definition at line 121 of file InversionControlBase.C.

122{
125}
const Real p
FEProblemBase & _fe_problem
void setPostprocessorValueByName(const PostprocessorName &name, const PostprocessorValue &value, std::size_t t_index=0)
const std::optional< PostprocessorName > _converged_param_name
Optional postprocessor to publish the parameter value that produced the current output.

Referenced by InversionControlBase::execute().

◆ setParameter()

void InversionControlBase::setParameter ( Real  p)
protectedinherited

Write the next parameter guess to the parameter postprocessor.

Definition at line 128 of file InversionControlBase.C.

129{
131}
const PostprocessorName _param_name
Name of the parameter postprocessor to update with the next guess.

Referenced by InversionControlBase::execute().

◆ setResidual()

void InversionControlBase::setResidual ( Real  value)
protectedinherited

Write a value to the residual postprocessor that the Convergence object compares against 1.

Definition at line 162 of file InversionControlBase.C.

163{
165}
const PostprocessorName _residual_name
Name of the postprocessor the control writes with the normalized convergence residual.

Referenced by InversionControlBase::execute().

◆ targetValue()

Real InversionControlBase::targetValue ( ) const
protectedinherited

Target output value at the current time.

Definition at line 96 of file InversionControlBase.C.

97{
99}
virtual Real value(Real t, const Point &p) const
const Function & _target_function
Target output as a function of time.

Referenced by InversionControlBase::execute(), and InversionControlBase::normalizedResidual().

◆ validParams()

InputParameters SecantInversionControl::validParams ( )
static

Definition at line 15 of file SecantInversionControl.C.

16{
19 "Adjusts a parameter postprocessor each fixed-point iteration using the secant method so "
20 "that a sub-app output postprocessor matches a target function of time.");
21
23 "initial_delta",
24 1e-3,
25 "initial_delta>0",
26 "Perturbation applied to the parameter on the first iteration of each fixed-point solve to "
27 "seed the secant method.");
28
29 return params;
30}
void addClassDescription(const std::string &doc_string)
void addRangeCheckedParam(const std::string &name, const T &value, const std::string &parsed_function, const std::string &doc_string)
static InputParameters validParams()

Member Data Documentation

◆ _abs_tol

const Real InversionControlBase::_abs_tol
protectedinherited

Absolute tolerance on |output - target|.

Definition at line 106 of file InversionControlBase.h.

Referenced by InversionControlBase::normalizedResidual().

◆ _converged_param_name

const std::optional<PostprocessorName> InversionControlBase::_converged_param_name
protectedinherited

Optional postprocessor to publish the parameter value that produced the current output.

Definition at line 100 of file InversionControlBase.h.

Referenced by InversionControlBase::publishConvergedParameter().

◆ _initial_delta

const Real SecantInversionControl::_initial_delta
private

Perturbation applied on the first iteration of each fixed-point solve to seed the secant method.

Definition at line 33 of file SecantInversionControl.h.

Referenced by computeUpdate().

◆ _output

const PostprocessorValue& InversionControlBase::_output
protectedinherited

Sub-app output value transferred back to the main app (compared against the target)

Definition at line 94 of file InversionControlBase.h.

Referenced by InversionControlBase::execute().

◆ _p_prev

Real SecantInversionControl::_p_prev
private

Previous iteration's parameter value (secant point); refreshed each fixed-point solve.

Definition at line 35 of file SecantInversionControl.h.

Referenced by computeUpdate().

◆ _param

const PostprocessorValue& InversionControlBase::_param
protectedinherited

Parameter value consumed by the most recent sub-app solve (read in place)

Definition at line 96 of file InversionControlBase.h.

Referenced by InversionControlBase::execute().

◆ _param_name

const PostprocessorName InversionControlBase::_param_name
protectedinherited

Name of the parameter postprocessor to update with the next guess.

Definition at line 98 of file InversionControlBase.h.

Referenced by NewtonInversionControl::computeUpdate(), and InversionControlBase::setParameter().

◆ _rel_tol

const Real InversionControlBase::_rel_tol
protectedinherited

Relative tolerance on |output - target|, relative to |target|.

Definition at line 108 of file InversionControlBase.h.

Referenced by InversionControlBase::normalizedResidual().

◆ _residual_name

const PostprocessorName InversionControlBase::_residual_name
protectedinherited

Name of the postprocessor the control writes with the normalized convergence residual.

Definition at line 104 of file InversionControlBase.h.

Referenced by InversionControlBase::setResidual().

◆ _target_function

const Function& InversionControlBase::_target_function
protectedinherited

Target output as a function of time.

Definition at line 102 of file InversionControlBase.h.

Referenced by InversionControlBase::targetValue().

◆ _y_prev

Real SecantInversionControl::_y_prev
private

Previous iteration's output value (secant point); refreshed each fixed-point solve.

Definition at line 37 of file SecantInversionControl.h.

Referenced by computeUpdate().


The documentation for this class was generated from the following files: