HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
localdofspace.hpp
Go to the documentation of this file.
1 #ifndef LOCALDOFSPACE_HPP
2 #define LOCALDOFSPACE_HPP
3 
4 #include <mesh.hpp>
5 
6 namespace HArDCore3D {
7 
14 
15  class LocalDOFSpace {
16  public:
19  const Mesh & mesh,
20  size_t n_local_vertex_dofs,
21  size_t n_local_edge_dofs,
22  size_t n_local_face_dofs,
23  size_t n_local_cell_dofs
24  );
25 
26  //------------------------------------------------------------------------------
27  // Accessors
28  //------------------------------------------------------------------------------
29 
31  const Mesh & mesh() const
32  {
33  return m_mesh;
34  }
35 
37  inline size_t numLocalDofsVertex() const
38  {
39  return m_n_local_vertex_dofs;
40  }
41 
43  inline size_t numLocalDofsEdge() const
44  {
45  return m_n_local_edge_dofs;
46  }
47 
49  inline size_t numLocalDofsFace() const
50  {
51  return m_n_local_face_dofs;
52  }
53 
55  inline size_t numLocalDofsCell() const
56  {
57  return m_n_local_cell_dofs;
58  }
59 
61  inline size_t numLocalDofs(size_t d) const
62  {
63  assert(d < 4);
64  if (d == 0) {
65  return m_n_local_vertex_dofs;
66  } else if (d == 1) {
67  return m_n_local_edge_dofs;
68  } else if (d == 2) {
69  return m_n_local_face_dofs;
70  } else {
71  return m_n_local_cell_dofs;
72  }
73  }
74 
75  //------------------------------------------------------------------------------
76  // Dimensions
77  //------------------------------------------------------------------------------
78 
80  inline size_t dimension() const
81  {
86  }
87 
89  inline size_t dimensionVertex(const Vertex & V) const
90  {
91  return m_n_local_vertex_dofs;
92  }
93 
95  inline size_t dimensionVertex(size_t iV) const
96  {
97  return dimensionVertex(*m_mesh.vertex(iV));
98  }
99 
101  inline size_t dimensionEdge(const Edge & E) const
102  {
103  return 2 * m_n_local_vertex_dofs
105  }
106 
108  inline size_t dimensionEdge(size_t iE) const
109  {
110  return dimensionEdge(*m_mesh.edge(iE));
111  }
112 
114  inline size_t dimensionFace(const Face & F) const
115  {
116  return F.n_vertices() * m_n_local_vertex_dofs
117  + F.n_edges() * m_n_local_edge_dofs
119  }
120 
122  inline size_t dimensionFace(size_t iF) const
123  {
124  return dimensionFace(*m_mesh.face(iF));
125  }
126 
128  inline size_t dimensionCell(const Cell & T) const
129  {
130  return T.n_vertices() * m_n_local_vertex_dofs
131  + T.n_edges() * m_n_local_edge_dofs
132  + T.n_faces() * m_n_local_face_dofs
134  }
135 
137  inline size_t dimensionCell(size_t iT) const
138  {
139  return dimensionCell(*m_mesh.cell(iT));
140  }
141 
143  inline size_t dimension(size_t d, size_t i) const
144  {
145  assert(d < 4);
146  if (d == 0) {
147  return dimensionVertex(i);
148  } else if (d == 1) {
149  return dimensionEdge(i);
150  } else if (d == 2) {
151  return dimensionFace(i);
152  } else {
153  return dimensionCell(i);
154  }
155  }
156 
157  //------------------------------------------------------------------------------
158  // Local offsets
159  //------------------------------------------------------------------------------
160 
162  inline size_t localOffset(const Edge & E, const Vertex & V) const
163  {
164  return E.index_vertex(&V) * m_n_local_vertex_dofs;
165  }
166 
168  inline size_t localOffset(const Edge & E) const
169  {
170  return 2 * m_n_local_vertex_dofs;
171  }
172 
174  inline size_t localOffset(const Face & F, const Vertex & V) const
175  {
176  return F.index_vertex(&V) * m_n_local_vertex_dofs;
177  }
178 
180  inline size_t localOffset(const Face & F, const Edge & E) const
181  {
182  return F.n_vertices() * m_n_local_vertex_dofs
183  + F.index_edge(&E) * m_n_local_edge_dofs;
184  }
185 
187  inline size_t localOffset(const Face & F) const
188  {
189  return F.n_vertices() * m_n_local_vertex_dofs
190  + F.n_edges() * m_n_local_edge_dofs;
191  }
192 
194  inline size_t localOffset(const Cell & T, const Vertex & V) const
195  {
196  return T.index_vertex(&V) * m_n_local_vertex_dofs;
197  }
198 
200  inline size_t localOffset(const Cell & T, const Edge & E) const
201  {
202  return T.n_vertices() * m_n_local_vertex_dofs
203  + T.index_edge(&E) * m_n_local_edge_dofs;
204  }
205 
207  inline size_t localOffset(const Cell & T, const Face & F) const
208  {
209  return T.n_vertices() * m_n_local_vertex_dofs
210  + T.n_edges() * m_n_local_edge_dofs
211  + T.index_face(&F) * m_n_local_face_dofs;
212  }
213 
215  inline size_t localOffset(const Cell & T) const
216  {
217  return T.n_vertices() * m_n_local_vertex_dofs
218  + T.n_edges() * m_n_local_edge_dofs
219  + T.n_faces() * m_n_local_face_dofs;
220  }
221 
222  protected:
223  const Mesh & m_mesh;
228  };
229 
231 
232 } // namespace HArDCore3D
233 #endif
Base class for DOF spaces: functions to access local DOFs (organised from the smallest dimension to t...
Definition: localdofspace.hpp:15
Class to describe a mesh.
Definition: MeshND.hpp:17
size_t dimensionEdge(size_t iE) const
Returns the dimension of the local space on the edge of index iE (including vertices)
Definition: localdofspace.hpp:108
size_t localOffset(const Cell &T, const Face &F) const
Returns the local offset of the face F with respect to the cell T.
Definition: localdofspace.hpp:207
size_t dimension() const
Returns the dimension of the global space (all DOFs for all geometric entities)
Definition: localdofspace.hpp:80
size_t dimensionFace(const Face &F) const
Returns the dimension of the local space on the face F (including edges and vertices)
Definition: localdofspace.hpp:114
const Mesh & mesh() const
Returns the mesh.
Definition: localdofspace.hpp:31
size_t dimensionCell(const Cell &T) const
Returns the dimension of the local space on the cell T (including faces, edges and vertices)
Definition: localdofspace.hpp:128
size_t numLocalDofsEdge() const
Returns the number of local edge DOFs.
Definition: localdofspace.hpp:43
size_t numLocalDofsCell() const
Returns the number of local cell DOFs.
Definition: localdofspace.hpp:55
size_t localOffset(const Cell &T, const Edge &E) const
Returns the local offset of the edge E with respect to the cell T.
Definition: localdofspace.hpp:200
size_t m_n_local_edge_dofs
Definition: localdofspace.hpp:225
size_t dimensionFace(size_t iF) const
Returns the dimension of the local space on the face of index iF (including edges and vertices)
Definition: localdofspace.hpp:122
size_t m_n_local_vertex_dofs
Definition: localdofspace.hpp:224
size_t dimensionVertex(const Vertex &V) const
Returns the dimension of the local space on the vertex V.
Definition: localdofspace.hpp:89
size_t localOffset(const Face &F) const
Returns the local offset of the unknowns attached to the face F.
Definition: localdofspace.hpp:187
size_t dimensionCell(size_t iT) const
Returns the dimension of the local space on the cell of index iT (including faces,...
Definition: localdofspace.hpp:137
size_t localOffset(const Cell &T) const
Returns the local offset of the unknowns attached to the element T.
Definition: localdofspace.hpp:215
size_t dimensionVertex(size_t iV) const
Returns the dimension of the local space on the vertex of index iV.
Definition: localdofspace.hpp:95
LocalDOFSpace(const Mesh &mesh, size_t n_local_vertex_dofs, size_t n_local_edge_dofs, size_t n_local_face_dofs, size_t n_local_cell_dofs)
Constructor.
Definition: localdofspace.cpp:5
size_t numLocalDofs(size_t d) const
Returns the number of local d-cell DOFs.
Definition: localdofspace.hpp:61
size_t m_n_local_face_dofs
Definition: localdofspace.hpp:226
size_t localOffset(const Face &F, const Vertex &V) const
Returns the local offset of the vertex V with respect to the face F.
Definition: localdofspace.hpp:174
size_t localOffset(const Edge &E) const
Returns the local offset of the unknowns attached to the edge E.
Definition: localdofspace.hpp:168
size_t numLocalDofsVertex() const
Returns the number of local vertex DOFs.
Definition: localdofspace.hpp:37
size_t m_n_local_cell_dofs
Definition: localdofspace.hpp:227
size_t dimensionEdge(const Edge &E) const
Returns the dimension of the local space on the edge E (including vertices)
Definition: localdofspace.hpp:101
size_t localOffset(const Edge &E, const Vertex &V) const
Returns the local offset of the vertex V with respect to the edge E.
Definition: localdofspace.hpp:162
size_t localOffset(const Face &F, const Edge &E) const
Returns the local offset of the edge E with respect to the face F.
Definition: localdofspace.hpp:180
size_t numLocalDofsFace() const
Returns the number of local face DOFs.
Definition: localdofspace.hpp:49
size_t dimension(size_t d, size_t i) const
Returns the dimension of the local space on the d-cell of index i (including its boundary)
Definition: localdofspace.hpp:143
size_t localOffset(const Cell &T, const Vertex &V) const
Returns the local offset of the vertex V with respect to the cell T.
Definition: localdofspace.hpp:194
const Mesh & m_mesh
Definition: localdofspace.hpp:223
Vertex< dimension > * vertex(std::size_t index) const
get a constant pointer to a vertex using its global index
Definition: MeshND.hpp:194
std::size_t n_vertices() const
number of vertices in the mesh.
Definition: MeshND.hpp:57
std::size_t n_edges() const
number of edges in the mesh.
Definition: MeshND.hpp:58
std::size_t n_faces() const
number of faces in the mesh.
Definition: MeshND.hpp:59
Face< dimension > * face(std::size_t index) const
get a constant pointer to a face using its global index
Definition: MeshND.hpp:196
std::size_t n_cells() const
number of cells in the mesh.
Definition: MeshND.hpp:60
Edge< dimension > * edge(std::size_t index) const
get a constant pointer to a edge using its global index
Definition: MeshND.hpp:195
Cell< dimension > * cell(std::size_t index) const
get a constant pointer to a cell using its global index
Definition: MeshND.hpp:197
Definition: ddr-magnetostatics.hpp:40
MeshND::Edge< 2 > Edge
Definition: Mesh2D.hpp:11
MeshND::Face< 2 > Face
Definition: Mesh2D.hpp:12
MeshND::Cell< 2 > Cell
Definition: Mesh2D.hpp:13
MeshND::Vertex< 2 > Vertex
Definition: Mesh2D.hpp:10