MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
triangle.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_TRIANGLE
13#define MFEM_TRIANGLE
14
15#include "../config/config.hpp"
16#include "../fem/fe.hpp"
17#include "element.hpp"
18
19namespace mfem
20{
21
22/// Data type triangle element
23class Triangle : public Element
24{
25protected:
26 int indices[3];
27
28 unsigned transform;
29
30public:
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 Type GetType() const override { return Element::TRIANGLE; }
43
44 /// Return 1 if the element needs refinement in order to get conforming mesh.
45 int NeedRefinement(HashTable<Hashed2> &v_to_v) const override;
46
47 /** Reorder the vertices so that the longest edge is from vertex 0
48 to vertex 1. If called it should be once from the mesh constructor,
49 because the order may be used later for setting the edges. **/
50 void MarkEdge(DenseMatrix & pmat);
51
52 static void MarkEdge(int *indices, const DSTable &v_to_v, const int *length);
53
54 /// Mark the longest edge by assuming/changing the order of the vertices.
55 void MarkEdge(const DSTable &v_to_v, const int *length) override
56 { MarkEdge(indices, v_to_v, length); }
57
58 void ResetTransform(int tr) override { transform = tr; }
59 unsigned GetTransform() const override { return transform; }
60
61 /// Add 'tr' to the current chain of coarse-fine transformations.
62 void PushTransform(int tr) override
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 /// Get the indices defining the vertices.
69 void GetVertices(Array<int> &v) const override;
70
71 /// Set the indices defining the vertices.
72 void SetVertices(const Array<int> &v) override;
73
74 /// @note The returned array should NOT be deleted by the caller.
75 int * GetVertices () override { return indices; }
76
77 /// Set the indices defining the vertices.
78 void SetVertices(const int *ind) override;
79
80
81 int GetNVertices() const override { return 3; }
82
83 int GetNEdges() const override { return (3); }
84
85 const int *GetEdgeVertices(int ei) const override
86 { return geom_t::Edges[ei]; }
87
88 /// @deprecated Use GetNFaces(void) and GetNFaceVertices(int) instead.
89 MFEM_DEPRECATED int GetNFaces(int &nFaceVertices) const override
90 { nFaceVertices = 0; return 0; }
91
92 int GetNFaces() const override { return 0; }
93
94 int GetNFaceVertices(int) const override { return 0; }
95
96 const int *GetFaceVertices(int fi) const override
97 { MFEM_ABORT("not implemented"); return NULL; }
98
99 Element *Duplicate(Mesh *m) const override
100 { return new Triangle(indices, attribute); }
101
102 virtual ~Triangle() = default;
103};
104
105// Defined in fe.cpp to ensure construction before 'mfem::Geometries'.
106extern MFEM_EXPORT Linear2DFiniteElement TriangleFE;
107
108}
109
110#endif
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
Abstract data type element.
Definition element.hpp:29
int attribute
Element's attribute (specifying material property, etc).
Definition element.hpp:33
Type
Constants for the classes derived from Element.
Definition element.hpp:41
A 2D linear element on triangle with nodes at the vertices of the triangle.
Mesh data type.
Definition mesh.hpp:56
Data type triangle element.
Definition triangle.hpp:24
void MarkEdge(DenseMatrix &pmat)
Definition triangle.cpp:53
int GetNEdges() const override
Definition triangle.hpp:83
void SetVertices(const Array< int > &v) override
Set the indices defining the vertices.
Definition triangle.cpp:194
const int * GetFaceVertices(int fi) const override
Definition triangle.hpp:96
int GetNFaceVertices(int) const override
Definition triangle.hpp:94
const int * GetEdgeVertices(int ei) const override
Definition triangle.hpp:85
unsigned transform
Definition triangle.hpp:28
int NeedRefinement(HashTable< Hashed2 > &v_to_v) const override
Return 1 if the element needs refinement in order to get conforming mesh.
Definition triangle.cpp:37
Geometry::Constants< Geometry::TRIANGLE > geom_t
Definition triangle.hpp:31
static void GetPointMatrix(unsigned transform, DenseMatrix &pm)
Calculate point matrix corresponding to a chain of transformations.
Definition triangle.cpp:126
void MarkEdge(const DSTable &v_to_v, const int *length) override
Mark the longest edge by assuming/changing the order of the vertices.
Definition triangle.hpp:55
void PushTransform(int tr) override
Add 'tr' to the current chain of coarse-fine transformations.
Definition triangle.hpp:62
void ResetTransform(int tr) override
Set current coarse-fine transformation number.
Definition triangle.hpp:58
unsigned GetTransform() const override
Return current coarse-fine transformation.
Definition triangle.hpp:59
int GetNFaces() const override
Definition triangle.hpp:92
virtual ~Triangle()=default
MFEM_DEPRECATED int GetNFaces(int &nFaceVertices) const override
Definition triangle.hpp:89
int * GetVertices() override
Definition triangle.hpp:75
Type GetType() const override
Return element's type.
Definition triangle.hpp:42
int GetNVertices() const override
Definition triangle.hpp:81
Element * Duplicate(Mesh *m) const override
Definition triangle.hpp:99
MFEM_EXPORT Linear2DFiniteElement TriangleFE
Definition fe.cpp:32
static const int Edges[NumEdges][2]
Definition geom.hpp:171