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

#include <TransientAndAdjoint.h>

Inheritance diagram for TransientAndAdjoint:
[legend]

Public Types

typedef DataFileName DataFileParameterType
 

Public Member Functions

 TransientAndAdjoint (const InputParameters &parameters)
 
virtual void preExecute () override
 For storing the initial condition. More...
 
virtual void postStep () override
 For storing the converged solution. More...
 
virtual void postExecute () override
 For solving the adjoint problem. More...
 
virtual void init () override
 
virtual Real relativeSolutionDifferenceNorm (bool check_aux) const override
 
virtual void execute () override
 
virtual void takeStep (Real input_dt=-1.0)
 
virtual Real computeConstrainedDT ()
 
virtual void estimateTimeError ()
 
virtual Real getDT ()
 
virtual bool keepGoing ()
 
virtual bool lastSolveConverged () const override
 
void computeDT ()
 
virtual void preStep ()
 
virtual void incrementStepOrReject ()
 
virtual void endStep (Real input_time=-1.0)
 
virtual void setTargetTime (Real target_time)
 
virtual Real getTime () const
 
virtual Real getTargetTime ()
 
virtual void setTime (Real t)
 
virtual void setTimeOld (Real t)
 
Real computeSolutionChangeNorm (bool check_aux, bool normalize_by_dt) const
 
TimeSteppergetTimeStepper ()
 
const TimeSteppergetTimeStepper () const
 
void setTimeStepper (TimeStepper &ts)
 
virtual std::string getTimeStepperName () const override
 
virtual std::vector< std::string > getTimeIntegratorNames () const override
 
Moose::TimeIntegratorType getTimeScheme () const
 
std::set< Real > & syncTimes ()
 
RealdtMax ()
 
RealdtMin ()
 
Real getStartTime () const
 
Real getEndTime () const
 
RealendTime ()
 
RealtimestepTol ()
 
virtual void setTimestepTolerance (const Real &tolerance)
 
bool atSyncPoint ()
 
Real unconstrainedDT ()
 
void parentOutputPositionChanged () override
 
virtual void forceNumSteps (const unsigned int num_steps)
 
virtual SolveObjecttimeStepSolveObject ()
 
bool convergedToSteadyState () const
 
virtual void preProblemInit ()
 
virtual void preSolve ()
 
virtual void postSolve ()
 
virtual Problemproblem ()
 
FEProblemBasefeProblem ()
 
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 InputParameters defaultSteadyStateConvergenceParams ()
 
static MooseEnum iterationMethods ()
 

Public Attributes

const ConsoleStream _console
 

Protected Member Functions

virtual std::set< TimeIntegrator *> getTimeIntegrators () const override
 
void setupTimeIntegrator ()
 
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

AdjointTransientSolve _adjoint_solve
 The transient adjoint solve object responsible for storing forward solutions and solving the adjoint system. More...
 
std::vector< Real > & _forward_times
 Cached forward time points so we can properly loop backward in time. More...
 
FEProblemSolve _feproblem_solve
 
FEProblemBase_problem
 
AuxiliarySystem_aux
 
Moose::TimeIntegratorType _time_scheme
 
TimeStepper_time_stepper
 
int_t_step
 
Real_time
 
Real_time_old
 
Real_dt
 
Real_dt_old
 
Real_unconstrained_dt
 
bool & _at_sync_point
 
bool & _last_solve_converged
 
bool _xfem_repeat_step
 
Real _end_time
 
Real _dtmin
 
Real _dtmax
 
unsigned int _num_steps
 
int _n_startup_steps
 
const bool _steady_state_detection
 
const Real _steady_state_start_time
 
std::set< Real > & _sync_times
 
bool _abort
 
const bool _error_on_dtmin
 
bool & _time_interval
 
Real _next_interval_output_time
 
Real _time_interval_output_interval
 
Real _start_time
 
Real _timestep_tolerance
 
Real_target_time
 
bool _use_multiapp_dt
 
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
 

Detailed Description

Definition at line 18 of file TransientAndAdjoint.h.

Constructor & Destructor Documentation

◆ TransientAndAdjoint()

TransientAndAdjoint::TransientAndAdjoint ( const InputParameters parameters)

Definition at line 38 of file TransientAndAdjoint.C.

40  _adjoint_solve(*this),
41  _forward_times(declareRecoverableData<std::vector<Real>>("forward_times"))
42 {
43  // Error out on unsupported time integration schemes
44  switch (getTimeScheme())
45  {
47  break;
48  default:
49  paramError(
50  "scheme", getParam<MooseEnum>("scheme"), " is not supported for computing adjoint.");
51  break;
52  }
53 }
Transient(const InputParameters &parameters)
std::vector< Real > & _forward_times
Cached forward time points so we can properly loop backward in time.
TI_IMPLICIT_EULER
AdjointTransientSolve _adjoint_solve
The transient adjoint solve object responsible for storing forward solutions and solving the adjoint ...
void paramError(const std::string &param, Args... args) const
const InputParameters & parameters() const
Moose::TimeIntegratorType getTimeScheme() const
T & declareRecoverableData(const std::string &data_name, Args &&... args)

Member Function Documentation

◆ postExecute()

void TransientAndAdjoint::postExecute ( )
overridevirtual

For solving the adjoint problem.

Reimplemented from Transient.

Definition at line 85 of file TransientAndAdjoint.C.

86 {
88 
89  // If it is a half transient, then the app is meant to be run with recovery. Therefore, it doesn't
90  // make sense to run the adjoint calculation since we aren't getting to the final time required
91  // for a consistent adjoint.
93  return;
94 
95  // Looping backward through forward time steps
96  for (const auto n : make_range(_forward_times.size() - 1))
97  {
98  // Set important time information so the Jacobian is properly computed in the forward system
99  _t_step = _forward_times.size() - 1 - n;
102  _dt = _time - _time_old;
104 
105  // Set the forward solution to the time step that is currently being solved
107 
108  // Incase there are some residual objects that need this call
111 
112  // Solve the adjoint system
114  if (!lastSolveConverged())
115  break;
116 
117  // FIXME: This works well enough for console and CSV output, but exodus is a mess since I don't
118  // think it knows what to do with backward timestepping or duplicate outputs at a given time
120  }
121 }
void timestepSetup() override
virtual void postExecute() override
bool & _last_solve_converged
Real & _time
FEProblemBase & _problem
std::vector< Real > & _forward_times
Cached forward time points so we can properly loop backward in time.
Real & _time_old
Real & _dt
bool testCheckpointHalfTransient() const
AdjointTransientSolve _adjoint_solve
The transient adjoint solve object responsible for storing forward solutions and solving the adjoint ...
const ExecFlagType EXEC_ADJOINT_TIMESTEP_END
MooseApp & _app
void setForwardSolution(int tstep)
Takes the previously saved forward solutions residing in the adjoint system and copies them to the av...
Real & _dt_old
virtual void onTimestepBegin() override
IntRange< T > make_range(T beg, T end)
virtual bool lastSolveConverged() const override
virtual bool solve() override
Overriding parent class so the time-derivative residual is stored for the next time step...
virtual void outputStep(ExecFlagType type)
int & _t_step

◆ postStep()

void TransientAndAdjoint::postStep ( )
overridevirtual

For storing the converged solution.

Reimplemented from Transient.

Definition at line 72 of file TransientAndAdjoint.C.

73 {
75 
76  // Save the converged forward solution and time
77  if (lastSolveConverged())
78  {
80  _forward_times.push_back(_time);
81  }
82 }
Real & _time
std::vector< Real > & _forward_times
Cached forward time points so we can properly loop backward in time.
virtual void postStep()
AdjointTransientSolve _adjoint_solve
The transient adjoint solve object responsible for storing forward solutions and solving the adjoint ...
void insertForwardSolution(int tstep)
This function should be called after every converged forward time step.
virtual bool lastSolveConverged() const override
int & _t_step

◆ preExecute()

void TransientAndAdjoint::preExecute ( )
overridevirtual

For storing the initial condition.

Reimplemented from Transient.

Definition at line 56 of file TransientAndAdjoint.C.

57 {
59 
60  // Save the forward initial condition
62 
63  // Save the time of the initial condition
64  // The vector of times should be reset unless we are recovering
65  if (!_app.isRecovering())
67  else
68  _forward_times.push_back(_time);
69 }
virtual void preExecute() override
Real & _time
std::vector< Real > & _forward_times
Cached forward time points so we can properly loop backward in time.
AdjointTransientSolve _adjoint_solve
The transient adjoint solve object responsible for storing forward solutions and solving the adjoint ...
void insertForwardSolution(int tstep)
This function should be called after every converged forward time step.
MooseApp & _app
bool isRecovering() const
int & _t_step

◆ validParams()

InputParameters TransientAndAdjoint::validParams ( )
static

Definition at line 18 of file TransientAndAdjoint.C.

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

Member Data Documentation

◆ _adjoint_solve

AdjointTransientSolve TransientAndAdjoint::_adjoint_solve
protected

The transient adjoint solve object responsible for storing forward solutions and solving the adjoint system.

Definition at line 42 of file TransientAndAdjoint.h.

Referenced by postExecute(), postStep(), and preExecute().

◆ _forward_times

std::vector<Real>& TransientAndAdjoint::_forward_times
protected

Cached forward time points so we can properly loop backward in time.

Definition at line 44 of file TransientAndAdjoint.h.

Referenced by postExecute(), postStep(), and preExecute().


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