19 #include "libmesh/unsteady_solver.h"    21 #include "libmesh/adjoint_refinement_estimator.h"    22 #include "libmesh/diff_solver.h"    23 #include "libmesh/diff_system.h"    24 #include "libmesh/dof_map.h"    25 #include "libmesh/error_vector.h"    26 #include "libmesh/int_range.h"    27 #include "libmesh/numeric_vector.h"    28 #include "libmesh/parameter_vector.h"    29 #include "libmesh/sensitivity_data.h"    30 #include "libmesh/solution_history.h"    41     first_adjoint_step (true)
    77     std::string old_adjoint_solution_name = 
"_old_adjoint_solution";
    78     old_adjoint_solution_name+= std::to_string(i);
    81     std::string adjoint_rhs_name = 
"adjoint_rhs";
    82     adjoint_rhs_name+= std::to_string(i);
    93 #ifdef LIBMESH_ENABLE_GHOSTED   108 #ifdef LIBMESH_ENABLE_GHOSTED   141       bool backtracking_failed =
   144       bool max_iterations =
   147       if (backtracking_failed || max_iterations)
   153               libMesh::out << 
"Newton backtracking failed.  Trying with smaller timestep, dt="   159               bool backtracking_still_failed =
   162               bool backtracking_max_iterations =
   165               if (!backtracking_still_failed && !backtracking_max_iterations)
   171                     libMesh::out << 
"Reduced dt solve succeeded." << std::endl;
   178           libMesh::out << 
"DiffSolver::solve() did not succeed after "   180                        << 
" attempts." << std::endl;
   181           libmesh_convergence_failure();
   221   old_nonlinear_soln = nonlinear_solution;
   230   std::pair<unsigned int, Real> adjoint_output = 
_system.ImplicitSystem::adjoint_solve(qoi_indices);
   236   return adjoint_output;
   249    std::string old_adjoint_solution_name = 
"_old_adjoint_solution";
   250    old_adjoint_solution_name+= std::to_string(i);
   253    old_adjoint_solution_i = adjoint_solution_i;
   319   const auto pv_size = parameter_vector.
size();
   322       sensitivities[i][j] = ( (sensitivities_left[i][j] + sensitivities_right[i][j])/2. )*(time_right - time_left);
   327   libmesh_not_implemented();
   330 #ifdef LIBMESH_ENABLE_AMR   333   libmesh_not_implemented();
   335 #endif // LIBMESH_ENABLE_AMR   351   std::unique_ptr<NumericVector<Number>> solution_copy =
   356   solution_copy->close();
 bool quiet
Print extra debugging information if quiet == false. 
virtual void reinit() override
The reinitialization function. 
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep. 
virtual void integrate_adjoint_refinement_error_estimate(AdjointRefinementEstimator &, ErrorVector &) override
A method to compute the adjoint refinement error estimate at the current timestep. 
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices) override
This method solves for the adjoint solution at the next adjoint timestep (or a steady state adjoint s...
std::unique_ptr< DiffSolver > _diff_solver
An implicit linear or nonlinear solver to use at each timestep. 
UnsteadySolver(sys_type &s)
Constructor. 
Data structure for specifying which Parameters should be independent variables in a parameter sensiti...
This is a generic class that defines a solver to handle time integration of DifferentiableSystems. 
This class implements a "brute force" goal-oriented error estimator which computes an estimate of err...
virtual void init_data()
The data initialization function. 
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
unsigned int n_qois() const
Number of currently active quantities of interest. 
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
virtual void init_data() override
The data initialization function. 
std::unique_ptr< SolutionHistory > solution_history
A std::unique_ptr to a SolutionHistory object. 
virtual void integrate_adjoint_sensitivity(const QoISet &qois, const ParameterVector ¶meter_vector, SensitivityData &sensitivities) override
A method to integrate the adjoint sensitivity w.r.t a given parameter vector. 
Number old_nonlinear_solution(const dof_id_type global_dof_number) const
virtual void reinit()
The reinitialization function. 
Provides a uniform interface to vector storage schemes for different linear algebra libraries...
NumericVector< Number > & add_vector(std::string_view vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system. 
This class defines a norm/seminorm to be applied to a NumericVector which contains coefficients in a ...
dof_id_type n_dofs(const unsigned int vn) const
The libMesh namespace provides an interface to certain functionality in the library. 
dof_id_type n_local_dofs() const
dof_id_type n_dofs() const
This class provides a specific system class. 
The DiffSolver reached the maximum allowed number of nonlinear iterations before satisfying any conve...
sys_type & _system
A reference to the system we are solving. 
std::vector< std::unique_ptr< NumericVector< Number > > > old_adjoints
A vector of pointers to vectors holding the adjoint solution at the last time step. 
virtual void adjoint_advance_timestep() override
This method advances the adjoint solution to the previous timestep, after an adjoint_solve() has been...
void remove_vector(std::string_view vec_name)
Removes the additional vector vec_name from this system. 
virtual ~UnsteadySolver()
Destructor. 
std::shared_ptr< NumericVector< Number > > old_local_nonlinear_solution
Serial vector of _system.get_vector("_old_nonlinear_solution") This is a shared_ptr so that it can be...
Data structure for holding completed parameter sensitivity calculations. 
virtual void init()
The initialization function. 
virtual void retrieve_timestep() override
This method retrieves all the stored solutions at the current system.time. 
virtual void adjoint_qoi_parameter_sensitivity(const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities) override
Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with r...
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time...
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values. 
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
unsigned int reduce_deltat_on_diffsolver_failure
This value (which defaults to zero) is the number of times the TimeSolver is allowed to halve deltat ...
std::size_t size(const System &sys) const
virtual void integrate_qoi_timestep() override
A method to integrate the system::QoI functionals. 
virtual void solve() override
This method solves for the solution at the next timestep. 
virtual void advance_timestep() override
This method advances the solution to the next timestep, after a solve() has been performed. 
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual void init_adjoints() override
Add adjoint vectors and old_adjoint_vectors as per the indices of QoISet. 
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
virtual Real du(const SystemNorm &norm) const override
Computes the size of ||u^{n+1} - u^{n}|| in some norm. 
The DiffSolver failed to find a descent direction by backtracking (See newton_solver.C) 
Real last_deltat
The deltat for the last completed timestep before the current one. 
virtual void init() override
The initialization function. 
const DofMap & get_dof_map() const
virtual void init_adjoints()
Initialize any adjoint related data structures, based on the number of qois. 
const std::vector< dof_id_type > & get_send_list() const
const NumericVector< Number > & get_vector(std::string_view vec_name) const
bool first_solve
A bool that will be true the first time solve() is called, and false thereafter. 
virtual void localize(std::vector< T > &v_local) const =0
Creates a copy of the global vector in the local vector v_local.