16 #include "libmesh/sparse_matrix.h" 17 #include "libmesh/numeric_vector.h" 31 _old_time_residual(_nl_adjoint.getResidualTimeVector()),
32 _forward_solutions(declareRecoverableData<
std::vector<
std::string>>(
"forward_solutions"))
54 auto t_step = cast_int<std::size_t>(tstep);
57 mooseError(
"Trying to insert a solution at a time-step greater than one past the previously " 58 "inserted time step. Previous time step = ",
60 ", inserted time step = ",
80 mooseError(
"Could not find forward solution at time step ", tstep,
".");
81 auto t_step = cast_int<std::size_t>(tstep);
84 unsigned int state = 0;
virtual void computeJacobianTag(const NumericVector< libMesh::Number > &soln, libMesh::SparseMatrix< libMesh::Number > &jacobian, TagID tag)
const unsigned int _forward_sys_num
The number of the nonlinear system representing the forward model.
static InputParameters validParams()
NumericVector< Number > & solution()
std::vector< std::string > & _forward_solutions
Name of the forward solution at each time step residing in the adjoint system.
virtual void add_vector_transpose(const NumericVector< T > &v, const SparseMatrix< T > &A)=0
virtual NumericVector< Number > & solutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time)
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...
AdjointTransientSolve(Executioner &ex)
static InputParameters validParams()
virtual const std::string & name() const
NumericVector< Number > & addVector(const std::string &vector_name, const bool project, const libMesh::ParallelType type)
bool converged(const std::vector< std::pair< unsigned int, Real >> &residuals, const std::vector< Real > &abs_tolerances)
Based on the residuals, determine if the iterative process converged or not.
static std::string getForwardSolutionName(int tstep)
Prescribed name of the forward solution at a specified time step.
void setCurrentNonlinearSystem(const unsigned int nl_sys_num)
virtual const NumericVector< Number > *const & currentSolution() const override final
virtual TagID getMatrixTagID(const TagName &tag_name) const
The solve object is responsible for solving the adjoint version of a forward model.
virtual void assembleAdjointSystem(SparseMatrix< Number > &matrix, const NumericVector< Number > &solution, NumericVector< Number > &rhs) override
Overriding parent class so the previous time-derivative residual is added to the right-hand-side of t...
virtual bool hasSolutionState(const unsigned int state, Moose::SolutionIterationType iteration_type=Moose::SolutionIterationType::Time) const
virtual bool solve() override
Solve the adjoint system with the following procedure:
void evaluateTimeResidual(const NumericVector< Number > &solution, NumericVector< Number > &residual)
This evaluates the time part of the adjoint residual.
void insertForwardSolution(int tstep)
This function should be called after every converged forward time step.
NumericVector< Number > & _old_time_residual
The residual contribution from previous adjoint solutions.
void setForwardSolution(int tstep)
Takes the previously saved forward solutions residing in the adjoint system and copies them to the av...
void mooseError(Args &&... args) const
virtual void assembleAdjointSystem(SparseMatrix< Number > &matrix, const NumericVector< Number > &solution, NumericVector< Number > &rhs)
Assembles adjoint system.
NonlinearSystemBase & _nl_adjoint
The nonlinear system representing the adjoint model.
virtual NumericVector< Number > & getVector(const std::string &name)
virtual bool solve() override
Overriding parent class so the time-derivative residual is stored for the next time step...
NonlinearSystemBase & _nl_forward
The nonlinear system representing the forward model.
virtual libMesh::System & system() override