HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
Loading...
Searching...
No Matches
variabledofspace.hpp
Go to the documentation of this file.
1#ifndef VARIABLEDOFSPACE_HPP
2#define VARIABLEDOFSPACE_HPP
3
4#include<mesh.hpp>
5
6namespace HArDCore3D
7{
14
18 public:
21 const Mesh & mesh,
22 const Eigen::VectorXi n_local_vertex_dofs,
23 const Eigen::VectorXi n_local_edge_dofs,
24 const Eigen::VectorXi n_local_face_dofs,
25 const Eigen::VectorXi n_local_cell_dofs
26 );
27
30 const Mesh & mesh,
32 const Eigen::VectorXi n_local_edge_dofs,
33 const Eigen::VectorXi n_local_face_dofs,
34 const Eigen::VectorXi n_local_cell_dofs
35 );
36
39 const Mesh & mesh,
41 size_t n_local_edge_dofs,
42 const Eigen::VectorXi n_local_face_dofs,
43 const Eigen::VectorXi n_local_cell_dofs
44 );
45
48 const Mesh & mesh,
50 size_t n_local_edge_dofs,
51 size_t n_local_face_dofs,
52 const Eigen::VectorXi n_local_cell_dofs
53 );
54
57 const Mesh & mesh,
59 size_t n_local_edge_dofs,
60 size_t n_local_face_dofs,
61 size_t n_local_cell_dofs
62 );
63
64
65 //------------------------------------------------------------------------------
66 // Accessors
67 //------------------------------------------------------------------------------
68
70 const Mesh & mesh() const
71 {
72 return m_mesh;
73 }
74
76 inline size_t numLocalDofsVertex(const size_t iV) const
77 {
78 assert(iV<m_mesh.n_vertices());
79 return m_n_local_vertex_dofs[iV];
80 }
81
83 inline size_t numLocalDofsVertex(const Vertex & V) const
84 {
85 return numLocalDofsVertex(V.global_index());
86 }
87
89 inline size_t numLocalDofsEdge(const size_t iE) const
90 {
91 assert(iE<m_mesh.n_edges());
92 return m_n_local_edge_dofs[iE];
93 }
94
96 inline size_t numLocalDofsEdge(const Edge & E) const
97 {
98 return numLocalDofsEdge(E.global_index());
99 }
100
102 inline size_t numLocalDofsFace(const size_t iF) const
103 {
104 assert(iF<m_mesh.n_faces());
105 return m_n_local_face_dofs[iF];
106 }
107
109 inline size_t numLocalDofsFace(const Face & F) const
110 {
111 return numLocalDofsFace(F.global_index());
112 }
113
115 inline size_t numLocalDofsCell(const size_t iT) const
116 {
117 assert(iT<m_mesh.n_cells());
118 return m_n_local_cell_dofs[iT];
119 }
120
122 inline size_t numLocalDofsCell(const Cell & T) const
123 {
124 return numLocalDofsCell(T.global_index());
125 }
126
127 //------------------------------------------------------------------------------
128 // Dimensions
129 //------------------------------------------------------------------------------
130
132
134 inline size_t nDOFs_vertices() const
135 {
136 return m_n_local_vertex_dofs.sum();
137 }
138
140 inline size_t nDOFs_edges() const
141 {
142 return m_n_local_edge_dofs.sum();
143 }
144
146 inline size_t nDOFs_faces() const
147 {
148 return m_n_local_face_dofs.sum();
149 }
150
152 inline size_t nDOFs_cells() const
153 {
154 return m_n_local_cell_dofs.sum();
155 }
156
158 inline size_t dimension() const
159 {
161 }
162
163 //--- Vertices -----//
165 inline size_t dimensionVertex(const Vertex & V) const
166 {
167 return m_n_local_vertex_dofs[V.global_index()];
168 }
169
171 inline size_t dimensionVertex(size_t iV) const
172 {
173 assert(iV<m_mesh.n_vertices());
174 return dimensionVertex(*m_mesh.vertex(iV));
175 }
176
177 //--- Edges ----//
179 inline size_t dimensionEdge(const Edge & E) const
180 {
181 return m_n_local_vertex_dofs[E.vertex(0)->global_index()] + m_n_local_vertex_dofs[E.vertex(1)->global_index()]
182 + m_n_local_edge_dofs[E.global_index()];
183 }
184
186 inline size_t dimensionEdge(size_t iE) const
187 {
188 assert(iE<m_mesh.n_edges());
189 return dimensionEdge(*m_mesh.edge(iE));
190 }
191
192 //--- Faces -----//
194 inline size_t dimensionFace(const Face & F) const
195 {
196 size_t nb_dofs = 0;
197 for (Vertex * V : F.get_vertices()){
198 nb_dofs += m_n_local_vertex_dofs[V->global_index()];
199 }
200 for (Edge * E : F.get_edges()){
201 nb_dofs += m_n_local_edge_dofs[E->global_index()];
202 }
203 return nb_dofs + m_n_local_face_dofs[F.global_index()];
204 }
205
207 inline size_t dimensionFace(size_t iF) const
208 {
209 return dimensionFace(*m_mesh.face(iF));
210 }
211
212 //--- Cell -----//
214 inline size_t dimensionCell(const Cell & T) const
215 {
216 size_t nb_dofs = 0;
217 for (Vertex * V : T.get_vertices()){
218 nb_dofs += m_n_local_vertex_dofs[V->global_index()];
219 }
220 for (Edge * E : T.get_edges()){
221 nb_dofs += m_n_local_edge_dofs[E->global_index()];
222 }
223 for (Face * F : T.get_faces()){
224 nb_dofs += m_n_local_face_dofs[F->global_index()];
225 }
226 return nb_dofs + m_n_local_cell_dofs[T.global_index()];
227 }
228
230 inline size_t dimensionCell(size_t iT) const
231 {
232 return dimensionCell(*m_mesh.cell(iT));
233 }
234
235 //------------------------------------------------------------------------------
236 // Local offsets
237 //------------------------------------------------------------------------------
238
240 inline size_t localOffset(const Edge & E, const Vertex & V) const
241 {
242 size_t nb_dofs = 0;
243 for (int iV=0; iV<E.index_vertex(&V); iV++){
244 nb_dofs += m_n_local_vertex_dofs[E.vertex(iV)->global_index()];
245 }
246 return nb_dofs;
247 }
248
250 inline size_t localOffset(const Edge & E) const
251 {
252 return m_n_local_vertex_dofs[E.vertex(0)->global_index()] + m_n_local_vertex_dofs[E.vertex(1)->global_index()];
253 }
254
256 inline size_t localOffset(const Face & F, const Vertex & V) const
257 {
258 size_t nb_dofs = 0;
259 for (int iV=0; iV<F.index_vertex(&V); iV++){
260 nb_dofs += m_n_local_vertex_dofs[F.vertex(iV)->global_index()];
261 }
262 return nb_dofs;
263 }
264
266 inline size_t localOffset(const Face & F, const Edge & E) const
267 {
268 size_t nb_dofs = 0;
269 for (size_t iV=0; iV<F.n_vertices(); iV++){
270 nb_dofs += m_n_local_vertex_dofs[F.vertex(iV)->global_index()];
271 }
272 for (int iE=0; iE<F.index_edge(&E); iE++){
273 nb_dofs += m_n_local_edge_dofs[F.edge(iE)->global_index()];
274 }
275 return nb_dofs;
276 }
277
279 inline size_t localOffset(const Face & F) const
280 {
281 size_t nb_dofs = 0;
282 for (size_t iV=0; iV<F.n_vertices(); iV++){
283 nb_dofs += m_n_local_vertex_dofs[F.vertex(iV)->global_index()];
284 }
285 for (size_t iE=0; iE<F.n_edges(); iE++){
286 nb_dofs += m_n_local_edge_dofs[F.edge(iE)->global_index()];
287 }
288 return nb_dofs;
289 }
290
292 inline size_t localOffset(const Cell & T, const Vertex & V) const
293 {
294 size_t nb_dofs = 0;
295 for (int iV=0; iV<T.index_vertex(&V); iV++){
296 nb_dofs += m_n_local_vertex_dofs[T.vertex(iV)->global_index()];
297 }
298 return nb_dofs;
299 }
300
302 inline size_t localOffset(const Cell & T, const Edge & E) const
303 {
304 size_t nb_dofs = 0;
305 for (size_t iV=0; iV<T.n_vertices(); iV++){
306 nb_dofs += m_n_local_vertex_dofs[T.vertex(iV)->global_index()];
307 }
308 for (int iE=0; iE<T.index_edge(&E); iE++){
309 nb_dofs += m_n_local_edge_dofs[T.edge(iE)->global_index()];
310 }
311 return nb_dofs;
312 }
313
315 inline size_t localOffset(const Cell & T, const Face & F) const
316 {
317 size_t nb_dofs = 0;
318 for (size_t iV=0; iV<T.n_vertices(); iV++){
319 nb_dofs += m_n_local_vertex_dofs[T.vertex(iV)->global_index()];
320 }
321 for (size_t iE=0; iE<T.n_edges(); iE++){
322 nb_dofs += m_n_local_edge_dofs[T.edge(iE)->global_index()];
323 }
324 for (int iF=0; iF<T.index_face(&F); iF++){
325 nb_dofs += m_n_local_face_dofs[T.face(iF)->global_index()];
326 }
327 return nb_dofs;
328 }
329
331 inline size_t localOffset(const Cell & T) const
332 {
333 size_t nb_dofs = 0;
334 for (size_t iV=0; iV<T.n_vertices(); iV++){
335 nb_dofs += m_n_local_vertex_dofs[T.vertex(iV)->global_index()];
336 }
337 for (size_t iE=0; iE<T.n_edges(); iE++){
338 nb_dofs += m_n_local_edge_dofs[T.edge(iE)->global_index()];
339 }
340 for (size_t iF=0; iF<T.n_faces(); iF++){
341 nb_dofs += m_n_local_face_dofs[T.face(iF)->global_index()];
342 }
343 return nb_dofs;
344 }
345
346 //------------------------------------------------------------------------------
347 // Global offsets
348 //------------------------------------------------------------------------------
349
351 inline size_t globalOffset(const Vertex & V) const
352 {
353 return ( m_n_local_vertex_dofs.head(V.global_index()) ).sum();
354 }
355
357 inline size_t globalOffset(const Edge & E) const
358 {
359 return m_n_local_vertex_dofs.sum()
360 + ( m_n_local_edge_dofs.head(E.global_index()) ).sum();
361 }
362
364 inline size_t globalOffset(const Face & F) const
365 {
366 return m_n_local_vertex_dofs.sum()
367 + m_n_local_edge_dofs.sum()
368 + ( m_n_local_face_dofs.head(F.global_index()) ).sum();
369 }
370
372 inline size_t globalOffset(const Cell & T) const
373 {
374 return m_n_local_vertex_dofs.sum()
375 + m_n_local_edge_dofs.sum()
376 + m_n_local_face_dofs.sum()
377 + ( m_n_local_cell_dofs.head(T.global_index()) ).sum();
378 }
379
380 //------------------------------------------------------------------------------
381 // Restrictions
382 //------------------------------------------------------------------------------
383
385 Eigen::VectorXd restrictEdge(size_t iE, const Eigen::VectorXd & vh) const;
386
388 Eigen::VectorXd restrictFace(size_t iF, const Eigen::VectorXd & vh) const;
389
391 Eigen::VectorXd restrictCell(size_t iT, const Eigen::VectorXd & vh) const;
392
394 inline Eigen::VectorXd restrict(const Edge & E, const Eigen::VectorXd vh) const
395 {
396 return restrictEdge(E.global_index(), vh);
397 }
398
400 inline Eigen::VectorXd restrict(const Face & F, const Eigen::VectorXd vh) const
401 {
402 return restrictFace(F.global_index(), vh);
403 }
404
406 inline Eigen::VectorXd restrict(const Cell & T, const Eigen::VectorXd vh) const
407 {
408 return restrictCell(T.global_index(), vh);
409 }
410
411 //------------------------------------------------------------------------------
412 // Extensions
413 //------------------------------------------------------------------------------
414
417 Eigen::MatrixXd extendOperator(const Cell & T, const Face & F, const Eigen::MatrixXd & opF) const;
418
420 Eigen::MatrixXd extendOperator(const Cell & T, const Edge & E, const Eigen::MatrixXd & opE) const;
421
423 Eigen::MatrixXd extendOperator(const Face & F, const Edge & E, const Eigen::MatrixXd & opE) const;
424
426 void extendOperator(const Cell & T, const Face & F, Eigen::Ref<Eigen::MatrixXd> opT, const Eigen::MatrixXd & opF) const;
427
429 void extendOperator(const Cell & T, const Edge & E, Eigen::MatrixXd & opT, const Eigen::MatrixXd & opE) const;
430
432 void extendOperator(const Face & F, const Edge & E, Eigen::MatrixXd & opF, const Eigen::MatrixXd & opE) const;
433
435 void addInnerProductContribution(const Cell & T, const Face & F, Eigen::MatrixXd & prodT, const Eigen::MatrixXd & prodF) const;
436
437 //------------------------------------------------------------------------------
438 // Global DOF indices for an element T
439 //------------------------------------------------------------------------------
440
442 std::vector<size_t> globalDOFIndices(const Cell & T) const;
443
445 std::vector<size_t> globalDOFIndices(const Face & F) const;
446
447 private:
448 const Mesh & m_mesh;
449 Eigen::VectorXi m_n_local_vertex_dofs;
450 Eigen::VectorXi m_n_local_edge_dofs;
451 Eigen::VectorXi m_n_local_face_dofs;
452 Eigen::VectorXi m_n_local_cell_dofs;
453
454
455 };
456
457} // namespace HArDCore3D
458
459#endif
Base class for global DOF spaces.
Definition variabledofspace.hpp:17
Class to describe a mesh.
Definition MeshND.hpp:17
@ Matrix
Definition basis.hpp:67
size_t globalOffset(const Face &F) const
Return the global offset for the unknowns on the face F.
Definition variabledofspace.hpp:364
size_t dimensionCell(const Cell &T) const
Returns the dimension of the local space on the cell T (including faces, edges and vertices)
Definition variabledofspace.hpp:214
Eigen::VectorXd restrict(const Edge &E, const Eigen::VectorXd vh) const
Restrict to an edge.
Definition variabledofspace.hpp:394
size_t numLocalDofsEdge(const size_t iE) const
Returns the number of local DOFs on edge of index iE.
Definition variabledofspace.hpp:89
size_t globalOffset(const Edge &E) const
Return the global offset for the unknowns on the edge E.
Definition variabledofspace.hpp:357
Eigen::VectorXd restrict(const Face &F, const Eigen::VectorXd vh) const
Restrict to a face.
Definition variabledofspace.hpp:400
size_t dimensionFace(const Face &F) const
Returns the dimension of the local space on the face F (including edges and vertices)
Definition variabledofspace.hpp:194
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 variabledofspace.hpp:207
size_t nDOFs_cells() const
Total number of cells DOFs.
Definition variabledofspace.hpp:152
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 variabledofspace.hpp:256
size_t nDOFs_vertices() const
Total number of vertices DOFs.
Definition variabledofspace.hpp:134
size_t dimensionEdge(size_t iE) const
Returns the dimension of the local space on the edge of index iE (including vertices)
Definition variabledofspace.hpp:186
size_t dimensionVertex(size_t iV) const
Returns the dimension of the local space on the vertex of index iV.
Definition variabledofspace.hpp:171
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 variabledofspace.hpp:302
size_t numLocalDofsVertex(const size_t iV) const
Returns the number of local DOFs on vertex of index iV.
Definition variabledofspace.hpp:76
Eigen::MatrixXd extendOperator(const Cell &T, const Face &F, const Eigen::MatrixXd &opF) const
Definition variabledofspace.cpp:172
size_t numLocalDofsCell(const Cell &T) const
Returns the number of local DOFs on cell T.
Definition variabledofspace.hpp:122
size_t dimensionEdge(const Edge &E) const
Returns the dimension of the local space on the edge E (including vertices)
Definition variabledofspace.hpp:179
size_t dimensionCell(size_t iT) const
Returns the dimension of the local space on the cell of index iT (including faces,...
Definition variabledofspace.hpp:230
size_t numLocalDofsEdge(const Edge &E) const
Returns the number of local DOFs on edge E.
Definition variabledofspace.hpp:96
void addInnerProductContribution(const Cell &T, const Face &F, Eigen::MatrixXd &prodT, const Eigen::MatrixXd &prodF) const
Takes an inner product prodF on a face F, and adds its contributions to the inner product prodT on th...
Definition variabledofspace.cpp:260
std::vector< size_t > globalDOFIndices(const Cell &T) const
Returns a vector listing the global DOFs attached to the element T: vertex DOFs, edge DOFs,...
Definition variabledofspace.cpp:367
size_t numLocalDofsFace(const Face &F) const
Returns the number of local DOFs on face F.
Definition variabledofspace.hpp:109
size_t localOffset(const Face &F) const
Returns the local offset of the unknowns attached to the face F.
Definition variabledofspace.hpp:279
Eigen::VectorXd restrictEdge(size_t iE, const Eigen::VectorXd &vh) const
Restrict to the edge (including its vertices) of index iE.
Definition variabledofspace.cpp:97
size_t dimension() const
Returns the dimension of the global space (all DOFs for all geometric entities)
Definition variabledofspace.hpp:158
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 variabledofspace.hpp:292
size_t localOffset(const Edge &E) const
Returns the local offset of the unknowns attached to the edge E.
Definition variabledofspace.hpp:250
size_t nDOFs_faces() const
Total number of faces DOFs.
Definition variabledofspace.hpp:146
size_t numLocalDofsVertex(const Vertex &V) const
Returns the number of local DOFs on vertex V.
Definition variabledofspace.hpp:83
size_t numLocalDofsCell(const size_t iT) const
Returns the number of local DOFs on cell of index iT.
Definition variabledofspace.hpp:115
size_t nDOFs_edges() const
Total number of edges DOFs.
Definition variabledofspace.hpp:140
Eigen::VectorXd restrictCell(size_t iT, const Eigen::VectorXd &vh) const
Restrict to the cell (including vertices, edges and faces) of index iT.
Definition variabledofspace.cpp:140
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 variabledofspace.hpp:240
size_t localOffset(const Cell &T) const
Returns the local offset of the unknowns attached to the element T.
Definition variabledofspace.hpp:331
size_t globalOffset(const Cell &T) const
Return the global offset for the unknowns on the cell T.
Definition variabledofspace.hpp:372
const Mesh & mesh() const
Returns the mesh.
Definition variabledofspace.hpp:70
size_t dimensionVertex(const Vertex &V) const
Returns the dimension of the local space on the vertex V.
Definition variabledofspace.hpp:165
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 variabledofspace.hpp:266
Eigen::VectorXd restrict(const Cell &T, const Eigen::VectorXd vh) const
Restrict to a cell.
Definition variabledofspace.hpp:406
Eigen::VectorXd restrictFace(size_t iF, const Eigen::VectorXd &vh) const
Restrict to the face (including vertices and edges) of index iF.
Definition variabledofspace.cpp:114
size_t globalOffset(const Vertex &V) const
Return the global offset for the unknowns on the vertex V.
Definition variabledofspace.hpp:351
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 variabledofspace.hpp:315
size_t numLocalDofsFace(const size_t iF) const
Returns the number of local DOFs on face of index iF.
Definition variabledofspace.hpp:102
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_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
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_faces() const
number of faces in the mesh.
Definition MeshND.hpp:59
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:41