28#ifndef MFEM_THREAD_SAFE
33 for (
int i = 0; i <=
p; i++)
49#ifdef MFEM_THREAD_SAFE
66 for (
int i = 0; i <=
p; i++)
73 for (
int i = 0; i <=
p; i++)
87#ifndef MFEM_THREAD_SAFE
94 for (
int o = 0, j = 0; j <=
p; j++)
95 for (
int i = 0; i <=
p; i++)
106#ifdef MFEM_THREAD_SAFE
114 for (
int o = 0, j = 0; j <=
p; j++)
115 for (
int i = 0; i <=
p; i++)
117 shape(o++) = shape_x(i)*shape_y(j);
126#ifdef MFEM_THREAD_SAFE
127 Vector shape_x(
p+1), shape_y(
p+1), dshape_x(
p+1), dshape_y(
p+1);
134 for (
int o = 0, j = 0; j <=
p; j++)
135 for (
int i = 0; i <=
p; i++)
137 dshape(o,0) = dshape_x(i)* shape_y(j);
138 dshape(o,1) = shape_x(i)*dshape_y(j); o++;
147#ifdef MFEM_THREAD_SAFE
151 for (
int i = 0; i <=
p; i++)
160 for (
int o = 0, j = 0; j <=
p; j++)
161 for (
int i = 0; i <=
p; i++)
163 dofs[o++] = shape_x(i)*shape_x(j);
167 for (
int o = 0, j = 0; j <=
p; j++)
168 for (
int i = 0; i <=
p; i++)
170 dofs[o++] = shape_y(i)*shape_x(j);
174 for (
int o = 0, j = 0; j <=
p; j++)
175 for (
int i = 0; i <=
p; i++)
177 dofs[o++] = shape_y(i)*shape_y(j);
181 for (
int o = 0, j = 0; j <=
p; j++)
182 for (
int i = 0; i <=
p; i++)
184 dofs[o++] = shape_x(i)*shape_y(j);
197 const int fe_ndof = fe.
GetDof();
198 Vector div_shape(fe_ndof);
206 for (
int iy = 0; iy <
order+1; ++iy)
208 const real_t hy = gll_pts[iy+1] - gll_pts[iy];
209 for (
int ix = 0; ix <
order+1; ++ix)
211 const int i = ix + iy*(
order+1);
212 const real_t hx = gll_pts[ix+1] - gll_pts[ix];
214 for (
int iq = 0; iq < ir.
Size(); ++iq)
217 ip.
x = gll_pts[ix] + hx*ip.
x;
218 ip.
y = gll_pts[iy] + hy*ip.
y;
231 for (
int j = 0; j < fe_ndof; j++)
233 const real_t div_j = div_shape(j);
240 for (
int i = 0; i <
dof; ++i)
242 for (
int j = 0; j < fe_ndof; j++)
244 if (std::fabs(div(i,j)) < 1e-12) { div(i,j) = 0.0; }
266 for (
int iy = 0; iy <
order+1; ++iy)
268 const real_t hy = gll_pts[iy+1] - gll_pts[iy];
269 for (
int ix = 0; ix <
order+1; ++ix)
271 const int i = ix + iy*(
order+1);
272 const real_t hx = gll_pts[ix+1] - gll_pts[ix];
274 for (
int iq = 0; iq < ir.
Size(); ++iq)
277 ip.
x = gll_pts[ix] + hx*ip.
x;
278 ip.
y = gll_pts[iy] + hy*ip.
y;
284 w *= hx*hy*Trans.
Weight();
303#ifndef MFEM_THREAD_SAFE
312 for (
int o = 0, k = 0; k <=
p; k++)
313 for (
int j = 0; j <=
p; j++)
314 for (
int i = 0; i <=
p; i++)
325#ifdef MFEM_THREAD_SAFE
326 Vector shape_x(
p+1), shape_y(
p+1), shape_z(
p+1);
334 for (
int o = 0, k = 0; k <=
p; k++)
335 for (
int j = 0; j <=
p; j++)
336 for (
int i = 0; i <=
p; i++)
338 shape(o++) = shape_x(i)*shape_y(j)*shape_z(k);
347#ifdef MFEM_THREAD_SAFE
348 Vector shape_x(
p+1), shape_y(
p+1), shape_z(
p+1);
349 Vector dshape_x(
p+1), dshape_y(
p+1), dshape_z(
p+1);
357 for (
int o = 0, k = 0; k <=
p; k++)
358 for (
int j = 0; j <=
p; j++)
359 for (
int i = 0; i <=
p; i++)
361 dshape(o,0) = dshape_x(i)* shape_y(j)* shape_z(k);
362 dshape(o,1) = shape_x(i)*dshape_y(j)* shape_z(k);
363 dshape(o,2) = shape_x(i)* shape_y(j)*dshape_z(k); o++;
372#ifdef MFEM_THREAD_SAFE
376 for (
int i = 0; i <=
p; i++)
385 for (
int o = 0, k = 0; k <=
p; k++)
386 for (
int j = 0; j <=
p; j++)
387 for (
int i = 0; i <=
p; i++)
389 dofs[o++] = shape_x(i)*shape_x(j)*shape_x(k);
393 for (
int o = 0, k = 0; k <=
p; k++)
394 for (
int j = 0; j <=
p; j++)
395 for (
int i = 0; i <=
p; i++)
397 dofs[o++] = shape_y(i)*shape_x(j)*shape_x(k);
401 for (
int o = 0, k = 0; k <=
p; k++)
402 for (
int j = 0; j <=
p; j++)
403 for (
int i = 0; i <=
p; i++)
405 dofs[o++] = shape_y(i)*shape_y(j)*shape_x(k);
409 for (
int o = 0, k = 0; k <=
p; k++)
410 for (
int j = 0; j <=
p; j++)
411 for (
int i = 0; i <=
p; i++)
413 dofs[o++] = shape_x(i)*shape_y(j)*shape_x(k);
417 for (
int o = 0, k = 0; k <=
p; k++)
418 for (
int j = 0; j <=
p; j++)
419 for (
int i = 0; i <=
p; i++)
421 dofs[o++] = shape_x(i)*shape_x(j)*shape_y(k);
425 for (
int o = 0, k = 0; k <=
p; k++)
426 for (
int j = 0; j <=
p; j++)
427 for (
int i = 0; i <=
p; i++)
429 dofs[o++] = shape_y(i)*shape_x(j)*shape_y(k);
433 for (
int o = 0, k = 0; k <=
p; k++)
434 for (
int j = 0; j <=
p; j++)
435 for (
int i = 0; i <=
p; i++)
437 dofs[o++] = shape_y(i)*shape_y(j)*shape_y(k);
441 for (
int o = 0, k = 0; k <=
p; k++)
442 for (
int j = 0; j <=
p; j++)
443 for (
int i = 0; i <=
p; i++)
445 dofs[o++] = shape_x(i)*shape_y(j)*shape_y(k);
458 const int fe_ndof = fe.
GetDof();
459 Vector div_shape(fe_ndof);
467 for (
int iz = 0; iz <
order+1; ++iz)
469 const real_t hz = gll_pts[iz+1] - gll_pts[iz];
470 for (
int iy = 0; iy <
order+1; ++iy)
472 const real_t hy = gll_pts[iy+1] - gll_pts[iy];
473 for (
int ix = 0; ix <
order+1; ++ix)
476 const real_t hx = gll_pts[ix+1] - gll_pts[ix];
478 for (
int iq = 0; iq < ir.
Size(); ++iq)
481 ip.
x = gll_pts[ix] + hx*ip.
x;
482 ip.
y = gll_pts[iy] + hy*ip.
y;
483 ip.
z = gll_pts[iz] + hz*ip.
z;
496 for (
int j = 0; j < fe_ndof; j++)
498 const real_t div_j = div_shape(j);
506 for (
int i = 0; i <
dof; ++i)
508 for (
int j = 0; j < fe_ndof; j++)
510 if (std::fabs(div(i,j)) < 1e-12) { div(i,j) = 0.0; }
532 for (
int iz = 0; iz <
order+1; ++iz)
534 const real_t hz = gll_pts[iz+1] - gll_pts[iz];
535 for (
int iy = 0; iy <
order+1; ++iy)
537 const real_t hy = gll_pts[iy+1] - gll_pts[iy];
538 for (
int ix = 0; ix <
order+1; ++ix)
540 const real_t hx = gll_pts[ix+1] - gll_pts[ix];
543 for (
int iq = 0; iq < ir.
Size(); ++iq)
546 ip.
x = gll_pts[ix] + hx*ip.
x;
547 ip.
y = gll_pts[iy] + hy*ip.
y;
548 ip.
z = gll_pts[iz] + hz*ip.
z;
576#ifndef MFEM_THREAD_SAFE
586 Vector shape_x(
p + 1), shape_y(
p + 1), shape_l(
p + 1);
589 for (
int o = 0, j = 0; j <=
p; j++)
590 for (
int i = 0; i + j <=
p; i++)
592 real_t w = op[i] + op[j] + op[
p-i-j];
597 for (
int k = 0; k <
dof; k++)
604 for (
int o = 0, j = 0; j <=
p; j++)
605 for (
int i = 0; i + j <=
p; i++)
607 T(o++, k) = shape_x(i)*shape_y(j)*shape_l(
p-i-j);
620#ifdef MFEM_THREAD_SAFE
621 Vector shape_x(
p + 1), shape_y(
p + 1), shape_l(
p + 1), u(
dof);
628 for (
int o = 0, j = 0; j <=
p; j++)
629 for (
int i = 0; i + j <=
p; i++)
631 u(o++) = shape_x(i)*shape_y(j)*shape_l(
p-i-j);
642#ifdef MFEM_THREAD_SAFE
643 Vector shape_x(
p + 1), shape_y(
p + 1), shape_l(
p + 1);
644 Vector dshape_x(
p + 1), dshape_y(
p + 1), dshape_l(
p + 1);
652 for (
int o = 0, j = 0; j <=
p; j++)
653 for (
int i = 0; i + j <=
p; i++)
656 du(o,0) = ((dshape_x(i)* shape_l(k)) -
657 ( shape_x(i)*dshape_l(k)))*shape_y(j);
658 du(o,1) = ((dshape_y(j)* shape_l(k)) -
659 ( shape_y(j)*dshape_l(k)))*shape_x(i);
671 for (
int i = 0; i <
dof; i++)
674 dofs[i] = pow(1.0 - ip.
x - ip.
y,
order);
678 for (
int i = 0; i <
dof; i++)
681 dofs[i] = pow(ip.
x,
order);
685 for (
int i = 0; i <
dof; i++)
688 dofs[i] = pow(ip.
y,
order);
701#ifndef MFEM_THREAD_SAFE
713 Vector shape_x(
p + 1), shape_y(
p + 1), shape_z(
p + 1), shape_l(
p + 1);
716 for (
int o = 0, k = 0; k <=
p; k++)
717 for (
int j = 0; j + k <=
p; j++)
718 for (
int i = 0; i + j + k <=
p; i++)
720 real_t w = op[i] + op[j] + op[k] + op[
p-i-j-k];
725 for (
int m = 0; m <
dof; m++)
733 for (
int o = 0, k = 0; k <=
p; k++)
734 for (
int j = 0; j + k <=
p; j++)
735 for (
int i = 0; i + j + k <=
p; i++)
737 T(o++, m) = shape_x(i)*shape_y(j)*shape_z(k)*shape_l(
p-i-j-k);
750#ifdef MFEM_THREAD_SAFE
751 Vector shape_x(
p + 1), shape_y(
p + 1), shape_z(
p + 1), shape_l(
p + 1);
760 for (
int o = 0, k = 0; k <=
p; k++)
761 for (
int j = 0; j + k <=
p; j++)
762 for (
int i = 0; i + j + k <=
p; i++)
764 u(o++) = shape_x(i)*shape_y(j)*shape_z(k)*shape_l(
p-i-j-k);
775#ifdef MFEM_THREAD_SAFE
776 Vector shape_x(
p + 1), shape_y(
p + 1), shape_z(
p + 1), shape_l(
p + 1);
777 Vector dshape_x(
p + 1), dshape_y(
p + 1), dshape_z(
p + 1), dshape_l(
p + 1);
786 for (
int o = 0, k = 0; k <=
p; k++)
787 for (
int j = 0; j + k <=
p; j++)
788 for (
int i = 0; i + j + k <=
p; i++)
790 int l =
p - i - j - k;
791 du(o,0) = ((dshape_x(i)* shape_l(l)) -
792 ( shape_x(i)*dshape_l(l)))*shape_y(j)*shape_z(k);
793 du(o,1) = ((dshape_y(j)* shape_l(l)) -
794 ( shape_y(j)*dshape_l(l)))*shape_x(i)*shape_z(k);
795 du(o,2) = ((dshape_z(k)* shape_l(l)) -
796 ( shape_z(k)*dshape_l(l)))*shape_x(i)*shape_y(j);
808 for (
int i = 0; i <
dof; i++)
811 dofs[i] = pow(1.0 - ip.
x - ip.
y - ip.
z,
order);
815 for (
int i = 0; i <
dof; i++)
818 dofs[i] = pow(ip.
x,
order);
822 for (
int i = 0; i <
dof; i++)
825 dofs[i] = pow(ip.
y,
order);
829 for (
int i = 0; i <
dof; i++)
832 dofs[i] = pow(ip.
z,
order);
845#ifndef MFEM_THREAD_SAFE
857 for (
int k=0; k<=
p; k++)
860 for (
int j=0; j<=
p; j++)
862 for (
int i=0; i<=j; i++)
874 for (
int i=0; i<
dof; i++)
885#ifdef MFEM_THREAD_SAFE
895 for (
int i=0; i<
dof; i++)
897 shape[i] = t_shape[t_dof[i]] * s_shape[s_dof[i]];
904#ifdef MFEM_THREAD_SAFE
918 for (
int i=0; i<
dof; i++)
920 dshape(i, 0) = t_dshape(t_dof[i],0) * s_shape[s_dof[i]];
921 dshape(i, 1) = t_dshape(t_dof[i],1) * s_shape[s_dof[i]];
922 dshape(i, 2) = t_shape[t_dof[i]] * s_dshape(s_dof[i],0);
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
@ GaussLobatto
Closed type.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
void Factor()
Factor the current DenseMatrix, *a.
void Mult(const real_t *x, real_t *y) const
Matrix vector multiplication with the inverse of dense matrix.
Data type dense matrix using column-major storage.
real_t * Data() const
Returns the matrix data array.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
Abstract class for all finite elements.
int dof
Number of degrees of freedom.
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
static int VerifyOpen(int b_type)
Ensure that the BasisType of b_type is open (doesn't have Quadrature1D points on the boundary).
virtual void CalcDivShape(const IntegrationPoint &ip, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in reference space at the g...
Geometry::Type geom_type
Geometry::Type of the reference element.
int GetDof() const
Returns the number of degrees of freedom in the finite element.
int order
Order/degree of the shape functions.
int dim
Dimension of reference space.
Describes the function space on each element.
Class for integration point with weight.
void Set2(const real_t x1, const real_t x2)
void Set3(const real_t x1, const real_t x2, const real_t x3)
Class for an integration rule - an Array of IntegrationPoint.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
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...
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...
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
L2_HexahedronElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_HexahedronElement of order p and BasisType btype.
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
virtual void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const
Compute the discrete divergence matrix from the given FiniteElement onto 'this' FiniteElement....
L2_QuadrilateralElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_QuadrilateralElement of order p and BasisType btype.
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
virtual void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const
Compute the discrete divergence matrix from the given FiniteElement onto 'this' FiniteElement....
virtual void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
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...
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...
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...
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
L2_SegmentElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_SegmentElement of order p and BasisType btype.
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...
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...
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...
L2_TetrahedronElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_TetrahedronElement of order p and BasisType btype.
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
L2_TriangleElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_TriangleElement of order p and BasisType btype.
virtual void ProjectDelta(int vertex, Vector &dofs) const
Project a delta function centered on the given vertex in the local finite dimensional space represent...
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...
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...
L2_WedgeElement(const int p, const int btype=BasisType::GaussLegendre)
Construct the L2_WedgeElement of order p and BasisType btype.
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...
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...
Class for standard nodal finite elements.
void Project(Coefficient &coeff, ElementTransformation &Trans, Vector &dofs) const override
Given a coefficient and a transformation, compute its projection (approximation) in the local finite ...
void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const override
Compute the discrete divergence matrix from the given FiniteElement onto 'this' FiniteElement....
void Eval(const real_t x, Vector &u) const
Evaluate the basis functions at point x in [0,1].
bool IsIntegratedType() const
Returns true if the basis is "integrated", false otherwise.
void ScaleIntegrated(bool scale_integrated_)
Set whether the "integrated" basis should be scaled by the subcell sizes. Has no effect for non-integ...
const real_t * OpenPoints(const int p, const int btype=BasisType::GaussLegendre)
Get coordinates of an open (GaussLegendre) set of points if degree p.
static real_t CalcDelta(const int p, const real_t x)
Evaluate a representation of a Delta function at point x.
const real_t * GetPoints(const int p, const int btype)
Get the coordinates of the points of the given BasisType, btype.
static void CalcBasis(const int p, const real_t x, real_t *u)
Evaluate the values of a hierarchical 1D basis at point x hierarchical = k-th basis function is degre...
void SetDataAndSize(real_t *d, int s)
Set the Vector data and size.
void SetSize(int s)
Resize the vector to size s.
Linear1DFiniteElement SegmentFE
real_t u(const Vector &xvec)
MFEM_EXPORT Linear2DFiniteElement TriangleFE
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
real_t p(const Vector &x, real_t t)