MFEM  v3.0
 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.googlecode.com.
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 public:
55  ~RefinementData() { delete fl_to_fc; delete I;}
56 };
57 
58 class NURBSExtension;
59 
62 {
63 protected:
66 
68  int vdim;
69 
71  int ndofs;
72 
76  int ordering;
77 
80  int *fdofs, *bdofs;
81 
84 
88 
90  int own_ext;
91 
92  // Matrix representing the prolongation from the global conforming dofs to
93  // a set of intermediate partially conforming dofs, e.g. the dofs associated
94  // with a "cut" space on a non-conforming mesh.
96  // Conforming restriction matrix such that cR.cP=I.
98 
99  void MarkDependency(const SparseMatrix *D, const Array<int> &row_marker,
100  Array<int> &col_marker);
101 
102  void UpdateNURBS();
103 
104  void Constructor();
105  void Destructor(); // does not destroy 'RefData'
106 
107  /* Create a FE space stealing all data (except RefData) from the
108  given FE space. This is used in SaveUpdate() */
110 
112  void ConstructRefinementData(int k, int cdofs, RefinementType type);
113 
115  DenseMatrix *LocalInterpolation(int k, int cdofs,
116  RefinementType type,
117  Array<int> &rows);
118 
125  NCMesh* ncmesh);
126 
127 public:
129  int dim = 1, int order = Ordering::byNODES);
130 
132  inline Mesh *GetMesh() const { return mesh; }
133 
136 
138  const SparseMatrix *GetConformingProlongation() const { return cP; }
140  const SparseMatrix *GetConformingRestriction() const { return cR; }
141 
143  inline int GetVDim() const { return vdim; }
144 
146  int GetOrder(int i) const;
147 
149  inline int GetNDofs() const { return ndofs; }
150 
151  inline int GetVSize() const { return vdim * ndofs; }
152 
155  inline int GetNConformingDofs() const { return cP ? cP->Width() : ndofs; }
156 
157  inline int GetConformingVSize() const { return vdim * GetNConformingDofs(); }
158 
160  inline int GetOrdering() const { return ordering; }
161 
162  const FiniteElementCollection *FEColl() const { return fec; }
163 
164  int GetNVDofs() const { return nvdofs; }
165  int GetNEDofs() const { return nedofs; }
166  int GetNFDofs() const { return nfdofs; }
167 
169  inline int GetNE() const { return mesh->GetNE(); }
170 
172  inline int GetNV() const { return mesh->GetNV(); }
173 
175  inline int GetNBE() const { return mesh->GetNBE(); }
176 
178  inline int GetElementType(int i) const
179  { return mesh->GetElementType(i); }
180 
182  inline void GetElementVertices(int i, Array<int> &vertices) const
183  { mesh->GetElementVertices(i, vertices); }
184 
186  inline int GetBdrElementType(int i) const
187  { return mesh->GetBdrElementType(i); }
188 
191  { return mesh->GetElementTransformation(i); }
192 
196  { mesh->GetElementTransformation(i, ElTr); }
197 
200  { return mesh->GetBdrElementTransformation(i); }
201 
202  int GetAttribute(int i) const { return mesh->GetAttribute(i); }
203 
204  int GetBdrAttribute(int i) const { return mesh->GetBdrAttribute(i); }
205 
207  virtual void GetElementDofs(int i, Array<int> &dofs) const;
208 
210  virtual void GetBdrElementDofs(int i, Array<int> &dofs) const;
211 
214  virtual void GetFaceDofs(int i, Array<int> &dofs) const;
215 
218  void GetEdgeDofs(int i, Array<int> &dofs) const;
219 
220  void GetVertexDofs(int i, Array<int> &dofs) const;
221 
222  void GetElementInteriorDofs(int i, Array<int> &dofs) const;
223 
224  void GetEdgeInteriorDofs(int i, Array<int> &dofs) const;
225 
226  void DofsToVDofs(Array<int> &dofs) const;
227 
228  void DofsToVDofs(int vd, Array<int> &dofs) const;
229 
230  int DofToVDof(int dof, int vd) const;
231 
232  int VDofToDof(int vdof) const
233  { return (ordering == Ordering::byNODES) ? (vdof%ndofs) : (vdof/vdim); }
234 
235  static void AdjustVDofs(Array<int> &vdofs);
236 
238  void GetElementVDofs(int i, Array<int> &dofs) const;
239 
241  void GetBdrElementVDofs(int i, Array<int> &dofs) const;
242 
244  void GetFaceVDofs(int iF, Array<int> &dofs) const;
245 
247  void GetEdgeVDofs(int iE, Array<int> &dofs) const;
248 
249  void GetElementInteriorVDofs(int i, Array<int> &vdofs) const;
250 
251  void GetEdgeInteriorVDofs(int i, Array<int> &vdofs) const;
252 
253  void BuildElementToDofTable();
254 
255  void BuildDofToArrays();
256 
257  const Table &GetElementToDofTable() const { return *elem_dof; }
258 
259  int GetElementForDof(int i) { return dof_elem_array[i]; }
260  int GetLocalDofForDof(int i) { return dof_ldof_array[i]; }
261 
263  const FiniteElement *GetFE(int i) const;
264 
266  const FiniteElement *GetBE(int i) const;
267 
268  const FiniteElement *GetFaceElement(int i) const;
269 
270  const FiniteElement *GetEdgeElement(int i) const;
271 
273  const FiniteElement *GetTraceElement(int i, int geom_type) const;
274 
284  int one_vdim = -1);
285 
287  virtual void GetEssentialVDofs(const Array<int> &bdr_attr_is_ess,
288  Array<int> &ess_dofs) const;
289 
296  {
297  MarkDependency(cP, dofs, cdofs);
298  }
299 
306  {
307  MarkDependency(cR, cdofs, dofs);
308  }
309 
311  Array<int> &bdr_attr_is_ess,
312  SparseMatrix *R);
313 
316  Array<int> &bdr_attr_is_ess,
317  int one_vdim = -1);
318 
322 
326 
331 
332  virtual void Update();
333 
338  virtual void UpdateAndInterpolate(int num_grid_fns, ...);
339 
342 
344  virtual FiniteElementSpace *SaveUpdate();
345 
346  void Save (std::ostream &out) const;
347 
348  virtual ~FiniteElementSpace();
349 };
350 
351 }
352 
353 #endif
~RefinementData()
Releases the allocated memory.
Definition: fespace.hpp:55
Abstract class for Finite Elements.
Definition: fe.hpp:42
const SparseMatrix * GetConformingRestriction() const
Definition: fespace.hpp:140
int GetVSize() const
Definition: fespace.hpp:151
int GetAttribute(int i) const
Definition: fespace.hpp:202
Array< RefinementData * > RefData
Collection of currently known refinement data.
Definition: fespace.hpp:83
int GetNDofs() const
Returns number of degrees of freedom.
Definition: fespace.hpp:149
int ndofs
Number of degrees of freedom. Number of unknowns are ndofs*vdim.
Definition: fespace.hpp:71
int GetBdrAttribute(int i) const
Return the attribute of boundary element i.
Definition: mesh.hpp:586
void GetElementInteriorVDofs(int i, Array< int > &vdofs) const
Definition: fespace.cpp:141
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:26
void GetElementVertices(int i, Array< int > &vertices) const
Returns the vertices of element i.
Definition: fespace.hpp:182
int GetNBE() const
Returns number of boundary elements.
Definition: mesh.hpp:399
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols.
Definition: operator.hpp:41
int VDofToDof(int vdof) const
Definition: fespace.hpp:232
int num_fine_elems
Number of the fine elements.
Definition: fespace.hpp:47
Data type dense matrix.
Definition: densemat.hpp:22
int vdim
Vector dimension (number of unknowns per degree of freedom).
Definition: fespace.hpp:68
int num_fine_dofs
Number of the fine dofs on the coarse element (fc)
Definition: fespace.hpp:49
SparseMatrix * GlobalRestrictionMatrix(FiniteElementSpace *cfes, int one_vdim=-1)
Definition: fespace.cpp:250
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:1024
int GetBdrAttribute(int i) const
Definition: fespace.hpp:204
int GetNE() const
Returns number of elements.
Definition: mesh.hpp:396
const SparseMatrix * GetConformingProlongation() const
Definition: fespace.hpp:138
int GetBdrElementType(int i) const
Returns the type of boundary element i.
Definition: fespace.hpp:186
void GetElementVertices(int i, Array< int > &dofs) const
Returns the indices of the dofs of element i.
Definition: mesh.hpp:443
int GetNV() const
Returns number of nodes in the mesh.
Definition: fespace.hpp:172
const FiniteElement * GetFaceElement(int i) const
Definition: fespace.cpp:998
int RefinementType
Type of refinement (int, a tree, etc.)
Definition: fespace.hpp:39
const FiniteElementCollection * fec
Definition: fespace.hpp:78
NURBSExtension * GetNURBSext()
Definition: fespace.hpp:134
int GetConformingVSize() const
Definition: fespace.hpp:157
DenseMatrix * LocalInterpolation(int k, int cdofs, RefinementType type, Array< int > &rows)
Generates the local interpolation matrix for coarse element k.
Definition: fespace.cpp:201
Array< int > dof_elem_array
Definition: fespace.hpp:87
virtual void GetFaceDofs(int i, Array< int > &dofs) const
Definition: fespace.cpp:888
ElementTransformation * GetBdrElementTransformation(int i)
Returns the transformation defining the i-th boundary element.
Definition: mesh.cpp:218
void ConvertFromConformingVDofs(const Array< int > &cdofs, Array< int > &dofs)
Definition: fespace.hpp:305
SparseMatrix * GetConformingProlongation()
Definition: fespace.hpp:137
int GetNE() const
Returns number of elements in the mesh.
Definition: fespace.hpp:169
void GetVertexDofs(int i, Array< int > &dofs) const
Definition: fespace.cpp:944
const FiniteElement * GetEdgeElement(int i) const
Definition: fespace.cpp:1019
int GetNBE() const
Returns number of boundary elements in the mesh.
Definition: fespace.hpp:175
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:51
Mesh * GetMesh() const
Returns the mesh.
Definition: fespace.hpp:132
SparseMatrix * cR
Definition: fespace.hpp:97
SparseMatrix * D2Const_GlobalRestrictionMatrix(FiniteElementSpace *cfes)
Definition: fespace.cpp:472
SparseMatrix * D2C_GlobalRestrictionMatrix(FiniteElementSpace *cfes)
Definition: fespace.cpp:444
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:739
NURBSExtension * StealNURBSext()
Definition: fespace.cpp:610
ElementTransformation * GetBdrElementTransformation(int i) const
Returns ElementTransformation for the i&#39;th boundary element.
Definition: fespace.hpp:199
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
Definition: fespace.hpp:195
Array< int > dof_ldof_array
Definition: fespace.hpp:87
int GetElementType(int i) const
Returns the type of element i.
Definition: mesh.cpp:3632
SparseMatrix * cP
Definition: fespace.hpp:95
FiniteElementSpace(FiniteElementSpace &)
Definition: fespace.cpp:534
int GetVDim() const
Returns vector dimension.
Definition: fespace.hpp:143
A class for non-conforming AMR on higher-order hexahedral, quadrilateral or triangular meshes...
Definition: ncmesh.hpp:65
void GetEdgeDofs(int i, Array< int > &dofs) const
Definition: fespace.cpp:925
void GetBdrElementVDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom for i&#39;th boundary element.
Definition: fespace.cpp:123
int GetBdrElementType(int i) const
Returns the type of boundary element i.
Definition: mesh.cpp:3647
void GetElementInteriorDofs(int i, Array< int > &dofs) const
Definition: fespace.cpp:954
int GetLocalDofForDof(int i)
Definition: fespace.hpp:260
int GetOrdering() const
Return the ordering method.
Definition: fespace.hpp:160
int GetElementForDof(int i)
Definition: fespace.hpp:259
ElementTransformation * GetElementTransformation(int i) const
Returns ElementTransformation for the i&#39;th element.
Definition: fespace.hpp:190
Data kept for every type of refinement.
Definition: fespace.hpp:42
virtual void Update()
Definition: fespace.cpp:1060
Abstract finite element space.
Definition: fespace.hpp:61
virtual ~FiniteElementSpace()
Definition: fespace.cpp:1030
SparseMatrix * NC_GlobalRestrictionMatrix(FiniteElementSpace *cfes, NCMesh *ncmesh)
Definition: fespace.cpp:292
SparseMatrix * H2L_GlobalRestrictionMatrix(FiniteElementSpace *lfes)
Definition: fespace.cpp:501
int GetOrder(int i) const
Returns the order of the i&#39;th finite element.
Definition: fespace.cpp:23
void GetElementVDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i&#39;th element.
Definition: fespace.cpp:117
virtual void GetEssentialVDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_dofs) const
Determine the boundary degrees of freedom.
Definition: fespace.cpp:362
void GetEdgeInteriorVDofs(int i, Array< int > &vdofs) const
Definition: fespace.cpp:148
void GetFaceVDofs(int iF, Array< int > &dofs) const
Returns indexes of degrees of freedom for i&#39;th face element (2D and 3D).
Definition: fespace.cpp:129
int GetElementType(int i) const
Returns the type of element i.
Definition: fespace.hpp:178
virtual void GetBdrElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom for i&#39;th boundary element.
Definition: fespace.cpp:825
int GetNV() const
Definition: mesh.hpp:393
int GetNVDofs() const
Definition: fespace.hpp:164
void ConvertToConformingVDofs(const Array< int > &dofs, Array< int > &cdofs)
Definition: fespace.hpp:295
Mesh * mesh
The mesh that FE space lives on.
Definition: fespace.hpp:65
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
Definition: mesh.cpp:157
virtual void UpdateAndInterpolate(int num_grid_fns,...)
Definition: fespace.cpp:1080
int GetNConformingDofs() const
Definition: fespace.hpp:155
void GetEdgeInteriorDofs(int i, Array< int > &dofs) const
Definition: fespace.cpp:966
RefinementType type
Refinement type.
Definition: fespace.hpp:45
void GetEdgeVDofs(int iE, Array< int > &dofs) const
Returns indexes of degrees of freedom for i&#39;th edge.
Definition: fespace.cpp:135
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i&#39;th element.
Definition: fespace.cpp:814
void ConstructRefinementData(int k, int cdofs, RefinementType type)
Constructs new refinement data using coarse element k as a template.
Definition: fespace.cpp:1117
int DofToVDof(int dof, int vd) const
Definition: fespace.cpp:88
void DofsToVDofs(Array< int > &dofs) const
Definition: fespace.cpp:29
const FiniteElementCollection * FEColl() const
Definition: fespace.hpp:162
const Table & GetElementToDofTable() const
Definition: fespace.hpp:257
SparseMatrix * GetConformingRestriction()
Definition: fespace.hpp:139
void EliminateEssentialBCFromGRM(FiniteElementSpace *cfes, Array< int > &bdr_attr_is_ess, SparseMatrix *R)
Definition: fespace.cpp:407
void MarkDependency(const SparseMatrix *D, const Array< int > &row_marker, Array< int > &col_marker)
Definition: fespace.cpp:383
const FiniteElement * GetBE(int i) const
Returns pointer to the FiniteElement for the i&#39;th boundary element.
Definition: fespace.cpp:976
NURBSExtension * NURBSext
Definition: fespace.hpp:89
void Save(std::ostream &out) const
Definition: fespace.cpp:1178
DenseMatrix * I
Local interpolation matrix.
Definition: fespace.hpp:53
virtual FiniteElementSpace * SaveUpdate()
Return a copy of the current FE space and update.
Definition: fespace.cpp:1073
int GetAttribute(int i) const
Return the attribute of element i.
Definition: mesh.hpp:583
int GetNFDofs() const
Definition: fespace.hpp:166
int GetNEDofs() const
Definition: fespace.hpp:165
static void AdjustVDofs(Array< int > &vdofs)
Definition: fespace.cpp:106
void UpdateAndInterpolate(GridFunction *gf)
A shortcut for passing only one GridFunction to UndateAndInterpolate.
Definition: fespace.hpp:341