MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
fe_l2.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, 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#include "fe_pyramid.hpp"
17
18namespace mfem
19{
20
21/// Arbitrary order L2 elements in 1D on a segment
23{
24private:
25#ifndef MFEM_THREAD_SAFE
26 mutable Vector shape_x, dshape_x;
27#endif
28
29public:
30 /// Construct the L2_SegmentElement of order @a p and BasisType @a btype
31 L2_SegmentElement(const int p, const int btype = BasisType::GaussLegendre);
32 void CalcShape(const IntegrationPoint &ip, Vector &shape) const override;
33 void CalcDShape(const IntegrationPoint &ip,
34 DenseMatrix &dshape) const override;
35 void ProjectDelta(int vertex, Vector &dofs) const override;
36
38 DenseMatrix &R) const override
39 { ScalarLocalL2Restriction(Trans, R, *this); }
40
41};
42
43
44/// Arbitrary order L2 elements in 2D on a square
46{
47private:
48#ifndef MFEM_THREAD_SAFE
49 mutable Vector shape_x, shape_y, dshape_x, dshape_y;
50#endif
51
52public:
53 /// Construct the L2_QuadrilateralElement of order @a p and BasisType @a btype
54 L2_QuadrilateralElement(const int p,
55 const int btype = BasisType::GaussLegendre);
56 void CalcShape(const IntegrationPoint &ip, Vector &shape) const override;
57 void CalcDShape(const IntegrationPoint &ip,
58 DenseMatrix &dshape) const override;
59 void ProjectDelta(int vertex, Vector &dofs) const override;
60 void ProjectCurl(const FiniteElement &fe,
62 DenseMatrix &curl) const override
63 { ProjectCurl_2D(fe, Trans, curl); }
64
66 DenseMatrix &R) const override
67 { ScalarLocalL2Restriction(Trans, R, *this); }
68
70 void ProjectDiv(const FiniteElement &fe,
72 DenseMatrix &div) const override;
73 void Project(Coefficient &coeff,
74 ElementTransformation &Trans, Vector &dofs) const override;
75};
76
77
78/// Arbitrary order L2 elements in 3D on a cube
80{
81private:
82#ifndef MFEM_THREAD_SAFE
83 mutable Vector shape_x, shape_y, shape_z, dshape_x, dshape_y, dshape_z;
84#endif
85
86public:
87 /// Construct the L2_HexahedronElement of order @a p and BasisType @a btype
88 L2_HexahedronElement(const int p,
89 const int btype = BasisType::GaussLegendre);
90 void CalcShape(const IntegrationPoint &ip, Vector &shape) const override;
91 void CalcDShape(const IntegrationPoint &ip,
92 DenseMatrix &dshape) const override;
93 void ProjectDelta(int vertex, Vector &dofs) const override;
94
96 DenseMatrix &R) const override
97 { ScalarLocalL2Restriction(Trans, R, *this); }
98
100 void ProjectDiv(const FiniteElement &fe,
102 DenseMatrix &div) const override;
103 void Project(Coefficient &coeff,
104 ElementTransformation &Trans, Vector &dofs) const override;
105};
106
107
108/// Arbitrary order L2 elements in 2D on a triangle
110{
111private:
112#ifndef MFEM_THREAD_SAFE
113 mutable Vector shape_x, shape_y, shape_l, dshape_x, dshape_y, dshape_l, u;
114 mutable DenseMatrix du;
115#endif
117
118public:
119 /// Construct the L2_TriangleElement of order @a p and BasisType @a btype
120 L2_TriangleElement(const int p,
121 const int btype = BasisType::GaussLegendre);
122 void CalcShape(const IntegrationPoint &ip, Vector &shape) const override;
123 void CalcDShape(const IntegrationPoint &ip,
124 DenseMatrix &dshape) const override;
125 void ProjectDelta(int vertex, Vector &dofs) const override;
128 DenseMatrix &curl) const override
129 { ProjectCurl_2D(fe, Trans, curl); }
130
132 DenseMatrix &R) const override
133 { ScalarLocalL2Restriction(Trans, R, *this); }
134
135};
136
137
138/// Arbitrary order L2 elements in 3D on a tetrahedron
140{
141private:
142#ifndef MFEM_THREAD_SAFE
143 mutable Vector shape_x, shape_y, shape_z, shape_l;
144 mutable Vector dshape_x, dshape_y, dshape_z, dshape_l, u;
145 mutable DenseMatrix du;
146#endif
148
149public:
150 /// Construct the L2_TetrahedronElement of order @a p and BasisType @a btype
151 L2_TetrahedronElement(const int p,
152 const int btype = BasisType::GaussLegendre);
153 void CalcShape(const IntegrationPoint &ip, Vector &shape) const override;
154 void CalcDShape(const IntegrationPoint &ip,
155 DenseMatrix &dshape) const override;
156 void ProjectDelta(int vertex, Vector &dofs) const override;
157
159 DenseMatrix &R) const override
160 { ScalarLocalL2Restriction(Trans, R, *this); }
161
162};
163
164
165/// Arbitrary order L2 elements in 3D on a wedge
167{
168private:
169#ifndef MFEM_THREAD_SAFE
170 mutable Vector t_shape, s_shape;
171 mutable DenseMatrix t_dshape, s_dshape;
172#endif
173 Array<int> t_dof, s_dof;
174
175 L2_TriangleElement TriangleFE;
176 L2_SegmentElement SegmentFE;
177
178public:
179 /// Construct the L2_WedgeElement of order @a p and BasisType @a btype
180 L2_WedgeElement(const int p,
181 const int btype = BasisType::GaussLegendre);
182 void CalcShape(const IntegrationPoint &ip, Vector &shape) const override;
183 void CalcDShape(const IntegrationPoint &ip,
184 DenseMatrix &dshape) const override;
185};
186
187/** Arbitrary order L2 basis functions defined on pyramid-shaped elements
188
189 This implementation is closely based on the finite elements
190 described in section 9.4 of the paper "Orientation embedded high
191 order shape functions for the exact sequence elements of all shapes"
192 by Federico Fuentes, Brendan Keith, Leszek Demkowicz, and Sriram
193 Nagaraj, see https://doi.org/10.1016/j.camwa.2015.04.027.
194 */
196 : public NodalFiniteElement, public FuentesPyramid
197{
198private:
199#ifndef MFEM_THREAD_SAFE
200 mutable Vector shape_x, shape_y, shape_z;
201 mutable Vector dshape_x, dshape_y, dshape_z;
202 mutable Vector u;
203 mutable DenseMatrix du;
204#endif
206
207public:
208 /// Construct the L2_PyramidElement of order @a p and BasisType @a btype
209 L2_FuentesPyramidElement(const int p,
210 const int btype = BasisType::GaussLegendre);
211 virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
212 virtual void CalcDShape(const IntegrationPoint &ip,
213 DenseMatrix &dshape) const;
214};
215
216/// Arbitrary order L2 elements in 3D on a pyramid
218{
219private:
220#ifndef MFEM_THREAD_SAFE
221 mutable Vector shape_x, shape_y, shape_z;
222 mutable Vector dshape_x, dshape_y, dshape_z, dshape_z_dt;
223 mutable Vector u;
224 mutable DenseMatrix du;
225#endif
227
228public:
229 /// Construct the L2_PyramidElement of order @a p and BasisType @a btype
230 L2_BergotPyramidElement(const int p,
231 const int btype = BasisType::GaussLegendre);
232 virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
233 virtual void CalcDShape(const IntegrationPoint &ip,
234 DenseMatrix &dshape) const;
235};
236
237} // namespace mfem
238
239#endif
@ GaussLegendre
Open type.
Definition fe_base.hpp:35
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
Data type dense matrix using column-major storage.
Definition densemat.hpp:24
Abstract class for all finite elements.
Definition fe_base.hpp:244
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
Class for integration point with weight.
Definition intrules.hpp:35
Arbitrary order L2 elements in 3D on a pyramid.
Definition fe_l2.hpp:218
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:1152
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:1191
L2_BergotPyramidElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_PyramidElement of order p and BasisType btype.
Definition fe_l2.cpp:1077
L2_FuentesPyramidElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_PyramidElement of order p and BasisType btype.
Definition fe_l2.cpp:926
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:1041
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:1002
Arbitrary order L2 elements in 3D on a cube.
Definition fe_l2.hpp:80
void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const override
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs.
Definition fe_l2.hpp:95
void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const override
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition fe_l2.cpp:342
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 ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const override
Compute the discrete divergence matrix from the given FiniteElement onto 'this' FiniteElement....
Definition fe_l2.cpp:451
void CalcShape(const IntegrationPoint &ip, Vector &shape) const override
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition fe_l2.cpp:320
void ProjectDelta(int vertex, Vector &dofs) const override
Project a delta function centered on the given vertex in the local finite dimensional space represent...
Definition fe_l2.cpp:367
void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const override
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
Definition fe_l2.cpp:521
Arbitrary order L2 elements in 2D on a square.
Definition fe_l2.hpp:46
void ProjectDelta(int vertex, Vector &dofs) const override
Project a delta function centered on the given vertex in the local finite dimensional space represent...
Definition fe_l2.cpp:142
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
void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const override
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs.
Definition fe_l2.hpp:65
void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const override
Compute the discrete divergence matrix from the given FiniteElement onto 'this' FiniteElement....
Definition fe_l2.cpp:190
void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const override
Compute the discrete curl matrix from the given FiniteElement onto 'this' FiniteElement....
Definition fe_l2.hpp:60
void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const override
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
Definition fe_l2.cpp:255
void CalcShape(const IntegrationPoint &ip, Vector &shape) const override
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition fe_l2.cpp:101
void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const override
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition fe_l2.cpp:121
Arbitrary order L2 elements in 1D on a segment.
Definition fe_l2.hpp:23
void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const override
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs.
Definition fe_l2.hpp:37
void CalcShape(const IntegrationPoint &ip, Vector &shape) const override
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition fe_l2.cpp:39
void ProjectDelta(int vertex, Vector &dofs) const override
Project a delta function centered on the given vertex in the local finite dimensional space represent...
Definition fe_l2.cpp:58
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
void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const override
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition fe_l2.cpp:46
Arbitrary order L2 elements in 3D on a tetrahedron.
Definition fe_l2.hpp:140
void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const override
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition fe_l2.cpp:770
void ProjectDelta(int vertex, Vector &dofs) const override
Project a delta function centered on the given vertex in the local finite dimensional space represent...
Definition fe_l2.cpp:803
void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const override
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs.
Definition fe_l2.hpp:158
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
void CalcShape(const IntegrationPoint &ip, Vector &shape) const override
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition fe_l2.cpp:745
Arbitrary order L2 elements in 2D on a triangle.
Definition fe_l2.hpp:110
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
void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const override
Compute the discrete curl matrix from the given FiniteElement onto 'this' FiniteElement....
Definition fe_l2.hpp:126
void GetLocalRestriction(ElementTransformation &Trans, DenseMatrix &R) const override
Return a local restriction matrix R (Dof x Dof) mapping fine dofs to coarse dofs.
Definition fe_l2.hpp:131
void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const override
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition fe_l2.cpp:637
void CalcShape(const IntegrationPoint &ip, Vector &shape) const override
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition fe_l2.cpp:615
void ProjectDelta(int vertex, Vector &dofs) const override
Project a delta function centered on the given vertex in the local finite dimensional space represent...
Definition fe_l2.cpp:666
Arbitrary order L2 elements in 3D on a wedge.
Definition fe_l2.hpp:167
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
void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const override
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition fe_l2.cpp:901
void CalcShape(const IntegrationPoint &ip, Vector &shape) const override
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition fe_l2.cpp:882
Class for standard nodal finite elements.
Definition fe_base.hpp:721
void ProjectCurl_2D(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Definition fe_base.cpp:724
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:602
Vector data type.
Definition vector.hpp:82
real_t p(const Vector &x, real_t t)