20#ifndef LIBMESH_DIFF_CONTEXT_H
21#define LIBMESH_DIFF_CONTEXT_H
24#include "libmesh/dense_matrix.h"
25#include "libmesh/dense_submatrix.h"
26#include "libmesh/dense_subvector.h"
27#include "libmesh/dense_vector.h"
28#include "libmesh/id_types.h"
40template <
typename T>
class NumericVector;
65 bool allocate_local_matrices =
true);
540 typedef std::map<const NumericVector<Number> *, std::pair<DenseVector<Number>, std::vector<DenseSubVector<Number>>>>::iterator
localized_vectors_iterator;
571 std::map<const NumericVector<Number> *, std::pair<DenseVector<Number>, std::vector<DenseSubVector<Number>>>>
_localized_vectors;
Defines a dense matrix for use in Finite Element-type computations.
Defines a dense submatrix for use in Finite Element-type computations.
Defines a dense subvector for use in finite element computations.
Defines a dense vector for use in Finite Element-type computations.
This class provides all data required for a physics package (e.g.
DenseVector< Number > _elem_solution_rate
Element by element components of du/dt as adjusted by a time_solver.
Real elem_solution_derivative
The derivative of elem_solution with respect to the current nonlinear solution.
const DenseSubVector< Number > & get_elem_fixed_solution(unsigned int var) const
Accessor for element fixed solution of a particular variable corresponding to the variable index argu...
std::map< const NumericVector< Number > *, std::pair< DenseVector< Number >, std::vector< DenseSubVector< Number > > > > _localized_vectors
Contains pointers to vectors the user has asked to be localized, keyed with pairs of element localize...
const DenseSubVector< Number > & get_elem_solution(unsigned int var) const
Accessor for element solution of a particular variable corresponding to the variable index argument.
DenseMatrix< Number > & get_elem_jacobian()
Non-const accessor for element Jacobian.
const DenseVector< Number > & get_elem_solution_rate() const
Accessor for element solution rate of change w.r.t.
Real time
For time-dependent problems, this is the time t for which the current nonlinear_solution is defined.
std::vector< Number > _elem_qoi
Element quantity of interest contributions.
std::vector< DenseSubVector< Number > > _elem_fixed_subsolutions
const std::vector< Number > & get_qois() const
Const accessor for QoI vector.
Real elem_solution_accel_derivative
The derivative of elem_solution_accel with respect to the current nonlinear solution,...
std::vector< DenseSubVector< Number > > _elem_subsolutions
DenseSubVector< Number > & get_elem_solution(unsigned int var)
Accessor for element solution of a particular variable corresponding to the variable index argument.
std::vector< std::vector< DenseSubMatrix< Number > > > _elem_subjacobians
DenseVector< Number > & get_elem_solution_rate()
Non-const accessor for element solution rate of change w.r.t.
DenseVector< Number > & get_localized_vector(const NumericVector< Number > &localized_vector)
Return a reference to DenseVector localization of localized_vector contained in the _localized_vector...
DenseSubMatrix< Number > & get_elem_jacobian(unsigned int var1, unsigned int var2)
Non-const accessor for element Jacobian of particular variables corresponding to the variable index a...
const Real system_time
This is the time stored in the System class at the time this context was created, i....
unsigned int n_vars() const
Number of variables in solution.
DenseVector< Number > _elem_fixed_solution
Element by element components of nonlinear_solution at a fixed point in a timestep,...
std::vector< dof_id_type > & get_dof_indices()
Non-const accessor for element dof indices.
virtual void elem_edge_reinit(Real)
Gives derived classes the opportunity to reinitialize data needed for an edge integration at a new po...
const DenseSubVector< Number > & get_elem_solution_accel(unsigned int var) const
Accessor for element solution accel for a particular variable corresponding to the variable index arg...
DenseVector< Number > _elem_solution
Element by element components of nonlinear_solution as adjusted by a time_solver.
virtual void elem_reinit(Real)
Gives derived classes the opportunity to reinitialize data (FE objects in FEMSystem,...
DenseSubVector< Number > & get_elem_solution_accel(unsigned int var)
Accessor for element solution accel for a particular variable corresponding to the variable index arg...
Real get_elem_solution_derivative() const
The derivative of the current elem_solution w.r.t.
std::vector< DenseSubVector< Number > > _elem_subsolution_rates
virtual void elem_side_reinit(Real)
Gives derived classes the opportunity to reinitialize data needed for a side integration at a new poi...
Real * _deltat
Defaults to nullptr, can optionally be used to point to a timestep value in the System-derived class ...
std::map< constNumericVector< Number > *, std::pair< DenseVector< Number >, std::vector< DenseSubVector< Number > > > >::iterator localized_vectors_iterator
Typedef for the localized_vectors iterator.
std::vector< DenseVector< Number > > & get_qoi_derivatives()
Non-const accessor for QoI derivatives.
const std::vector< dof_id_type > & get_dof_indices() const
Accessor for element dof indices.
Real elem_solution_rate_derivative
The derivative of elem_solution_rate with respect to the current nonlinear solution,...
std::vector< Number > & get_qois()
Non-const accessor for QoI vector.
const DenseSubVector< Number > & get_elem_residual(unsigned int var) const
Const accessor for element residual of a particular variable corresponding to the variable index argu...
Real get_system_time() const
Accessor for the time variable stored in the system class.
const DenseSubVector< Number > & get_qoi_derivatives(std::size_t qoi, unsigned int var) const
Const accessor for QoI derivative of a particular qoi and variable corresponding to the index argumen...
bool is_adjoint() const
Accessor for querying whether we need to do a primal or adjoint solve.
std::vector< std::vector< DenseSubVector< Number > > > _elem_qoi_subderivatives
std::vector< DenseSubVector< Number > > _elem_subresiduals
Element residual subvectors and (if _have_local_matrices) Jacobian submatrices.
DenseVector< Number > & get_elem_fixed_solution()
Non-const accessor for element fixed solution.
const System & _system
A reference to the system this context is constructed with.
std::vector< std::vector< dof_id_type > > _dof_indices_var
DenseVector< Number > & get_elem_solution()
Non-const accessor for element solution.
DenseVector< Number > & get_elem_solution_accel()
Non-const accessor for element solution accel of change w.r.t.
const DenseVector< Number > & get_elem_solution() const
Accessor for element solution.
bool _is_adjoint
Is this context to be used for a primal or adjoint solve?
const DenseVector< Number > & get_elem_solution_accel() const
Accessor for element solution accel of change w.r.t.
DenseMatrix< Number > _elem_jacobian
Element jacobian: derivatives of elem_residual with respect to elem_solution.
Real get_elem_solution_accel_derivative() const
The derivative of the current elem_solution_accel w.r.t.
DenseSubVector< Number > & get_elem_fixed_solution(unsigned int var)
Accessor for element fixed solution of a particular variable corresponding to the variable index argu...
DenseSubVector< Number > & get_elem_solution_rate(unsigned int var)
Accessor for element solution rate for a particular variable corresponding to the variable index argu...
unsigned int n_dof_indices() const
Total number of dof indices on the element.
const DenseSubMatrix< Number > & get_elem_jacobian(unsigned int var1, unsigned int var2) const
Const accessor for element Jacobian of particular variables corresponding to the variable index argum...
DenseVector< Number > _elem_residual
Element residual vector.
Real fixed_solution_derivative
The derivative of elem_fixed_solution with respect to the nonlinear solution, for use by systems cons...
unsigned int n_dof_indices(unsigned int var) const
Total number of dof indices of the particular variable corresponding to the index argument.
virtual ~DiffContext()
Destructor.
void set_deltat_pointer(Real *dt)
Points the _deltat member of this class at a timestep value stored in the creating System,...
std::vector< dof_id_type > & get_dof_indices(unsigned int var)
Accessor for element dof indices of a particular variable corresponding to the index argument.
void set_time(Real time_in)
Set the time for which the current nonlinear_solution is defined.
bool & is_adjoint()
Accessor for setting whether we need to do a primal or adjoint solve.
DenseSubVector< Number > & get_localized_subvector(const NumericVector< Number > &localized_vector, unsigned int var)
Return a reference to DenseSubVector localization of localized_vector at variable var contained in th...
std::vector< dof_id_type > _dof_indices
Global Degree of freedom index lists.
const System & get_system() const
Accessor for associated system.
const DenseVector< Number > & get_elem_fixed_solution() const
Accessor for element fixed solution.
void add_localized_vector(NumericVector< Number > &localized_vector, const System &sys)
Adds a vector to the map of localized vectors.
DenseSubVector< Number > & get_elem_residual(unsigned int var)
Non-const accessor for element residual of a particular variable corresponding to the variable index ...
std::vector< DenseSubVector< Number > > _elem_subsolution_accels
const std::vector< dof_id_type > & get_dof_indices(unsigned int var) const
Accessor for element dof indices of a particular variable corresponding to the index argument.
Real get_time() const
Accessor for the time for which the current nonlinear_solution is defined.
DenseVector< Number > _elem_solution_accel
Element by element components of du/dt as adjusted by a time_solver.
const DenseSubVector< Number > & get_elem_solution_rate(unsigned int var) const
Accessor for element solution rate for a particular variable corresponding to the variable index argu...
virtual void nonlocal_reinit(Real)
Gives derived classes the opportunity to reinitialize data needed for nonlocal calculations at a new ...
const std::vector< DenseVector< Number > > & get_qoi_derivatives() const
Const accessor for QoI derivatives.
DenseSubVector< Number > & get_qoi_derivatives(std::size_t qoi, unsigned int var)
Non-const accessor for QoI derivative of a particular qoi and variable corresponding to the index arg...
std::vector< DenseVector< Number > > _elem_qoi_derivative
Element quantity of interest derivative contributions.
DenseVector< Number > & get_elem_residual()
Non-const accessor for element residual.
Real get_elem_solution_rate_derivative() const
The derivative of the current elem_solution_rate w.r.t.
const bool _have_local_matrices
Whether we have local matrices allocated/initialized.
const DenseVector< Number > & get_elem_residual() const
Const accessor for element residual.
const DenseMatrix< Number > & get_elem_jacobian() const
Const accessor for element Jacobian.
Real get_fixed_solution_derivative() const
The derivative of the current fixed_elem_solution w.r.t.
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
Manages consistently variables, degrees of freedom, and coefficient vectors.
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real