20#ifndef LIBMESH_FEM_CONTEXT_H
21#define LIBMESH_FEM_CONTEXT_H
24#include "libmesh/diff_context.h"
25#include "libmesh/id_types.h"
26#include "libmesh/fe_type.h"
27#include "libmesh/fe_base.h"
28#include "libmesh/vector_value.h"
30#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
31#include "libmesh/tensor_value.h"
44template <
typename T>
class FEGenericBase;
48template <
typename T>
class NumericVector;
75 const std::vector<unsigned int> *
active_vars =
nullptr,
76 bool allocate_local_matrices =
true);
88 int extra_quadrature_order,
89 const std::vector<unsigned int> *
active_vars =
nullptr,
90 bool allocate_local_matrices =
true);
168#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
243#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
276 template<
typename OutputShape>
278 { this->get_element_fe<OutputShape>(var,fe,this->
get_elem_dim()); }
293 template<
typename OutputShape>
295 unsigned short dim )
const;
302 unsigned short dim )
const;
316 template<
typename OutputShape>
318 { this->get_side_fe<OutputShape>(var,fe,this->
get_elem_dim()); }
333 template<
typename OutputShape>
335 unsigned short dim )
const;
342 unsigned short dim )
const;
353 template<
typename OutputShape>
369 template<
typename OutputType>
372 OutputType & u)
const;
378 template<
typename OutputType>
381 std::vector<OutputType> & interior_values_vector)
const;
389 template<
typename OutputType>
392 OutputType & u)
const;
398 template<
typename OutputType>
401 std::vector<OutputType> & side_values_vector)
const;
412 template<
typename OutputType>
424 template<
typename OutputType>
426 OutputType & du)
const;
434 template<
typename OutputType>
437 std::vector<OutputType> & interior_gradients_vector)
const;
445 template<
typename OutputType>
448 OutputType & du)
const;
456 template<
typename OutputType>
459 std::vector<OutputType> & side_gradients_vector)
const;
470 template<
typename OutputType>
476#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
483 template<
typename OutputType>
486 OutputType & d2u)
const;
493 template<
typename OutputType>
496 std::vector<OutputType> & d2u_vals)
const;
504 template<
typename OutputType>
507 OutputType & d2u)
const;
514 template<
typename OutputType>
517 std::vector<OutputType> & d2u_vals)
const;
528 template<
typename OutputType>
541 template<
typename OutputType>
544 OutputType & u)
const;
552 template<
typename OutputType>
555 OutputType & u)
const;
562 template<
typename OutputType>
565 OutputType & u)
const;
571 template<
typename OutputType>
574 OutputType & u)
const;
581 template<
typename OutputType>
584 OutputType & u)
const;
590 template<
typename OutputType>
593 OutputType & u)
const;
599 template<
typename OutputType>
602 OutputType & u)
const;
610 template<
typename OutputType>
613 OutputType & u)
const;
621 template<
typename OutputType>
624 OutputType & u)
const;
635 template<
typename OutputType>
647 template<
typename OutputType>
650 OutputType & grad_u)
const;
658 template<
typename OutputType>
661 OutputType & grad_u)
const;
672 template<
typename OutputType>
678#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
685 template<
typename OutputType>
688 OutputType & hess_u)
const;
696 template<
typename OutputType>
699 OutputType & hess_u)
const;
710 template<
typename OutputType>
722 template<
typename OutputType>
725 OutputType & curl_u)
const;
734 template<
typename OutputType>
744 template<
typename OutputType>
747 OutputType & div_u)
const;
786 virtual void elem_fe_reinit(
const std::vector<Point> *
const pts =
nullptr);
903 {
return (this->
_elem !=
nullptr); }
910 return *(this->
_elem); }
917 return *(
const_cast<Elem *
>(this->
_elem)); }
937 {
return this->
_dim; }
1042 template<
typename OutputShape>
1046 const int get_derivative_level = -1)
const;
1081#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1086 template<
typename OutputShape>
1089 const int get_derivative_level )
const;
1109 template <
typename OutputType>
1138 template<
typename OutputType,
1141 void some_value(
unsigned int var,
unsigned int qp, OutputType & u)
const;
1147 template<
typename OutputType,
1150 void some_gradient(
unsigned int var,
unsigned int qp, OutputType & u)
const;
1152#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1157 template<
typename OutputType,
1160 void some_hessian(
unsigned int var,
unsigned int qp, OutputType & u)
const;
1168 std::vector<std::map<FEType, std::unique_ptr<FEAbstract>>>
_element_fe;
1169 std::vector<std::map<FEType, std::unique_ptr<FEAbstract>>>
_side_fe;
1170 std::map<FEType, std::unique_ptr<FEAbstract>>
_edge_fe;
1276template<
typename OutputShape>
1279 unsigned short dim )
const
1288 unsigned short dim )
const
1303template<
typename OutputShape>
1306 unsigned short dim )
const
1310 fe = cast_ptr<FEGenericBase<OutputShape> *>( (
_side_fe_var[
dim][var] ) );
1315 unsigned short dim )
const
1330template<
typename OutputShape>
1335 fe = cast_ptr<FEGenericBase<OutputShape> *>(
_edge_fe_var[var] );
void ErrorVector unsigned int
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
Defines a dense subvector for use in finite element computations.
This class provides all data required for a physics package (e.g.
This is the base class from which all geometric element types are derived.
This class forms the foundation from which generic finite elements may be derived.
This class forms the foundation from which generic finite elements may be derived.
This class provides all data required for a physics package (e.g.
void set_mesh_y_var(unsigned int y_var)
Accessor for y-variable of moving mesh System.
const NumericVector< Number > * _custom_solution
Data with which to do algebra reinitialization.
void some_value(unsigned int var, unsigned int qp, OutputType &u) const
Helper function to reduce some code duplication in the *interior_value methods.
FEType find_hardest_fe_type()
Helper function for creating quadrature rules.
void interior_values(unsigned int var, const NumericVector< Number > &_system_vector, std::vector< OutputType > &interior_values_vector) const
Fills a vector of values of the _system_vector at the all the quadrature points in the current elemen...
void point_accel(unsigned int var, const Point &p, OutputType &u) const
void interior_curl(unsigned int var, unsigned int qp, OutputType &curl_u) const
virtual void side_fe_reinit()
Reinitializes side FE objects on the current geometric element.
void get_side_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for edge/face (2D/3D) finite element object for variable var for the largest dimension in th...
void _do_elem_position_set(Real theta)
Uses the coordinate data specified by mesh_*_position configuration to set the geometry of elem to th...
unsigned int _mesh_x_var
Variables from which to acquire moving mesh information.
Gradient interior_gradient(unsigned int var, unsigned int qp) const
void interior_rate_gradient(unsigned int var, unsigned int qp, OutputType &u) const
void side_gradients(unsigned int var, const NumericVector< Number > &_system_vector, std::vector< OutputType > &side_gradients_vector) const
Fills a vector with the gradient of the solution variable var at all the quadrature points on the cur...
std::map< FEType, std::unique_ptr< FEAbstract > > _edge_fe
System * _mesh_sys
System from which to acquire moving mesh information.
FEBase * get_side_fe(unsigned int var) const
Accessor for side finite element object for scalar-valued variable var for the largest dimension in t...
Number side_value(unsigned int var, unsigned int qp) const
void attach_quadrature_rules()
Helper function for attaching quadrature rules.
unsigned char edge
Current edge for edge_* to examine.
void set_mesh_x_var(unsigned int x_var)
Accessor for x-variable of moving mesh System.
void some_hessian(unsigned int var, unsigned int qp, OutputType &u) const
Helper function to reduce some code duplication in the *interior_hessian methods.
void interior_rate(unsigned int var, unsigned int qp, OutputType &u) const
Tensor side_hessian(unsigned int var, unsigned int qp) const
unsigned int get_mesh_y_var() const
Accessor for y-variable of moving mesh System.
bool _real_grad_fe_is_inf
const std::set< unsigned char > & elem_dimensions() const
std::vector< std::vector< FEAbstract * > > _element_fe_var
Pointers to the same finite element objects, but indexed by variable number.
void point_curl(unsigned int var, const Point &p, OutputType &curl_u, const Real tolerance=TOLERANCE) const
virtual void elem_reinit(Real theta) override
Resets the current time in the context.
Gradient fixed_side_gradient(unsigned int var, unsigned int qp) const
FEBase * get_element_fe(unsigned int var) const
Accessor for interior finite element object for scalar-valued variable var for the largest dimension ...
Number fixed_point_value(unsigned int var, const Point &p) const
std::vector< std::map< FEType, std::unique_ptr< FEAbstract > > > _element_fe
Finite element objects for each variable's interior, sides and edges.
void get_edge_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for edge (3D only!) finite element object for variable var.
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
std::vector< std::unique_ptr< QBase > > _side_qrule
Quadrature rules for element sides The FEM context will try to find a quadrature rule that correctly ...
void side_values(unsigned int var, const NumericVector< Number > &_system_vector, std::vector< OutputType > &side_values_vector) const
Fills a vector of values of the _system_vector at the all the quadrature points on the current elemen...
FEGenericBase< OutputShape > * cached_fe(const unsigned int elem_dim, const FEType fe_type, const int get_derivative_level) const
Tensor fixed_side_hessian(unsigned int var, unsigned int qp) const
Elem & get_elem()
Accessor for current Elem object.
unsigned char side
Current side for side_* to examine.
void side_boundary_ids(std::vector< boundary_id_type > &vec_to_fill) const
As above, but fills in the std::set provided by the user.
int _real_fe_derivative_level
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
Gradient side_gradient(unsigned int var, unsigned int qp) const
const DenseSubVector< Number > &(DiffContext::* diff_subsolution_getter)(unsigned int) const
Helper typedef to simplify refactoring.
const QBase & get_element_qrule(unsigned short dim) const
Accessor for element interior quadrature rule.
unsigned char get_dim() const
Accessor for cached mesh dimension.
Number interior_value(unsigned int var, unsigned int qp) const
void some_gradient(unsigned int var, unsigned int qp, OutputType &u) const
Helper function to reduce some code duplication in the *interior_gradient methods.
std::vector< std::vector< FEAbstract * > > _side_fe_var
unsigned char _elem_dim
Cached dimension of this->_elem.
void side_hessians(unsigned int var, const NumericVector< Number > &_system_vector, std::vector< OutputType > &d2u_vals) const
Fills a vector of hessians of the _system_vector at the all the quadrature points on the current elem...
const Elem & get_elem() const
Accessor for current Elem object.
virtual void elem_side_reinit(Real theta) override
Resets the current time in the context.
void side_accel(unsigned int var, unsigned int qp, OutputType &u) const
void set_jacobian_tolerance(Real tol)
Calls set_jacobian_tolerance() on all the FE objects controlled by this class.
void elem_position_get()
Uses the geometry of elem to set the coordinate data specified by mesh_*_position configuration.
AlgebraicType
Enum describing what data to use when initializing algebraic structures on each element.
void set_custom_solution(const NumericVector< Number > *custom_sol)
Set a NumericVector to be used in place of current_local_solution for calculating elem_solution.
std::unique_ptr< FEGenericBase< RealGradient > > _real_grad_fe
void set_elem(const Elem *e)
Helper function to promote accessor usage.
void side_rate(unsigned int var, unsigned int qp, OutputType &u) const
void interior_hessians(unsigned int var, const NumericVector< Number > &_system_vector, std::vector< OutputType > &d2u_vals) const
Fills a vector of hessians of the _system_vector at the all the quadrature points in the current elem...
virtual void elem_edge_reinit(Real theta) override
Resets the current time in the context.
const QBase & get_edge_qrule() const
Accessor for element edge quadrature rule.
int _real_grad_fe_derivative_level
void use_default_quadrature_rules(int extra_quadrature_order=0)
Use quadrature rules designed to over-integrate a mass matrix, plus extra_quadrature_order.
void elem_position_set(Real theta)
Uses the coordinate data specified by mesh_*_position configuration to set the geometry of elem to th...
virtual void set_mesh_system(System *sys)
Tells the FEMContext that system sys contains the isoparametric Lagrangian variables which correspond...
const QBase & get_side_qrule(unsigned short dim) const
Accessor for element side quadrature rule.
void interior_gradients(unsigned int var, const NumericVector< Number > &_system_vector, std::vector< OutputType > &interior_gradients_vector) const
Fills a vector with the gradient of the solution variable var at all the quadrature points in the cur...
bool has_elem() const
Test for current Elem object.
void interior_div(unsigned int var, unsigned int qp, OutputType &div_u) const
FEGenericBase< OutputShape > * build_new_fe(const FEGenericBase< OutputShape > *fe, const Point &p, const Real tolerance=TOLERANCE, const int get_derivative_level=-1) const
Helper function to reduce some code duplication in the *_point_* methods.
void _update_time_from_system(Real theta)
Update the time in the context object for the given value of theta, based on the values of "time" and...
int _extra_quadrature_order
The extra quadrature order for this context.
void interior_accel(unsigned int var, unsigned int qp, OutputType &u) const
const Elem * _elem
Current element for element_* to examine.
unsigned char get_elem_dim() const
std::unique_ptr< const std::vector< unsigned int > > _active_vars
Variables on which to enable calculations, or nullptr if all variables in the System are to be enable...
unsigned int get_mesh_x_var() const
Accessor for x-variable of moving mesh System.
Number fixed_side_value(unsigned int var, unsigned int qp) const
const std::vector< unsigned int > * active_vars() const
Return a pointer to the vector of active variables being computed for, or a null pointer if all varia...
virtual void elem_fe_reinit(const std::vector< Point > *const pts=nullptr)
Reinitializes interior FE objects on the current geometric element.
void set_mesh_z_var(unsigned int z_var)
Accessor for z-variable of moving mesh System.
std::set< unsigned char > _elem_dims
Cached dimensions of elements in the mesh, plus dimension 0 if SCALAR variables are in use.
unsigned char get_side() const
Accessor for current side of Elem object.
void get_element_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for interior finite element object for variable var for the largest dimension in the mesh.
Number point_value(unsigned int var, const Point &p) const
Tensor point_hessian(unsigned int var, const Point &p) const
std::vector< FEAbstract * > _edge_fe_var
virtual ~FEMContext()
Destructor.
void point_rate(unsigned int var, const Point &p, OutputType &u) const
const System * get_mesh_system() const
Accessor for moving mesh System.
Gradient point_gradient(unsigned int var, const Point &p) const
void set_algebraic_type(const AlgebraicType atype)
Setting which determines whether to initialize algebraic structures (elem_*) on each element and set ...
Tensor fixed_interior_hessian(unsigned int var, unsigned int qp) const
const QBase & get_side_qrule() const
Accessor for element side quadrature rule for the dimension of the current _elem.
std::vector< std::map< FEType, std::unique_ptr< FEAbstract > > > _side_fe
Tensor fixed_point_hessian(unsigned int var, const Point &p) const
void use_unweighted_quadrature_rules(int extra_quadrature_order=0)
Use quadrature rules designed to exactly integrate unweighted undistorted basis functions,...
bool has_side_boundary_id(boundary_id_type id) const
Reports if the boundary id is found on the current side.
unsigned char get_edge() const
Accessor for current edge of Elem object.
Number fixed_interior_value(unsigned int var, unsigned int qp) const
const BoundaryInfo & _boundary_info
Saved reference to BoundaryInfo on the mesh for this System.
std::unique_ptr< QBase > _edge_qrule
Quadrature rules for element edges.
System * get_mesh_system()
Accessor for moving mesh System.
Gradient fixed_point_gradient(unsigned int var, const Point &p) const
unsigned char _dim
Cached dimension of largest dimension element in this mesh.
AlgebraicType algebraic_type() const
Gradient fixed_interior_gradient(unsigned int var, unsigned int qp) const
AlgebraicType _atype
Keep track of what type of algebra reinitialization is to be done.
unsigned int get_mesh_z_var() const
Accessor for z-variable of moving mesh System.
virtual void nonlocal_reinit(Real theta) override
Gives derived classes the opportunity to reinitialize data needed for nonlocal calculations at a new ...
std::vector< std::unique_ptr< QBase > > _element_qrule
Quadrature rule for element interior.
virtual void edge_fe_reinit()
Reinitializes edge FE objects on the current geometric element.
std::unique_ptr< FEGenericBase< Real > > _real_fe
void init_internal_data(const System &sys)
Helper function used in constructors to set up internal data.
Tensor interior_hessian(unsigned int var, unsigned int qp) const
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Provides a uniform interface to vector storage schemes for different linear algebra libraries.
A Point defines a location in LIBMESH_DIM dimensional Real space.
The QBase class provides the basic functionality from which various quadrature rules can be derived.
Manages consistently variables, degrees of freedom, and coefficient vectors.
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
The libMesh namespace provides an interface to certain functionality in the library.
static constexpr Real TOLERANCE
FEGenericBase< Real > FEBase
template class LIBMESH_EXPORT FEGenericBase< Real >
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Helper nested class for C++03-compatible "template typedef".
void(FEMContext::* grad_getter)(unsigned int, grad_base *&, unsigned short) const
TensorTools::MakeReal< Rank1Decrement >::type grad_shape
TensorTools::MakeReal< Rank2Decrement >::type hess_shape
TensorTools::DecrementRank< Rank1Decrement >::type Rank2Decrement
TensorTools::DecrementRank< OutputType >::type Rank1Decrement
void(FEMContext::* value_getter)(unsigned int, value_base *&, unsigned short) const
FEGenericBase< hess_shape > hess_base
void(FEMContext::* hess_getter)(unsigned int, hess_base *&, unsigned short) const
FEGenericBase< grad_shape > grad_base
TensorTools::MakeReal< OutputType >::type value_shape
FEGenericBase< value_shape > value_base