Flow123d  release_3.0.0-922-g9fcbba1
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 element (not shared by adjacent elements).
45  virtual unsigned int n_elem_dofs(const ElementAccessor<3> &cell) const = 0;
46 
47  /// Number of dofs associated to generalized n-face (node, line, triangle or tetrahedron).
48  template<unsigned int dim>
49  unsigned int n_face_dofs(unsigned int face_id)
50  {
51  ASSERT(false).error("Not implemented.");
52  return 0;
53  }
54 
55  /// Return finite element object for given element.
56  template<unsigned int dim>
58 
59  /// Destructor.
60  virtual ~DiscreteSpace() {};
61 
62 
63 protected:
64 
65  /// Constructor.
67  : mesh_(mesh) {}
68 
69  virtual FiniteElement<0> *fe0d(const ElementAccessor<3> &) const = 0;
70  virtual FiniteElement<1> *fe1d(const ElementAccessor<3> &) const = 0;
71  virtual FiniteElement<2> *fe2d(const ElementAccessor<3> &) const = 0;
72  virtual FiniteElement<3> *fe3d(const ElementAccessor<3> &) const = 0;
73 
75 
76 };
77 
78 
79 
80 /**
81  * Implementation of DiscreteSpace when all elements have the same FiniteElement.
82  */
84 public:
85 
87  : DiscreteSpace(mesh), fe0_(fe0), fe1_(fe1), fe2_(fe2), fe3_(fe3) {}
88 
89  unsigned int n_elem_dofs(const ElementAccessor<3> &cell) const override;
90 
91  unsigned int n_node_dofs(unsigned int nid) const override;
92 
93  FiniteElement<0> *fe0d(const ElementAccessor<3> &cell) const override { return fe0_; }
94  FiniteElement<1> *fe1d(const ElementAccessor<3> &cell) const override { return fe1_; }
95  FiniteElement<2> *fe2d(const ElementAccessor<3> &cell) const override { return fe2_; }
96  FiniteElement<3> *fe3d(const ElementAccessor<3> &cell) const override { return fe3_; }
97 
98 
99 private:
100 
105 
106 };
107 
108 
109 
110 
111 
112 
113 
114 #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:80
#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 FiniteElement< 2 > * fe2d(const ElementAccessor< 3 > &) const =0