Flow123d  release_3.0.0-1140-gd35b574
discrete_space.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file discrete_space.hh
15  * @brief Declaration of class which provides the finite element for every mesh cell.
16  * @author Jan Stebel
17  */
18 
19 #ifndef DISCRETE_SPACE_HH_
20 #define DISCRETE_SPACE_HH_
21 
22 #include "mesh/accessors.hh"
23 
24 
25 template<unsigned int dim> class FiniteElement;
26 class Mesh;
27 
28 
29 /**
30  * Abstract class for definition of finite element functions on the mesh.
31  * This should include
32  * - simple FE spaces using the same finite element on
33  * all mesh elements with the same dimension,
34  * - p-refined spaces using variable FE order,
35  * - XFEM with arbitrary shape functions on every element.
36  *
37  */
39 public:
40 
41  /// Number of dofs associated to node. @p nid is the node index in the mesh tree.
42  virtual unsigned int n_node_dofs(unsigned int nid) const = 0;
43 
44  /// Number of dofs associated to edge.
45  virtual unsigned int n_edge_dofs(const Edge &edge) const = 0;
46 
47  /// Number of dofs associated to element (not shared by adjacent elements).
48  virtual unsigned int n_elem_dofs(const ElementAccessor<3> &cell) const = 0;
49 
50  /// Number of dofs associated to generalized n-face (node, line, triangle or tetrahedron).
51  template<unsigned int dim>
52  unsigned int n_face_dofs(unsigned int face_id)
53  {
54  ASSERT(false).error("Not implemented.");
55  return 0;
56  }
57 
58  /// Return finite element object for given element.
59  template<unsigned int dim>
61 
62  /// Destructor.
63  virtual ~DiscreteSpace() {};
64 
65 
66 protected:
67 
68  /// Constructor.
70  : mesh_(mesh) {}
71 
72  virtual FiniteElement<0> *fe0d(const ElementAccessor<3> &) const = 0;
73  virtual FiniteElement<1> *fe1d(const ElementAccessor<3> &) const = 0;
74  virtual FiniteElement<2> *fe2d(const ElementAccessor<3> &) const = 0;
75  virtual FiniteElement<3> *fe3d(const ElementAccessor<3> &) const = 0;
76 
78 
79 };
80 
81 
82 
83 /**
84  * Implementation of DiscreteSpace when all elements have the same FiniteElement.
85  */
87 public:
88 
90  : DiscreteSpace(mesh), fe0_(fe0), fe1_(fe1), fe2_(fe2), fe3_(fe3) {}
91 
92  unsigned int n_elem_dofs(const ElementAccessor<3> &cell) const override;
93 
94  unsigned int n_edge_dofs(const Edge &edge) const override;
95 
96  unsigned int n_node_dofs(unsigned int nid) const override;
97 
98  FiniteElement<0> *fe0d(const ElementAccessor<3> &cell) const override { return fe0_; }
99  FiniteElement<1> *fe1d(const ElementAccessor<3> &cell) const override { return fe1_; }
100  FiniteElement<2> *fe2d(const ElementAccessor<3> &cell) const override { return fe2_; }
101  FiniteElement<3> *fe3d(const ElementAccessor<3> &cell) const override { return fe3_; }
102 
103 
104 private:
105 
110 
111 };
112 
113 
114 
115 
116 
117 
118 
119 #endif /* DISCRETE_SPACE_HH_ */
unsigned int n_face_dofs(unsigned int face_id)
Number of dofs associated to generalized n-face (node, line, triangle or tetrahedron).
FiniteElement< 2 > * fe2_
virtual FiniteElement< 1 > * fe1d(const ElementAccessor< 3 > &) const =0
FiniteElement< 1 > * fe1_
virtual unsigned int n_node_dofs(unsigned int nid) const =0
Number of dofs associated to node. nid is the node index in the mesh tree.
Definition: mesh.h:76
Definition: edges.h:26
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Definition: asserts.hh:346
FiniteElement< dim > * fe(const ElementAccessor< 3 > &) const
Return finite element object for given element.
FiniteElement< 1 > * fe1d(const ElementAccessor< 3 > &cell) const override
EqualOrderDiscreteSpace(Mesh *mesh, FiniteElement< 0 > *fe0, FiniteElement< 1 > *fe1, FiniteElement< 2 > *fe2, FiniteElement< 3 > *fe3)
virtual FiniteElement< 0 > * fe0d(const ElementAccessor< 3 > &) const =0
virtual FiniteElement< 3 > * fe3d(const ElementAccessor< 3 > &) const =0
virtual ~DiscreteSpace()
Destructor.
FiniteElement< 2 > * fe2d(const ElementAccessor< 3 > &cell) const override
FiniteElement< 0 > * fe0d(const ElementAccessor< 3 > &cell) const override
DiscreteSpace(Mesh *mesh)
Constructor.
FiniteElement< 3 > * fe3_
FiniteElement< 3 > * fe3d(const ElementAccessor< 3 > &cell) const override
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
FiniteElement< 0 > * fe0_
virtual unsigned int n_elem_dofs(const ElementAccessor< 3 > &cell) const =0
Number of dofs associated to element (not shared by adjacent elements).
virtual unsigned int n_edge_dofs(const Edge &edge) const =0
Number of dofs associated to edge.
virtual FiniteElement< 2 > * fe2d(const ElementAccessor< 3 > &) const =0