MFEM  v3.0
 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.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_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 
41  explicit Element(int bg = Geometry::POINT) { attribute = -1; base_geom = bg; }
42 
44  virtual void SetVertices(const int *ind);
45 
47  virtual int GetType() const = 0;
48 
49  int GetGeometryType() const { return base_geom; }
50 
52  virtual void GetVertices(Array<int> &v) const = 0;
53 
54  virtual int *GetVertices() = 0;
55 
56  const int *GetVertices() const
57  { return const_cast<Element *>(this)->GetVertices(); }
58 
59  virtual int GetNVertices() const = 0;
60 
61  virtual int GetNEdges() const = 0;
62 
63  virtual const int *GetEdgeVertices(int) const = 0;
64 
65  virtual int GetNFaces(int &nFaceVertices) const = 0;
66 
67  virtual const int *GetFaceVertices(int fi) const = 0;
68 
70  virtual void MarkEdge(DenseMatrix &pmat) {}
71 
73  virtual void MarkEdge(const DSTable &v_to_v, const int *length) {}
74 
76  virtual int NeedRefinement(DSTable &v_to_v, int *middle) const { return 0; }
77 
79  inline int GetAttribute() const { return attribute; }
80 
82  inline void SetAttribute(const int attr) { attribute = attr; }
83 
84  virtual int GetRefinementFlag() { return 0; }
85 
86  virtual Element *Duplicate(Mesh *m) const = 0;
87 
89  virtual ~Element() { }
90 };
91 
92 class RefinedElement : public Element
93 {
94 public:
95 
96  enum { COARSE = 0, FINE = 1 };
97 
98  // The default value is set in the file 'point.cpp'
99  static int State;
100 
102 
104 
106  { attribute = ce->GetAttribute(); CoarseElem = ce; }
107  // Assumes that the coarse element and its first child have the
108  // same attribute and the same base geometry ...
109 
111  {
112  base_geom = ce->GetGeometryType();
113  attribute = ce->GetAttribute();
114  CoarseElem = ce;
115  }
116 
118  {
119  if (State == RefinedElement::COARSE) return CoarseElem;
120  return FirstChild;
121  }
122  const Element *IAm() const
123  {
124  if (State == RefinedElement::COARSE) return CoarseElem;
125  return FirstChild;
126  }
127 
128  virtual void SetVertices(const int *ind) { IAm()->SetVertices(ind); }
129 
130  virtual void GetVertices(Array<int> &v) const { IAm()->GetVertices(v); }
131 
132  virtual int *GetVertices() { return IAm()->GetVertices(); }
133 
134  virtual int GetNVertices() const { return IAm()->GetNVertices(); }
135 
136  virtual int GetNEdges() const { return(IAm()->GetNEdges()); }
137 
138  virtual const int *GetEdgeVertices(int ei) const
139  { return(IAm()->GetEdgeVertices(ei)); }
140 
141  virtual int GetNFaces(int &nFaceVertices) const
142  { return IAm()->GetNFaces(nFaceVertices); }
143 
144  virtual const int *GetFaceVertices(int fi) const
145  { return IAm()->GetFaceVertices(fi); };
146 
147  virtual void MarkEdge(DenseMatrix &pmat) { IAm()->MarkEdge(pmat); }
148 
149  virtual void MarkEdge(const DSTable &v_to_v, const int *length)
150  { IAm()->MarkEdge(v_to_v, length); }
151 
152  virtual int NeedRefinement(DSTable &v_to_v, int *middle) const
153  { return IAm()->NeedRefinement(v_to_v, middle); }
154 };
155 
157 {
158 public:
160 
163 
164  virtual int GetType() const { return Element::BISECTED; }
165 
166  virtual Element *Duplicate(Mesh *m) const
167  { mfem_error("BisectedElement::Duplicate()"); return NULL; }
168 };
169 
171 {
172 public:
174 
176 
177  virtual int GetType() const { return Element::QUADRISECTED; }
178 
179  virtual Element *Duplicate(Mesh *m) const
180  { mfem_error("QuadrisectedElement::Duplicate()"); return NULL; }
181 };
182 
184 {
185 public:
186  int Child[7];
187 
189 
190  virtual int GetType() const { return Element::OCTASECTED; }
191 
192  virtual Element *Duplicate(Mesh *m) const
193  { mfem_error("OctasectedElement::Duplicate()"); return NULL; }
194 };
195 
196 #ifdef MFEM_USE_MEMALLOC
197 // defined in tetrahedron.cpp
198 extern MemAlloc <BisectedElement, 1024> BEMemory;
199 #endif
200 
201 }
202 
203 #endif
virtual int GetNFaces(int &nFaceVertices) const
Definition: element.hpp:141
virtual int GetType() const
Returns element&#39;s type.
Definition: element.hpp:190
virtual int * GetVertices()=0
virtual int GetType() const
Returns element&#39;s type.
Definition: element.hpp:177
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:136
OctasectedElement(Element *ce)
Definition: element.hpp:188
virtual void MarkEdge(DenseMatrix &pmat)
Mark the longest edge by assuming/changing the order of the vertices.
Definition: element.hpp:147
virtual void GetVertices(Array< int > &v) const
Returns element&#39;s vertices.
Definition: element.hpp:130
virtual Element * Duplicate(Mesh *m) const
Definition: element.hpp:192
virtual int GetNVertices() const
Definition: element.hpp:134
Data type dense matrix.
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:117
QuadrisectedElement(Element *ce)
Definition: element.hpp:175
virtual Element * Duplicate(Mesh *m) const
Definition: element.hpp:179
int GetGeometryType() const
Definition: element.hpp:49
virtual Element * Duplicate(Mesh *m) const
Definition: element.hpp:166
virtual const int * GetFaceVertices(int fi) const
Definition: element.hpp:144
Element * CoarseElem
Definition: element.hpp:101
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:73
virtual const int * GetEdgeVertices(int) const =0
virtual int GetRefinementFlag()
Definition: element.hpp:84
Type
Constants for the classes derived from Element.
Definition: element.hpp:37
const Element * IAm() const
Definition: element.hpp:122
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:149
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:76
int GetAttribute() const
Return element&#39;s attribute.
Definition: element.hpp:79
virtual void SetVertices(const int *ind)
Set the indices the element according to the input.
Definition: element.hpp:128
Element * FirstChild
Definition: element.hpp:101
static int State
Definition: element.hpp:99
virtual void MarkEdge(DenseMatrix &pmat)
Mark the longest edge by assuming/changing the order of the vertices.
Definition: element.hpp:70
void SetCoarseElem(Element *ce)
Definition: element.hpp:110
MemAlloc< BisectedElement, 1024 > BEMemory
int attribute
Element&#39;s attribute (specifying material property, etc).
Definition: element.hpp:32
BisectedElement(Element *ce)
Definition: element.hpp:162
void mfem_error(const char *msg)
Definition: error.cpp:23
RefinedElement(Element *ce)
Definition: element.hpp:105
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:152
Element(int bg=Geometry::POINT)
Default element constructor.
Definition: element.hpp:41
virtual int GetNFaces(int &nFaceVertices) const =0
const int * GetVertices() const
Definition: element.hpp:56
virtual ~Element()
Destroys element.
Definition: element.hpp:89
virtual int * GetVertices()
Definition: element.hpp:132
virtual int GetNVertices() const =0
void SetAttribute(const int attr)
Set element&#39;s attribute.
Definition: element.hpp:82
virtual const int * GetFaceVertices(int fi) const =0
virtual int GetType() const
Returns element&#39;s type.
Definition: element.hpp:164
virtual const int * GetEdgeVertices(int ei) const
Definition: element.hpp:138
Abstract data type element.
Definition: element.hpp:27
virtual int GetType() const =0
Returns element&#39;s type.