HArD::Core2D
Hybrid Arbitrary Degree::Core 2D - Library to implement 2D schemes with edge 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 HArDCore2D
7{
14
18 public:
21 const Mesh & mesh,
22 const Eigen::VectorXd n_local_vertex_dofs,
23 const Eigen::VectorXd n_local_edge_dofs,
24 const Eigen::VectorXd n_local_cell_dofs
25 );
26
29 const Mesh & mesh,
30 size_t n_local_vertex_dofs,
31 const Eigen::VectorXd n_local_edge_dofs,
32 const Eigen::VectorXd n_local_cell_dofs
33 );
34
37 const Mesh & mesh,
38 size_t n_local_vertex_dofs,
39 size_t n_local_edge_dofs,
40 const Eigen::VectorXd n_local_cell_dofs
41 );
42
43
46 const Mesh & mesh,
47 size_t n_local_vertex_dofs,
48 size_t n_local_edge_dofs,
49 size_t n_local_cell_dofs
50 );
51
52
53 //------------------------------------------------------------------------------
54 // Accessors
55 //------------------------------------------------------------------------------
56
58 const Mesh & mesh() const
59 {
60 return m_mesh;
61 }
62
64 inline size_t numLocalDofsVertex(const size_t iV) const
65 {
66 assert(iV<m_mesh.n_vertices());
67 return m_n_local_vertex_dofs[iV];
68 }
69
71 inline size_t numLocalDofsVertex(const Vertex & V) const
72 {
73 return numLocalDofsVertex(V.global_index());
74 }
75
77 inline size_t numLocalDofsEdge(const size_t iE) const
78 {
79 assert(iE<m_mesh.n_edges());
80 return m_n_local_edge_dofs[iE];
81 }
82
84 inline size_t numLocalDofsEdge(const Edge & E) const
85 {
86 return numLocalDofsEdge(E.global_index());
87 }
88
89
91 inline size_t numLocalDofsCell(const size_t iT) const
92 {
93 assert(iT<m_mesh.n_cells());
94 return m_n_local_cell_dofs[iT];
95 }
96
98 inline size_t numLocalDofsCell(const Cell & T) const
99 {
100 return numLocalDofsCell(T.global_index());
101 }
102
103 //------------------------------------------------------------------------------
104 // Dimensions
105 //------------------------------------------------------------------------------
106
108
110 inline size_t nDOFs_vertices() const
111 {
112 return m_n_local_vertex_dofs.sum();
113 }
114
116 inline size_t nDOFs_edges() const
117 {
118 return m_n_local_edge_dofs.sum();
119 }
120
121
123 inline size_t nDOFs_cells() const
124 {
125 return m_n_local_cell_dofs.sum();
126 }
127
129 inline size_t dimension() const
130 {
131 return nDOFs_vertices() + nDOFs_edges() + nDOFs_cells();
132 }
133
134 //--- Vertices -----//
136 inline size_t dimensionVertex(const Vertex & V) const
137 {
138 return m_n_local_vertex_dofs[V.global_index()];
139 }
140
142 inline size_t dimensionVertex(size_t iV) const
143 {
144 assert(iV<m_mesh.n_vertices());
145 return dimensionVertex(*m_mesh.vertex(iV));
146 }
147
148 //--- Edges ----//
150 inline size_t dimensionEdge(const Edge & E) const
151 {
152 return m_n_local_vertex_dofs[E.vertex(0)->global_index()] + m_n_local_vertex_dofs[E.vertex(1)->global_index()]
153 + m_n_local_edge_dofs[E.global_index()];
154 }
155
157 inline size_t dimensionEdge(size_t iE) const
158 {
159 assert(iE<m_mesh.n_edges());
160 return dimensionEdge(*m_mesh.edge(iE));
161 }
162
163 //--- Cell -----//
165 inline size_t dimensionCell(const Cell & T) const
166 {
167 size_t nb_dofs = 0;
168 for (Vertex * V : T.get_vertices()){
169 nb_dofs += m_n_local_vertex_dofs[V->global_index()];
170 }
171 for (Edge * E : T.get_edges()){
172 nb_dofs += m_n_local_edge_dofs[E->global_index()];
173 }
174 return nb_dofs + m_n_local_cell_dofs[T.global_index()];
175 }
176
178 inline size_t dimensionCell(size_t iT) const
179 {
180 return dimensionCell(*m_mesh.cell(iT));
181 }
182
183 //------------------------------------------------------------------------------
184 // Local offsets
185 //------------------------------------------------------------------------------
186
188 inline size_t localOffset(const Edge & E, const Vertex & V) const
189 {
190 size_t nb_dofs = 0;
191 for (int iV=0; iV<E.index_vertex(&V); iV++){
192 nb_dofs += m_n_local_vertex_dofs[E.vertex(iV)->global_index()];
193 }
194 return nb_dofs;
195 }
196
198 inline size_t localOffset(const Edge & E) const
199 {
200 return m_n_local_vertex_dofs[E.vertex(0)->global_index()] + m_n_local_vertex_dofs[E.vertex(1)->global_index()];
201 }
202
203
204
206 inline size_t localOffset(const Cell & T, const Vertex & V) const
207 {
208 size_t nb_dofs = 0;
209 for (int iV=0; iV<T.index_vertex(&V); iV++){
210 nb_dofs += m_n_local_vertex_dofs[T.vertex(iV)->global_index()];
211 }
212 return nb_dofs;
213 }
214
216 inline size_t localOffset(const Cell & T, const Edge & E) const
217 {
218 size_t nb_dofs = 0;
219 for (size_t iV=0; iV<T.n_vertices(); iV++){
220 nb_dofs += m_n_local_vertex_dofs[T.vertex(iV)->global_index()];
221 }
222 for (int iE=0; iE<T.index_edge(&E); iE++){
223 nb_dofs += m_n_local_edge_dofs[T.edge(iE)->global_index()];
224 }
225 return nb_dofs;
226 }
227
229 inline size_t localOffset(const Cell & T) const
230 {
231 size_t nb_dofs = 0;
232 for (size_t iV=0; iV<T.n_vertices(); iV++){
233 nb_dofs += m_n_local_vertex_dofs[T.vertex(iV)->global_index()];
234 }
235 for (size_t iE=0; iE<T.n_edges(); iE++){
236 nb_dofs += m_n_local_edge_dofs[T.edge(iE)->global_index()];
237 }
238 return nb_dofs;
239 }
240
241 //------------------------------------------------------------------------------
242 // Global offsets
243 //------------------------------------------------------------------------------
244
246 inline size_t globalOffset(const Vertex & V) const
247 {
248 return ( m_n_local_vertex_dofs.head(V.global_index()) ).sum();
249 }
250
252 inline size_t globalOffset(const Edge & E) const
253 {
254 return m_n_local_vertex_dofs.sum()
255 + ( m_n_local_edge_dofs.head(E.global_index()) ).sum();
256 }
257
258
260 inline size_t globalOffset(const Cell & T) const
261 {
262 return m_n_local_vertex_dofs.sum()
263 + m_n_local_edge_dofs.sum()
264 + ( m_n_local_cell_dofs.head(T.global_index()) ).sum();
265 }
266
267 //------------------------------------------------------------------------------
268 // Restrictions
269 //------------------------------------------------------------------------------
270
272 Eigen::VectorXd restrictEdge(size_t iE, const Eigen::VectorXd & vh) const;
273
274
276 Eigen::VectorXd restrictCell(size_t iT, const Eigen::VectorXd & vh) const;
277
279 inline Eigen::VectorXd restrict(const Edge & E, const Eigen::VectorXd vh) const
280 {
281 return restrictEdge(E.global_index(), vh);
282 }
283
284
286 inline Eigen::VectorXd restrict(const Cell & T, const Eigen::VectorXd vh) const
287 {
288 return restrictCell(T.global_index(), vh);
289 }
290
291 //------------------------------------------------------------------------------
292 // Extensions
293 //------------------------------------------------------------------------------
294
295
297 Eigen::MatrixXd extendOperator(const Cell & T, const Edge & E, const Eigen::MatrixXd & opE) const;
298
299 //------------------------------------------------------------------------------
300 // Global DOF indices for an element T
301 //------------------------------------------------------------------------------
302
304 std::vector<size_t> globalDOFIndices(const Cell & T) const;
306 std::vector<size_t> globalDOFIndices(const Edge & E) const;
307
308
309 private:
310 const Mesh & m_mesh;
311 Eigen::VectorXd m_n_local_vertex_dofs;
312 Eigen::VectorXd m_n_local_edge_dofs;
313 Eigen::VectorXd m_n_local_cell_dofs;
314
315
316 };
317
318} // namespace HArDCore2D
319
320#endif
Base class for global DOF spaces.
Definition variabledofspace.hpp:17
Definition Mesh2D.hpp:26
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:216
size_t dimensionEdge(const Edge &E) const
Returns the dimension of the local space on the edge E (including vertices)
Definition variabledofspace.hpp:150
size_t nDOFs_edges() const
Total number of edges DOFs.
Definition variabledofspace.hpp:116
Eigen::VectorXd restrict(const Edge &E, const Eigen::VectorXd vh) const
Restrict to an edge.
Definition variabledofspace.hpp:279
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:206
const Mesh & mesh() const
Returns the mesh.
Definition variabledofspace.hpp:58
size_t globalOffset(const Edge &E) const
Return the global offset for the unknowns on the edge E.
Definition variabledofspace.hpp:252
size_t dimensionVertex(const Vertex &V) const
Returns the dimension of the local space on the vertex V.
Definition variabledofspace.hpp:136
size_t numLocalDofsVertex(const Vertex &V) const
Returns the number of local DOFs on vertex V.
Definition variabledofspace.hpp:71
size_t dimension() const
Returns the dimension of the global space (all DOFs for all geometric entities)
Definition variabledofspace.hpp:129
size_t globalOffset(const Cell &T) const
Return the global offset for the unknowns on the cell T.
Definition variabledofspace.hpp:260
size_t numLocalDofsEdge(const size_t iE) const
Returns the number of local DOFs on edge of index iE.
Definition variabledofspace.hpp:77
size_t nDOFs_cells() const
Total number of cells DOFs.
Definition variabledofspace.hpp:123
size_t numLocalDofsEdge(const Edge &E) const
Returns the number of local DOFs on edge E.
Definition variabledofspace.hpp:84
size_t dimensionVertex(size_t iV) const
Returns the dimension of the local space on the vertex of index iV.
Definition variabledofspace.hpp:142
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:149
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:178
size_t numLocalDofsCell(const Cell &T) const
Returns the number of local DOFs on cell T.
Definition variabledofspace.hpp:98
size_t localOffset(const Edge &E) const
Returns the local offset of the unknowns attached to the edge E.
Definition variabledofspace.hpp:198
Eigen::MatrixXd extendOperator(const Cell &T, const Edge &E, const Eigen::MatrixXd &opE) const
Extend an edge operator to a cell.
Definition variabledofspace.cpp:126
Eigen::VectorXd restrictEdge(size_t iE, const Eigen::VectorXd &vh) const
Restrict to the edge (including its vertices) of index iE.
Definition variabledofspace.cpp:73
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:165
size_t numLocalDofsVertex(const size_t iV) const
Returns the number of local DOFs on vertex of index iV.
Definition variabledofspace.hpp:64
size_t nDOFs_vertices() const
Total number of vertices DOFs.
Definition variabledofspace.hpp:110
size_t globalOffset(const Vertex &V) const
Return the global offset for the unknowns on the vertex V.
Definition variabledofspace.hpp:246
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:188
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:95
size_t numLocalDofsCell(const size_t iT) const
Returns the number of local DOFs on cell of index iT.
Definition variabledofspace.hpp:91
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:157
size_t localOffset(const Cell &T) const
Returns the local offset of the unknowns attached to the element T.
Definition variabledofspace.hpp:229
Eigen::VectorXd restrict(const Cell &T, const Eigen::VectorXd vh) const
Restrict to a cell.
Definition variabledofspace.hpp:286
std::size_t n_vertices() const
number of vertices in the mesh.
Definition Mesh2D.hpp:60
Cell * cell(std::size_t index) const
get a constant pointer to a cell using its global index
Definition Mesh2D.hpp:178
Edge * edge(std::size_t index) const
get a constant pointer to a edge using its global index
Definition Mesh2D.hpp:168
std::size_t n_cells() const
number of cells in the mesh.
Definition Mesh2D.hpp:63
Vertex * vertex(std::size_t index) const
get a constant pointer to a vertex using its global index
Definition Mesh2D.hpp:163
std::size_t n_edges() const
number of edges in the mesh.
Definition Mesh2D.hpp:61
if(strcmp(field, 'real')) % real valued entries T
Definition mmread.m:93
Definition ddr-klplate.hpp:27