MFEM  v4.6.0
Finite element discretization library
element.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
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 #include "../general/hash.hpp"
21 
22 namespace mfem
23 {
24 
25 class Mesh;
26 
27 /// Abstract data type element
28 class Element
29 {
30 protected:
31 
32  /// Element's attribute (specifying material property, etc).
33  int attribute;
34 
35  /// Element's type from the Finite Element's perspective
37 
38 public:
39 
40  /// Constants for the classes derived from Element.
43  };
44 
45  /// Default element constructor.
47  { attribute = 1; base_geom = bg; }
48 
49  /// Returns element's type
50  virtual Type GetType() const = 0;
51 
53 
54  /// Return element's attribute.
55  inline int GetAttribute() const { return attribute; }
56 
57  /// Set element's attribute.
58  inline void SetAttribute(const int attr) { attribute = attr; }
59 
60  /// Set the indices the element according to the input.
61  virtual void SetVertices(const int *ind);
62 
63  /// Returns element's vertices.
64  virtual void GetVertices(Array<int> &v) const = 0;
65 
66  /// @note The returned array should NOT be deleted by the caller.
67  virtual int *GetVertices() = 0;
68 
69  const int *GetVertices() const
70  { return const_cast<Element *>(this)->GetVertices(); }
71 
72  virtual int GetNVertices() const = 0;
73 
74  virtual int GetNEdges() const = 0;
75 
76  virtual const int *GetEdgeVertices(int) const = 0;
77 
78  /// @deprecated Use GetNFaces(void) and GetNFaceVertices(int) instead.
79  MFEM_DEPRECATED virtual int GetNFaces(int &nFaceVertices) const = 0;
80 
81  virtual int GetNFaces() const = 0;
82 
83  virtual int GetNFaceVertices(int fi) const = 0;
84 
85  virtual const int *GetFaceVertices(int fi) const = 0;
86 
87  /// Mark the longest edge by assuming/changing the order of the vertices.
88  virtual void MarkEdge(const DSTable &v_to_v, const int *length) {}
89 
90  /// Return 1 if the element needs refinement in order to get conforming mesh.
91  virtual int NeedRefinement(HashTable<Hashed2> &v_to_v) const { return 0; }
92 
93  /// Set current coarse-fine transformation number.
94  virtual void ResetTransform(int tr) {}
95 
96  /// Add 'tr' to the current chain of coarse-fine transformations.
97  virtual void PushTransform(int tr) {}
98 
99  /// Return current coarse-fine transformation.
100  virtual unsigned GetTransform() const { return 0; }
101 
102  /// @note The returned object should be deleted by the caller.
103  virtual Element *Duplicate(Mesh *m) const = 0;
104 
105  /// Destroys element.
106  virtual ~Element() { }
107 };
108 
109 }
110 
111 #endif
virtual int * GetVertices()=0
virtual Element * Duplicate(Mesh *m) const =0
virtual int GetNEdges() const =0
const int * GetVertices() const
Definition: element.hpp:69
int GetAttribute() const
Return element&#39;s attribute.
Definition: element.hpp:55
virtual void SetVertices(const int *ind)
Set the indices the element according to the input.
Definition: element.cpp:17
virtual void ResetTransform(int tr)
Set current coarse-fine transformation number.
Definition: element.hpp:94
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:88
virtual int GetNFaceVertices(int fi) const =0
Element(Geometry::Type bg=Geometry::POINT)
Default element constructor.
Definition: element.hpp:46
virtual const int * GetEdgeVertices(int) const =0
Geometry::Type base_geom
Element&#39;s type from the Finite Element&#39;s perspective.
Definition: element.hpp:36
Geometry::Type GetGeometryType() const
Definition: element.hpp:52
virtual int NeedRefinement(HashTable< Hashed2 > &v_to_v) const
Return 1 if the element needs refinement in order to get conforming mesh.
Definition: element.hpp:91
Type
Constants for the classes derived from Element.
Definition: element.hpp:41
virtual unsigned GetTransform() const
Return current coarse-fine transformation.
Definition: element.hpp:100
int attribute
Element&#39;s attribute (specifying material property, etc).
Definition: element.hpp:33
virtual ~Element()
Destroys element.
Definition: element.hpp:106
virtual int GetNVertices() const =0
void SetAttribute(const int attr)
Set element&#39;s attribute.
Definition: element.hpp:58
virtual const int * GetFaceVertices(int fi) const =0
virtual int GetNFaces() const =0
Abstract data type element.
Definition: element.hpp:28
virtual void PushTransform(int tr)
Add &#39;tr&#39; to the current chain of coarse-fine transformations.
Definition: element.hpp:97
virtual Type GetType() const =0
Returns element&#39;s type.