MFEM  v3.1
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
element.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_ELEMENT
13 #define MFEM_ELEMENT
14 
15 #include "../config/config.hpp"
16 #include "../general/array.hpp"
17 #include "../general/table.hpp"
18 #include "../linalg/densemat.hpp"
19 #include "../fem/geom.hpp"
20 
21 namespace mfem
22 {
23 
24 class Mesh;
25 
27 class Element
28 {
29 protected:
30 
33 
34 public:
35 
39  };
40 
42  explicit Element(int bg = Geometry::POINT) { attribute = -1; base_geom = bg; }
43 
45  virtual void SetVertices(const int *ind);
46 
48  virtual int GetType() const = 0;
49 
50  int GetGeometryType() const { return base_geom; }
51 
53  virtual void GetVertices(Array<int> &v) const = 0;
54 
55  virtual int *GetVertices() = 0;
56 
57  const int *GetVertices() const
58  { return const_cast<Element *>(this)->GetVertices(); }
59 
60  virtual int GetNVertices() const = 0;
61 
62  virtual int GetNEdges() const = 0;
63 
64  virtual const int *GetEdgeVertices(int) const = 0;
65 
66  virtual int GetNFaces(int &nFaceVertices) const = 0;
67 
68  virtual const int *GetFaceVertices(int fi) const = 0;
69 
71  virtual void MarkEdge(DenseMatrix &pmat) {}
72 
74  virtual void MarkEdge(const DSTable &v_to_v, const int *length) {}
75 
77  virtual int NeedRefinement(DSTable &v_to_v, int *middle) const { return 0; }
78 
80  inline int GetAttribute() const { return attribute; }
81 
83  inline void SetAttribute(const int attr) { attribute = attr; }
84 
85  virtual int GetRefinementFlag() { return 0; }
86 
87  virtual Element *Duplicate(Mesh *m) const = 0;
88 
90  virtual ~Element() { }
91 };
92 
93 class RefinedElement : public Element
94 {
95 public:
96 
97  enum { COARSE = 0, FINE = 1 };
98 
99  // The default value is set in the file 'point.cpp'
100  static int State;
101 
103 
105 
107  { attribute = ce->GetAttribute(); CoarseElem = ce; }
108  // Assumes that the coarse element and its first child have the
109  // same attribute and the same base geometry ...
110 
112  {
113  base_geom = ce->GetGeometryType();
114  attribute = ce->GetAttribute();
115  CoarseElem = ce;
116  }
117 
119  {
120  if (State == RefinedElement::COARSE) { return CoarseElem; }
121  return FirstChild;
122  }
123  const Element *IAm() const
124  {
125  if (State == RefinedElement::COARSE) { return CoarseElem; }
126  return FirstChild;
127  }
128 
129  virtual void SetVertices(const int *ind) { IAm()->SetVertices(ind); }
130 
131  virtual void GetVertices(Array<int> &v) const { IAm()->GetVertices(v); }
132 
133  virtual int *GetVertices() { return IAm()->GetVertices(); }
134 
135  virtual int GetNVertices() const { return IAm()->GetNVertices(); }
136 
137  virtual int GetNEdges() const { return (IAm()->GetNEdges()); }
138 
139  virtual const int *GetEdgeVertices(int ei) const
140  { return (IAm()->GetEdgeVertices(ei)); }
141 
142  virtual int GetNFaces(int &nFaceVertices) const
143  { return IAm()->GetNFaces(nFaceVertices); }
144 
145  virtual const int *GetFaceVertices(int fi) const
146  { return IAm()->GetFaceVertices(fi); }
147 
148  virtual void MarkEdge(DenseMatrix &pmat) { IAm()->MarkEdge(pmat); }
149 
150  virtual void MarkEdge(const DSTable &v_to_v, const int *length)
151  { IAm()->MarkEdge(v_to_v, length); }
152 
153  virtual int NeedRefinement(DSTable &v_to_v, int *middle) const
154  { return IAm()->NeedRefinement(v_to_v, middle); }
155 };
156 
158 {
159 public:
161 
164 
165  virtual int GetType() const { return Element::BISECTED; }
166 
167  virtual Element *Duplicate(Mesh *m) const
168  { mfem_error("BisectedElement::Duplicate()"); return NULL; }
169 };
170 
172 {
173 public:
175 
177 
178  virtual int GetType() const { return Element::QUADRISECTED; }
179 
180  virtual Element *Duplicate(Mesh *m) const
181  { mfem_error("QuadrisectedElement::Duplicate()"); return NULL; }
182 };
183 
185 {
186 public:
187  int Child[7];
188 
190 
191  virtual int GetType() const { return Element::OCTASECTED; }
192 
193  virtual Element *Duplicate(Mesh *m) const
194  { mfem_error("OctasectedElement::Duplicate()"); return NULL; }
195 };
196 
197 #ifdef MFEM_USE_MEMALLOC
198 // defined in tetrahedron.cpp
199 extern MemAlloc <BisectedElement, 1024> BEMemory;
200 #endif
201 
202 }
203 
204 #endif
virtual int GetNFaces(int &nFaceVertices) const
Definition: element.hpp:142
virtual int GetType() const
Returns element&#39;s type.
Definition: element.hpp:191
virtual int * GetVertices()=0
virtual int GetType() const
Returns element&#39;s type.
Definition: element.hpp:178
virtual Element * Duplicate(Mesh *m) const =0
virtual int GetNEdges() const =0
virtual void GetVertices(Array< int > &v) const =0
Returns element&#39;s vertices.
virtual int GetNEdges() const
Definition: element.hpp:137
OctasectedElement(Element *ce)
Definition: element.hpp:189
virtual void MarkEdge(DenseMatrix &pmat)
Mark the longest edge by assuming/changing the order of the vertices.
Definition: element.hpp:148
virtual void GetVertices(Array< int > &v) const
Returns element&#39;s vertices.
Definition: element.hpp:131
virtual Element * Duplicate(Mesh *m) const
Definition: element.hpp:193
virtual int GetNVertices() const
Definition: element.hpp:135
Data type dense matrix using column-major storage.
Definition: densemat.hpp:22
virtual void SetVertices(const int *ind)
Set the indices the element according to the input.
Definition: element.cpp:17
Element * IAm()
Definition: element.hpp:118
QuadrisectedElement(Element *ce)
Definition: element.hpp:176
virtual Element * Duplicate(Mesh *m) const
Definition: element.hpp:180
int GetGeometryType() const
Definition: element.hpp:50
virtual Element * Duplicate(Mesh *m) const
Definition: element.hpp:167
virtual const int * GetFaceVertices(int fi) const
Definition: element.hpp:145
Element * CoarseElem
Definition: element.hpp:102
virtual void MarkEdge(const DSTable &v_to_v, const int *length)
Mark the longest edge by assuming/changing the order of the vertices.
Definition: element.hpp:74
virtual const int * GetEdgeVertices(int) const =0
virtual int GetRefinementFlag()
Definition: element.hpp:85
Type
Constants for the classes derived from Element.
Definition: element.hpp:37
const Element * IAm() const
Definition: element.hpp:123
virtual void MarkEdge(const DSTable &v_to_v, const int *length)
Mark the longest edge by assuming/changing the order of the vertices.
Definition: element.hpp:150
virtual int NeedRefinement(DSTable &v_to_v, int *middle) const
Return 1 if the element needs refinement in order to get conforming mesh.
Definition: element.hpp:77
int GetAttribute() const
Return element&#39;s attribute.
Definition: element.hpp:80
virtual void SetVertices(const int *ind)
Set the indices the element according to the input.
Definition: element.hpp:129
Element * FirstChild
Definition: element.hpp:102
static int State
Definition: element.hpp:100
virtual void MarkEdge(DenseMatrix &pmat)
Mark the longest edge by assuming/changing the order of the vertices.
Definition: element.hpp:71
void SetCoarseElem(Element *ce)
Definition: element.hpp:111
MemAlloc< BisectedElement, 1024 > BEMemory
int attribute
Element&#39;s attribute (specifying material property, etc).
Definition: element.hpp:32
BisectedElement(Element *ce)
Definition: element.hpp:163
void mfem_error(const char *msg)
Definition: error.cpp:23
RefinedElement(Element *ce)
Definition: element.hpp:106
virtual int NeedRefinement(DSTable &v_to_v, int *middle) const
Return 1 if the element needs refinement in order to get conforming mesh.
Definition: element.hpp:153
Element(int bg=Geometry::POINT)
Default element constructor.
Definition: element.hpp:42
virtual int GetNFaces(int &nFaceVertices) const =0
const int * GetVertices() const
Definition: element.hpp:57
virtual ~Element()
Destroys element.
Definition: element.hpp:90
virtual int * GetVertices()
Definition: element.hpp:133
virtual int GetNVertices() const =0
void SetAttribute(const int attr)
Set element&#39;s attribute.
Definition: element.hpp:83
virtual const int * GetFaceVertices(int fi) const =0
virtual int GetType() const
Returns element&#39;s type.
Definition: element.hpp:165
virtual const int * GetEdgeVertices(int ei) const
Definition: element.hpp:139
Abstract data type element.
Definition: element.hpp:27
virtual int GetType() const =0
Returns element&#39;s type.