MFEM  v3.4
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 int GetType() const { return Element::TRIANGLE; }
43 
44  /// Return 1 if the element needs refinement in order to get conforming mesh.
45  virtual int NeedRefinement(DSTable &v_to_v, int *middle) 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  virtual void MarkEdge(DenseMatrix & pmat);
54 
55  /// Mark the longest edge by assuming/changing the order of the vertices.
56  virtual void MarkEdge(const DSTable &v_to_v, const int *length);
57 
58  virtual void ResetTransform(int tr) { transform = tr; }
59  virtual unsigned GetTransform() const { return transform; }
60 
61  /// Add 'tr' to the current chain of coarse-fine transformations.
62  virtual void PushTransform(int tr)
63  { transform = (transform << 3) | (tr + 1); }
64 
65  /// Calculate point matrix corresponding to a chain of transformations.
66  static void GetPointMatrix(unsigned transform, DenseMatrix &pm);
67 
68  /// Returns the indices of the element's vertices.
69  virtual void GetVertices(Array<int> &v) const;
70 
71  virtual int *GetVertices() { return indices; }
72 
73  virtual int GetNVertices() const { return 3; }
74 
75  virtual int GetNEdges() const { return (3); }
76 
77  virtual const int *GetEdgeVertices(int ei) const
78  { return geom_t::Edges[ei]; }
79 
80  virtual int GetNFaces(int &nFaceVertices) const
81  { nFaceVertices = 0; return 0; }
82 
83  virtual const int *GetFaceVertices(int fi) const
84  { MFEM_ABORT("not implemented"); return NULL; }
85 
86  virtual Element *Duplicate(Mesh *m) const
87  { return new Triangle(indices, attribute); }
88 
89  virtual ~Triangle() { }
90 };
91 
92 extern Linear2DFiniteElement TriangleFE;
93 
94 }
95 
96 #endif
virtual int * GetVertices()
Definition: triangle.hpp:71
virtual int NeedRefinement(DSTable &v_to_v, int *middle) const
Return 1 if the element needs refinement in order to get conforming mesh.
Definition: triangle.cpp:37
virtual int GetNFaces(int &nFaceVertices) const
Definition: triangle.hpp:80
virtual int GetNVertices() const
Definition: triangle.hpp:73
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
virtual const int * GetEdgeVertices(int ei) const
Definition: triangle.hpp:77
virtual void MarkEdge(DenseMatrix &pmat)
Definition: triangle.cpp:55
static const int Edges[NumEdges][2]
Definition: geom.hpp:128
virtual void ResetTransform(int tr)
Set current coarse-fine transformation number.
Definition: triangle.hpp:58
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:47
Geometry::Constants< Geometry::TRIANGLE > geom_t
Definition: triangle.hpp:31
virtual unsigned GetTransform() const
Return current coarse-fine transformation.
Definition: triangle.hpp:59
virtual const int * GetFaceVertices(int fi) const
Definition: triangle.hpp:83
virtual Element * Duplicate(Mesh *m) const
Definition: triangle.hpp:86
int attribute
Element&#39;s attribute (specifying material property, etc).
Definition: element.hpp:32
Linear2DFiniteElement TriangleFE
Definition: triangle.cpp:198
virtual int GetNEdges() const
Definition: triangle.hpp:75
virtual int GetType() const
Return element&#39;s type.
Definition: triangle.hpp:42
virtual void PushTransform(int tr)
Add &#39;tr&#39; to the current chain of coarse-fine transformations.
Definition: triangle.hpp:62
Abstract data type element.
Definition: element.hpp:27
virtual ~Triangle()
Definition: triangle.hpp:89
static void GetPointMatrix(unsigned transform, DenseMatrix &pm)
Calculate point matrix corresponding to a chain of transformations.
Definition: triangle.cpp:127
int indices[3]
Definition: triangle.hpp:26