libMesh
fe_interface.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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_FE_INTERFACE_H
21 #define LIBMESH_FE_INTERFACE_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/vector_value.h"
26 
27 // C++ includes
28 #include <map>
29 #include <vector>
30 
31 namespace libMesh
32 {
33 
34 
35 // forward declarations
36 class BoundaryInfo;
37 class DofConstraints;
38 class DofMap;
39 class Elem;
40 class FEType;
41 class FEComputeData;
42 class Point;
43 class MeshBase;
44 enum FEFamily : int;
45 enum Order : int;
46 enum FEFieldType : int;
47 enum ElemType : int;
48 enum FEContinuity : int;
49 
50 #ifdef LIBMESH_ENABLE_PERIODIC
51 class PeriodicBoundaries;
52 class PointLocatorBase;
53 #endif
54 
66 {
67 private:
68 
72  FEInterface();
73 
74 public:
75 
79  virtual ~FEInterface() {}
80 
88  static unsigned int n_shape_functions(const unsigned int dim,
89  const FEType & fe_t,
90  const ElemType t);
91 
99  static unsigned int n_dofs(const unsigned int dim,
100  const FEType & fe_t,
101  const ElemType t);
102 
110  static unsigned int n_dofs(const unsigned int dim,
111  const FEType & fe_t,
112  const Elem * elem);
113 
121  static unsigned int n_dofs_at_node(const unsigned int dim,
122  const FEType & fe_t,
123  const ElemType t,
124  const unsigned int n);
125 
126  typedef unsigned int (*n_dofs_at_node_ptr) (const ElemType,
127  const Order,
128  const unsigned int);
129 
134  static n_dofs_at_node_ptr
135  n_dofs_at_node_function(const unsigned int dim,
136  const FEType & fe_t);
137 
145  static unsigned int n_dofs_per_elem(const unsigned int dim,
146  const FEType & fe_t,
147  const ElemType t);
148 
156  static void dofs_on_side(const Elem * const elem,
157  const unsigned int dim,
158  const FEType & fe_t,
159  unsigned int s,
160  std::vector<unsigned int> & di);
161 
169  static void dofs_on_edge(const Elem * const elem,
170  const unsigned int dim,
171  const FEType & fe_t,
172  unsigned int e,
173  std::vector<unsigned int> & di);
174 
186  static void nodal_soln(const unsigned int dim,
187  const FEType & fe_t,
188  const Elem * elem,
189  const std::vector<Number> & elem_soln,
190  std::vector<Number> & nodal_soln);
191 
195  static Point map(unsigned int dim,
196  const FEType & fe_t,
197  const Elem * elem,
198  const Point & p);
199 
203  static Point inverse_map (const unsigned int dim,
204  const FEType & fe_t,
205  const Elem * elem,
206  const Point & p,
207  const Real tolerance = TOLERANCE,
208  const bool secure = true);
209 
213  static void inverse_map (const unsigned int dim,
214  const FEType & fe_t,
215  const Elem * elem,
216  const std::vector<Point> & physical_points,
217  std::vector<Point> & reference_points,
218  const Real tolerance = TOLERANCE,
219  const bool secure = true);
220 
229  static bool on_reference_element(const Point & p,
230  const ElemType t,
231  const Real eps=TOLERANCE);
241  static Real shape(const unsigned int dim,
242  const FEType & fe_t,
243  const ElemType t,
244  const unsigned int i,
245  const Point & p);
246 
256  static Real shape(const unsigned int dim,
257  const FEType & fe_t,
258  const Elem * elem,
259  const unsigned int i,
260  const Point & p);
261 
271  template<typename OutputType>
272  static void shape(const unsigned int dim,
273  const FEType & fe_t,
274  const ElemType t,
275  const unsigned int i,
276  const Point & p,
277  OutputType & phi);
278 
288  template<typename OutputType>
289  static void shape(const unsigned int dim,
290  const FEType & fe_t,
291  const Elem * elem,
292  const unsigned int i,
293  const Point & p,
294  OutputType & phi);
295 
296  typedef Real (*shape_ptr) (const Elem * elem,
297  const Order o,
298  const unsigned int i,
299  const Point & p,
300  const bool add_p_level);
301 
306  static shape_ptr
307  shape_function(const unsigned int dim,
308  const FEType & fe_t);
309 
310 
321  static Real shape_deriv(const unsigned int dim,
322  const FEType & fe_t,
323  const ElemType t,
324  const unsigned int i,
325  const unsigned int j,
326  const Point & p);
327 
338  static Real shape_deriv (const unsigned int dim,
339  const FEType & fe_t,
340  const Elem *elem,
341  const unsigned int i,
342  const unsigned int j,
343  const Point & p);
344 
345  typedef Real (*shape_deriv_ptr) (const Elem * elem,
346  const Order o,
347  const unsigned int i,
348  const unsigned int j,
349  const Point & p,
350  const bool add_p_level);
351 
356  static shape_deriv_ptr
357  shape_deriv_function(const unsigned int dim,
358  const FEType & fe_t);
359 
360 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
361 
380  static Real shape_second_deriv(const unsigned int dim,
381  const FEType & fe_t,
382  const ElemType t,
383  const unsigned int i,
384  const unsigned int j,
385  const Point & p);
386 
402  static Real shape_second_deriv (const unsigned int dim,
403  const FEType & fe_t,
404  const Elem *elem,
405  const unsigned int i,
406  const unsigned int j,
407  const Point & p);
408 
409  typedef Real (*shape_second_deriv_ptr) (const Elem * elem,
410  const Order o,
411  const unsigned int i,
412  const unsigned int j,
413  const Point & p,
414  const bool add_p_level);
415 
421  shape_second_deriv_function(const unsigned int dim,
422  const FEType & fe_t);
423 #endif
424 
435  static void compute_data(const unsigned int dim,
436  const FEType & fe_t,
437  const Elem * elem,
438  FEComputeData & data);
439 
440 #ifdef LIBMESH_ENABLE_AMR
441 
446  static void compute_constraints (DofConstraints & constraints,
447  DofMap & dof_map,
448  const unsigned int variable_number,
449  const Elem * elem);
450 #endif // #ifdef LIBMESH_ENABLE_AMR
451 
452 #ifdef LIBMESH_ENABLE_PERIODIC
453 
458  static void compute_periodic_constraints (DofConstraints & constraints,
459  DofMap & dof_map,
460  const PeriodicBoundaries & boundaries,
461  const MeshBase & mesh,
462  const PointLocatorBase * point_locator,
463  const unsigned int variable_number,
464  const Elem * elem);
465 #endif // #ifdef LIBMESH_ENABLE_PERIODIC
466 
471  static unsigned int max_order (const FEType & fe_t,
472  const ElemType & el_t);
473 
478  static bool extra_hanging_dofs (const FEType & fe_t);
479 
484  static FEFieldType field_type (const FEType & fe_type);
485 
490  static FEFieldType field_type (const FEFamily & fe_family);
491 
496  static unsigned int n_vec_dim (const MeshBase & mesh,
497  const FEType & fe_type);
505  static FEContinuity get_continuity(const FEType & fe_type);
506 
507 private:
508 
509 
514  static bool is_InfFE_elem(const ElemType et);
515 
516 
517 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
518 
519  /*
520  * All these private members do the same as their public
521  * counterparts, except for infinite elements. This disentangles
522  * the calls to \p FE and \p InfFE.
523  */
524 
525  static unsigned int ifem_n_shape_functions(const unsigned int dim,
526  const FEType & fe_t,
527  const ElemType t);
528 
529  static unsigned int ifem_n_dofs(const unsigned int dim,
530  const FEType & fe_t,
531  const ElemType t);
532 
533  static unsigned int ifem_n_dofs_at_node(const unsigned int dim,
534  const FEType & fe_t,
535  const ElemType t,
536  const unsigned int n);
537 
538  static unsigned int ifem_n_dofs_per_elem(const unsigned int dim,
539  const FEType & fe_t,
540  const ElemType t);
541 
542  static void ifem_nodal_soln(const unsigned int dim,
543  const FEType & fe_t,
544  const Elem * elem,
545  const std::vector<Number> & elem_soln,
546  std::vector<Number> & nodal_soln);
547 
548  static Point ifem_map (const unsigned int dim,
549  const FEType & fe_t,
550  const Elem * elem,
551  const Point & p);
552 
553  static Point ifem_inverse_map (const unsigned int dim,
554  const FEType & fe_t,
555  const Elem * elem,
556  const Point & p,
557  const Real tolerance = TOLERANCE,
558  const bool secure = true);
559 
560  static void ifem_inverse_map (const unsigned int dim,
561  const FEType & fe_t,
562  const Elem * elem,
563  const std::vector<Point> & physical_points,
564  std::vector<Point> & reference_points,
565  const Real tolerance = TOLERANCE,
566  const bool secure = true);
567 
568 
569  static bool ifem_on_reference_element(const Point & p,
570  const ElemType t,
571  const Real eps);
572 
573  static Real ifem_shape(const unsigned int dim,
574  const FEType & fe_t,
575  const ElemType t,
576  const unsigned int i,
577  const Point & p);
578 
579  static Real ifem_shape(const unsigned int dim,
580  const FEType & fe_t,
581  const Elem * elem,
582  const unsigned int i,
583  const Point & p);
584 
585 
586  static Real ifem_shape_deriv(const unsigned int dim,
587  const FEType & fe_t,
588  const ElemType t,
589  const unsigned int i,
590  const unsigned int j,
591  const Point & p);
592 
593  static Real ifem_shape_deriv(const unsigned int dim,
594  const FEType & fe_t,
595  const Elem * elem,
596  const unsigned int i,
597  const unsigned int j,
598  const Point & p);
599 
600  static void ifem_compute_data(const unsigned int dim,
601  const FEType & fe_t,
602  const Elem * elem,
603  FEComputeData & data);
604 
605 #endif
606 
607 
608 };
609 
610 } // namespace libMesh
611 
612 #endif // LIBMESH_FE_INTERFACE_H
libMesh::DofConstraints
The constraint matrix storage format.
Definition: dof_map.h:105
libMesh::FEInterface::shape_function
static shape_ptr shape_function(const unsigned int dim, const FEType &fe_t)
Definition: fe_interface.C:838
libMesh::PeriodicBoundaries
We're using a class instead of a typedef to allow forward declarations and future flexibility.
Definition: periodic_boundaries.h:51
libMesh::FEInterface::on_reference_element
static bool on_reference_element(const Point &p, const ElemType t, const Real eps=TOLERANCE)
Definition: fe_interface.C:677
libMesh::FEInterface::extra_hanging_dofs
static bool extra_hanging_dofs(const FEType &fe_t)
Definition: fe_interface.C:1656
libMesh::FEComputeData
class FEComputeData hides arbitrary data to be passed to and from children of FEBase through the FEIn...
Definition: fe_compute_data.h:51
libMesh::FEInterface::n_shape_functions
static unsigned int n_shape_functions(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface.C:446
libMesh::FEInterface::get_continuity
static FEContinuity get_continuity(const FEType &fe_type)
Returns the input FEType's FEContinuity based on the underlying FEFamily and potentially the Order,...
Definition: fe_interface.C:1719
libMesh::FEInterface::n_vec_dim
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
Definition: fe_interface.C:1701
libMesh::FEInterface::inverse_map
static Point inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
This is now deprecated; use FEMap::inverse_map instead.
Definition: fe_interface.C:620
libMesh::FEInterface::ifem_nodal_soln
static void ifem_nodal_soln(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln)
Definition: fe_interface_inf_fe.C:229
libMesh::FEInterface
This class provides an encapsulated access to all static public member functions of finite element cl...
Definition: fe_interface.h:65
libMesh::FEInterface::n_dofs_at_node_function
static n_dofs_at_node_ptr n_dofs_at_node_function(const unsigned int dim, const FEType &fe_t)
Definition: fe_interface.C:523
libMesh::FEInterface::ifem_n_dofs
static unsigned int ifem_n_dofs(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface_inf_fe.C:134
libMesh::FEInterface::n_dofs_at_node
static unsigned int n_dofs_at_node(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int n)
Definition: fe_interface.C:503
libMesh::FEInterface::shape_second_deriv
static Real shape_second_deriv(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const unsigned int j, const Point &p)
Definition: fe_interface.C:924
libMesh::FEInterface::ifem_n_dofs_per_elem
static unsigned int ifem_n_dofs_per_elem(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface_inf_fe.C:198
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::FEInterface::~FEInterface
virtual ~FEInterface()
Destructor.
Definition: fe_interface.h:79
libMesh::Order
Order
Definition: enum_order.h:40
libMesh::FEInterface::shape_deriv_function
static shape_deriv_ptr shape_deriv_function(const unsigned int dim, const FEType &fe_t)
Definition: fe_interface.C:916
libMesh::TOLERANCE
static const Real TOLERANCE
Definition: libmesh_common.h:128
libMesh::FEInterface::is_InfFE_elem
static bool is_InfFE_elem(const ElemType et)
Definition: fe_interface.C:46
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::FEInterface::shape_ptr
Real(* shape_ptr)(const Elem *elem, const Order o, const unsigned int i, const Point &p, const bool add_p_level)
Definition: fe_interface.h:296
libMesh::FEInterface::n_dofs_at_node_ptr
unsigned int(* n_dofs_at_node_ptr)(const ElemType, const Order, const unsigned int)
Definition: fe_interface.h:126
dim
unsigned int dim
Definition: adaptivity_ex3.C:113
libMesh::FEInterface::nodal_soln
static void nodal_soln(const unsigned int dim, const FEType &fe_t, const Elem *elem, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln)
Build the nodal soln from the element soln.
Definition: fe_interface.C:580
libMesh::FEInterface::compute_periodic_constraints
static void compute_periodic_constraints(DofConstraints &constraints, DofMap &dof_map, const PeriodicBoundaries &boundaries, const MeshBase &mesh, const PointLocatorBase *point_locator, const unsigned int variable_number, const Elem *elem)
Computes the constraint matrix contributions (for periodic boundary conditions) corresponding to vari...
Definition: fe_interface.C:1259
libMesh::FEInterface::ifem_shape_deriv
static Real ifem_shape_deriv(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const unsigned int j, const Point &p)
Definition: fe_interface_inf_fe.C:893
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
libMesh::FEInterface::n_dofs_per_elem
static unsigned int n_dofs_per_elem(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface.C:534
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
libMesh::FEInterface::dofs_on_edge
static void dofs_on_edge(const Elem *const elem, const unsigned int dim, const FEType &fe_t, unsigned int e, std::vector< unsigned int > &di)
Fills the vector di with the local degree of freedom indices associated with edge e of element elem A...
Definition: fe_interface.C:566
libMesh::FEInterface::ifem_n_dofs_at_node
static unsigned int ifem_n_dofs_at_node(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int n)
Definition: fe_interface_inf_fe.C:165
libMesh::FEInterface::n_dofs
static unsigned int n_dofs(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface.C:472
libMesh::FEInterface::shape_deriv_ptr
Real(* shape_deriv_ptr)(const Elem *elem, const Order o, const unsigned int i, const unsigned int j, const Point &p, const bool add_p_level)
Definition: fe_interface.h:345
libMesh::FEInterface::ifem_n_shape_functions
static unsigned int ifem_n_shape_functions(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface_inf_fe.C:102
libMesh::FEInterface::map
static Point map(unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p)
This is now deprecated; use FEMap::map instead.
Definition: fe_interface.C:604
libMesh::FEInterface::ifem_shape
static Real ifem_shape(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const Point &p)
Definition: fe_interface_inf_fe.C:675
libMesh::FEInterface::dofs_on_side
static void dofs_on_side(const Elem *const elem, const unsigned int dim, const FEType &fe_t, unsigned int s, std::vector< unsigned int > &di)
Fills the vector di with the local degree of freedom indices associated with side s of element elem A...
Definition: fe_interface.C:553
libMesh::FEInterface::shape_deriv
static Real shape_deriv(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const unsigned int j, const Point &p)
Definition: fe_interface.C:845
libMesh::FEType
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:178
libMesh::FEInterface::ifem_on_reference_element
static bool ifem_on_reference_element(const Point &p, const ElemType t, const Real eps)
Definition: fe_interface_inf_fe.C:665
libMesh::FEFamily
FEFamily
Definition: enum_fe_family.h:34
libMesh::DofMap
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:176
libMesh::FEInterface::field_type
static FEFieldType field_type(const FEType &fe_type)
Definition: fe_interface.C:1683
libMesh::FEInterface::shape_second_deriv_ptr
Real(* shape_second_deriv_ptr)(const Elem *elem, const Order o, const unsigned int i, const unsigned int j, const Point &p, const bool add_p_level)
Definition: fe_interface.h:409
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
libMesh::FEInterface::compute_constraints
static void compute_constraints(DofConstraints &constraints, DofMap &dof_map, const unsigned int variable_number, const Elem *elem)
Computes the constraint matrix contributions (for non-conforming adapted meshes) corresponding to var...
Definition: fe_interface.C:1103
data
IterBase * data
Ideally this private member data should have protected access.
Definition: variant_filter_iterator.h:337
libMesh::FEInterface::ifem_inverse_map
static Point ifem_inverse_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_interface_inf_fe.C:510
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::FEContinuity
FEContinuity
Definition: enum_fe_family.h:77
libMesh::FEInterface::shape_second_deriv_function
static shape_second_deriv_ptr shape_second_deriv_function(const unsigned int dim, const FEType &fe_t)
Definition: fe_interface.C:989
libMesh::PointLocatorBase
This is the base class for point locators.
Definition: point_locator_base.h:62
libMesh::FEInterface::ifem_compute_data
static void ifem_compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Definition: fe_interface_inf_fe.C:918
libMesh::FEInterface::max_order
static unsigned int max_order(const FEType &fe_t, const ElemType &el_t)
Definition: fe_interface.C:1281
libMesh::FEFieldType
FEFieldType
Definition: enum_fe_family.h:92
int
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
libMesh::ElemType
ElemType
Defines an enum for geometric element types.
Definition: enum_elem_type.h:33
libMesh::FEInterface::FEInterface
FEInterface()
Empty constructor.
Definition: fe_interface.C:36
libMesh::FEInterface::compute_data
static void compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
Lets the appropriate child of FEBase compute the requested data for the input specified in data,...
Definition: fe_interface.C:1028
libMesh::FEInterface::shape
static Real shape(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const Point &p)
Definition: fe_interface.C:687
libMesh::FEInterface::ifem_map
static Point ifem_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p)
Definition: fe_interface_inf_fe.C:479