https://mooseframework.inl.gov
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
SteadyAndAdjoint Class Reference

#include <SteadyAndAdjoint.h>

Inheritance diagram for SteadyAndAdjoint:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 SteadyAndAdjoint (const InputParameters &parameters)
 
virtual void execute () override
 This call is basically a copy from Steady without the AMR loop and with a call to the adjoint solver after the fixed point solver. More...
 
virtual bool lastSolveConverged () const override
 Copy of the functionality from Steady to keep track of whether the latest solve converged. More...
 
virtual void init () override
 
virtual void checkIntegrity ()
 
virtual unsigned int getIterationNumberOutput () const
 
virtual void setIterationNumberOutput (unsigned int iteration_number)
 
virtual void preProblemInit ()
 
virtual void preExecute ()
 
virtual void postExecute ()
 
virtual void preSolve ()
 
virtual void postSolve ()
 
virtual Problemproblem ()
 
FEProblemBasefeProblem ()
 
virtual std::string getTimeStepperName () const
 
virtual std::vector< std::string > getTimeIntegratorNames () const
 
virtual void parentOutputPositionChanged ()
 
FixedPointSolvefixedPointSolve ()
 
const bool & verbose () const
 
virtual bool enabled () const
 
std::shared_ptr< MooseObjectgetSharedPtr ()
 
std::shared_ptr< const MooseObjectgetSharedPtr () const
 
MooseAppgetMooseApp () const
 
const std::string & type () const
 
virtual const std::string & name () const
 
std::string typeAndName () const
 
std::string errorPrefix (const std::string &error_type) const
 
void callMooseError (std::string msg, const bool with_prefix) const
 
MooseObjectParameterName uniqueParameterName (const std::string &parameter_name) const
 
const InputParametersparameters () const
 
MooseObjectName uniqueName () 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
 
getCheckedPointerParam (const std::string &name, const std::string &error_string="") const
 
bool isParamValid (const std::string &name) const
 
bool isParamSetByUser (const std::string &nm) const
 
void paramError (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
 
void connectControllableParams (const std::string &parameter, const std::string &object_type, const std::string &object_name, const std::string &object_parameter) const
 
void mooseError (Args &&... args) const
 
void mooseErrorNonPrefixed (Args &&... args) const
 
void mooseDocumentedError (const std::string &repo_name, const unsigned int issue_num, Args &&... args) const
 
void mooseWarning (Args &&... args) const
 
void mooseWarningNonPrefixed (Args &&... args) const
 
void mooseDeprecated (Args &&... args) const
 
void mooseInfo (Args &&... args) 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
 
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 UserObjectgetUserObjectBase (const std::string &param_name, bool is_dependency=true) const
 
const UserObjectgetUserObjectBaseByName (const UserObjectName &object_name, bool is_dependency=true) const
 
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
 
PerfGraphperfGraph ()
 
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
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValue (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOld (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
const PostprocessorValuegetPostprocessorValueOlder (const std::string &param_name, const unsigned int index=0) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
virtual const PostprocessorValuegetPostprocessorValueByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOldByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
const PostprocessorValuegetPostprocessorValueOlderByName (const PostprocessorName &name) const
 
virtual void store (nlohmann::json &json) const
 
virtual bool shouldStore () const
 
virtual void declareLateValues ()
 
void buildOutputHideVariableList (std::set< std::string > variable_names)
 
const std::set< OutputName > & getOutputs ()
 
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 MooseEnum iterationMethods ()
 

Public Attributes

const ConsoleStream _console
 

Protected Member Functions

virtual PostprocessorValueaddAttributeReporter (const std::string &name, Real initial_value=0)
 
virtual void addUserObjectDependencyHelper (const UserObject &) const
 
virtual void addPostprocessorDependencyHelper (const PostprocessorName &) 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
 
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
 
T & declareUnusedValue (Args &&... args)
 
const ReporterNamegetReporterName (const std::string &param_name) const
 
virtual void addReporterDependencyHelper (const ReporterName &)
 
T & declareValue (const std::string &param_name, Args &&... args)
 
T & declareValue (const std::string &param_name, ReporterMode mode, Args &&... args)
 
T & declareValue (const std::string &param_name, Args &&... args)
 
T & declareValue (const std::string &param_name, ReporterMode mode, Args &&... args)
 
T & declareValue (const std::string &param_name, Args &&... args)
 
T & declareValue (const std::string &param_name, ReporterMode mode, Args &&... args)
 
T & declareValue (const std::string &param_name, Args &&... args)
 
T & declareValue (const std::string &param_name, ReporterMode mode, Args &&... args)
 
T & declareValueByName (const ReporterValueName &value_name, Args &&... args)
 
T & declareValueByName (const ReporterValueName &value_name, ReporterMode mode, Args &&... args)
 
T & declareValueByName (const ReporterValueName &value_name, Args &&... args)
 
T & declareValueByName (const ReporterValueName &value_name, ReporterMode mode, Args &&... args)
 
T & declareValueByName (const ReporterValueName &value_name, Args &&... args)
 
T & declareValueByName (const ReporterValueName &value_name, ReporterMode mode, Args &&... args)
 
T & declareValueByName (const ReporterValueName &value_name, Args &&... args)
 
T & declareValueByName (const ReporterValueName &value_name, ReporterMode mode, Args &&... args)
 
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

AdjointSolve _adjoint_solve
 The solver which computes the adjoint system. More...
 
FEProblemSolve _feproblem_solve
 
FEProblemBase_problem
 
Real _system_time
 
int_time_step
 
Real_time
 
unsigned int _output_iteration_number
 
FEProblemBase_fe_problem
 
MooseEnum _iteration_method
 
std::unique_ptr< FixedPointSolve_fixed_point_solve
 
std::string _restart_file_base
 
const bool & _verbose
 
const bool & _enabled
 
MooseApp_app
 
const std::string _type
 
const std::string _name
 
const InputParameters_pars
 
Factory_factory
 
ActionFactory_action_factory
 
MooseApp_restartable_app
 
const std::string _restartable_system_name
 
const THREAD_ID _restartable_tid
 
const bool _restartable_read_only
 
MooseApp_pg_moose_app
 
const std::string _prefix
 
const Parallel::Communicator & _communicator
 

Private Attributes

bool _last_solve_converged = true
 

Detailed Description

Definition at line 18 of file SteadyAndAdjoint.h.

Constructor & Destructor Documentation

◆ SteadyAndAdjoint()

SteadyAndAdjoint::SteadyAndAdjoint ( const InputParameters parameters)

Definition at line 37 of file SteadyAndAdjoint.C.

39 {
40 }
AdjointSolve _adjoint_solve
The solver which computes the adjoint system.
const InputParameters & parameters() const
Steady(const InputParameters &parameters)

Member Function Documentation

◆ execute()

void SteadyAndAdjoint::execute ( )
overridevirtual

This call is basically a copy from Steady without the AMR loop and with a call to the adjoint solver after the fixed point solver.

Reimplemented from Steady.

Definition at line 43 of file SteadyAndAdjoint.C.

44 {
45  // This is basically copied from Steady (without AMR)
46  if (_app.isRecovering())
47  {
48  _console << "\nCannot recover steady solves!\nExiting...\n" << std::endl;
49  _last_solve_converged = true;
50  return;
51  }
52 
53  _time_step = 0;
54  _time = _time_step;
55  _problem.outputStep(EXEC_INITIAL);
57 
58  preExecute();
59 
61  _time_step = 1;
63 
64  // Solving forward and adjoint problem here (only difference from Steady)
66 
67  if (!lastSolveConverged())
68  _console << "Forward solve did not converge." << std::endl;
69 
70  _console << "Starting Adjoint solve" << std::endl;
71 
72  // this is to check that they are both true
73  bool adjoint_solve_converged = _adjoint_solve.solve();
74  _last_solve_converged &= adjoint_solve_converged;
75 
76  if (!lastSolveConverged())
77  {
78  if (!adjoint_solve_converged)
79  _console << "Adjoint solve did not converge." << std::endl;
80  }
81  else
82  {
83  _time = _time_step;
84  _problem.outputStep(EXEC_TIMESTEP_END);
86  }
87 
88  {
89  TIME_SECTION("final", 1, "Executing Final Objects")
90  _problem.execMultiApps(EXEC_FINAL);
91  _problem.finalizeMultiApps();
93  _problem.execute(EXEC_FINAL);
94  _time = _time_step;
95  _problem.outputStep(EXEC_FINAL);
97  }
98 
99  postExecute();
100 }
virtual void preExecute()
void timestepSetup() override
Real & _time
AdjointSolve _adjoint_solve
The solver which computes the adjoint system.
int & _time_step
virtual bool lastSolveConverged() const override
Copy of the functionality from Steady to keep track of whether the latest solve converged.
virtual void advanceState()
Real _system_time
virtual void postExecute()
virtual bool solve() override
Solve the adjoint system with the following procedure:
Definition: AdjointSolve.C:79
FEProblemBase & _problem
MooseApp & _app
virtual void execute() override
This call is basically a copy from Steady without the AMR loop and with a call to the adjoint solver ...
const ConsoleStream _console
bool isRecovering() const
std::unique_ptr< FixedPointSolve > _fixed_point_solve
virtual void outputStep(ExecFlagType type)

◆ lastSolveConverged()

virtual bool SteadyAndAdjoint::lastSolveConverged ( ) const
inlineoverridevirtual

Copy of the functionality from Steady to keep track of whether the latest solve converged.

Reimplemented from Steady.

Definition at line 34 of file SteadyAndAdjoint.h.

Referenced by execute().

34 { return _last_solve_converged; }

◆ validParams()

InputParameters SteadyAndAdjoint::validParams ( )
static

Definition at line 16 of file SteadyAndAdjoint.C.

17 {
19  params += AdjointSolve::validParams();
20  params.addClassDescription(
21  "Executioner for evaluating steady-state simulations and their adjoint.");
22 
23  // We need the full matrix for the adjoint solve, so set this to NEWTON
24  params.set<MooseEnum>("solve_type") = "newton";
25  params.suppressParameter<MooseEnum>("solve_type");
26 
27  // The adjoint system (second one) is solved by _adjoint_solve
28  // This is a parameter of the MultiSystemSolveObject, which we set from here, the executioner.
29  // We seek to prevent the MultiSystemSolveObject from solving both systems
30  // This is abusing input parameters, but SolveObjects do not have their own syntax
31  // and we need to send this parameter from the executioner to the default nested SolveObject
32  params.renameParam("system_names", "forward_system", "");
33 
34  return params;
35 }
void renameParam(const std::string &old_name, const std::string &new_name, const std::string &new_docstring)
static InputParameters validParams()
Definition: AdjointSolve.C:27
T & set(const std::string &name, bool quiet_mode=false)
void suppressParameter(const std::string &name)
static InputParameters validParams()
void addClassDescription(const std::string &doc_string)

Member Data Documentation

◆ _adjoint_solve

AdjointSolve SteadyAndAdjoint::_adjoint_solve
protected

The solver which computes the adjoint system.

This is where the real magic happens, so it is recommended to look into this object to understand the algorithm.

Definition at line 39 of file SteadyAndAdjoint.h.

Referenced by execute().

◆ _last_solve_converged

bool SteadyAndAdjoint::_last_solve_converged = true
private

Definition at line 42 of file SteadyAndAdjoint.h.

Referenced by execute(), and lastSolveConverged().


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