libMesh
fe_interface.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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/enum_elem_type.h"
26 #include "libmesh/vector_value.h"
27 #include "libmesh/enum_fe_family.h"
28 #include "libmesh/enum_order.h"
29 
30 // C++ includes
31 #include <map>
32 #include <vector>
33 
34 namespace libMesh
35 {
36 
37 
38 // forward declarations
39 class BoundaryInfo;
40 class DofConstraints;
41 class DofMap;
42 class Elem;
43 class FEType;
44 class FEComputeData;
45 class Point;
46 class MeshBase;
47 
48 #ifdef LIBMESH_ENABLE_PERIODIC
49 class PeriodicBoundaries;
50 class PointLocatorBase;
51 #endif
52 
64 {
65 private:
66 
70  FEInterface();
71 
72 public:
73 
77  virtual ~FEInterface() {}
78 
86  static unsigned int n_shape_functions(const unsigned int dim,
87  const FEType & fe_t,
88  const ElemType t);
89 
97  static unsigned int n_dofs(const unsigned int dim,
98  const FEType & fe_t,
99  const ElemType t);
100 
108  static unsigned int n_dofs_at_node(const unsigned int dim,
109  const FEType & fe_t,
110  const ElemType t,
111  const unsigned int n);
112 
113  typedef unsigned int (*n_dofs_at_node_ptr) (const ElemType,
114  const Order,
115  const unsigned int);
116 
121  static n_dofs_at_node_ptr
122  n_dofs_at_node_function(const unsigned int dim,
123  const FEType & fe_t);
124 
132  static unsigned int n_dofs_per_elem(const unsigned int dim,
133  const FEType & fe_t,
134  const ElemType t);
135 
143  static void dofs_on_side(const Elem * const elem,
144  const unsigned int dim,
145  const FEType & fe_t,
146  unsigned int s,
147  std::vector<unsigned int> & di);
148 
156  static void dofs_on_edge(const Elem * const elem,
157  const unsigned int dim,
158  const FEType & fe_t,
159  unsigned int e,
160  std::vector<unsigned int> & di);
161 
173  static void nodal_soln(const unsigned int dim,
174  const FEType & fe_t,
175  const Elem * elem,
176  const std::vector<Number> & elem_soln,
177  std::vector<Number> & nodal_soln);
178 
183  static Point map(unsigned int dim,
184  const FEType & fe_t,
185  const Elem * elem,
186  const Point & p);
187 
197  static Point inverse_map (const unsigned int dim,
198  const FEType & fe_t,
199  const Elem * elem,
200  const Point & p,
201  const Real tolerance = TOLERANCE,
202  const bool secure = true);
203 
215  static void inverse_map (const unsigned int dim,
216  const FEType & fe_t,
217  const Elem * elem,
218  const std::vector<Point> & physical_points,
219  std::vector<Point> & reference_points,
220  const Real tolerance = TOLERANCE,
221  const bool secure = true);
222 
231  static bool on_reference_element(const Point & p,
232  const ElemType t,
233  const Real eps=TOLERANCE);
243  static Real shape(const unsigned int dim,
244  const FEType & fe_t,
245  const ElemType t,
246  const unsigned int i,
247  const Point & p);
248 
258  static Real shape(const unsigned int dim,
259  const FEType & fe_t,
260  const Elem * elem,
261  const unsigned int i,
262  const Point & p);
263 
273  template<typename OutputType>
274  static void shape(const unsigned int dim,
275  const FEType & fe_t,
276  const ElemType t,
277  const unsigned int i,
278  const Point & p,
279  OutputType & phi);
280 
290  template<typename OutputType>
291  static void shape(const unsigned int dim,
292  const FEType & fe_t,
293  const Elem * elem,
294  const unsigned int i,
295  const Point & p,
296  OutputType & phi);
297 
308  static void compute_data(const unsigned int dim,
309  const FEType & fe_t,
310  const Elem * elem,
311  FEComputeData & data);
312 
313 #ifdef LIBMESH_ENABLE_AMR
314 
319  static void compute_constraints (DofConstraints & constraints,
320  DofMap & dof_map,
321  const unsigned int variable_number,
322  const Elem * elem);
323 #endif // #ifdef LIBMESH_ENABLE_AMR
324 
325 #ifdef LIBMESH_ENABLE_PERIODIC
326 
331  static void compute_periodic_constraints (DofConstraints & constraints,
332  DofMap & dof_map,
333  const PeriodicBoundaries & boundaries,
334  const MeshBase & mesh,
335  const PointLocatorBase * point_locator,
336  const unsigned int variable_number,
337  const Elem * elem);
338 #endif // #ifdef LIBMESH_ENABLE_PERIODIC
339 
344  static unsigned int max_order (const FEType & fe_t,
345  const ElemType & el_t);
346 
351  static bool extra_hanging_dofs (const FEType & fe_t);
352 
357  static FEFieldType field_type (const FEType & fe_type);
358 
363  static FEFieldType field_type (const FEFamily & fe_family);
364 
369  static unsigned int n_vec_dim (const MeshBase & mesh,
370  const FEType & fe_type);
371 
372 private:
373 
374 
379  static bool is_InfFE_elem(const ElemType et);
380 
381 
382 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
383 
384  /*
385  * All these private members do the same as their public
386  * counterparts, except for infinite elements. This disentangles
387  * the calls to \p FE and \p InfFE.
388  */
389 
390  static unsigned int ifem_n_shape_functions(const unsigned int dim,
391  const FEType & fe_t,
392  const ElemType t);
393 
394  static unsigned int ifem_n_dofs(const unsigned int dim,
395  const FEType & fe_t,
396  const ElemType t);
397 
398  static unsigned int ifem_n_dofs_at_node(const unsigned int dim,
399  const FEType & fe_t,
400  const ElemType t,
401  const unsigned int n);
402 
403  static unsigned int ifem_n_dofs_per_elem(const unsigned int dim,
404  const FEType & fe_t,
405  const ElemType t);
406 
407  static void ifem_nodal_soln(const unsigned int dim,
408  const FEType & fe_t,
409  const Elem * elem,
410  const std::vector<Number> & elem_soln,
411  std::vector<Number> & nodal_soln);
412 
413  static Point ifem_map (const unsigned int dim,
414  const FEType & fe_t,
415  const Elem * elem,
416  const Point & p);
417 
418  static Point ifem_inverse_map (const unsigned int dim,
419  const FEType & fe_t,
420  const Elem * elem,
421  const Point & p,
422  const Real tolerance = TOLERANCE,
423  const bool secure = true);
424 
425  static void ifem_inverse_map (const unsigned int dim,
426  const FEType & fe_t,
427  const Elem * elem,
428  const std::vector<Point> & physical_points,
429  std::vector<Point> & reference_points,
430  const Real tolerance = TOLERANCE,
431  const bool secure = true);
432 
433 
434  static bool ifem_on_reference_element(const Point & p,
435  const ElemType t,
436  const Real eps);
437 
438  static Real ifem_shape(const unsigned int dim,
439  const FEType & fe_t,
440  const ElemType t,
441  const unsigned int i,
442  const Point & p);
443 
444  static Real ifem_shape(const unsigned int dim,
445  const FEType & fe_t,
446  const Elem * elem,
447  const unsigned int i,
448  const Point & p);
449 
450  static void ifem_compute_data(const unsigned int dim,
451  const FEType & fe_t,
452  const Elem * elem,
453  FEComputeData & data);
454 
455 #endif
456 
457 
458 };
459 
460 
461 
462 
463 
464 // ------------------------------------------------------------
465 // FEInterface class inline members
466 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
467 
469 {
470  return false;
471 }
472 
473 #else
474 
475 inline bool FEInterface::is_InfFE_elem(const ElemType et)
476 {
477 
478  switch (et)
479  {
480  case INFEDGE2:
481  case INFQUAD4:
482  case INFQUAD6:
483  case INFHEX8:
484  case INFHEX16:
485  case INFHEX18:
486  case INFPRISM6:
487  case INFPRISM12:
488  {
489  return true;
490  }
491 
492  default:
493  {
494  return false;
495  }
496  }
497 }
498 
499 #endif //ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
500 
501 
502 
503 } // namespace libMesh
504 
505 
506 
507 
508 #endif // LIBMESH_FE_INTERFACE_H
static unsigned int n_dofs_per_elem(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface.C:473
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:510
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:178
static Point map(unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p)
Definition: fe_interface.C:550
static unsigned int n_dofs(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface.C:414
static unsigned int ifem_n_shape_functions(const unsigned int dim, const FEType &fe_t, const ElemType t)
static bool ifem_on_reference_element(const Point &p, const ElemType t, const Real eps)
static Real ifem_shape(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int i, const Point &p)
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:495
unsigned int dim
class FEComputeData hides arbitrary data to be passed to and from children of FEBase through the FEIn...
We&#39;re using a class instead of a typedef to allow forward declarations and future flexibility...
ElemType
Defines an enum for geometric element types.
FEFieldType
defines an enum for finite element field types - i.e.
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
MeshBase & mesh
static FEFieldType field_type(const FEType &fe_type)
static const Real TOLERANCE
The libMesh namespace provides an interface to certain functionality in the library.
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)
static unsigned int max_order(const FEType &fe_t, const ElemType &el_t)
This is the MeshBase class.
Definition: mesh_base.h:68
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:863
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:167
FEFamily
defines an enum for finite element families.
FEInterface()
Empty constructor.
Definition: fe_interface.C:32
static void ifem_compute_data(const unsigned int dim, const FEType &fe_t, const Elem *elem, FEComputeData &data)
static bool extra_hanging_dofs(const FEType &fe_t)
static unsigned int n_shape_functions(const unsigned int dim, const FEType &fe_t, const ElemType t)
Definition: fe_interface.C:385
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:641
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:827
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)
Definition: fe_interface.C:569
static Point ifem_map(const unsigned int dim, const FEType &fe_t, const Elem *elem, const Point &p)
This is the base class for point locators.
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)
static bool on_reference_element(const Point &p, const ElemType t, const Real eps=TOLERANCE)
Definition: fe_interface.C:631
This class provides an encapsulated access to all static public member functions of finite element cl...
Definition: fe_interface.h:63
static unsigned int ifem_n_dofs_per_elem(const unsigned int dim, const FEType &fe_t, const ElemType t)
static unsigned int n_vec_dim(const MeshBase &mesh, const FEType &fe_type)
static n_dofs_at_node_ptr n_dofs_at_node_function(const unsigned int dim, const FEType &fe_t)
Definition: fe_interface.C:459
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:436
static unsigned int ifem_n_dofs(const unsigned int dim, const FEType &fe_t, const ElemType t)
unsigned int(* n_dofs_at_node_ptr)(const ElemType, const Order, const unsigned int)
Definition: fe_interface.h:113
virtual ~FEInterface()
Destructor.
Definition: fe_interface.h:77
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Order
defines an enum for polynomial orders.
Definition: enum_order.h:32
static bool is_InfFE_elem(const ElemType et)
Definition: fe_interface.h:468
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:526
IterBase * data
Ideally this private member data should have protected access.
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...
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
The constraint matrix storage format.
Definition: dof_map.h:96
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360
static unsigned int ifem_n_dofs_at_node(const unsigned int dim, const FEType &fe_t, const ElemType t, const unsigned int n)