MFEM  v3.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
fespace.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
3 // reserved. See file COPYRIGHT for details.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability see http://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the GNU Lesser General Public License (as published by the Free
10 // Software Foundation) version 2.1 dated February 1999.
11 
12 #ifndef MFEM_FESPACE
13 #define MFEM_FESPACE
14 
15 #include "../config/config.hpp"
16 #include "../linalg/sparsemat.hpp"
17 #include "../mesh/mesh.hpp"
18 #include "fe_coll.hpp"
19 #include <iostream>
20 
21 namespace mfem
22 {
23 
24 /* Class FiniteElementSpace - responsible for providing FEM view of the mesh
25  (mainly managing the set of degrees of freedom). */
26 
29 class Ordering
30 {
31 public:
35  enum Type { byNODES, byVDIM };
36 };
37 
39 typedef int RefinementType;
40 
43 {
44 public:
56  ~RefinementData() { delete fl_to_fc; delete I;}
57 };
58 
59 class NURBSExtension;
60 
63 {
64 protected:
67 
69  int vdim;
70 
72  int ndofs;
73 
77  int ordering;
78 
81  int *fdofs, *bdofs;
82 
85 
89 
91  int own_ext;
92 
93  // Matrix representing the prolongation from the global conforming dofs to
94  // a set of intermediate partially conforming dofs, e.g. the dofs associated
95  // with a "cut" space on a non-conforming mesh.
97  // Conforming restriction matrix such that cR.cP=I.
99 
100  void UpdateNURBS();
101 
102  void Constructor();
103  void Destructor(); // does not destroy 'RefData'
104 
105  /* Create a FE space stealing all data (except RefData) from the
106  given FE space. This is used in SaveUpdate() */
108 
110  void ConstructRefinementData(int k, int cdofs, RefinementType type);
111 
113  DenseMatrix *LocalInterpolation(int k, int cdofs,
114  RefinementType type,
115  Array<int> &rows);
116 
123  NCMesh* ncmesh);
124 
128  void GetEdgeFaceDofs(int type, int index, Array<int> &dofs);
129 
132 
133  void MakeVDimMatrix(SparseMatrix &mat) const;
134 
135 public:
137  int vdim = 1, int ordering = Ordering::byNODES);
138 
140  inline Mesh *GetMesh() const { return mesh; }
141 
144 
145  bool Conforming() const { return mesh->ncmesh == NULL; }
146  bool Nonconforming() const { return mesh->ncmesh != NULL; }
147 
151  { return GetConformingRestriction(); }
152 
154  inline int GetVDim() const { return vdim; }
155 
157  int GetOrder(int i) const;
159  int GetFaceOrder(int i) const;
160 
162  inline int GetNDofs() const { return ndofs; }
163 
164  inline int GetVSize() const { return vdim * ndofs; }
165 
167  virtual int GetTrueVSize() { return GetConformingVSize(); }
168 
171  int GetNConformingDofs();
172 
174 
176  inline int GetOrdering() const { return ordering; }
177 
178  const FiniteElementCollection *FEColl() const { return fec; }
179 
180  int GetNVDofs() const { return nvdofs; }
181  int GetNEDofs() const { return nedofs; }
182  int GetNFDofs() const { return nfdofs; }
183 
185  inline int GetNE() const { return mesh->GetNE(); }
186 
188  inline int GetNV() const { return mesh->GetNV(); }
189 
191  inline int GetNBE() const { return mesh->GetNBE(); }
192 
194  inline int GetElementType(int i) const
195  { return mesh->GetElementType(i); }
196 
198  inline void GetElementVertices(int i, Array<int> &vertices) const
199  { mesh->GetElementVertices(i, vertices); }
200 
202  inline int GetBdrElementType(int i) const
203  { return mesh->GetBdrElementType(i); }
204 
207  { return mesh->GetElementTransformation(i); }
208 
212  { mesh->GetElementTransformation(i, ElTr); }
213 
216  { return mesh->GetBdrElementTransformation(i); }
217 
218  int GetAttribute(int i) const { return mesh->GetAttribute(i); }
219 
220  int GetBdrAttribute(int i) const { return mesh->GetBdrAttribute(i); }
221 
223  virtual void GetElementDofs(int i, Array<int> &dofs) const;
224 
226  virtual void GetBdrElementDofs(int i, Array<int> &dofs) const;
227 
230  virtual void GetFaceDofs(int i, Array<int> &dofs) const;
231 
234  void GetEdgeDofs(int i, Array<int> &dofs) const;
235 
236  void GetVertexDofs(int i, Array<int> &dofs) const;
237 
238  void GetElementInteriorDofs(int i, Array<int> &dofs) const;
239 
240  int GetNumElementInteriorDofs(int i) const
242 
243  void GetEdgeInteriorDofs(int i, Array<int> &dofs) const;
244 
245  void DofsToVDofs(Array<int> &dofs) const;
246 
247  void DofsToVDofs(int vd, Array<int> &dofs, int ndofs = -1) const;
248 
249  int DofToVDof(int dof, int vd, int ndofs = -1) const;
250 
251  int VDofToDof(int vdof) const
252  { return (ordering == Ordering::byNODES) ? (vdof%ndofs) : (vdof/vdim); }
253 
254  static void AdjustVDofs(Array<int> &vdofs);
255 
257  void GetElementVDofs(int i, Array<int> &vdofs) const;
258 
260  void GetBdrElementVDofs(int i, Array<int> &vdofs) const;
261 
263  void GetFaceVDofs(int i, Array<int> &vdofs) const;
264 
266  void GetEdgeVDofs(int i, Array<int> &vdofs) const;
267 
268  void GetVertexVDofs(int i, Array<int> &vdofs) const;
269 
270  void GetElementInteriorVDofs(int i, Array<int> &vdofs) const;
271 
272  void GetEdgeInteriorVDofs(int i, Array<int> &vdofs) const;
273 
274  void BuildElementToDofTable();
275 
276  void BuildDofToArrays();
277 
278  const Table &GetElementToDofTable() const { return *elem_dof; }
279  const Table &GetBdrElementToDofTable() const { return *bdrElem_dof; }
280 
281  int GetElementForDof(int i) { return dof_elem_array[i]; }
282  int GetLocalDofForDof(int i) { return dof_ldof_array[i]; }
283 
285  const FiniteElement *GetFE(int i) const;
286 
288  const FiniteElement *GetBE(int i) const;
289 
290  const FiniteElement *GetFaceElement(int i) const;
291 
292  const FiniteElement *GetEdgeElement(int i) const;
293 
295  const FiniteElement *GetTraceElement(int i, int geom_type) const;
296 
306  int one_vdim = -1);
307 
310  virtual void GetEssentialVDofs(const Array<int> &bdr_attr_is_ess,
311  Array<int> &ess_vdofs) const;
312 
315  virtual void GetEssentialTrueDofs(const Array<int> &bdr_attr_is_ess,
316  Array<int> &ess_tdof_list);
317 
319  static void MarkerToList(const Array<int> &marker, Array<int> &list);
323  static void ListToMarker(const Array<int> &list, int marker_size,
324  Array<int> &marker, int mark_val = -1);
325 
330  void ConvertToConformingVDofs(const Array<int> &dofs, Array<int> &cdofs);
331 
338  void ConvertFromConformingVDofs(const Array<int> &cdofs, Array<int> &dofs);
339 
341  Array<int> &bdr_attr_is_ess,
342  SparseMatrix *R);
343 
346  Array<int> &bdr_attr_is_ess,
347  int one_vdim = -1);
348 
352 
356 
361 
362  virtual void Update();
363 
368  virtual void UpdateAndInterpolate(int num_grid_fns, ...);
369 
372 
374  virtual FiniteElementSpace *SaveUpdate();
375 
376  void Save (std::ostream &out) const;
377 
378  virtual ~FiniteElementSpace();
379 };
380 
381 }
382 
383 #endif
~RefinementData()
Releases the allocated memory.
Definition: fespace.hpp:56
Abstract class for Finite Elements.
Definition: fe.hpp:44
int GetVSize() const
Definition: fespace.hpp:164
void GetVertexVDofs(int i, Array< int > &vdofs) const
Definition: fespace.cpp:185
int GetAttribute(int i) const
Definition: fespace.hpp:218
Array< RefinementData * > RefData
Collection of currently known refinement data.
Definition: fespace.hpp:84
int GetNDofs() const
Returns number of degrees of freedom.
Definition: fespace.hpp:162
int ndofs
Number of degrees of freedom. Number of unknowns are ndofs*vdim.
Definition: fespace.hpp:72
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
Definition: mesh.hpp:649
const Table & GetBdrElementToDofTable() const
Definition: fespace.hpp:279
void GetElementInteriorVDofs(int i, Array< int > &vdofs) const
Definition: fespace.cpp:191
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:27
int DofToVDof(int dof, int vd, int ndofs=-1) const
Definition: fespace.cpp:116
void GetElementVertices(int i, Array< int > &vertices) const
Returns the vertices of element i.
Definition: fespace.hpp:198
int GetNBE() const
Returns number of boundary elements.
Definition: mesh.hpp:457
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i&#39;th element.
Definition: fespace.cpp:161
virtual void GetEssentialVDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_vdofs) const
Definition: fespace.cpp:432
int VDofToDof(int vdof) const
Definition: fespace.hpp:251
int GetElementBaseGeometry(int i) const
Definition: mesh.hpp:494
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list)
Definition: fespace.cpp:469
int num_fine_elems
Number of the fine elements.
Definition: fespace.hpp:48
int GetFaceOrder(int i) const
Returns the order of the i&#39;th face finite element.
Definition: fespace.cpp:29
void GetEdgeFaceDofs(int type, int index, Array< int > &dofs)
Definition: fespace.cpp:720
Data type dense matrix using column-major storage.
Definition: densemat.hpp:22
int vdim
Vector dimension (number of unknowns per degree of freedom).
Definition: fespace.hpp:69
int num_fine_dofs
Number of the fine dofs on the coarse element (fc)
Definition: fespace.hpp:50
int GetNumElementInteriorDofs(int i) const
Definition: fespace.hpp:240
SparseMatrix * GlobalRestrictionMatrix(FiniteElementSpace *cfes, int one_vdim=-1)
Definition: fespace.cpp:302
const FiniteElement * GetTraceElement(int i, int geom_type) const
Return the trace element from element &#39;i&#39; to the given &#39;geom_type&#39;.
Definition: fespace.cpp:1473
int GetBdrAttribute(int i) const
Definition: fespace.hpp:220
int GetNE() const
Returns number of elements.
Definition: mesh.hpp:454
int GetBdrElementType(int i) const
Returns the type of boundary element i.
Definition: fespace.hpp:202
void GetElementVertices(int i, Array< int > &dofs) const
Returns the indices of the dofs of element i.
Definition: mesh.hpp:501
int GetNV() const
Returns number of nodes in the mesh.
Definition: fespace.hpp:188
const FiniteElement * GetFaceElement(int i) const
Definition: fespace.cpp:1445
void GetConformingInterpolation()
Definition: fespace.cpp:733
int RefinementType
Type of refinement (int, a tree, etc.)
Definition: fespace.hpp:39
const FiniteElementCollection * fec
Definition: fespace.hpp:79
NURBSExtension * GetNURBSext()
Definition: fespace.hpp:142
DenseMatrix * LocalInterpolation(int k, int cdofs, RefinementType type, Array< int > &rows)
Generates the local interpolation matrix for coarse element k.
Definition: fespace.cpp:250
Array< int > dof_elem_array
Definition: fespace.hpp:88
static void MarkerToList(const Array< int > &marker, Array< int > &list)
Convert a Boolean marker array to a list containing all marked indices.
Definition: fespace.cpp:487
virtual void GetFaceDofs(int i, Array< int > &dofs) const
Definition: fespace.cpp:1295
ElementTransformation * GetBdrElementTransformation(int i)
Returns the transformation defining the i-th boundary element.
Definition: mesh.cpp:246
void ConvertFromConformingVDofs(const Array< int > &cdofs, Array< int > &dofs)
Definition: fespace.cpp:523
int GetNE() const
Returns number of elements in the mesh.
Definition: fespace.hpp:185
void GetVertexDofs(int i, Array< int > &dofs) const
Definition: fespace.cpp:1383
const FiniteElement * GetEdgeElement(int i) const
Definition: fespace.cpp:1468
const SparseMatrix * GetConformingRestriction()
Definition: fespace.cpp:919
int GetNBE() const
Returns number of boundary elements in the mesh.
Definition: fespace.hpp:191
Data type sparse matrix.
Definition: sparsemat.hpp:38
Table * fl_to_fc
(local dofs of) fine element &lt;-&gt; fine dofs on the coarse element
Definition: fespace.hpp:52
Mesh * GetMesh() const
Returns the mesh.
Definition: fespace.hpp:140
SparseMatrix * cR
Definition: fespace.hpp:98
SparseMatrix * D2Const_GlobalRestrictionMatrix(FiniteElementSpace *cfes)
Definition: fespace.cpp:615
SparseMatrix * D2C_GlobalRestrictionMatrix(FiniteElementSpace *cfes)
Definition: fespace.cpp:583
virtual void GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i&#39;th element.
Definition: fespace.cpp:1100
NURBSExtension * StealNURBSext()
Definition: fespace.cpp:1008
ElementTransformation * GetBdrElementTransformation(int i) const
Returns ElementTransformation for the i&#39;th boundary element.
Definition: fespace.hpp:215
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
Definition: fespace.hpp:211
Array< int > dof_ldof_array
Definition: fespace.hpp:88
int GetElementType(int i) const
Returns the type of element i.
Definition: mesh.cpp:4382
const SparseMatrix * GetConformingProlongation()
Definition: fespace.cpp:912
bool Conforming() const
Definition: fespace.hpp:145
SparseMatrix * cP
Definition: fespace.hpp:96
FiniteElementSpace(FiniteElementSpace &)
Definition: fespace.cpp:932
int GetVDim() const
Returns vector dimension.
Definition: fespace.hpp:154
A class for non-conforming AMR on higher-order hexahedral, quadrilateral or triangular meshes...
Definition: ncmesh.hpp:63
virtual const SparseMatrix * GetRestrictionMatrix()
Definition: fespace.hpp:150
void GetEdgeDofs(int i, Array< int > &dofs) const
Definition: fespace.cpp:1354
int GetBdrElementType(int i) const
Returns the type of boundary element i.
Definition: mesh.cpp:4401
void GetElementInteriorDofs(int i, Array< int > &dofs) const
Definition: fespace.cpp:1395
int GetLocalDofForDof(int i)
Definition: fespace.hpp:282
int GetOrdering() const
Return the ordering method.
Definition: fespace.hpp:176
int GetElementForDof(int i)
Definition: fespace.hpp:281
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i&#39;th element.
Definition: fespace.hpp:206
Data kept for every type of refinement.
Definition: fespace.hpp:42
virtual void Update()
Definition: fespace.cpp:1511
Abstract finite element space.
Definition: fespace.hpp:62
virtual ~FiniteElementSpace()
Definition: fespace.cpp:1479
SparseMatrix * NC_GlobalRestrictionMatrix(FiniteElementSpace *cfes, NCMesh *ncmesh)
Definition: fespace.cpp:346
SparseMatrix * H2L_GlobalRestrictionMatrix(FiniteElementSpace *lfes)
Definition: fespace.cpp:646
int GetOrder(int i) const
Returns the order of the i&#39;th finite element.
Definition: fespace.cpp:23
void MakeVDimMatrix(SparseMatrix &mat) const
Definition: fespace.cpp:885
void GetEdgeInteriorVDofs(int i, Array< int > &vdofs) const
Definition: fespace.cpp:197
int GetElementType(int i) const
Returns the type of element i.
Definition: fespace.hpp:194
bool Nonconforming() const
Definition: fespace.hpp:146
virtual void GetBdrElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom for i&#39;th boundary element.
Definition: fespace.cpp:1212
int GetNV() const
Definition: mesh.hpp:451
int GetNVDofs() const
Definition: fespace.hpp:180
void ConvertToConformingVDofs(const Array< int > &dofs, Array< int > &cdofs)
Definition: fespace.cpp:515
virtual int GetTrueVSize()
Return the number of vector true (conforming) dofs.
Definition: fespace.hpp:167
Mesh * mesh
The mesh that FE space lives on.
Definition: fespace.hpp:66
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
Definition: mesh.cpp:173
virtual void UpdateAndInterpolate(int num_grid_fns,...)
Definition: fespace.cpp:1531
void GetEdgeInteriorDofs(int i, Array< int > &dofs) const
Definition: fespace.cpp:1407
RefinementType type
Refinement type.
Definition: fespace.hpp:46
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i&#39;th element.
Definition: fespace.cpp:1199
NCMesh * ncmesh
Definition: mesh.hpp:143
void GetFaceVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i&#39;th face element (2D and 3D).
Definition: fespace.cpp:173
void GetEdgeVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i&#39;th edge.
Definition: fespace.cpp:179
static void ListToMarker(const Array< int > &list, int marker_size, Array< int > &marker, int mark_val=-1)
Definition: fespace.cpp:504
void ConstructRefinementData(int k, int cdofs, RefinementType type)
Constructs new refinement data using coarse element k as a template.
Definition: fespace.cpp:1568
void DofsToVDofs(Array< int > &dofs) const
Definition: fespace.cpp:35
const FiniteElementCollection * FEColl() const
Definition: fespace.hpp:178
const Table & GetElementToDofTable() const
Definition: fespace.hpp:278
void EliminateEssentialBCFromGRM(FiniteElementSpace *cfes, Array< int > &bdr_attr_is_ess, SparseMatrix *R)
Definition: fespace.cpp:532
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement for the i&#39;th boundary element.
Definition: fespace.cpp:1419
NURBSExtension * NURBSext
Definition: fespace.hpp:90
void GetBdrElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom for i&#39;th boundary element.
Definition: fespace.cpp:167
virtual int DofForGeometry(int GeomType) const =0
void Save(std::ostream &out) const
Definition: fespace.cpp:1635
DenseMatrix * I
Local interpolation matrix.
Definition: fespace.hpp:54
virtual FiniteElementSpace * SaveUpdate()
Return a copy of the current FE space and update.
Definition: fespace.cpp:1524
int GetAttribute(int i) const
Return the attribute of element i.
Definition: mesh.hpp:646
int GetNFDofs() const
Definition: fespace.hpp:182
int GetNEDofs() const
Definition: fespace.hpp:181
static void AdjustVDofs(Array< int > &vdofs)
Definition: fespace.cpp:148
void UpdateAndInterpolate(GridFunction *gf)
A shortcut for passing only one GridFunction to UndateAndInterpolate.
Definition: fespace.hpp:371