MFEM  v3.3.2
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
tetrahedron.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_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  /// Return element's type.
55  virtual int GetType() const { return Element::TETRAHEDRON; }
56 
57  void ParseRefinementFlag(int refinement_edges[2], int &type, int &flag);
58  void CreateRefinementFlag(int refinement_edges[2], int type, int flag = 0);
59 
60  void GetMarkedFace(const int face, int *fv);
61 
62  virtual int GetRefinementFlag() { return refinement_flag; }
63 
64  void SetRefinementFlag(int rf) { refinement_flag = rf; }
65 
66  /// Return 1 if the element needs refinement in order to get conforming mesh.
67  virtual int NeedRefinement(DSTable &v_to_v, int *middle) const;
68 
69  /// Set the vertices according to the given input.
70  virtual void SetVertices(const int *ind);
71 
72  /// Mark the longest edge by assuming/changing the order of the vertices.
73  virtual void MarkEdge(DenseMatrix &pmat) { }
74 
75  /** Reorder the vertices so that the longest edge is from vertex 0
76  to vertex 1. If called it should be once from the mesh constructor,
77  because the order may be used later for setting the edges. **/
78  virtual void MarkEdge(const DSTable &v_to_v, const int *length);
79 
80  virtual void ResetTransform(int tr) { transform = tr; }
81  virtual unsigned GetTransform() const { return transform; }
82 
83  /// Add 'tr' to the current chain of coarse-fine transformations.
84  virtual void PushTransform(int tr)
85  { transform = (transform << 3) | (tr + 1); }
86 
87  /// Calculate point matrix corresponding to a chain of transformations.
88  static void GetPointMatrix(unsigned transform, DenseMatrix &pm);
89 
90  /// Returns the indices of the element's vertices.
91  virtual void GetVertices(Array<int> &v) const;
92 
93  virtual int *GetVertices() { return indices; }
94 
95  virtual int GetNVertices() const { return 4; }
96 
97  virtual int GetNEdges() const { return (6); }
98 
99  virtual const int *GetEdgeVertices(int ei) const
100  { return geom_t::Edges[ei]; }
101 
102  virtual int GetNFaces(int &nFaceVertices) const
103  { nFaceVertices = 3; return 4; }
104 
105  virtual const int *GetFaceVertices(int fi) const
106  { MFEM_ABORT("not implemented"); return NULL; }
107 
108  virtual Element *Duplicate(Mesh *m) const;
109 
110  virtual ~Tetrahedron() { }
111 };
112 
113 extern Linear3DFiniteElement TetrahedronFE;
114 
115 }
116 
117 #endif
virtual int GetNFaces(int &nFaceVertices) const
virtual int GetNEdges() const
Definition: tetrahedron.hpp:97
virtual int GetType() const
Return element&#39;s type.
Definition: tetrahedron.hpp:55
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
virtual void SetVertices(const int *ind)
Set the vertices according to the given input.
virtual ~Tetrahedron()
virtual Element * Duplicate(Mesh *m) const
void CreateRefinementFlag(int refinement_edges[2], int type, int flag=0)
Definition: tetrahedron.cpp:59
virtual void ResetTransform(int tr)
Set current coarse-fine transformation number.
Definition: tetrahedron.hpp:80
static const int Edges[NumEdges][2]
Definition: geom.hpp:173
Geometry::Constants< Geometry::TETRAHEDRON > geom_t
Definition: tetrahedron.hpp:40
Data type tetrahedron element.
Definition: tetrahedron.hpp:22
virtual const int * GetFaceVertices(int fi) const
virtual unsigned GetTransform() const
Return current coarse-fine transformation.
Definition: tetrahedron.hpp:81
virtual void PushTransform(int tr)
Add &#39;tr&#39; to the current chain of coarse-fine transformations.
Definition: tetrahedron.hpp:84
virtual void MarkEdge(DenseMatrix &pmat)
Mark the longest edge by assuming/changing the order of the vertices.
Definition: tetrahedron.hpp:73
Linear3DFiniteElement TetrahedronFE
virtual int * GetVertices()
Definition: tetrahedron.hpp:93
virtual const int * GetEdgeVertices(int ei) const
Definition: tetrahedron.hpp:99
virtual int NeedRefinement(DSTable &v_to_v, int *middle) const
Return 1 if the element needs refinement in order to get conforming mesh.
static void GetPointMatrix(unsigned transform, DenseMatrix &pm)
Calculate point matrix corresponding to a chain of transformations.
virtual int GetNVertices() const
Definition: tetrahedron.hpp:95
void GetMarkedFace(const int face, int *fv)
void SetRefinementFlag(int rf)
Definition: tetrahedron.hpp:64
void ParseRefinementFlag(int refinement_edges[2], int &type, int &flag)
Definition: tetrahedron.cpp:43
virtual int GetRefinementFlag()
Definition: tetrahedron.hpp:62
Abstract data type element.
Definition: element.hpp:27