libMesh
fem_context.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_FEM_CONTEXT_H
21 #define LIBMESH_FEM_CONTEXT_H
22 
23 // Local Includes
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"
29 
30 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
31 #include "libmesh/tensor_value.h"
32 #endif
33 
34 // C++ includes
35 #include <map>
36 #include <set>
37 
38 namespace libMesh
39 {
40 
41 // Forward Declarations
42 class BoundaryInfo;
43 class Elem;
44 template <typename T> class FEGenericBase;
46 class QBase;
47 class Point;
48 template <typename T> class NumericVector;
49 
62 class FEMContext : public DiffContext
63 {
64 public:
65 
73  explicit
74  FEMContext (const System & sys,
75  const std::vector<unsigned int> * active_vars = nullptr,
76  bool allocate_local_matrices = true);
77 
86  explicit
87  FEMContext (const System & sys,
88  int extra_quadrature_order,
89  const std::vector<unsigned int> * active_vars = nullptr,
90  bool allocate_local_matrices = true);
91 
92 
96  virtual ~FEMContext ();
97 
102  void use_default_quadrature_rules(int extra_quadrature_order=0);
103 
108  void use_unweighted_quadrature_rules(int extra_quadrature_order=0);
109 
113  bool has_side_boundary_id(boundary_id_type id) const;
114 
118  void side_boundary_ids(std::vector<boundary_id_type> & vec_to_fill) const;
119 
126  Number interior_value(unsigned int var, unsigned int qp) const;
127 
134  Number side_value(unsigned int var, unsigned int qp) const;
135 
142  Number point_value(unsigned int var, const Point & p) const;
143 
150  Gradient interior_gradient(unsigned int var, unsigned int qp) const;
151 
158  Gradient side_gradient(unsigned int var, unsigned int qp) const;
159 
166  Gradient point_gradient(unsigned int var, const Point & p) const;
167 
168 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
169 
175  Tensor interior_hessian(unsigned int var, unsigned int qp) const;
176 
183  Tensor side_hessian(unsigned int var, unsigned int qp) const;
184 
191  Tensor point_hessian(unsigned int var, const Point & p) const;
192 
193 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
194 
201  Number fixed_interior_value(unsigned int var, unsigned int qp) const;
202 
209  Number fixed_side_value(unsigned int var, unsigned int qp) const;
210 
217  Number fixed_point_value(unsigned int var, const Point & p) const;
218 
225  Gradient fixed_interior_gradient(unsigned int var, unsigned int qp) const;
226 
233  Gradient fixed_side_gradient(unsigned int var, unsigned int qp) const;
234 
241  Gradient fixed_point_gradient(unsigned int var, const Point & p) const;
242 
243 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
244 
250  Tensor fixed_interior_hessian(unsigned int var, unsigned int qp) const;
251 
258  Tensor fixed_side_hessian(unsigned int var, unsigned int qp) const;
259 
266  Tensor fixed_point_hessian (unsigned int var, const Point & p) const;
267 
268 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
269 
276  template<typename OutputShape>
277  void get_element_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const
278  { this->get_element_fe<OutputShape>(var,fe,this->get_elem_dim()); }
279 
286  FEBase * get_element_fe( unsigned int var ) const
287  { return this->get_element_fe(var,this->get_elem_dim()); }
288 
293  template<typename OutputShape>
294  void get_element_fe( unsigned int var, FEGenericBase<OutputShape> *& fe,
295  unsigned short dim ) const;
296 
301  void get_element_fe( unsigned int var, FEAbstract *& fe,
302  unsigned short dim ) const;
303 
308  FEBase * get_element_fe( unsigned int var, unsigned short dim ) const;
309 
316  template<typename OutputShape>
317  void get_side_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const
318  { this->get_side_fe<OutputShape>(var,fe,this->get_elem_dim()); }
319 
326  FEBase * get_side_fe( unsigned int var ) const
327  { return this->get_side_fe(var,this->get_elem_dim()); }
328 
333  template<typename OutputShape>
334  void get_side_fe( unsigned int var, FEGenericBase<OutputShape> *& fe,
335  unsigned short dim ) const;
336 
341  void get_side_fe( unsigned int var, FEAbstract *& fe,
342  unsigned short dim ) const;
343 
348  FEBase * get_side_fe( unsigned int var, unsigned short dim ) const;
349 
353  template<typename OutputShape>
354  void get_edge_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const;
355 
356  void get_edge_fe( unsigned int var, FEAbstract *& fe ) const;
357 
361  FEBase * get_edge_fe( unsigned int var ) const;
362 
369  template<typename OutputType>
370  void interior_value(unsigned int var,
371  unsigned int qp,
372  OutputType & u) const;
373 
378  template<typename OutputType>
379  void interior_values(unsigned int var,
380  const NumericVector<Number> & _system_vector,
381  std::vector<OutputType> & interior_values_vector) const;
382 
389  template<typename OutputType>
390  void side_value(unsigned int var,
391  unsigned int qp,
392  OutputType & u) const;
393 
398  template<typename OutputType>
399  void side_values(unsigned int var,
400  const NumericVector<Number> & _system_vector,
401  std::vector<OutputType> & side_values_vector) const;
402 
412  template<typename OutputType>
413  void point_value(unsigned int var,
414  const Point & p,
415  OutputType & u,
416  const Real tolerance = TOLERANCE) const;
417 
424  template<typename OutputType>
425  void interior_gradient(unsigned int var, unsigned int qp,
426  OutputType & du) const;
427 
434  template<typename OutputType>
435  void interior_gradients(unsigned int var,
436  const NumericVector<Number> & _system_vector,
437  std::vector<OutputType> & interior_gradients_vector) const;
438 
445  template<typename OutputType>
446  void side_gradient(unsigned int var,
447  unsigned int qp,
448  OutputType & du) const;
449 
456  template<typename OutputType>
457  void side_gradients(unsigned int var,
458  const NumericVector<Number> & _system_vector,
459  std::vector<OutputType> & side_gradients_vector) const;
460 
470  template<typename OutputType>
471  void point_gradient(unsigned int var,
472  const Point & p,
473  OutputType & grad_u,
474  const Real tolerance = TOLERANCE) const;
475 
476 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
477 
483  template<typename OutputType>
484  void interior_hessian(unsigned int var,
485  unsigned int qp,
486  OutputType & d2u) const;
487 
493  template<typename OutputType>
494  void interior_hessians(unsigned int var,
495  const NumericVector<Number> & _system_vector,
496  std::vector<OutputType> & d2u_vals) const;
497 
504  template<typename OutputType>
505  void side_hessian(unsigned int var,
506  unsigned int qp,
507  OutputType & d2u) const;
508 
514  template<typename OutputType>
515  void side_hessians(unsigned int var,
516  const NumericVector<Number> & _system_vector,
517  std::vector<OutputType> & d2u_vals) const;
518 
528  template<typename OutputType>
529  void point_hessian(unsigned int var,
530  const Point & p,
531  OutputType & hess_u,
532  const Real tolerance = TOLERANCE) const;
533 
534 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
535 
541  template<typename OutputType>
542  void interior_rate(unsigned int var,
543  unsigned int qp,
544  OutputType & u) const;
545 
546 
552  template<typename OutputType>
553  void interior_rate_gradient(unsigned int var,
554  unsigned int qp,
555  OutputType & u) const;
556 
557 
562  template<typename OutputType>
563  void side_rate(unsigned int var,
564  unsigned int qp,
565  OutputType & u) const;
566 
571  template<typename OutputType>
572  void point_rate(unsigned int var,
573  const Point & p,
574  OutputType & u) const;
575 
581  template<typename OutputType>
582  void interior_accel(unsigned int var,
583  unsigned int qp,
584  OutputType & u) const;
585 
590  template<typename OutputType>
591  void side_accel(unsigned int var,
592  unsigned int qp,
593  OutputType & u) const;
594 
599  template<typename OutputType>
600  void point_accel(unsigned int var,
601  const Point & p,
602  OutputType & u) const;
603 
610  template<typename OutputType>
611  void fixed_interior_value(unsigned int var,
612  unsigned int qp,
613  OutputType & u) const;
614 
621  template<typename OutputType>
622  void fixed_side_value(unsigned int var,
623  unsigned int qp,
624  OutputType & u) const;
625 
635  template<typename OutputType>
636  void fixed_point_value(unsigned int var,
637  const Point & p,
638  OutputType & u,
639  const Real tolerance = TOLERANCE) const;
640 
647  template<typename OutputType>
648  void fixed_interior_gradient(unsigned int var,
649  unsigned int qp,
650  OutputType & grad_u) const;
651 
658  template<typename OutputType>
659  void fixed_side_gradient(unsigned int var,
660  unsigned int qp,
661  OutputType & grad_u) const;
662 
672  template<typename OutputType>
673  void fixed_point_gradient(unsigned int var,
674  const Point & p,
675  OutputType & grad_u,
676  const Real tolerance = TOLERANCE) const;
677 
678 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
679 
685  template<typename OutputType>
686  void fixed_interior_hessian(unsigned int var,
687  unsigned int qp,
688  OutputType & hess_u) const;
689 
696  template<typename OutputType>
697  void fixed_side_hessian(unsigned int var,
698  unsigned int qp,
699  OutputType & hess_u) const;
700 
710  template<typename OutputType>
711  void fixed_point_hessian(unsigned int var,
712  const Point & p,
713  OutputType & hess_u,
714  const Real tolerance = TOLERANCE) const;
715 
716 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
717 
722  template<typename OutputType>
723  void interior_curl(unsigned int var,
724  unsigned int qp,
725  OutputType & curl_u) const;
726 
734  template<typename OutputType>
735  void point_curl(unsigned int var,
736  const Point & p,
737  OutputType & curl_u,
738  const Real tolerance = TOLERANCE) const;
739 
744  template<typename OutputType>
745  void interior_div(unsigned int var,
746  unsigned int qp,
747  OutputType & div_u) const;
748 
749  // should be protected:
755  virtual void elem_reinit(Real theta) override;
756 
762  virtual void elem_side_reinit(Real theta) override;
763 
769  virtual void elem_edge_reinit(Real theta) override;
770 
775  virtual void nonlocal_reinit(Real theta) override;
776 
780  virtual void pre_fe_reinit(const System &,
781  const Elem * e);
782 
786  virtual void elem_fe_reinit(const std::vector<Point> * const pts = nullptr);
787 
791  virtual void side_fe_reinit();
792 
796  virtual void edge_fe_reinit();
797 
802  const QBase & get_element_qrule() const
803  { return this->get_element_qrule(this->get_elem_dim()); }
804 
809  const QBase & get_side_qrule() const
810  { return this->get_side_qrule(this->get_elem_dim()); }
811 
815  const QBase & get_element_qrule( unsigned short dim ) const
817  return *(this->_element_qrule[dim]); }
818 
822  const QBase & get_side_qrule( unsigned short dim ) const
823  {
825  return *(this->_side_qrule[dim]);
826  }
827 
831  const QBase & get_edge_qrule() const
832  { return *(this->_edge_qrule); }
833 
842  virtual void set_mesh_system(System * sys)
843  { this->_mesh_sys = sys; }
844 
848  const System * get_mesh_system() const
849  { return this->_mesh_sys; }
850 
855  { return this->_mesh_sys; }
856 
860  unsigned int get_mesh_x_var() const
861  { return _mesh_x_var; }
862 
868  void set_mesh_x_var(unsigned int x_var)
869  { _mesh_x_var = x_var; }
870 
874  unsigned int get_mesh_y_var() const
875  { return _mesh_y_var; }
876 
882  void set_mesh_y_var(unsigned int y_var)
883  { _mesh_y_var = y_var; }
884 
888  unsigned int get_mesh_z_var() const
889  { return _mesh_z_var; }
890 
896  void set_mesh_z_var(unsigned int z_var)
897  { _mesh_z_var = z_var; }
898 
902  bool has_elem() const
903  { return (this->_elem != nullptr); }
904 
908  const Elem & get_elem() const
909  { libmesh_assert(this->_elem);
910  return *(this->_elem); }
911 
916  { libmesh_assert(this->_elem);
917  return *(const_cast<Elem *>(this->_elem)); }
918 
922  unsigned char get_side() const
923  { return side; }
924 
928  unsigned char get_edge() const
929  { return edge; }
930 
936  unsigned char get_dim() const
937  { return this->_dim; }
938 
944  unsigned char get_elem_dim() const
945  { return this->_elem ? this->_elem_dim : this->_dim; }
946 
951  const std::set<unsigned char> & elem_dimensions() const
952  { return _elem_dims; }
953 
959  void elem_position_set(Real theta);
960 
965  void elem_position_get();
966 
971  enum AlgebraicType { NONE = 0, // Do not reinitialize dof_indices
972  DOFS_ONLY, // Reinitialize dof_indices, not
973  // algebraic structures
974  CURRENT, // Use dof_indices, current solution
975  OLD, // Use old_dof_indices, custom solution
976  OLD_DOFS_ONLY}; // Reinitialize old_dof_indices, not
977  // algebraic structures
978 
987  { _atype = atype; }
988 
989  /*
990  * Get the current AlgebraicType setting
991  */
992  AlgebraicType algebraic_type() const { return _atype; }
993 
1002  { _custom_solution = custom_sol; }
1003 
1008  void set_jacobian_tolerance(Real tol);
1009 
1013  unsigned char side;
1014 
1018  unsigned char edge;
1019 
1024 
1028  void attach_quadrature_rules();
1029 
1034  const std::vector<unsigned int> * active_vars() const { return _active_vars.get(); }
1035 
1042  template<typename OutputShape>
1044  const Point & p,
1045  const Real tolerance = TOLERANCE,
1046  const int get_derivative_level = -1) const;
1047 
1048 protected:
1049 
1054  std::unique_ptr<const std::vector<unsigned int>> _active_vars;
1055 
1060 
1065 
1070 
1075 
1076  mutable std::unique_ptr<FEGenericBase<Real>> _real_fe;
1077  mutable std::unique_ptr<FEGenericBase<RealGradient>> _real_grad_fe;
1080 
1081 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
1082  mutable bool _real_fe_is_inf;
1083  mutable bool _real_grad_fe_is_inf;
1084 #endif
1085 
1086  template<typename OutputShape>
1087  FEGenericBase<OutputShape> * cached_fe( const unsigned int elem_dim,
1088  const FEType fe_type,
1089  const int get_derivative_level ) const;
1090 
1094  void set_elem( const Elem * e );
1095 
1096  // gcc-3.4, oracle 12.3 require this typedef to be public
1097  // in order to use it in a return type
1098 public:
1099 
1103  typedef const DenseSubVector<Number> & (DiffContext::*diff_subsolution_getter)(unsigned int) const;
1104 
1105 protected:
1109  template <typename OutputType>
1110  struct FENeeded
1111  {
1112  // Rank decrementer helper types
1115 
1116  // Typedefs for "Value getter" function pointer
1119  typedef void (FEMContext::*value_getter) (unsigned int, value_base *&, unsigned short) const;
1120 
1121  // Typedefs for "Grad getter" function pointer
1124  typedef void (FEMContext::*grad_getter) (unsigned int, grad_base *&, unsigned short) const;
1125 
1126  // Typedefs for "Hessian getter" function pointer
1129  typedef void (FEMContext::*hess_getter) (unsigned int, hess_base *&, unsigned short) const;
1130  };
1131 
1132 
1133 
1138  template<typename OutputType,
1139  typename FENeeded<OutputType>::value_getter fe_getter,
1140  diff_subsolution_getter subsolution_getter>
1141  void some_value(unsigned int var, unsigned int qp, OutputType & u) const;
1142 
1147  template<typename OutputType,
1148  typename FENeeded<OutputType>::grad_getter fe_getter,
1149  diff_subsolution_getter subsolution_getter>
1150  void some_gradient(unsigned int var, unsigned int qp, OutputType & u) const;
1151 
1152 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
1153 
1157  template<typename OutputType,
1158  typename FENeeded<OutputType>::hess_getter fe_getter,
1159  diff_subsolution_getter subsolution_getter>
1160  void some_hessian(unsigned int var, unsigned int qp, OutputType & u) const;
1161 #endif
1162 
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;
1171 
1172 
1179  std::vector<std::vector<FEAbstract *>> _element_fe_var;
1180  std::vector<std::vector<FEAbstract *>> _side_fe_var;
1181  std::vector<FEAbstract *> _edge_fe_var;
1182 
1188 
1192  const Elem * _elem;
1193 
1197  unsigned char _dim;
1198 
1202  unsigned char _elem_dim;
1203 
1208  std::set<unsigned char> _elem_dims;
1209 
1216  std::vector<std::unique_ptr<QBase>> _element_qrule;
1217 
1224  std::vector<std::unique_ptr<QBase>> _side_qrule;
1225 
1233  std::unique_ptr<QBase> _edge_qrule;
1234 
1239 
1240 private:
1244  void init_internal_data(const System & sys);
1245 
1254  void _do_elem_position_set(Real theta);
1255 
1261  void _update_time_from_system(Real theta);
1262 };
1263 
1264 
1265 
1266 // ------------------------------------------------------------
1267 // FEMContext inline methods
1268 
1269 inline
1271 {
1272  if (_mesh_sys)
1273  this->_do_elem_position_set(theta);
1274 }
1275 
1276 template<typename OutputShape>
1277 inline
1279  unsigned short dim ) const
1280 {
1281  libmesh_assert( !_element_fe_var[dim].empty() );
1282  libmesh_assert_less ( var, (_element_fe_var[dim].size() ) );
1283  fe = cast_ptr<FEGenericBase<OutputShape> *>( (_element_fe_var[dim][var] ) );
1284 }
1285 
1286 inline
1287 void FEMContext::get_element_fe( unsigned int var, FEAbstract *& fe,
1288  unsigned short dim ) const
1289 {
1290  libmesh_assert( !_element_fe_var[dim].empty() );
1291  libmesh_assert_less ( var, (_element_fe_var[dim].size() ) );
1292  fe = _element_fe_var[dim][var];
1293 }
1294 
1295 inline
1296 FEBase * FEMContext::get_element_fe( unsigned int var, unsigned short dim ) const
1297 {
1298  libmesh_assert( !_element_fe_var[dim].empty() );
1299  libmesh_assert_less ( var, (_element_fe_var[dim].size() ) );
1300  return cast_ptr<FEBase *>( (_element_fe_var[dim][var] ) );
1301 }
1302 
1303 template<typename OutputShape>
1304 inline
1306  unsigned short dim ) const
1307 {
1308  libmesh_assert( !_side_fe_var[dim].empty() );
1309  libmesh_assert_less ( var, (_side_fe_var[dim].size() ) );
1310  fe = cast_ptr<FEGenericBase<OutputShape> *>( (_side_fe_var[dim][var] ) );
1311 }
1312 
1313 inline
1314 void FEMContext::get_side_fe( unsigned int var, FEAbstract *& fe,
1315  unsigned short dim ) const
1316 {
1317  libmesh_assert( !_side_fe_var[dim].empty() );
1318  libmesh_assert_less ( var, (_side_fe_var[dim].size() ) );
1319  fe = _side_fe_var[dim][var];
1320 }
1321 
1322 inline
1323 FEBase * FEMContext::get_side_fe( unsigned int var, unsigned short dim ) const
1324 {
1325  libmesh_assert( !_side_fe_var[dim].empty() );
1326  libmesh_assert_less ( var, (_side_fe_var[dim].size() ) );
1327  return cast_ptr<FEBase *>( (_side_fe_var[dim][var] ) );
1328 }
1329 
1330 template<typename OutputShape>
1331 inline
1332 void FEMContext::get_edge_fe( unsigned int var, FEGenericBase<OutputShape> *& fe ) const
1333 {
1334  libmesh_assert_less ( var, _edge_fe_var.size() );
1335  fe = cast_ptr<FEGenericBase<OutputShape> *>( _edge_fe_var[var] );
1336 }
1337 
1338 inline
1339 void FEMContext::get_edge_fe( unsigned int var, FEAbstract *& fe ) const
1340 {
1341  libmesh_assert_less ( var, _edge_fe_var.size() );
1342  fe = _edge_fe_var[var];
1343 }
1344 
1345 inline
1346 FEBase * FEMContext::get_edge_fe( unsigned int var ) const
1347 {
1348  libmesh_assert_less ( var, _edge_fe_var.size() );
1349  return cast_ptr<FEBase *>( _edge_fe_var[var] );
1350 }
1351 
1352 
1353 } // namespace libMesh
1354 
1355 #endif // LIBMESH_FEM_CONTEXT_H
void point_accel(unsigned int var, const Point &p, OutputType &u) const
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:196
void interior_curl(unsigned int var, unsigned int qp, OutputType &curl_u) const
Definition: fem_context.C:598
unsigned char get_edge() const
Accessor for current edge of Elem object.
Definition: fem_context.h:928
virtual void nonlocal_reinit(Real theta) override
Gives derived classes the opportunity to reinitialize data needed for nonlocal calculations at a new ...
Definition: fem_context.C:1467
FEGenericBase< OutputShape > * cached_fe(const unsigned int elem_dim, const FEType fe_type, const int get_derivative_level) const
void(FEMContext::* value_getter)(unsigned int, value_base *&, unsigned short) const
Definition: fem_context.h:1119
Number fixed_side_value(unsigned int var, unsigned int qp) const
Definition: fem_context.C:1135
Number side_value(unsigned int var, unsigned int qp) const
Definition: fem_context.C:661
Tensor fixed_point_hessian(unsigned int var, const Point &p) const
Definition: fem_context.C:1306
void set_mesh_z_var(unsigned int z_var)
Accessor for z-variable of moving mesh System.
Definition: fem_context.h:896
void point_rate(unsigned int var, const Point &p, OutputType &u) const
Number interior_value(unsigned int var, unsigned int qp) const
Definition: fem_context.C:412
void elem_position_set(Real theta)
Uses the coordinate data specified by mesh_*_position configuration to set the geometry of elem to th...
Definition: fem_context.h:1270
This class provides all data required for a physics package (e.g.
Definition: diff_context.h:55
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...
Definition: fem_context.h:317
virtual void pre_fe_reinit(const System &, const Elem *e)
Reinitializes local data vectors/matrices on the current geometric element.
Definition: fem_context.C:1683
unsigned int get_mesh_x_var() const
Accessor for x-variable of moving mesh System.
Definition: fem_context.h:860
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...
Definition: fem_context.h:1054
void set_mesh_x_var(unsigned int x_var)
Accessor for x-variable of moving mesh System.
Definition: fem_context.h:868
const NumericVector< Number > * _custom_solution
Data with which to do algebra reinitialization.
Definition: fem_context.h:1074
void set_elem(const Elem *e)
Helper function to promote accessor usage.
Definition: fem_context.C:1914
void get_edge_fe(unsigned int var, FEGenericBase< OutputShape > *&fe) const
Accessor for edge (3D only!) finite element object for variable var.
Definition: fem_context.h:1332
unsigned int _mesh_z_var
Definition: fem_context.h:1064
std::unique_ptr< FEGenericBase< RealGradient > > _real_grad_fe
Definition: fem_context.h:1077
static constexpr Real TOLERANCE
unsigned char get_elem_dim() const
Definition: fem_context.h:944
const Elem & get_elem() const
Accessor for current Elem object.
Definition: fem_context.h:908
unsigned int dim
FEMContext(const System &sys, const std::vector< unsigned int > *active_vars=nullptr, bool allocate_local_matrices=true)
Constructor.
Definition: fem_context.C:39
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...
Definition: fem_context.C:831
void interior_accel(unsigned int var, unsigned int qp, OutputType &u) const
Definition: fem_context.C:1390
TensorTools::MakeReal< OutputType >::type value_shape
Definition: fem_context.h:1117
const QBase & get_element_qrule(unsigned short dim) const
Accessor for element interior quadrature rule.
Definition: fem_context.h:815
const DenseSubVector< Number > &(DiffContext::* diff_subsolution_getter)(unsigned int) const
Helper typedef to simplify refactoring.
Definition: fem_context.h:1103
FEGenericBase< value_shape > value_base
Definition: fem_context.h:1118
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...
Definition: fem_context.C:494
virtual void elem_edge_reinit(Real theta) override
Resets the current time in the context.
Definition: fem_context.C:1452
This is the base class from which all geometric element types are derived.
Definition: elem.h:94
void set_algebraic_type(const AlgebraicType atype)
Setting which determines whether to initialize algebraic structures (elem_*) on each element and set ...
Definition: fem_context.h:986
int _extra_quadrature_order
The extra quadrature order for this context.
Definition: fem_context.h:1238
This class defines a vector in LIBMESH_DIM dimensional Real or Complex space.
void elem_position_get()
Uses the geometry of elem to set the coordinate data specified by mesh_*_position configuration...
Definition: fem_context.C:1526
The libMesh namespace provides an interface to certain functionality in the library.
FEGenericBase< hess_shape > hess_base
Definition: fem_context.h:1128
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...
Definition: fem_context.C:432
bool has_side_boundary_id(boundary_id_type id) const
Reports if the boundary id is found on the current side.
Definition: fem_context.C:298
void use_default_quadrature_rules(int extra_quadrature_order=0)
Use quadrature rules designed to over-integrate a mass matrix, plus extra_quadrature_order.
Definition: fem_context.C:155
virtual ~FEMContext()
Destructor.
Definition: fem_context.C:292
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.
Definition: fem_context.C:305
unsigned char get_side() const
Accessor for current side of Elem object.
Definition: fem_context.h:922
Number point_value(unsigned int var, const Point &p) const
Definition: fem_context.C:874
std::vector< std::map< FEType, std::unique_ptr< FEAbstract > > > _element_fe
Finite element objects for each variable&#39;s interior, sides and edges.
Definition: fem_context.h:1168
unsigned char get_dim() const
Accessor for cached mesh dimension.
Definition: fem_context.h:936
virtual void elem_fe_reinit(const std::vector< Point > *const pts=nullptr)
Reinitializes interior FE objects on the current geometric element.
Definition: fem_context.C:1477
std::unique_ptr< FEGenericBase< Real > > _real_fe
Definition: fem_context.h:1076
Number fixed_interior_value(unsigned int var, unsigned int qp) const
Definition: fem_context.C:1059
void interior_rate_gradient(unsigned int var, unsigned int qp, OutputType &u) const
Definition: fem_context.C:1369
Defines a dense subvector for use in finite element computations.
virtual void set_mesh_system(System *sys)
Tells the FEMContext that system sys contains the isoparametric Lagrangian variables which correspond...
Definition: fem_context.h:842
Tensor fixed_side_hessian(unsigned int var, unsigned int qp) const
Definition: fem_context.C:1184
unsigned char edge
Current edge for edge_* to examine.
Definition: fem_context.h:1018
std::set< unsigned char > _elem_dims
Cached dimensions of elements in the mesh, plus dimension 0 if SCALAR variables are in use...
Definition: fem_context.h:1208
Gradient interior_gradient(unsigned int var, unsigned int qp) const
Definition: fem_context.C:467
void point_curl(unsigned int var, const Point &p, OutputType &curl_u, const Real tolerance=TOLERANCE) const
Definition: fem_context.C:1023
int8_t boundary_id_type
Definition: id_types.h:51
unsigned char _elem_dim
Cached dimension of this->_elem.
Definition: fem_context.h:1202
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...
Definition: fem_context.C:764
Tensor side_hessian(unsigned int var, unsigned int qp) const
Definition: fem_context.C:802
virtual void side_fe_reinit()
Reinitializes side FE objects on the current geometric element.
Definition: fem_context.C:1498
std::map< FEType, std::unique_ptr< FEAbstract > > _edge_fe
Definition: fem_context.h:1170
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...
Definition: fem_context.C:1923
void init_internal_data(const System &sys)
Helper function used in constructors to set up internal data.
Definition: fem_context.C:198
Gradient fixed_point_gradient(unsigned int var, const Point &p) const
Definition: fem_context.C:1255
const QBase & get_side_qrule(unsigned short dim) const
Accessor for element side quadrature rule.
Definition: fem_context.h:822
void side_accel(unsigned int var, unsigned int qp, OutputType &u) const
Definition: fem_context.C:1402
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
void set_jacobian_tolerance(Real tol)
Calls set_jacobian_tolerance() on all the FE objects controlled by this class.
Definition: fem_context.C:1586
System * _mesh_sys
System from which to acquire moving mesh information.
Definition: fem_context.h:1059
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...
Definition: fem_context.C:556
void some_value(unsigned int var, unsigned int qp, OutputType &u) const
Helper function to reduce some code duplication in the *interior_value methods.
Definition: fem_context.C:315
void some_hessian(unsigned int var, unsigned int qp, OutputType &u) const
Helper function to reduce some code duplication in the *interior_hessian methods. ...
Definition: fem_context.C:382
FEType find_hardest_fe_type()
Helper function for creating quadrature rules.
Definition: fem_context.C:86
Tensor interior_hessian(unsigned int var, unsigned int qp) const
Definition: fem_context.C:532
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...
Definition: fem_context.h:1034
Tensor point_hessian(unsigned int var, const Point &p) const
Definition: fem_context.C:972
Gradient fixed_interior_gradient(unsigned int var, unsigned int qp) const
Definition: fem_context.C:1082
unsigned int _mesh_x_var
Variables from which to acquire moving mesh information.
Definition: fem_context.h:1064
The BoundaryInfo class contains information relevant to boundary conditions including storing faces...
Definition: boundary_info.h:57
libmesh_assert(ctx)
void use_unweighted_quadrature_rules(int extra_quadrature_order=0)
Use quadrature rules designed to exactly integrate unweighted undistorted basis functions, plus extra_quadrature_order.
Definition: fem_context.C:177
TensorTools::MakeReal< Rank1Decrement >::type grad_shape
Definition: fem_context.h:1122
This class provides all data required for a physics package (e.g.
Definition: fem_context.h:62
TensorTools::MakeReal< Rank2Decrement >::type hess_shape
Definition: fem_context.h:1127
AlgebraicType _atype
Keep track of what type of algebra reinitialization is to be done.
Definition: fem_context.h:1069
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...
Definition: fem_context.C:684
const BoundaryInfo & _boundary_info
Saved reference to BoundaryInfo on the mesh for this System.
Definition: fem_context.h:1187
std::vector< std::vector< FEAbstract * > > _element_fe_var
Pointers to the same finite element objects, but indexed by variable number.
Definition: fem_context.h:1179
FEGenericBase< grad_shape > grad_base
Definition: fem_context.h:1123
void(FEMContext::* hess_getter)(unsigned int, hess_base *&, unsigned short) const
Definition: fem_context.h:1129
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...
Definition: fem_context.h:326
FEGenericBase< Real > FEBase
int _real_grad_fe_derivative_level
Definition: fem_context.h:1079
TensorTools::DecrementRank< Rank1Decrement >::type Rank2Decrement
Definition: fem_context.h:1114
virtual void elem_side_reinit(Real theta) override
Resets the current time in the context.
Definition: fem_context.C:1437
Number fixed_point_value(unsigned int var, const Point &p) const
Definition: fem_context.C:1209
unsigned char _dim
Cached dimension of largest dimension element in this mesh.
Definition: fem_context.h:1197
virtual void edge_fe_reinit()
Reinitializes edge FE objects on the current geometric element.
Definition: fem_context.C:1514
std::vector< FEAbstract * > _edge_fe_var
Definition: fem_context.h:1181
Elem & get_elem()
Accessor for current Elem object.
Definition: fem_context.h:915
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 ...
Definition: fem_context.h:1224
std::vector< std::map< FEType, std::unique_ptr< FEAbstract > > > _side_fe
Definition: fem_context.h:1169
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
std::vector< std::unique_ptr< QBase > > _element_qrule
Quadrature rule for element interior.
Definition: fem_context.h:1216
unsigned char side
Current side for side_* to examine.
Definition: fem_context.h:1013
AlgebraicType
Enum describing what data to use when initializing algebraic structures on each element.
Definition: fem_context.h:971
TensorTools::DecrementRank< OutputType >::type Rank1Decrement
Definition: fem_context.h:1113
void set_mesh_y_var(unsigned int y_var)
Accessor for y-variable of moving mesh System.
Definition: fem_context.h:882
std::unique_ptr< QBase > _edge_qrule
Quadrature rules for element edges.
Definition: fem_context.h:1233
Helper nested class for C++03-compatible "template typedef".
Definition: fem_context.h:1110
const System * get_mesh_system() const
Accessor for moving mesh System.
Definition: fem_context.h:848
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...
Definition: fem_context.h:277
unsigned int _mesh_y_var
Definition: fem_context.h:1064
Gradient fixed_side_gradient(unsigned int var, unsigned int qp) const
Definition: fem_context.C:1159
unsigned int get_mesh_y_var() const
Accessor for y-variable of moving mesh System.
Definition: fem_context.h:874
void(FEMContext::* grad_getter)(unsigned int, grad_base *&, unsigned short) const
Definition: fem_context.h:1124
AlgebraicType algebraic_type() const
Definition: fem_context.h:992
DiffContext(const System &, bool allocate_local_matrices=true)
Constructor.
Definition: diff_context.C:32
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.
Definition: fem_context.C:2023
void interior_div(unsigned int var, unsigned int qp, OutputType &div_u) const
Definition: fem_context.C:629
const QBase & get_edge_qrule() const
Accessor for element edge quadrature rule.
Definition: fem_context.h:831
void some_gradient(unsigned int var, unsigned int qp, OutputType &u) const
Helper function to reduce some code duplication in the *interior_gradient methods.
Definition: fem_context.C:349
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...
Definition: fem_context.h:1001
std::vector< std::vector< FEAbstract * > > _side_fe_var
Definition: fem_context.h:1180
This class forms the foundation from which generic finite elements may be derived.
Definition: fe_abstract.h:99
Gradient point_gradient(unsigned int var, const Point &p) const
Definition: fem_context.C:920
const Elem * _elem
Current element for element_* to examine.
Definition: fem_context.h:1192
void attach_quadrature_rules()
Helper function for attaching quadrature rules.
Definition: fem_context.C:127
void _do_elem_position_set(Real theta)
Uses the coordinate data specified by mesh_*_position configuration to set the geometry of elem to th...
Definition: fem_context.C:1607
bool has_elem() const
Test for current Elem object.
Definition: fem_context.h:902
Gradient side_gradient(unsigned int var, unsigned int qp) const
Definition: fem_context.C:719
FEBase * get_element_fe(unsigned int var) const
Accessor for interior finite element object for scalar-valued variable var for the largest dimension ...
Definition: fem_context.h:286
void interior_rate(unsigned int var, unsigned int qp, OutputType &u) const
Definition: fem_context.C:1359
template class LIBMESH_EXPORT FEGenericBase< Real >
Definition: fe_base.C:2625
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:39
System * get_mesh_system()
Accessor for moving mesh System.
Definition: fem_context.h:854
The QBase class provides the basic functionality from which various quadrature rules can be derived...
Definition: quadrature.h:61
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
void side_rate(unsigned int var, unsigned int qp, OutputType &u) const
Definition: fem_context.C:1380
This class forms the foundation from which generic finite elements may be derived.
const QBase & get_element_qrule() const
Accessor for element interior quadrature rule for the dimension of the current _elem.
Definition: fem_context.h:802
virtual void elem_reinit(Real theta) override
Resets the current time in the context.
Definition: fem_context.C:1413
unsigned int get_mesh_z_var() const
Accessor for z-variable of moving mesh System.
Definition: fem_context.h:888
const std::set< unsigned char > & elem_dimensions() const
Definition: fem_context.h:951
const QBase & get_side_qrule() const
Accessor for element side quadrature rule for the dimension of the current _elem. ...
Definition: fem_context.h:809
This class defines a tensor in LIBMESH_DIM dimensional Real or Complex space.
Tensor fixed_interior_hessian(unsigned int var, unsigned int qp) const
Definition: fem_context.C:1109