MFEM  v4.3.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
triangle.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2021, 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_TRIANGLE
13 #define MFEM_TRIANGLE
14 
15 #include "../config/config.hpp"
16 #include "../fem/fe.hpp"
17 #include "element.hpp"
18 
19 namespace mfem
20 {
21 
22 /// Data type triangle element
23 class Triangle : public Element
24 {
25 protected:
26  int indices[3];
27 
28  unsigned transform;
29 
30 public:
32 
34 
35  /// Constructs triangle by specifying the indices and the attribute.
36  Triangle(const int *ind, int attr = 1);
37 
38  /// Constructs triangle by specifying the indices and the attribute.
39  Triangle(int ind1, int ind2, int ind3, int attr = 1);
40 
41  /// Return element's type.
42  virtual Type GetType() const { return Element::TRIANGLE; }
43 
44  /// Return 1 if the element needs refinement in order to get conforming mesh.
45  virtual int NeedRefinement(HashTable<Hashed2> &v_to_v) const;
46 
47  /// Set the vertices according to the given input.
48  virtual void SetVertices(const int *ind);
49 
50  /** Reorder the vertices so that the longest edge is from vertex 0
51  to vertex 1. If called it should be once from the mesh constructor,
52  because the order may be used later for setting the edges. **/
53  void MarkEdge(DenseMatrix & pmat);
54 
55  static void MarkEdge(int *indices, const DSTable &v_to_v, const int *length);
56 
57  /// Mark the longest edge by assuming/changing the order of the vertices.
58  virtual void MarkEdge(const DSTable &v_to_v, const int *length)
59  { MarkEdge(indices, v_to_v, length); }
60 
61  virtual void ResetTransform(int tr) { transform = tr; }
62  virtual unsigned GetTransform() const { return transform; }
63 
64  /// Add 'tr' to the current chain of coarse-fine transformations.
65  virtual void PushTransform(int tr)
66  { transform = (transform << 3) | (tr + 1); }
67 
68  /// Calculate point matrix corresponding to a chain of transformations.
69  static void GetPointMatrix(unsigned transform, DenseMatrix &pm);
70 
71  /// Returns the indices of the element's vertices.
72  virtual void GetVertices(Array<int> &v) const;
73 
74  virtual int *GetVertices() { return indices; }
75 
76  virtual int GetNVertices() const { return 3; }
77 
78  virtual int GetNEdges() const { return (3); }
79 
80  virtual const int *GetEdgeVertices(int ei) const
81  { return geom_t::Edges[ei]; }
82 
83  /// @deprecated Use GetNFaces(void) and GetNFaceVertices(int) instead.
84  MFEM_DEPRECATED virtual int GetNFaces(int &nFaceVertices) const
85  { nFaceVertices = 0; return 0; }
86 
87  virtual int GetNFaces() const { return 0; }
88 
89  virtual int GetNFaceVertices(int) const { return 0; }
90 
91  virtual const int *GetFaceVertices(int fi) const
92  { MFEM_ABORT("not implemented"); return NULL; }
93 
94  virtual Element *Duplicate(Mesh *m) const
95  { return new Triangle(indices, attribute); }
96 
97  virtual ~Triangle() { }
98 };
99 
100 // Defined in fe.cpp to ensure construction before 'mfem::Geometries'.
101 extern Linear2DFiniteElement TriangleFE;
102 
103 }
104 
105 #endif
virtual int * GetVertices()
Definition: triangle.hpp:74
virtual int GetNVertices() const
Definition: triangle.hpp:76
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
virtual const int * GetEdgeVertices(int ei) const
Definition: triangle.hpp:80
virtual MFEM_DEPRECATED int GetNFaces(int &nFaceVertices) const
Definition: triangle.hpp:84
virtual void MarkEdge(const DSTable &v_to_v, const int *length)
Mark the longest edge by assuming/changing the order of the vertices.
Definition: triangle.hpp:58
void MarkEdge(DenseMatrix &pmat)
Definition: triangle.cpp:53
static const int Edges[NumEdges][2]
Definition: geom.hpp:155
virtual void ResetTransform(int tr)
Set current coarse-fine transformation number.
Definition: triangle.hpp:61
Type
Constants for the classes derived from Element.
Definition: element.hpp:41
unsigned transform
Definition: triangle.hpp:28
Data type triangle element.
Definition: triangle.hpp:23
virtual void SetVertices(const int *ind)
Set the vertices according to the given input.
Definition: triangle.cpp:45
Geometry::Constants< Geometry::TRIANGLE > geom_t
Definition: triangle.hpp:31
virtual unsigned GetTransform() const
Return current coarse-fine transformation.
Definition: triangle.hpp:62
virtual const int * GetFaceVertices(int fi) const
Definition: triangle.hpp:91
virtual int GetNFaceVertices(int) const
Definition: triangle.hpp:89
virtual Element * Duplicate(Mesh *m) const
Definition: triangle.hpp:94
int attribute
Element&#39;s attribute (specifying material property, etc).
Definition: element.hpp:33
Linear2DFiniteElement TriangleFE
Definition: fe.cpp:13490
virtual Type GetType() const
Return element&#39;s type.
Definition: triangle.hpp:42
virtual int GetNEdges() const
Definition: triangle.hpp:78
virtual int GetNFaces() const
Definition: triangle.hpp:87
virtual void PushTransform(int tr)
Add &#39;tr&#39; to the current chain of coarse-fine transformations.
Definition: triangle.hpp:65
virtual int NeedRefinement(HashTable< Hashed2 > &v_to_v) const
Return 1 if the element needs refinement in order to get conforming mesh.
Definition: triangle.cpp:37
Abstract data type element.
Definition: element.hpp:28
virtual ~Triangle()
Definition: triangle.hpp:97
static void GetPointMatrix(unsigned transform, DenseMatrix &pm)
Calculate point matrix corresponding to a chain of transformations.
Definition: triangle.cpp:126
int indices[3]
Definition: triangle.hpp:26