MFEM  v4.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, 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_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  virtual int GetNFaces(int &nFaceVertices) const
84  { nFaceVertices = 0; return 0; }
85 
86  virtual const int *GetFaceVertices(int fi) const
87  { MFEM_ABORT("not implemented"); return NULL; }
88 
89  virtual Element *Duplicate(Mesh *m) const
90  { return new Triangle(indices, attribute); }
91 
92  virtual ~Triangle() { }
93 };
94 
95 // Defined in fe.cpp to ensure construction before 'mfem::Geometries'.
96 extern Linear2DFiniteElement TriangleFE;
97 
98 }
99 
100 #endif
virtual int * GetVertices()
Definition: triangle.hpp:74
virtual int GetNFaces(int &nFaceVertices) const
Definition: triangle.hpp:83
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 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:136
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:86
virtual Element * Duplicate(Mesh *m) const
Definition: triangle.hpp:89
int attribute
Element&#39;s attribute (specifying material property, etc).
Definition: element.hpp:33
Linear2DFiniteElement TriangleFE
Definition: fe.cpp:11959
virtual Type GetType() const
Return element&#39;s type.
Definition: triangle.hpp:42
virtual int GetNEdges() const
Definition: triangle.hpp:78
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:92
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