20 #include "libmesh/euler2_solver.h"    22 #include "libmesh/adjoint_refinement_estimator.h"    23 #include "libmesh/diff_system.h"    24 #include "libmesh/error_vector.h"    25 #include "libmesh/int_range.h"    26 #include "libmesh/numeric_vector.h"   107                                       ResFuncType time_deriv,
   108                                       ResFuncType constraint,
   109                                       ReinitFuncType reinit_func,
   110                                       bool compute_second_order_eqns)
   116   for (
unsigned int i=0; i != n_dofs; ++i)
   117     old_elem_solution(i) =
   143   if (request_jacobian)
   159   (context.*reinit_func)(1.);
   164   bool jacobian_computed =
   184   jacobian_computed = (
_system.
get_physics()->*constraint)(jacobian_computed, context) &&
   195   if (request_jacobian)
   206   (context.*reinit_func)(0.);
   244   (context.*reinit_func)(1.);
   248   if (request_jacobian)
   250       if (jacobian_computed)
   258   if (jacobian_computed)
   261   return jacobian_computed;
   275   std::vector<Number> left_contribution(
_system.
n_qois(), 0.0);
   277   std::vector<Number> right_contribution(
_system.
n_qois(), 0.0);
   317     _system.
set_qoi(j, ( ( ((1.0 - 
theta)*left_contribution[j]) + (
theta*right_contribution[j]) )/2.0 )*(time_right - time_left));
   321 #ifdef LIBMESH_ENABLE_AMR   326   libmesh_not_implemented();
   332   std::vector<Number> qoi_error_estimates_left(
_system.
n_qois());
   333   std::vector<Number> qoi_error_estimates_right(
_system.
n_qois());
   383       QoI_elementwise_error_left[i] = 0.0;
   399         qoi_error_estimates_left[j] = 0.0;
   467     QoI_elementwise_error[i] = float(((QoI_elementwise_error_right[i] + QoI_elementwise_error_left[i])/2)
   468                                      * (time_right - time_left));
   481 #endif // LIBMESH_ENABLE_AMR Real time
For time-dependent problems, this is the time t at the beginning of the current timestep. 
virtual bool side_constraint(bool request_jacobian, DiffContext &)
Adds the constraint contribution on side of elem to elem_residual. 
QoISet & qoi_set()
Access to the QoISet (default: weight all QoIs equally) to use when computing errors. 
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian. 
bool compute_second_order_eqns(bool compute_jacobian, DiffContext &c)
If there are second order variables, then we need to compute their residual equations and correspondi...
Real fixed_solution_derivative
The derivative of elem_fixed_solution with respect to the nonlinear solution, for use by systems cons...
void swap(DenseMatrix< T > &other_matrix)
STL-like swap method. 
This class provides all data required for a physics package (e.g. 
void prepare_accel(DiffContext &context)
If there are second order variables in the system, then we also prepare the accel for those variables...
virtual bool _general_residual(bool request_jacobian, DiffContext &, ResFuncType mass, ResFuncType damping, ResFuncType time_deriv, ResFuncType constraint, ReinitFuncType reinit, bool compute_second_order_eqns)
This method is the underlying implementation of the public residual methods. 
Euler2Solver(sys_type &s)
Constructor. 
const DenseVector< Number > & get_elem_fixed_solution() const
Accessor for element fixed solution. 
This class implements a "brute force" goal-oriented error estimator which computes an estimate of err...
static constexpr Real TOLERANCE
const DenseVector< Number > & get_elem_solution_rate() const
Accessor for element solution rate of change w.r.t. 
Number get_qoi_value(unsigned int qoi_index) const
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 bool side_damping_residual(bool request_jacobian, DiffContext &)
Subtracts a damping vector contribution on side of elem from elem_residual. 
Number old_nonlinear_solution(const dof_id_type global_dof_number) const
virtual std::unique_ptr< NumericVector< T > > clone() const =0
virtual bool nonlocal_time_derivative(bool request_jacobian, DiffContext &)
Adds any nonlocal time derivative contributions (e.g. 
virtual bool damping_residual(bool request_jacobian, DiffContext &)
Subtracts a damping vector contribution on elem from elem_residual. 
The libMesh namespace provides an interface to certain functionality in the library. 
virtual ~Euler2Solver()
Destructor. 
virtual bool nonlocal_constraint(bool request_jacobian, DiffContext &)
Adds any nonlocal constraint contributions (e.g. 
virtual void elem_reinit(Real)
Gives derived classes the opportunity to reinitialize data (FE objects in FEMSystem, for example) needed for an interior integration at a new point within a timestep. 
bool _eulerian_time_deriv(bool request_jacobian, DiffContext &)
This method simply combines element_time_derivative() and eulerian_residual(), which makes its addres...
void swap(DenseVector< T > &other_vector)
STL-like swap method. 
virtual bool mass_residual(bool request_jacobian, DiffContext &)
Subtracts a mass vector contribution on elem from elem_residual. 
This class provides a specific system class. 
bool has_index(std::size_t) const
Return whether or not this index is in the set to be calculated. 
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. 
const std::set< unsigned int > & get_second_order_vars() const
Generic class from which first order UnsteadySolvers should subclass. 
Real elem_solution_rate_derivative
The derivative of elem_solution_rate with respect to the current nonlinear solution, for use by systems with non default mass_residual terms. 
const DenseVector< Number > & get_elem_solution() const
Accessor for element solution. 
virtual bool element_residual(bool request_jacobian, DiffContext &) override
This method uses the DifferentiablePhysics' element_time_derivative() and element_constraint() to bui...
virtual void retrieve_timestep() override
This method retrieves all the stored solutions at the current system.time. 
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time...
bool use_fixed_solution
A boolean to be set to true by systems using elem_fixed_solution, for optional use by e...
Real elem_solution_derivative
The derivative of elem_solution with respect to the current nonlinear solution. 
virtual bool nonlocal_residual(bool request_jacobian, DiffContext &) override
This method uses the DifferentiablePhysics' nonlocal_time_derivative() and nonlocal_constraint() to b...
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices. 
Real theta
The value for the theta method to employ: 1.0 corresponds to backwards Euler, 0.0 corresponds to forw...
virtual bool side_residual(bool request_jacobian, DiffContext &) override
This method uses the DifferentiablePhysics' side_time_derivative() and side_constraint() to build a f...
virtual void integrate_qoi_timestep() override
A method to integrate the system::QoI functionals. 
Number & get_global_QoI_error_estimate(unsigned int qoi_index)
This is an accessor function to access the computed global QoI error estimates. 
bool have_second_order_scalar_vars() const
Check for any second order vars that are also belong to FEFamily::SCALAR. 
virtual void estimate_error(const System &system, ErrorVector &error_per_cell, const NumericVector< Number > *solution_vector=nullptr, bool estimate_parent_error=false) override
This function does uniform refinements and an adjoint solve to get an adjoint solution on each cell...
const DifferentiablePhysics * get_physics() const
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual. 
virtual void update()
Update the local values to reflect the solution on neighboring processors. 
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void set_qoi_error_estimate(unsigned int qoi_index, Number qoi_error_estimate)
virtual void swap(NumericVector< T > &v)
Swaps the contents of this with v. 
virtual void elem_side_reinit(Real)
Gives derived classes the opportunity to reinitialize data needed for a side integration at a new poi...
virtual bool nonlocal_damping_residual(bool request_jacobian, DiffContext &)
Subtracts any nonlocal damping vector contributions (e.g. 
virtual void assemble_qoi(const QoISet &qoi_indices=QoISet()) override
Prepares qoi for quantity of interest assembly, then calls user qoi function. 
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...
virtual void integrate_adjoint_refinement_error_estimate(AdjointRefinementEstimator &adjoint_refinement_error_estimator, ErrorVector &QoI_elementwise_error) override
A method to compute the adjoint refinement error estimate at the current timestep. 
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
virtual unsigned int size() const override final
void set_qoi(unsigned int qoi_index, Number qoi_value)
Real last_step_deltat
We will need to move the system.time around to ensure that residuals are built with the right deltat ...
virtual bool side_mass_residual(bool request_jacobian, DiffContext &)
Subtracts a mass vector contribution on side of elem from elem_residual. 
virtual bool side_time_derivative(bool request_jacobian, DiffContext &)
Adds the time derivative contribution on side of elem to elem_residual. 
virtual bool element_constraint(bool request_jacobian, DiffContext &)
Adds the constraint contribution on elem to elem_residual. 
virtual Real error_order() const override
Error convergence order: 2 for Crank-Nicolson, 1 otherwise. 
virtual bool nonlocal_mass_residual(bool request_jacobian, DiffContext &c)
Subtracts any nonlocal mass vector contributions (e.g. 
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
virtual void nonlocal_reinit(Real)
Gives derived classes the opportunity to reinitialize data needed for nonlocal calculations at a new ...