MFEM  v4.6.0
Finite element discretization library
tetrahedron.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_TETRAHEDRON
13 #define MFEM_TETRAHEDRON
14 
15 #include "../config/config.hpp"
16 #include "element.hpp"
17 
18 namespace mfem
19 {
20 
21 /// Data type tetrahedron element
22 class Tetrahedron : public Element
23 {
24 protected:
25  int indices[4];
26 
27  /** The refinement flag keeps (in order) :
28  1. Two marked edges given with local index (0..5) for the two faces
29  that don't have the refinement edge as edge. The refinement edge
30  is determined by the first two nodes of the tetrahedron. Each
31  marked edge is stored in 3 bits (or as implemented in the functions
32  CreateRefinementFlag and ParseRefinementFlag.
33  2. Type of the element, stored in the next 3 bits.
34  3. The rest is free for now. **/
36 
37  unsigned transform;
38 
39 public:
41 
42  /// Constants for different types of tetrahedrons.
43  enum { TYPE_PU=0, TYPE_A=1, TYPE_PF=2, TYPE_O=3, TYPE_M=4 };
44 
46  { refinement_flag = 0; transform = 0; }
47 
48  /// Constructs tetrahedron by specifying the indices and the attribute.
49  Tetrahedron(const int *ind, int attr = 1);
50 
51  /// Constructs tetrahedron by specifying the indices and the attribute.
52  Tetrahedron(int ind1, int ind2, int ind3, int ind4, int attr = 1);
53 
54  /// Initialize the vertex indices and the attribute of a Tetrahedron.
55  void Init(int ind1, int ind2, int ind3, int ind4, int attr = 1,
56  int ref_flag = 0);
57 
58  /// Return element's type.
59  virtual Type GetType() const { return Element::TETRAHEDRON; }
60 
61  void ParseRefinementFlag(int refinement_edges[2], int &type, int &flag);
62  void CreateRefinementFlag(int refinement_edges[2], int type, int flag = 0);
63 
64  void GetMarkedFace(const int face, int *fv);
65 
67 
68  void SetRefinementFlag(int rf) { refinement_flag = rf; }
69 
70  /// Return 1 if the element needs refinement in order to get conforming mesh.
71  virtual int NeedRefinement(HashTable<Hashed2> &v_to_v) const;
72 
73  /// Set the vertices according to the given input.
74  virtual void SetVertices(const int *ind);
75 
76  /** Reorder the vertices so that the longest edge is from vertex 0
77  to vertex 1. If called it should be once from the mesh constructor,
78  because the order may be used later for setting the edges. **/
79  virtual void MarkEdge(const DSTable &v_to_v, const int *length);
80 
81  virtual void ResetTransform(int tr) { transform = tr; }
82  virtual unsigned GetTransform() const { return transform; }
83 
84  /// Add 'tr' to the current chain of coarse-fine transformations.
85  virtual void PushTransform(int tr)
86  { transform = (transform << 3) | (tr + 1); }
87 
88  /// Calculate point matrix corresponding to a chain of transformations.
89  static void GetPointMatrix(unsigned transform, DenseMatrix &pm);
90 
91  /// Returns the indices of the element's vertices.
92  virtual void GetVertices(Array<int> &v) const;
93 
94  virtual int *GetVertices() { return indices; }
95 
96  virtual int GetNVertices() const { return 4; }
97 
98  virtual int GetNEdges() const { return (6); }
99 
100  virtual const int *GetEdgeVertices(int ei) const
101  { return geom_t::Edges[ei]; }
102 
103  /// @deprecated Use GetNFaces(void) and GetNFaceVertices(int) instead.
104  MFEM_DEPRECATED virtual int GetNFaces(int &nFaceVertices) const
105  { nFaceVertices = 3; return 4; }
106 
107  virtual int GetNFaces() const { return 4; }
108 
109  virtual int GetNFaceVertices(int) const { return 3; }
110 
111  virtual const int *GetFaceVertices(int fi) const
112  { return geom_t::FaceVert[fi]; }
113 
114  virtual Element *Duplicate(Mesh *m) const;
115 
116  virtual ~Tetrahedron() { }
117 };
118 
119 // Defined in fe.cpp to ensure construction before 'mfem::Geometries'.
120 extern MFEM_EXPORT class Linear3DFiniteElement TetrahedronFE;
121 
122 }
123 
124 #endif
virtual Element * Duplicate(Mesh *m) const
void Init(int ind1, int ind2, int ind3, int ind4, int attr=1, int ref_flag=0)
Initialize the vertex indices and the attribute of a Tetrahedron.
Definition: tetrahedron.cpp:43
virtual int GetNFaces() const
virtual int GetNFaceVertices(int) const
virtual unsigned GetTransform() const
Return current coarse-fine transformation.
Definition: tetrahedron.hpp:82
static const int FaceVert[NumFaces][MaxFaceVert]
Definition: geom.hpp:226
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
virtual int GetNVertices() const
Definition: tetrahedron.hpp:96
virtual void SetVertices(const int *ind)
Set the vertices according to the given input.
virtual ~Tetrahedron()
void CreateRefinementFlag(int refinement_edges[2], int type, int flag=0)
Definition: tetrahedron.cpp:71
virtual Type GetType() const
Return element&#39;s type.
Definition: tetrahedron.hpp:59
Type
Constants for the classes derived from Element.
Definition: element.hpp:41
virtual void ResetTransform(int tr)
Set current coarse-fine transformation number.
Definition: tetrahedron.hpp:81
static const int Edges[NumEdges][2]
Definition: geom.hpp:222
Geometry::Constants< Geometry::TETRAHEDRON > geom_t
Definition: tetrahedron.hpp:40
Data type tetrahedron element.
Definition: tetrahedron.hpp:22
virtual void PushTransform(int tr)
Add &#39;tr&#39; to the current chain of coarse-fine transformations.
Definition: tetrahedron.hpp:85
virtual const int * GetEdgeVertices(int ei) const
virtual int GetNEdges() const
Definition: tetrahedron.hpp:98
MFEM_EXPORT class Linear3DFiniteElement TetrahedronFE
Definition: fe.cpp:36
virtual int * GetVertices()
Definition: tetrahedron.hpp:94
static void GetPointMatrix(unsigned transform, DenseMatrix &pm)
Calculate point matrix corresponding to a chain of transformations.
virtual int NeedRefinement(HashTable< Hashed2 > &v_to_v) const
Return 1 if the element needs refinement in order to get conforming mesh.
void GetMarkedFace(const int face, int *fv)
void SetRefinementFlag(int rf)
Definition: tetrahedron.hpp:68
void ParseRefinementFlag(int refinement_edges[2], int &type, int &flag)
Definition: tetrahedron.cpp:55
virtual const int * GetFaceVertices(int fi) const
virtual void MarkEdge(const DSTable &v_to_v, const int *length)
Abstract data type element.
Definition: element.hpp:28
virtual MFEM_DEPRECATED int GetNFaces(int &nFaceVertices) const