MFEM  v4.6.0
Finite element discretization library
fe_l2.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, 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_FE_L2
13 #define MFEM_FE_L2
14 
15 #include "fe_base.hpp"
16 
17 namespace mfem
18 {
19 
20 /// Arbitrary order L2 elements in 1D on a segment
22 {
23 private:
24 #ifndef MFEM_THREAD_SAFE
25  mutable Vector shape_x, dshape_x;
26 #endif
27 
28 public:
29  /// Construct the L2_SegmentElement of order @a p and BasisType @a btype
30  L2_SegmentElement(const int p, const int btype = BasisType::GaussLegendre);
31  virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
32  virtual void CalcDShape(const IntegrationPoint &ip,
33  DenseMatrix &dshape) const;
34  virtual void ProjectDelta(int vertex, Vector &dofs) const;
35 
37  DenseMatrix &R) const
38  { ScalarLocalL2Restriction(Trans, R, *this); }
39 
40 };
41 
42 
43 /// Arbitrary order L2 elements in 2D on a square
45 {
46 private:
47 #ifndef MFEM_THREAD_SAFE
48  mutable Vector shape_x, shape_y, dshape_x, dshape_y;
49 #endif
50 
51 public:
52  /// Construct the L2_QuadrilateralElement of order @a p and BasisType @a btype
53  L2_QuadrilateralElement(const int p,
54  const int btype = BasisType::GaussLegendre);
55  virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
56  virtual void CalcDShape(const IntegrationPoint &ip,
57  DenseMatrix &dshape) const;
58  virtual void ProjectDelta(int vertex, Vector &dofs) const;
59  virtual void ProjectCurl(const FiniteElement &fe,
60  ElementTransformation &Trans,
61  DenseMatrix &curl) const
62  { ProjectCurl_2D(fe, Trans, curl); }
63 
65  DenseMatrix &R) const
66  { ScalarLocalL2Restriction(Trans, R, *this); }
67 
69  virtual void ProjectDiv(const FiniteElement &fe,
70  ElementTransformation &Trans,
71  DenseMatrix &div) const;
72  virtual void Project(Coefficient &coeff,
73  ElementTransformation &Trans, Vector &dofs) const;
74 };
75 
76 
77 /// Arbitrary order L2 elements in 3D on a cube
79 {
80 private:
81 #ifndef MFEM_THREAD_SAFE
82  mutable Vector shape_x, shape_y, shape_z, dshape_x, dshape_y, dshape_z;
83 #endif
84 
85 public:
86  /// Construct the L2_HexahedronElement of order @a p and BasisType @a btype
87  L2_HexahedronElement(const int p,
88  const int btype = BasisType::GaussLegendre);
89  virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
90  virtual void CalcDShape(const IntegrationPoint &ip,
91  DenseMatrix &dshape) const;
92  virtual void ProjectDelta(int vertex, Vector &dofs) const;
93 
95  DenseMatrix &R) const
96  { ScalarLocalL2Restriction(Trans, R, *this); }
97 
99  virtual void ProjectDiv(const FiniteElement &fe,
100  ElementTransformation &Trans,
101  DenseMatrix &div) const;
102  virtual void Project(Coefficient &coeff,
103  ElementTransformation &Trans, Vector &dofs) const;
104 };
105 
106 
107 /// Arbitrary order L2 elements in 2D on a triangle
109 {
110 private:
111 #ifndef MFEM_THREAD_SAFE
112  mutable Vector shape_x, shape_y, shape_l, dshape_x, dshape_y, dshape_l, u;
113  mutable DenseMatrix du;
114 #endif
116 
117 public:
118  /// Construct the L2_TriangleElement of order @a p and BasisType @a btype
119  L2_TriangleElement(const int p,
120  const int btype = BasisType::GaussLegendre);
121  virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
122  virtual void CalcDShape(const IntegrationPoint &ip,
123  DenseMatrix &dshape) const;
124  virtual void ProjectDelta(int vertex, Vector &dofs) const;
125  virtual void ProjectCurl(const FiniteElement &fe,
126  ElementTransformation &Trans,
127  DenseMatrix &curl) const
128  { ProjectCurl_2D(fe, Trans, curl); }
129 
131  DenseMatrix &R) const
132  { ScalarLocalL2Restriction(Trans, R, *this); }
133 
134 };
135 
136 
137 /// Arbitrary order L2 elements in 3D on a tetrahedron
139 {
140 private:
141 #ifndef MFEM_THREAD_SAFE
142  mutable Vector shape_x, shape_y, shape_z, shape_l;
143  mutable Vector dshape_x, dshape_y, dshape_z, dshape_l, u;
144  mutable DenseMatrix du;
145 #endif
147 
148 public:
149  /// Construct the L2_TetrahedronElement of order @a p and BasisType @a btype
150  L2_TetrahedronElement(const int p,
151  const int btype = BasisType::GaussLegendre);
152  virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
153  virtual void CalcDShape(const IntegrationPoint &ip,
154  DenseMatrix &dshape) const;
155  virtual void ProjectDelta(int vertex, Vector &dofs) const;
156 
158  DenseMatrix &R) const
159  { ScalarLocalL2Restriction(Trans, R, *this); }
160 
161 };
162 
163 
164 /// Arbitrary order L2 elements in 3D on a wedge
166 {
167 private:
168 #ifndef MFEM_THREAD_SAFE
169  mutable Vector t_shape, s_shape;
170  mutable DenseMatrix t_dshape, s_dshape;
171 #endif
172  Array<int> t_dof, s_dof;
173 
174  L2_TriangleElement TriangleFE;
175  L2_SegmentElement SegmentFE;
176 
177 public:
178  /// Construct the L2_WedgeElement of order @a p and BasisType @a btype
179  L2_WedgeElement(const int p,
180  const int btype = BasisType::GaussLegendre);
181  virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
182  virtual void CalcDShape(const IntegrationPoint &ip,
183  DenseMatrix &dshape) const;
184 };
185 
186 } // namespace mfem
187 
188 #endif
Abstract class for all finite elements.
Definition: fe_base.hpp:233
Arbitrary order L2 elements in 3D on a wedge.
Definition: fe_l2.hpp:165
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
Definition: fe_l2.cpp:142
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition: fe_l2.cpp:39
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition: fe_l2.cpp:901
Arbitrary order L2 elements in 2D on a triangle.
Definition: fe_l2.hpp:108
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition: fe_l2.cpp:615
Arbitrary order L2 elements in 3D on a cube.
Definition: fe_l2.hpp:78
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
Definition: fe_l2.cpp:255
virtual void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs. ...
Definition: fe_l2.hpp:64
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition: fe_l2.cpp:101
L2_SegmentElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_SegmentElement of order p and BasisType btype.
Definition: fe_l2.cpp:23
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition: fe_l2.cpp:320
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition: fe_l2.cpp:637
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
Definition: fe_l2.cpp:803
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
Definition: fe_base.cpp:126
virtual void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs. ...
Definition: fe_l2.hpp:36
Class for standard nodal finite elements.
Definition: fe_base.hpp:708
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition: fe_l2.cpp:342
virtual void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Compute the discrete curl matrix from the given FiniteElement onto &#39;this&#39; FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
Definition: fe_l2.hpp:125
Arbitrary order L2 elements in 1D on a segment.
Definition: fe_l2.hpp:21
virtual void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Compute the discrete curl matrix from the given FiniteElement onto &#39;this&#39; FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
Definition: fe_l2.hpp:59
void ProjectCurl_2D(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Definition: fe_base.cpp:638
virtual void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const
Compute the discrete divergence matrix from the given FiniteElement onto &#39;this&#39; FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
Definition: fe_l2.cpp:451
virtual void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs. ...
Definition: fe_l2.hpp:157
L2_QuadrilateralElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_QuadrilateralElement of order p and BasisType btype.
Definition: fe_l2.cpp:82
L2_WedgeElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_WedgeElement of order p and BasisType btype.
Definition: fe_l2.cpp:839
L2_TetrahedronElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_TetrahedronElement of order p and BasisType btype.
Definition: fe_l2.cpp:695
Arbitrary order L2 elements in 3D on a tetrahedron.
Definition: fe_l2.hpp:138
virtual void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs. ...
Definition: fe_l2.hpp:94
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
Definition: coefficient.hpp:41
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition: fe_l2.cpp:882
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
Definition: fe_l2.cpp:367
Class for integration point with weight.
Definition: intrules.hpp:31
virtual void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const
Compute the discrete divergence matrix from the given FiniteElement onto &#39;this&#39; FiniteElement. The ElementTransformation is included to support cases when the matrix depends on it.
Definition: fe_l2.cpp:190
Arbitrary order L2 elements in 2D on a square.
Definition: fe_l2.hpp:44
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition: fe_l2.cpp:46
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
Definition: fe_l2.cpp:58
Vector data type.
Definition: vector.hpp:58
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition: fe_l2.cpp:121
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
Definition: fe_l2.cpp:521
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition: fe_l2.cpp:745
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition: fe_l2.cpp:770
L2_HexahedronElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_HexahedronElement of order p and BasisType btype.
Definition: fe_l2.cpp:298
void ScalarLocalL2Restriction(ElementTransformation &Trans, DenseMatrix &R, const ScalarFiniteElement &coarse_fe) const
Get restriction matrix R defined through local L2-projection in the space defined by the coarse_fe...
Definition: fe_base.cpp:589
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
Definition: fe_l2.cpp:666
L2_TriangleElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_TriangleElement of order p and BasisType btype.
Definition: fe_l2.cpp:570
virtual void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs. ...
Definition: fe_l2.hpp:130