MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
tetrahedron.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, 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
18namespace mfem
19{
20
21/// Data type tetrahedron element
22class Tetrahedron : public Element
23{
24protected:
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
39public:
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
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 Type GetType() const override { return Element::TETRAHEDRON; }
60
61 void ParseRefinementFlag(int refinement_edges[2], int &type,
62 int &flag) const;
63 void CreateRefinementFlag(int refinement_edges[2], int type, int flag = 0);
64
65 void GetMarkedFace(const int face, int *fv) const;
66
67 int GetRefinementFlag() const { return refinement_flag; }
68
69 void SetRefinementFlag(int rf) { refinement_flag = rf; }
70
71 /// Return 1 if the element needs refinement in order to get conforming mesh.
72 int NeedRefinement(HashTable<Hashed2> &v_to_v) const override;
73
74 /** Reorder the vertices so that the longest edge is from vertex 0
75 to vertex 1. If called it should be once from the mesh constructor,
76 because the order may be used later for setting the edges. **/
77 void MarkEdge(const DSTable &v_to_v, const int *length) override;
78
79 void ResetTransform(int tr) override { transform = tr; }
80 unsigned GetTransform() const override { return transform; }
81
82 /// Add 'tr' to the current chain of coarse-fine transformations.
83 void PushTransform(int tr) override
84 { transform = (transform << 3) | (tr + 1); }
85
86 /// Calculate point matrix corresponding to a chain of transformations.
87 static void GetPointMatrix(unsigned transform, DenseMatrix &pm);
88
89 /// Get the indices defining the vertices.
90 void GetVertices(Array<int> &v) const override;
91
92 /// Set the indices defining the vertices.
93 void SetVertices(const Array<int> &v) override;
94
95 /// @note The returned array should NOT be deleted by the caller.
96 int * GetVertices () override { return indices; }
97
98 /// Set the indices defining the vertices.
99 void SetVertices(const int *ind) override;
100
101 int GetNVertices() const override { return 4; }
102
103 int GetNEdges() const override { return (6); }
104
105 const int *GetEdgeVertices(int ei) const override
106 { return geom_t::Edges[ei]; }
107
108 /// @deprecated Use GetNFaces(void) and GetNFaceVertices(int) instead.
109 MFEM_DEPRECATED int GetNFaces(int &nFaceVertices) const override
110 { nFaceVertices = 3; return 4; }
111
112 int GetNFaces() const override { return 4; }
113
114 int GetNFaceVertices(int) const override { return 3; }
115
116 const int *GetFaceVertices(int fi) const override
117 { return geom_t::FaceVert[fi]; }
118
119 Element *Duplicate(Mesh *m) const override;
120
121 virtual ~Tetrahedron() = default;
122};
123
124// Defined in fe.cpp to ensure construction before 'mfem::Geometries'.
125extern MFEM_EXPORT class Linear3DFiniteElement TetrahedronFE;
126
127}
128
129#endif
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
Abstract data type element.
Definition element.hpp:29
Type
Constants for the classes derived from Element.
Definition element.hpp:41
A 3D linear element on a tetrahedron with nodes at the vertices of the tetrahedron.
Mesh data type.
Definition mesh.hpp:56
Data type tetrahedron element.
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.
int GetNEdges() const override
int GetNVertices() const override
void PushTransform(int tr) override
Add 'tr' to the current chain of coarse-fine transformations.
MFEM_DEPRECATED int GetNFaces(int &nFaceVertices) const override
Geometry::Constants< Geometry::TETRAHEDRON > geom_t
const int * GetEdgeVertices(int ei) const override
int NeedRefinement(HashTable< Hashed2 > &v_to_v) const override
Return 1 if the element needs refinement in order to get conforming mesh.
void ParseRefinementFlag(int refinement_edges[2], int &type, int &flag) const
int GetNFaceVertices(int) const override
int * GetVertices() override
Element * Duplicate(Mesh *m) const override
void SetRefinementFlag(int rf)
int GetRefinementFlag() const
virtual ~Tetrahedron()=default
void SetVertices(const Array< int > &v) override
Set the indices defining the vertices.
int GetNFaces() const override
const int * GetFaceVertices(int fi) const override
void ResetTransform(int tr) override
Set current coarse-fine transformation number.
unsigned GetTransform() const override
Return current coarse-fine transformation.
static void GetPointMatrix(unsigned transform, DenseMatrix &pm)
Calculate point matrix corresponding to a chain of transformations.
Type GetType() const override
Return element's type.
void MarkEdge(const DSTable &v_to_v, const int *length) override
void GetMarkedFace(const int face, int *fv) const
void CreateRefinementFlag(int refinement_edges[2], int type, int flag=0)
MFEM_EXPORT class Linear3DFiniteElement TetrahedronFE
Definition fe.cpp:36
static const int Edges[NumEdges][2]
Definition geom.hpp:225
static const int FaceVert[NumFaces][MaxFaceVert]
Definition geom.hpp:229