MFEM v4.9.0
Finite element discretization library
Loading...
Searching...
No Matches
fe_base.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_BASE
13#define MFEM_FE_BASE
14
15#include "../intrules.hpp"
16#include "../geom.hpp"
17#include "../doftrans.hpp"
19
20#include <map>
21#include <memory>
22#include <unordered_map>
23#include <utility>
24
25namespace mfem
26{
27
28/// Possible basis types. Note that not all elements can use all BasisType(s).
30{
31public:
32 enum
33 {
34 Invalid = -1,
35 GaussLegendre = 0, ///< Open type
36 GaussLobatto = 1, ///< Closed type
37 Positive = 2, ///< Bernstein polynomials
38 OpenUniform = 3, ///< Nodes: x_i = (i+1)/(n+1), i=0,...,n-1
39 ClosedUniform = 4, ///< Nodes: x_i = i/(n-1), i=0,...,n-1
40 OpenHalfUniform = 5, ///< Nodes: x_i = (i+1/2)/n, i=0,...,n-1
41 Serendipity = 6, ///< Serendipity basis (squares / cubes)
42 ClosedGL = 7, ///< Closed GaussLegendre
43 IntegratedGLL = 8, ///< Integrated GLL indicator functions
44 NumBasisTypes = 9 /**< Keep track of maximum types to prevent
45 hard-coding */
46 };
47 /** @brief If the input does not represents a valid BasisType, abort with an
48 error; otherwise return the input. */
49 static int Check(int b_type)
50 {
51 MFEM_VERIFY(0 <= b_type && b_type < NumBasisTypes,
52 "unknown BasisType: " << b_type);
53 return b_type;
54 }
55 /** @brief If the input does not represents a valid nodal BasisType, abort
56 with an error; otherwise return the input. */
57 static int CheckNodal(int b_type)
58 {
59 MFEM_VERIFY(Check(b_type) != Positive && b_type != IntegratedGLL,
60 "invalid nodal BasisType: " << Name(b_type));
61 return b_type;
62 }
63 /** @brief Get the corresponding Quadrature1D constant, when that makes
64 sense; otherwise return Quadrature1D::Invalid. */
65 static int GetQuadrature1D(int b_type)
66 {
67 switch (b_type)
68 {
71 case Positive: return Quadrature1D::ClosedUniform; // <-----
78 }
80 }
81 /// Return the nodal BasisType corresponding to the Quadrature1D type.
82 static int GetNodalBasis(int qpt_type)
83 {
84 switch (qpt_type)
85 {
92 }
93 return Invalid;
94 }
95 /// Check and convert a BasisType constant to a string identifier.
96 static const char *Name(int b_type)
97 {
98 static const char *name[] =
99 {
100 "Gauss-Legendre", "Gauss-Lobatto", "Positive (Bernstein)",
101 "Open uniform", "Closed uniform", "Open half uniform",
102 "Serendipity", "Closed Gauss-Legendre",
103 "Integrated Gauss-Lobatto indicator"
104 };
105 return name[Check(b_type)];
106 }
107 /// Check and convert a BasisType constant to a char basis identifier.
108 static char GetChar(int b_type)
109 {
110 static const char ident[]
111 = { 'g', 'G', 'P', 'u', 'U', 'o', 'S', 'c', 'i' };
112 return ident[Check(b_type)];
113 }
114 /// Convert char basis identifier to a BasisType constant.
115 static int GetType(char b_ident)
116 {
117 switch (b_ident)
118 {
119 case 'g': return GaussLegendre;
120 case 'G': return GaussLobatto;
121 case 's': return GaussLobatto;
122 case 'P': return Positive;
123 case 'u': return OpenUniform;
124 case 'U': return ClosedUniform;
125 case 'o': return OpenHalfUniform;
126 case 'S': return Serendipity;
127 case 'c': return ClosedGL;
128 case 'i': return IntegratedGLL;
129 }
130 MFEM_ABORT("unknown BasisType identifier");
131 return -1;
132 }
133};
134
135/** @brief Structure representing the matrices/tensors needed to evaluate (in
136 reference space) the values, gradients, divergences, or curls of a
137 FiniteElement at the quadrature points of a given IntegrationRule. */
138/** Objects of this type are typically created and owned by the respective
139 FiniteElement object. */
141{
142public:
143 /// The FiniteElement that created and owns this object.
144 /** This pointer is not owned. */
145 const class FiniteElement *FE;
146
147 /** @brief IntegrationRule that defines the quadrature points at which the
148 basis functions of the #FE are evaluated. */
149 /** This pointer is not owned. */
151
152 /// Type of data stored in the arrays #B, #Bt, #G, and #Gt.
153 enum Mode
154 {
155 /** @brief Full multidimensional representation which does not use tensor
156 product structure. The ordering of the degrees of freedom is as
157 defined by #FE */
159
160 /** @brief Tensor product representation using 1D matrices/tensors with
161 dimensions using 1D number of quadrature points and degrees of
162 freedom. */
163 /** When representing a vector-valued FiniteElement, two DofToQuad objects
164 are used to describe the "closed" and "open" 1D basis functions. */
166
167 /** @brief Full multidimensional representation which does not use tensor
168 product structure. The ordering of the degrees of freedom is the
169 same as TENSOR, but the sizes of B and G are the same as FULL.*/
171 };
172
173 /// Describes the contents of the #B, #Bt, #G, and #Gt arrays, see #Mode.
175
176 /** @brief Number of degrees of freedom = number of basis functions. When
177 #mode is TENSOR, this is the 1D number. */
178 int ndof;
179
180 /** @brief Number of quadrature points. When #mode is TENSOR, this is the 1D
181 number. */
182 int nqpt;
183
184 /// Basis functions evaluated at quadrature points.
185 /** The storage layout is column-major with dimensions:
186 - #nqpt x #ndof, for scalar elements, or
187 - #nqpt x dim x #ndof, for vector elements,
188
189 where
190
191 - dim = dimension of the finite element reference space when #mode is
192 FULL, and dim = 1 when #mode is TENSOR. */
194
195 /// Transpose of #B.
196 /** The storage layout is column-major with dimensions:
197 - #ndof x #nqpt, for scalar elements, or
198 - #ndof x #nqpt x dim, for vector elements. */
200
201 /** @brief Gradients/divergences/curls of basis functions evaluated at
202 quadrature points. */
203 /** The storage layout is column-major with dimensions:
204 - #nqpt x dim x #ndof, for scalar elements, or
205 - #nqpt x #ndof, for H(div) vector elements, or
206 - #nqpt x cdim x #ndof, for H(curl) vector elements,
207
208 where
209
210 - dim = dimension of the finite element reference space when #mode is
211 FULL, and 1 when #mode is TENSOR,
212 - cdim = 1/1/3 in 1D/2D/3D, respectively, when #mode is FULL, and cdim =
213 1 when #mode is TENSOR. */
215
216 /// Transpose of #G.
217 /** The storage layout is column-major with dimensions:
218 - #ndof x #nqpt x dim, for scalar elements, or
219 - #ndof x #nqpt, for H(div) vector elements, or
220 - #ndof x #nqpt x cdim, for H(curl) vector elements. */
222
223 /// Returns absolute value of the maps
224 DofToQuad Abs() const;
225};
226
227/// Describes the function space on each element
229{
230public:
231 enum
232 {
233 Pk, ///< Polynomials of order k
234 Qk, ///< Tensor products of polynomials of order k
235 rQk, ///< Refined tensor products of polynomials of order k
236 Uk ///< Rational polynomials of order k
237 };
238};
239
240class ElementTransformation;
241class Coefficient;
242class VectorCoefficient;
243class MatrixCoefficient;
244
245/// Abstract class for all finite elements.
247{
248protected:
249 int dim; ///< Dimension of reference space
250 int vdim; ///< Vector dimension of vector-valued basis functions
251 int cdim; ///< Dimension of curl for vector-valued basis functions
252 Geometry::Type geom_type; ///< Geometry::Type of the reference element
255 mutable
256 int dof, ///< Number of degrees of freedom
257 order; ///< Order/degree of the shape functions
258 mutable int orders[Geometry::MaxDim]; ///< Anisotropic orders
260#ifndef MFEM_THREAD_SAFE
261 mutable DenseMatrix vshape; // Dof x Dim
262#endif
263 /// Container for all DofToQuad objects created by the FiniteElement.
264 /** Multiple DofToQuad objects may be needed when different quadrature rules
265 or different DofToQuad::Mode are used. */
267
268public:
269 /// Enumeration for range_type and deriv_range_type
271
272 /** @brief Enumeration for MapType: defines how reference functions are
273 mapped to physical space.
274
275 A reference function $ \hat u(\hat x) $ can be mapped to a function
276 $ u(x) $ on a general physical element in following ways:
277 - $ x = T(\hat x) $ is the image of the reference point $ \hat x $
278 - $ J = J(\hat x) $ is the Jacobian matrix of the transformation T
279 - $ w = w(\hat x) = det(J) $ is the transformation weight factor for square J
280 - $ w = w(\hat x) = det(J^t J)^{1/2} $ is the transformation weight factor in general
281 */
283 {
284 UNKNOWN_MAP_TYPE = -1, /**< Used to distinguish an unset MapType variable
285 from the known values below. */
286 VALUE, /**< For scalar fields; preserves point values
287 $ u(x) = \hat u(\hat x) $ @anchor map_type_value */
288 INTEGRAL, /**< For scalar fields; preserves volume integrals
289 $ u(x) = (1/w) \hat u(\hat x) $ */
290 H_DIV, /**< For vector fields; preserves surface integrals of the
291 normal component $ u(x) = (J/w) \hat u(\hat x) $ */
292 H_CURL /**< For vector fields; preserves line integrals of the
293 tangential component
294 $ u(x) = J^{-t} \hat u(\hat x) $ (square J),
295 $ u(x) = J(J^t J)^{-1} \hat u(\hat x) $ (general J) */
296 };
297
298 /** @brief Enumeration for DerivType: defines which derivative method
299 is implemented.
300
301 Each FiniteElement class implements up to one type of derivative. The
302 value returned by GetDerivType() indicates which derivative method is
303 implemented.
304 */
306 {
307 NONE, ///< No derivatives implemented
308 GRAD, ///< Implements CalcDShape methods
309 DIV, ///< Implements CalcDivShape methods
310 CURL ///< Implements CalcCurlShape methods
311 };
312
313 /** @brief Construct FiniteElement with given
314 @param D Reference space dimension
315 @param G Geometry type (of type Geometry::Type)
316 @param Do Number of degrees of freedom in the FiniteElement
317 @param O Order/degree of the FiniteElement
318 @param F FunctionSpace type of the FiniteElement
319 */
320 FiniteElement(int D, Geometry::Type G, int Do, int O,
321 int F = FunctionSpace::Pk);
322
323 /// Returns the reference space dimension for the finite element.
324 int GetDim() const { return dim; }
325
326 /** @brief Returns the vector dimension for vector-valued finite elements,
327 which is also the dimension of the interpolation operation. */
328 int GetRangeDim() const { return vdim; }
329
330 /// Returns the dimension of the curl for vector-valued finite elements.
331 int GetCurlDim() const { return cdim; }
332
333 /// Returns the Geometry::Type of the reference element.
335
336 /// Returns the number of degrees of freedom in the finite element.
337 int GetDof() const { return dof; }
338
339 /** @brief Returns the order of the finite element. In the case of
340 anisotropic orders, returns the maximum order. */
341 int GetOrder() const { return order; }
342
343 /** @brief Returns true if the FiniteElement basis *may be using* different
344 orders/degrees in different spatial directions. */
345 bool HasAnisotropicOrders() const { return orders[0] != -1; }
346
347 /// Returns an array containing the anisotropic orders/degrees.
348 const int *GetAnisotropicOrders() const { return orders; }
349
350 /// Returns the type of FunctionSpace on the element.
351 int Space() const { return func_space; }
352
353 /// Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
354 int GetRangeType() const { return range_type; }
355
356 /** @brief Returns the FiniteElement::RangeType of the element derivative, either
357 SCALAR or VECTOR. */
358 int GetDerivRangeType() const { return deriv_range_type; }
359
360 /** @brief Returns the FiniteElement::MapType of the element describing how reference
361 functions are mapped to physical space, one of {VALUE, INTEGRAL
362 H_DIV, H_CURL}. */
363 int GetMapType() const { return map_type; }
364
365 /** @brief Returns the FiniteElement::DerivType of the element describing the
366 spatial derivative method implemented, one of {NONE, GRAD,
367 DIV, CURL}. */
368 int GetDerivType() const { return deriv_type; }
369
370 /** @brief Returns the FiniteElement::DerivType of the element describing how
371 reference function derivatives are mapped to physical space, one of {VALUE,
372 INTEGRAL, H_DIV, H_CURL}. */
373 int GetDerivMapType() const { return deriv_map_type; }
374
375 /** @brief Evaluate the values of all shape functions of a scalar finite
376 element in reference space at the given point @a ip. */
377 /** The size (#dof) of the result Vector @a shape must be set in advance. */
378 virtual void CalcShape(const IntegrationPoint &ip,
379 Vector &shape) const = 0;
380
381 /** @brief Evaluate the values of all shape functions of a scalar finite
382 element in physical space at the point described by @a Trans. */
383 /** The size (#dof) of the result Vector @a shape must be set in advance. */
384 void CalcPhysShape(ElementTransformation &Trans, Vector &shape) const;
385
386 /** @brief Evaluate the gradients of all shape functions of a scalar finite
387 element in reference space at the given point @a ip. */
388 /** Each row of the result DenseMatrix @a dshape contains the derivatives of
389 one shape function. The size (#dof x #dim) of @a dshape must be set in
390 advance. */
391 virtual void CalcDShape(const IntegrationPoint &ip,
392 DenseMatrix &dshape) const = 0;
393
394 /** @brief Evaluate the gradients of all shape functions of a scalar finite
395 element in physical space at the point described by @a Trans. */
396 /** Each row of the result DenseMatrix @a dshape contains the derivatives of
397 one shape function. The size (#dof x SDim) of @a dshape must be set in
398 advance, where SDim >= #dim is the physical space dimension as described
399 by @a Trans. */
400 void CalcPhysDShape(ElementTransformation &Trans, DenseMatrix &dshape) const;
401
402 /// Get a const reference to the nodes of the element
403 const IntegrationRule & GetNodes() const { return Nodes; }
404
405 /** @brief Evaluate the Hessians of all shape functions of a scalar finite
406 element in reference space at the given point @a ip. */
407 /** Each row of the result DenseMatrix @a Hessian contains upper triangular
408 part of the Hessian of one shape function.
409 The order in 2D is {u_xx, u_xy, u_yy}.
410 The size (#dof x (#dim (#dim+1)/2) of @a Hessian must be set in advance.*/
411 virtual void CalcHessian(const IntegrationPoint &ip,
412 DenseMatrix &Hessian) const;
413
414 /** @brief Evaluate the Hessian of all shape functions of a scalar finite
415 element in physical space at the given point @a ip. */
416 /** The size (#dof, #dim*(#dim+1)/2) of @a Hessian must be set in advance. */
418 DenseMatrix& Hessian) const;
419
420 /** @brief Evaluate the Laplacian of all shape functions of a scalar finite
421 element in physical space at the given point @a ip. */
422 /** The size (#dof) of @a Laplacian must be set in advance. */
424 Vector& Laplacian) const;
425
426 /** @brief Evaluate the Laplacian of all shape functions of a scalar finite
427 element in physical space at the given point @a ip. */
428 /** The size (#dof) of @a Laplacian must be set in advance. */
430 Vector& Laplacian) const;
431
432 /** @brief Evaluate the values of all shape functions of a *vector* finite
433 element in reference space at the given point @a ip. */
434 /** Each row of the result DenseMatrix @a shape contains the components of
435 one vector shape function. The size (#dof x #dim) of @a shape must be set
436 in advance. */
437 virtual void CalcVShape(const IntegrationPoint &ip,
438 DenseMatrix &shape) const;
439
440 /** @brief Evaluate the values of all shape functions of a *vector* finite
441 element in physical space at the point described by @a Trans. */
442 /** Each row of the result DenseMatrix @a shape contains the components of
443 one vector shape function. The size (#dof x SDim) of @a shape must be set
444 in advance, where SDim >= #dim is the physical space dimension as
445 described by @a Trans. */
446 virtual void CalcVShape(ElementTransformation &Trans,
447 DenseMatrix &shape) const;
448
449 /// Equivalent to the CalcVShape() method with the same arguments.
451 { CalcVShape(Trans, shape); }
452
453 /** @brief Evaluate the divergence of all shape functions of a *vector*
454 finite element in reference space at the given point @a ip. */
455 /** The size (#dof) of the result Vector @a divshape must be set in advance.
456 */
457 virtual void CalcDivShape(const IntegrationPoint &ip,
458 Vector &divshape) const;
459
460 /** @brief Evaluate the divergence of all shape functions of a *vector*
461 finite element in physical space at the point described by @a Trans. */
462 /** The size (#dof) of the result Vector @a divshape must be set in advance.
463 */
464 void CalcPhysDivShape(ElementTransformation &Trans, Vector &divshape) const;
465
466 /** @brief Evaluate the curl of all shape functions of a *vector* finite
467 element in reference space at the given point @a ip. */
468 /** Each row of the result DenseMatrix @a curl_shape contains the components
469 of the curl of one vector shape function. The size (#dof x CDim) of
470 @a curl_shape must be set in advance, where CDim = 3 for #dim = 3 and
471 CDim = 1 for #dim = 2. */
472 virtual void CalcCurlShape(const IntegrationPoint &ip,
473 DenseMatrix &curl_shape) const;
474
475 /** @brief Evaluate the curl of all shape functions of a *vector* finite
476 element in physical space at the point described by @a Trans. */
477 /** Each row of the result DenseMatrix @a curl_shape contains the components
478 of the curl of one vector shape function. The size (#dof x CDim) of
479 @a curl_shape must be set in advance, where CDim = 3 for #dim = 3 and
480 CDim = 1 for #dim = 2. */
481 virtual void CalcPhysCurlShape(ElementTransformation &Trans,
482 DenseMatrix &curl_shape) const;
483
484 /** @brief Get the dofs associated with the given @a face.
485 @a *dofs is set to an internal array of the local dofc on the
486 face, while *ndofs is set to the number of dofs on that face.
487 */
488 virtual void GetFaceDofs(int face, int **dofs, int *ndofs) const;
489
490 /** @brief Return the local interpolation matrix @a I (Dof x Dof) where the
491 fine element is the image of the base geometry under the given
492 transformation. */
494 DenseMatrix &I) const;
495
496 /** @brief Return a local restriction matrix @a R (Dof x Dof) mapping fine
497 dofs to coarse dofs.
498
499 The fine element is the image of the base geometry under the given
500 transformation, @a Trans.
501
502 The assumption in this method is that a subset of the coarse dofs can be
503 expressed only in terms of the dofs of the given fine element.
504
505 Rows in @a R corresponding to coarse dofs that cannot be expressed in
506 terms of the fine dofs will be marked as invalid by setting the first
507 entry (column 0) in the row to infinity().
508
509 This method assumes that the dimensions of @a R are set before it is
510 called. */
511 virtual void GetLocalRestriction(ElementTransformation &Trans,
512 DenseMatrix &R) const;
513
514 /** @brief Return interpolation matrix, @a I, which maps dofs from a coarse
515 element, @a fe, to the fine dofs on @a this finite element. */
516 /** @a Trans represents the mapping from the reference element of @a this
517 element into a subset of the reference space of the element @a fe, thus
518 allowing the "coarse" FiniteElement to be different from the "fine"
519 FiniteElement as when h-refinement is combined with p-refinement or
520 p-derefinement. It is assumed that both finite elements use the same
521 FiniteElement::MapType. */
522 virtual void GetTransferMatrix(const FiniteElement &fe,
524 DenseMatrix &I) const;
525
526 /** @brief Given a coefficient and a transformation, compute its projection
527 (approximation) in the local finite dimensional space in terms
528 of the degrees of freedom. */
529 /** The approximation used to project is usually local interpolation of
530 degrees of freedom. The derived class could use other methods not
531 implemented yet, e.g. local L2 projection. */
532 virtual void Project(Coefficient &coeff,
533 ElementTransformation &Trans, Vector &dofs) const;
534
535 /** @brief Given a vector coefficient and a transformation, compute its
536 projection (approximation) in the local finite dimensional space
537 in terms of the degrees of freedom. (VectorFiniteElements) */
538 /** The approximation used to project is usually local interpolation of
539 degrees of freedom. The derived class could use other methods not
540 implemented yet, e.g. local L2 projection. */
541 virtual void Project(VectorCoefficient &vc,
542 ElementTransformation &Trans, Vector &dofs) const;
543
544 /** @brief Given a vector of values at the finite element nodes and a
545 transformation, compute its projection (approximation) in the local
546 finite dimensional space in terms of the degrees of freedom. Valid for
547 VectorFiniteElements. */
548 virtual void ProjectFromNodes(Vector &vc, ElementTransformation &Trans,
549 Vector &dofs) const;
550
551 /** @brief Given a matrix coefficient and a transformation, compute an
552 approximation ("projection") in the local finite dimensional space in
553 terms of the degrees of freedom. For VectorFiniteElements, the rows of
554 the coefficient are projected in the vector space. */
555 virtual void ProjectMatrixCoefficient(
556 MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const;
557
558 /** @brief Project a delta function centered on the given @a vertex in
559 the local finite dimensional space represented by the @a dofs. */
560 virtual void ProjectDelta(int vertex, Vector &dofs) const;
561
562 /** @brief Compute the embedding/projection matrix from the given
563 FiniteElement onto 'this' FiniteElement. The ElementTransformation is
564 included to support cases when the projection depends on it. */
565 virtual void Project(const FiniteElement &fe, ElementTransformation &Trans,
566 DenseMatrix &I) const;
567
568 /** @brief Compute the discrete gradient matrix from the given FiniteElement
569 onto 'this' FiniteElement. The ElementTransformation is included to
570 support cases when the matrix depends on it. */
571 virtual void ProjectGrad(const FiniteElement &fe,
573 DenseMatrix &grad) const;
574
575 /** @brief Compute the discrete curl matrix from the given FiniteElement onto
576 'this' FiniteElement. The ElementTransformation is included to support
577 cases when the matrix depends on it. */
578 virtual void ProjectCurl(const FiniteElement &fe,
580 DenseMatrix &curl) const;
581
582 /** @brief Compute the discrete divergence matrix from the given
583 FiniteElement onto 'this' FiniteElement. The ElementTransformation is
584 included to support cases when the matrix depends on it. */
585 virtual void ProjectDiv(const FiniteElement &fe,
587 DenseMatrix &div) const;
588
589 /** @brief Return a DofToQuad structure corresponding to the given
590 IntegrationRule using the given DofToQuad::Mode. */
591 /** See the documentation for DofToQuad for more details. */
592 virtual const DofToQuad &GetDofToQuad(const IntegrationRule &ir,
593 DofToQuad::Mode mode) const;
594
595
596 /** @brief Return the mapping from lexicographic face DOFs to lexicographic
597 element DOFs for the given local face @a face_id. */
598 /** Given the @a ith DOF (lexicographically ordered) on the face referenced
599 by @a face_id, face_map[i] gives the corresponding index of the DOF in
600 the element (also lexicographically ordered).
601
602 @note For L2 spaces, this is only well-defined for "closed" bases such as
603 the Gauss-Lobatto or Bernstein (positive) bases.
604
605 @warning GetFaceMap() is currently only implemented for tensor-product
606 (quadrilateral and hexahedral) elements. Its functionality may change
607 when simplex elements are supported in the future. */
608 virtual void GetFaceMap(const int face_id, Array<int> &face_map) const;
609
610 /** @brief Return a DoF transformation object for this particular type of
611 basis.
612 */
614 { return NULL; }
615
616 /// Deconstruct the FiniteElement
617 virtual ~FiniteElement();
618
619 /** @brief Return true if the BasisType of @a b_type is closed
620 (has Quadrature1D points on the boundary). */
621 static bool IsClosedType(int b_type)
622 {
623 const int q_type = BasisType::GetQuadrature1D(b_type);
624 return ((q_type != Quadrature1D::Invalid) &&
626 }
627
628 /** @brief Return true if the BasisType of @a b_type is open
629 (doesn't have Quadrature1D points on the boundary). */
630 static bool IsOpenType(int b_type)
631 {
632 const int q_type = BasisType::GetQuadrature1D(b_type);
633 return ((q_type != Quadrature1D::Invalid) &&
635 }
636
637 /** @brief Ensure that the BasisType of @a b_type is closed
638 (has Quadrature1D points on the boundary). */
639 static int VerifyClosed(int b_type)
640 {
641 MFEM_VERIFY(IsClosedType(b_type),
642 "invalid closed basis type: " << b_type);
643 return b_type;
644 }
645
646 /** @brief Ensure that the BasisType of @a b_type is open
647 (doesn't have Quadrature1D points on the boundary). */
648 static int VerifyOpen(int b_type)
649 {
650 MFEM_VERIFY(IsOpenType(b_type), "invalid open basis type: " << b_type);
651 return b_type;
652 }
653
654 /** @brief Ensure that the BasisType of @a b_type nodal
655 (satisfies the interpolation property). */
656 static int VerifyNodal(int b_type)
657 {
658 return BasisType::CheckNodal(b_type);
659 }
660};
661
662/** @brief Class for finite elements with basis functions
663 that return scalar values. */
665{
666protected:
668 {
669 MFEM_VERIFY(fe.GetRangeType() == SCALAR,
670 "'fe' must be a ScalarFiniteElement");
671 return static_cast<const ScalarFiniteElement &>(fe);
672 }
673
674public:
675 /** @brief Construct ScalarFiniteElement with given
676 @param D Reference space dimension
677 @param G Geometry type (of type Geometry::Type)
678 @param Do Number of degrees of freedom in the FiniteElement
679 @param O Order/degree of the FiniteElement
680 @param F FunctionSpace type of the FiniteElement
681 */
682 ScalarFiniteElement(int D, Geometry::Type G, int Do, int O,
683 int F = FunctionSpace::Pk)
684 : FiniteElement(D, G, Do, O, F)
686
687 /** @brief Set the FiniteElement::MapType of the element to either VALUE or
688 INTEGRAL. Also sets the FiniteElement::DerivType to GRAD if the
689 FiniteElement::MapType is VALUE. */
690 virtual void SetMapType(int M)
691 {
692 MFEM_VERIFY(M == VALUE || M == INTEGRAL, "unknown MapType");
693 map_type = M;
694 deriv_type = (M == VALUE) ? GRAD : NONE;
695 }
696
697 /** @brief Get the matrix @a I that defines nodal interpolation
698 @a between this element and the refined element @a fine_fe. */
700 DenseMatrix &I,
701 const ScalarFiniteElement &fine_fe) const;
702
703 /** @brief Get matrix @a I "Interpolation" defined through local
704 L2-projection in the space defined by the @a fine_fe. */
705 /** If the "fine" elements cannot represent all basis functions of the
706 "coarse" element, then boundary values from different sub-elements are
707 generally different. */
709 DenseMatrix &I,
710 const ScalarFiniteElement &fine_fe) const;
711
712 /** @brief Get restriction matrix @a R defined through local L2-projection
713 in the space defined by the @a coarse_fe. */
714 /** If the "fine" elements cannot represent all basis functions of the
715 "coarse" element, then boundary values from different sub-elements are
716 generally different. */
718 DenseMatrix &R,
719 const ScalarFiniteElement &coarse_fe) const;
720};
721
722/// Class for standard nodal finite elements.
724{
725private:
726 /// Create and cache the LEXICOGRAPHIC_FULL DofToQuad maps.
727 void CreateLexicographicFullMap(const IntegrationRule &ir) const;
728protected:
730 void ProjectCurl_2D(const FiniteElement &fe,
732 DenseMatrix &curl) const;
733
734public:
735 /** @brief Construct NodalFiniteElement with given
736 @param D Reference space dimension
737 @param G Geometry type (of type Geometry::Type)
738 @param Do Number of degrees of freedom in the FiniteElement
739 @param O Order/degree of the FiniteElement
740 @param F FunctionSpace type of the FiniteElement
741 */
742 NodalFiniteElement(int D, Geometry::Type G, int Do, int O,
743 int F = FunctionSpace::Pk)
744 : ScalarFiniteElement(D, G, Do, O, F) { }
745
746 const DofToQuad &GetDofToQuad(const IntegrationRule &ir,
747 DofToQuad::Mode mode) const override;
748
750 DenseMatrix &I) const override
751 { NodalLocalInterpolation(Trans, I, *this); }
752
754 DenseMatrix &R) const override;
755
758 DenseMatrix &I) const override
759 { CheckScalarFE(fe).NodalLocalInterpolation(Trans, I, *this); }
760
761 void Project(Coefficient &coeff,
762 ElementTransformation &Trans, Vector &dofs) const override;
763
764 void Project(VectorCoefficient &vc,
765 ElementTransformation &Trans, Vector &dofs) const override;
766
767 // (mc.height x mc.width) @ DOFs -> (Dof x mc.width x mc.height) in dofs
769 MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const override;
770
771 void Project(const FiniteElement &fe, ElementTransformation &Trans,
772 DenseMatrix &I) const override;
773
774 void ProjectGrad(const FiniteElement &fe,
776 DenseMatrix &grad) const override;
777
778 void ProjectDiv(const FiniteElement &fe,
780 DenseMatrix &div) const override;
781
782 /** @brief Get an Array<int> that maps lexicographically ordered indices to
783 the indices of the respective nodes/dofs/basis functions.
784
785 Lexicographic ordering of nodes is defined in terms of reference-space
786 coordinates (x,y,z). Lexicographically ordered nodes are listed first in
787 order of increasing x-coordinate, and then in order of increasing
788 y-coordinate, and finally in order of increasing z-coordinate.
789
790 For example, the six nodes of a quadratic triangle are lexicographically
791 ordered as follows:
792
793 5
794 |\
795 3 4
796 | \
797 0-1-2
798
799 The resulting array may be empty if the DOFs are already ordered
800 lexicographically, or if the finite element does not support creating
801 this permutation. The array returned is the same as the array given by
802 TensorBasisElement::GetDofMap, but it is also available for non-tensor
803 elements. */
805
806 /// Given a lexicographically ordered Vector @a dofs, containing @a ncomp
807 /// components of the size of the scalar FiniteElement, reorder its entries
808 /// into native (H1) ordering.
809 /// The function assumes that GetLexicographicOrdering() is not empty.
810 void ReorderLexToNative(int ncomp, Vector &dofs) const;
811};
812
813/** @brief Intermediate class for finite elements whose basis functions return
814 vector values. */
816{
817 // Hide the scalar functions CalcShape and CalcDShape.
818private:
819 /// Overrides the scalar CalcShape function to print an error.
820 void CalcShape(const IntegrationPoint &ip,
821 Vector &shape) const override;
822
823 /// Overrides the scalar CalcDShape function to print an error.
824 void CalcDShape(const IntegrationPoint &ip,
825 DenseMatrix &dshape) const override;
826
827protected:
829#ifndef MFEM_THREAD_SAFE
832#endif
833 void SetDerivMembers();
834
836 DenseMatrix &shape) const;
837
839 DenseMatrix &shape) const;
840
841 /** @brief Project a vector coefficient onto the RT basis functions
842 @param nk Face normal vectors for this element type
843 @param d2n Offset into nk for each degree of freedom
844 @param vc Vector coefficient to be projected
845 @param Trans Transformation from reference to physical coordinates
846 @param dofs Expansion coefficients for the approximation of vc
847 */
848 void Project_RT(const real_t *nk, const Array<int> &d2n,
850 Vector &dofs) const;
851
852 /// Projects the vector of values given at FE nodes to RT space
853 /** Project vector values onto the RT basis functions
854 @param nk Face normal vectors for this element type
855 @param d2n Offset into nk for each degree of freedom
856 @param vc Vector values at each interpolation point
857 @param Trans Transformation from reference to physical coordinates
858 @param dofs Expansion coefficients for the approximation of vc
859 */
860 void Project_RT(const real_t *nk, const Array<int> &d2n,
861 Vector &vc, ElementTransformation &Trans,
862 Vector &dofs) const;
863
864 /// Project the rows of the matrix coefficient in an RT space
866 const real_t *nk, const Array<int> &d2n,
867 MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const;
868
869 /** @brief Project vector-valued basis functions onto the RT basis functions
870 @param nk Face normal vectors for this element type
871 @param d2n Offset into nk for each degree of freedom
872 @param fe Vector-valued finite element basis
873 @param Trans Transformation from reference to physical coordinates
874 @param I Expansion coefficients for the approximation of each basis
875 function
876
877 Note: If the FiniteElement, fe, is scalar-valued the projection will
878 assume that a FiniteElementSpace is being used to define a vector
879 field using the scalar basis functions for each component of the
880 vector field.
881 */
882 void Project_RT(const real_t *nk, const Array<int> &d2n,
883 const FiniteElement &fe, ElementTransformation &Trans,
884 DenseMatrix &I) const;
885
886 // rotated gradient in 2D
887 void ProjectGrad_RT(const real_t *nk, const Array<int> &d2n,
888 const FiniteElement &fe, ElementTransformation &Trans,
889 DenseMatrix &grad) const;
890
891 // Compute the curl as a discrete operator from ND FE (fe) to ND FE (this).
892 // The natural FE for the range is RT, so this is an approximation.
893 void ProjectCurl_ND(const real_t *tk, const Array<int> &d2t,
894 const FiniteElement &fe, ElementTransformation &Trans,
895 DenseMatrix &curl) const;
896
897 void ProjectCurl_RT(const real_t *nk, const Array<int> &d2n,
898 const FiniteElement &fe, ElementTransformation &Trans,
899 DenseMatrix &curl) const;
900
901 /** @brief Project a vector coefficient onto the ND basis functions
902 @param tk Edge tangent vectors for this element type
903 @param d2t Offset into tk for each degree of freedom
904 @param vc Vector coefficient to be projected
905 @param Trans Transformation from reference to physical coordinates
906 @param dofs Expansion coefficients for the approximation of vc
907 */
908 void Project_ND(const real_t *tk, const Array<int> &d2t,
910 Vector &dofs) const;
911
912 /// Projects the vector of values given at FE nodes to ND space
913 /** Project vector values onto the ND basis functions
914 @param tk Edge tangent vectors for this element type
915 @param d2t Offset into tk for each degree of freedom
916 @param vc Vector values at each interpolation point
917 @param Trans Transformation from reference to physical coordinates
918 @param dofs Expansion coefficients for the approximation of vc
919 */
920 void Project_ND(const real_t *tk, const Array<int> &d2t,
921 Vector &vc, ElementTransformation &Trans,
922 Vector &dofs) const;
923
924 /// Project the rows of the matrix coefficient in an ND space
926 const real_t *tk, const Array<int> &d2t,
927 MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const;
928
929 /** @brief Project vector-valued basis functions onto the ND basis functions
930 @param tk Edge tangent vectors for this element type
931 @param d2t Offset into tk for each degree of freedom
932 @param fe Vector-valued finite element basis
933 @param Trans Transformation from reference to physical coordinates
934 @param I Expansion coefficients for the approximation of each basis
935 function
936
937 Note: If the FiniteElement, fe, is scalar-valued the projection will
938 assume that a FiniteElementSpace is being used to define a vector
939 field using the scalar basis functions for each component of the
940 vector field.
941 */
942 void Project_ND(const real_t *tk, const Array<int> &d2t,
943 const FiniteElement &fe, ElementTransformation &Trans,
944 DenseMatrix &I) const;
945
946 void ProjectGrad_ND(const real_t *tk, const Array<int> &d2t,
947 const FiniteElement &fe, ElementTransformation &Trans,
948 DenseMatrix &grad) const;
949
952 DenseMatrix &I) const;
953
955 const real_t *nk, const Array<int> &d2n,
957 DenseMatrix &I) const;
958
961 DenseMatrix &I) const;
962
964 const real_t *tk, const Array<int> &d2t,
966 DenseMatrix &I) const;
967
968 void LocalRestriction_RT(const real_t *nk, const Array<int> &d2n,
970 DenseMatrix &R) const;
971
972 void LocalRestriction_ND(const real_t *tk, const Array<int> &d2t,
974 DenseMatrix &R) const;
975
977 {
978 if (fe.GetRangeType() != VECTOR)
979 { mfem_error("'fe' must be a VectorFiniteElement"); }
980 return static_cast<const VectorFiniteElement &>(fe);
981 }
982
983public:
984 VectorFiniteElement(int D, Geometry::Type G, int Do, int O, int M,
985 int F = FunctionSpace::Pk);
986};
987
988/// @brief Class for computing 1D special polynomials and their associated basis
989/// functions
991{
992public:
993 /// One-dimensional basis evaluation type
995 {
996 ChangeOfBasis = 0, ///< Use change of basis, O(p^2) Evals
997 Barycentric = 1, ///< Use barycentric Lagrangian interpolation, O(p) Evals
998 Positive = 2, ///< Fast evaluation of Bernstein polynomials
999 Integrated = 3, ///< Integrated indicator functions (cf. Gerritsma)
1000 NumEvalTypes = 4 ///< Keep count of the number of eval types
1002
1003 /// @brief Class for evaluating 1D nodal, positive (Bernstein), or integrated
1004 /// (Gerritsma) bases.
1005 class Basis
1006 {
1007 private:
1008 EvalType etype; ///< Determines how the basis functions should be evaluated.
1010 mutable Vector x, w;
1011 /// The following data members are used for "integrated basis type", which
1012 /// is defined in terms of nodal basis of one degree higher.
1013 ///@{
1014 mutable Vector u_aux, d_aux, d2_aux;
1015 ///@}
1016 /// @brief An auxiliary nodal basis used to evaluate the integrated basis.
1017 /// This member variable is NULL whenever etype != Integrated.
1018 Basis *auxiliary_basis;
1019 /// Should the integrated basis functions be scaled? See ScaleIntegrated.
1020 bool scale_integrated;
1021
1022 public:
1023 /// Create a nodal or positive (Bernstein) basis of degree @a p
1024 Basis(const int p, const real_t *nodes, EvalType etype = Barycentric);
1025 /// Evaluate the basis functions at point @a x in [0,1]
1026 void Eval(const real_t x, Vector &u) const;
1027 /// @brief Evaluate the basis functions and their derivatives at point @a
1028 /// x in [0,1]
1029 void Eval(const real_t x, Vector &u, Vector &d) const;
1030 /// @brief Evaluate the basis functions and their first two derivatives at
1031 /// point @a x in [0,1]
1032 void Eval(const real_t x, Vector &u, Vector &d, Vector &d2) const;
1033 /// @brief Evaluate the "integrated" basis type using pre-computed closed
1034 /// basis derivatives.
1035 ///
1036 /// This basis is given by the negative partial sum of the corresponding
1037 /// closed basis derivatives. The closed basis derivatives are given by @a
1038 /// d, and the result is stored in @a i.
1039 void EvalIntegrated(const Vector &d, Vector &i) const;
1040 /// @brief Set whether the "integrated" basis should be scaled by the
1041 /// subcell sizes. Has no effect for non-integrated bases.
1042 ///
1043 /// Generally, this should be true for mfem::FiniteElement::MapType VALUE
1044 /// and false for all other map types. If this option is enabled, the
1045 /// basis functions will be scaled by the widths of the subintervals, so
1046 /// that the basis functions represent mean values. Otherwise, the basis
1047 /// functions represent integrated values.
1048 void ScaleIntegrated(bool scale_integrated_);
1049 /// Returns true if the basis is "integrated", false otherwise.
1050 bool IsIntegratedType() const { return etype == Integrated; }
1051 ~Basis();
1052 };
1053
1054private:
1055 /// key: (btype, p), value: underlying storage Array
1056 typedef std::unordered_map<std::pair<int, int>,
1057 std::unique_ptr<Basis>, PairHasher>
1058 BasisMap;
1059 /// key: (btype, p), value: underlying storage Array
1060 typedef std::unordered_map<std::pair<int, int>,
1061 std::unique_ptr<Array<real_t>>, PairHasher>
1062 PointsMap;
1063
1064 MemoryType h_mt;
1065 PointsMap points_container;
1066 BasisMap bases_container;
1067
1068 static Array2D<int> binom;
1069
1070 static void CalcMono(const int p, const real_t x, real_t *u);
1071 static void CalcMono(const int p, const real_t x, real_t *u, real_t *d);
1072
1073 static void CalcChebyshev(const int p, const real_t x, real_t *u);
1074 static void CalcChebyshev(const int p, const real_t x, real_t *u, real_t *d);
1075 static void CalcChebyshev(const int p, const real_t x, real_t *u, real_t *d,
1076 real_t *dd);
1077
1078 QuadratureFunctions1D quad_func;
1079
1080public:
1082
1083 /** @brief Get a pointer to an array containing the binomial coefficients "p
1084 choose k" for k=0,...,p for the given p. */
1085 static const int *Binom(const int p);
1086
1087 /** @brief Get the coordinates of the points of the given BasisType,
1088 @a btype.
1089
1090 @param[in] p The polynomial degree; the number of points is `p+1`.
1091 @param[in] btype The BasisType.
1092
1093 @return A pointer to an array containing the `p+1` coordinates of the
1094 points. Returns NULL if the BasisType has no associated set of
1095 points. */
1096 const Array<real_t>* GetPointsArray(const int p, const int btype);
1097
1098 /** @brief Get the coordinates of the points of the given BasisType,
1099 @a btype.
1100
1101 @param[in] p The polynomial degree; the number of points is `p+1`.
1102 @param[in] btype The BasisType.
1103 @param[in] on_device true if the requested pointer should be accessible
1104 from the device.
1105
1106 @return A pointer to an array containing the `p+1` coordinates of the
1107 points. Returns NULL if the BasisType has no associated set of
1108 points. */
1109 const real_t *GetPoints(const int p, const int btype,
1110 bool on_device = false)
1111 {
1112 return GetPointsArray(p, btype)->Read(on_device);
1113 }
1114
1115 /// Get coordinates of an open (GaussLegendre) set of points if degree @a p
1116 const real_t *OpenPoints(const int p,
1117 const int btype = BasisType::GaussLegendre,
1118 bool on_device = false)
1119 {
1120 return GetPoints(p, btype, on_device);
1121 }
1122
1123 /// Get coordinates of a closed (GaussLegendre) set of points if degree @a p
1124 const real_t *ClosedPoints(const int p,
1125 const int btype = BasisType::GaussLobatto,
1126 bool on_device = false)
1127 {
1128 return GetPoints(p, btype, on_device);
1129 }
1130
1131 /** @brief Get a Poly_1D::Basis object of the given degree and BasisType,
1132 @a btype.
1133
1134 @param[in] p The polynomial degree of the basis.
1135 @param[in] btype The BasisType.
1136
1137 @return A reference to an object of type Poly_1D::Basis that represents
1138 the requested basis type. */
1139 Basis &GetBasis(const int p, const int btype);
1140
1141 /** @brief Evaluate the values of a hierarchical 1D basis at point x
1142 hierarchical = k-th basis function is degree k polynomial */
1143 static void CalcBasis(const int p, const real_t x, real_t *u)
1144 // { CalcMono(p, x, u); }
1145 // Bernstein basis is not hierarchical --> does not work for triangles
1146 // and tetrahedra
1147 // { CalcBernstein(p, x, u); }
1148 // { CalcLegendre(p, x, u); }
1149 { CalcChebyshev(p, x, u); }
1150
1151 /** @brief Evaluate the values of a hierarchical 1D basis at point x
1152 hierarchical = k-th basis function is degree k polynomial */
1153 static void CalcBasis(const int p, const real_t x, Vector &u)
1154 { CalcBasis(p, x, u.GetData()); }
1155
1156 /// Evaluate the values and derivatives of a hierarchical 1D basis at point @a x
1157 static void CalcBasis(const int p, const real_t x, real_t *u, real_t *d)
1158 // { CalcMono(p, x, u, d); }
1159 // { CalcBernstein(p, x, u, d); }
1160 // { CalcLegendre(p, x, u, d); }
1161 { CalcChebyshev(p, x, u, d); }
1162
1163 /** @brief Evaluate the values and derivatives of a hierarchical 1D basis at
1164 point @a x. */
1165 static void CalcBasis(const int p, const real_t x, Vector &u, Vector &d)
1166 { CalcBasis(p, x, u.GetData(), d.GetData()); }
1167
1168 /// Evaluate the values, derivatives and second derivatives of a hierarchical 1D basis at point x
1169 static void CalcBasis(const int p, const real_t x, real_t *u, real_t *d,
1170 real_t *dd)
1171 // { CalcMono(p, x, u, d); }
1172 // { CalcBernstein(p, x, u, d); }
1173 // { CalcLegendre(p, x, u, d); }
1174 { CalcChebyshev(p, x, u, d, dd); }
1175
1176 /** @brief Evaluate the values, derivatives and second derivatives of a
1177 hierarchical 1D basis at point @a x. */
1178 static void CalcBasis(const int p, const real_t x, Vector &u, Vector &d,
1179 Vector &dd)
1180 { CalcBasis(p, x, u.GetData(), d.GetData(), dd.GetData()); }
1181
1182 /// Evaluate a representation of a Delta function at point x
1183 static real_t CalcDelta(const int p, const real_t x)
1184 { return pow(x, (real_t) p); }
1185
1186 /** @brief Compute the points for the Chebyshev polynomials of order @a p
1187 and place them in the already allocated @a x array. */
1188 static void ChebyshevPoints(const int p, real_t *x);
1189
1190 /** @brief Compute the @a p terms in the expansion of the binomial (x + y)^p
1191 and store them in the already allocated @a u array. */
1192 static void CalcBinomTerms(const int p, const real_t x, const real_t y,
1193 real_t *u);
1194 /** @brief Compute the terms in the expansion of the binomial (x + y)^p and
1195 their derivatives with respect to x assuming that dy/dx = -1. Store the
1196 results in the already allocated @a u and @a d arrays.*/
1197 static void CalcBinomTerms(const int p, const real_t x, const real_t y,
1198 real_t *u, real_t *d);
1199 /** @brief Compute the derivatives (w.r.t. x) of the terms in the expansion
1200 of the binomial (x + y)^p assuming that dy/dx = -1. Store the results
1201 in the already allocated @a d array.*/
1202 static void CalcDBinomTerms(const int p, const real_t x, const real_t y,
1203 real_t *d);
1204 /** @brief Compute the derivatives (w.r.t. x) of the terms in the expansion
1205 of the binomial (x + y)^p. Store the results in the already allocated
1206 @a d array.*/
1207 static void CalcDxBinomTerms(const int p, const real_t x, const real_t y,
1208 real_t *d);
1209 /** @brief Compute the derivatives (w.r.t. y) of the terms in the expansion
1210 of the binomial (x + y)^p. Store the results in the already allocated
1211 @a d array.*/
1212 static void CalcDyBinomTerms(const int p, const real_t x, const real_t y,
1213 real_t *d);
1214
1215 /** @brief Compute the values of the Bernstein basis functions of order
1216 @a p at coordinate @a x and store the results in the already allocated
1217 @a u array. */
1218 static void CalcBernstein(const int p, const real_t x, real_t *u)
1219 { CalcBinomTerms(p, x, 1. - x, u); }
1220
1221 /** @brief Compute the values of the Bernstein basis functions of order
1222 @a p at coordinate @a x and store the results in the already allocated
1223 @a u array. */
1224 static void CalcBernstein(const int p, const real_t x, Vector &u)
1225 { CalcBernstein(p, x, u.GetData()); }
1226
1227 /** @brief Compute the values and derivatives of the Bernstein basis functions
1228 of order @a p at coordinate @a x and store the results in the already allocated
1229 @a u and @a d arrays. */
1230 static void CalcBernstein(const int p, const real_t x, real_t *u, real_t *d)
1231 { CalcBinomTerms(p, x, 1. - x, u, d); }
1232
1233 /** @brief Compute the values and derivatives of the Bernstein basis
1234 functions of order @a p at coordinate @a x and store the results in the
1235 already allocated @a u and @a d arrays. */
1236 static void CalcBernstein(const int p, const real_t x, Vector &u, Vector &d)
1237 { CalcBernstein(p, x, u.GetData(), d.GetData()); }
1238
1239 static void CalcLegendre(const int p, const real_t x, real_t *u);
1240 static void CalcLegendre(const int p, const real_t x, real_t *u, real_t *d);
1241
1242 ~Poly_1D() = default;
1243};
1244
1245extern MFEM_EXPORT Poly_1D poly1d;
1246
1247/// An element defined as an ND tensor product of 1D elements on a segment,
1248/// square, or cube
1250{
1251protected:
1256
1257public:
1259 {
1262 Sr_DOF_MAP = 2, // Sr = Serendipity
1263 };
1264
1265 TensorBasisElement(const int dims, const int p, const int btype,
1266 const DofMapType dmtype);
1267
1268 int GetBasisType() const { return b_type; }
1269
1270 const Poly_1D::Basis &GetBasis1D() const { return basis1d; }
1271
1272 /** @brief Get an Array<int> that maps lexicographically ordered indices to
1273 the indices of the respective nodes/dofs/basis functions. If the dofs are
1274 ordered lexicographically, i.e. the mapping is identity, the returned
1275 Array will be empty. */
1276 const Array<int> &GetDofMap() const { return dof_map; }
1277
1279 {
1280 switch (dim)
1281 {
1282 case 1: return Geometry::SEGMENT;
1283 case 2: return Geometry::SQUARE;
1284 case 3: return Geometry::CUBE;
1285 default:
1286 MFEM_ABORT("invalid dimension: " << dim);
1287 return Geometry::INVALID;
1288 }
1289 }
1290
1291 /// Return @a base raised to the power @a dim.
1292 static int Pow(int base, int dim)
1293 {
1294 switch (dim)
1295 {
1296 case 1: return base;
1297 case 2: return base*base;
1298 case 3: return base*base*base;
1299 default: MFEM_ABORT("invalid dimension: " << dim); return -1;
1300 }
1301 }
1302
1303 static const DofToQuad &GetTensorDofToQuad(
1304 const FiniteElement &fe, const IntegrationRule &ir,
1305 DofToQuad::Mode mode, const Poly_1D::Basis &basis, bool closed,
1306 Array<DofToQuad*> &dof2quad_array);
1307};
1308
1310 public TensorBasisElement
1311{
1312public:
1313 NodalTensorFiniteElement(const int dims, const int p, const int btype,
1314 const DofMapType dmtype);
1315
1316 const DofToQuad &GetDofToQuad(const IntegrationRule &ir,
1317 DofToQuad::Mode mode) const override;
1318
1319 void SetMapType(const int map_type_) override;
1320
1322 ElementTransformation &Trans,
1323 DenseMatrix &I) const override
1324 {
1326 {
1327 CheckScalarFE(fe).ScalarLocalInterpolation(Trans, I, *this);
1328 }
1329 else
1330 {
1332 }
1333 }
1334
1335 void GetFaceMap(const int face_id, Array<int> &face_map) const override;
1336};
1337
1339 public TensorBasisElement
1340{
1341private:
1342 mutable Array<DofToQuad*> dof2quad_array_open;
1343
1344protected:
1346
1347public:
1348 VectorTensorFiniteElement(const int dims, const int d, const int p,
1349 const int cbtype, const int obtype,
1350 const int M, const DofMapType dmtype);
1351
1352 // For 1D elements: there is only an "open basis", no "closed basis"
1353 VectorTensorFiniteElement(const int dims, const int d, const int p,
1354 const int obtype, const int M,
1355 const DofMapType dmtype);
1356
1358 DofToQuad::Mode mode) const override
1359 {
1360 return (mode == DofToQuad::TENSOR) ?
1361 GetTensorDofToQuad(*this, ir, mode, basis1d, true, dof2quad_array) :
1363 }
1364
1366 DofToQuad::Mode mode) const
1367 {
1368 MFEM_VERIFY(mode == DofToQuad::TENSOR, "invalid mode requested");
1369 return GetTensorDofToQuad(*this, ir, mode, obasis1d, false,
1370 dof2quad_array_open);
1371 }
1372
1374};
1375
1376void InvertLinearTrans(ElementTransformation &trans,
1377 const IntegrationPoint &pt, Vector &x);
1378
1379} // namespace mfem
1380
1381#endif
Dynamic 2D array using row-major layout.
Definition array.hpp:430
const T * Read(bool on_dev=true) const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
Definition array.hpp:381
Possible basis types. Note that not all elements can use all BasisType(s).
Definition fe_base.hpp:30
static int GetQuadrature1D(int b_type)
Get the corresponding Quadrature1D constant, when that makes sense; otherwise return Quadrature1D::In...
Definition fe_base.hpp:65
static int Check(int b_type)
If the input does not represents a valid BasisType, abort with an error; otherwise return the input.
Definition fe_base.hpp:49
static char GetChar(int b_type)
Check and convert a BasisType constant to a char basis identifier.
Definition fe_base.hpp:108
@ ClosedGL
Closed GaussLegendre.
Definition fe_base.hpp:42
@ OpenHalfUniform
Nodes: x_i = (i+1/2)/n, i=0,...,n-1.
Definition fe_base.hpp:40
@ Serendipity
Serendipity basis (squares / cubes)
Definition fe_base.hpp:41
@ GaussLobatto
Closed type.
Definition fe_base.hpp:36
@ GaussLegendre
Open type.
Definition fe_base.hpp:35
@ Positive
Bernstein polynomials.
Definition fe_base.hpp:37
@ OpenUniform
Nodes: x_i = (i+1)/(n+1), i=0,...,n-1.
Definition fe_base.hpp:38
@ IntegratedGLL
Integrated GLL indicator functions.
Definition fe_base.hpp:43
@ ClosedUniform
Nodes: x_i = i/(n-1), i=0,...,n-1.
Definition fe_base.hpp:39
static int CheckNodal(int b_type)
If the input does not represents a valid nodal BasisType, abort with an error; otherwise return the i...
Definition fe_base.hpp:57
static const char * Name(int b_type)
Check and convert a BasisType constant to a string identifier.
Definition fe_base.hpp:96
static int GetType(char b_ident)
Convert char basis identifier to a BasisType constant.
Definition fe_base.hpp:115
static int GetNodalBasis(int qpt_type)
Return the nodal BasisType corresponding to the Quadrature1D type.
Definition fe_base.hpp:82
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
Structure representing the matrices/tensors needed to evaluate (in reference space) the values,...
Definition fe_base.hpp:141
Mode mode
Describes the contents of the B, Bt, G, and Gt arrays, see Mode.
Definition fe_base.hpp:174
const IntegrationRule * IntRule
IntegrationRule that defines the quadrature points at which the basis functions of the FE are evaluat...
Definition fe_base.hpp:150
Array< real_t > G
Gradients/divergences/curls of basis functions evaluated at quadrature points.
Definition fe_base.hpp:214
Mode
Type of data stored in the arrays B, Bt, G, and Gt.
Definition fe_base.hpp:154
@ FULL
Full multidimensional representation which does not use tensor product structure. The ordering of the...
Definition fe_base.hpp:158
@ LEXICOGRAPHIC_FULL
Full multidimensional representation which does not use tensor product structure. The ordering of the...
Definition fe_base.hpp:170
@ TENSOR
Tensor product representation using 1D matrices/tensors with dimensions using 1D number of quadrature...
Definition fe_base.hpp:165
Array< real_t > B
Basis functions evaluated at quadrature points.
Definition fe_base.hpp:193
int ndof
Number of degrees of freedom = number of basis functions. When mode is TENSOR, this is the 1D number.
Definition fe_base.hpp:178
Array< real_t > Gt
Transpose of G.
Definition fe_base.hpp:221
const class FiniteElement * FE
The FiniteElement that created and owns this object.
Definition fe_base.hpp:145
int nqpt
Number of quadrature points. When mode is TENSOR, this is the 1D number.
Definition fe_base.hpp:182
Array< real_t > Bt
Transpose of B.
Definition fe_base.hpp:199
DofToQuad Abs() const
Returns absolute value of the maps.
Definition fe_base.cpp:23
Abstract class for all finite elements.
Definition fe_base.hpp:247
virtual void CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape) const
Evaluate the values of all shape functions of a vector finite element in reference space at the given...
Definition fe_base.cpp:50
static int VerifyNodal(int b_type)
Ensure that the BasisType of b_type nodal (satisfies the interpolation property).
Definition fe_base.hpp:656
int dof
Number of degrees of freedom.
Definition fe_base.hpp:256
virtual void CalcHessian(const IntegrationPoint &ip, DenseMatrix &Hessian) const
Evaluate the Hessians of all shape functions of a scalar finite element in reference space at the giv...
Definition fe_base.cpp:111
virtual void ProjectMatrixCoefficient(MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
Given a matrix coefficient and a transformation, compute an approximation ("projection") in the local...
Definition fe_base.cpp:154
virtual ~FiniteElement()
Deconstruct the FiniteElement.
Definition fe_base.cpp:523
int GetDerivMapType() const
Returns the FiniteElement::DerivType of the element describing how reference function derivatives are...
Definition fe_base.hpp:373
virtual void ProjectDiv(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &div) const
Compute the discrete divergence matrix from the given FiniteElement onto 'this' FiniteElement....
Definition fe_base.cpp:185
virtual void ProjectFromNodes(Vector &vc, ElementTransformation &Trans, Vector &dofs) const
Given a vector of values at the finite element nodes and a transformation, compute its projection (ap...
Definition fe_base.cpp:148
virtual void GetFaceDofs(int face, int **dofs, int *ndofs) const
Get the dofs associated with the given face. *dofs is set to an internal array of the local dofc on t...
Definition fe_base.cpp:106
virtual const DofToQuad & GetDofToQuad(const IntegrationRule &ir, DofToQuad::Mode mode) const
Return a DofToQuad structure corresponding to the given IntegrationRule using the given DofToQuad::Mo...
Definition fe_base.cpp:375
RangeType
Enumeration for range_type and deriv_range_type.
Definition fe_base.hpp:270
static bool IsOpenType(int b_type)
Return true if the BasisType of b_type is open (doesn't have Quadrature1D points on the boundary).
Definition fe_base.hpp:630
int GetRangeDim() const
Returns the vector dimension for vector-valued finite elements, which is also the dimension of the in...
Definition fe_base.hpp:328
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Definition fe_base.hpp:341
void CalcPhysDShape(ElementTransformation &Trans, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in physical space at the poi...
Definition fe_base.cpp:202
int GetDerivType() const
Returns the FiniteElement::DerivType of the element describing the spatial derivative method implemen...
Definition fe_base.hpp:368
virtual void CalcCurlShape(const IntegrationPoint &ip, DenseMatrix &curl_shape) const
Evaluate the curl of all shape functions of a vector finite element in reference space at the given p...
Definition fe_base.cpp:75
virtual void ProjectGrad(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
Compute the discrete gradient matrix from the given FiniteElement onto 'this' FiniteElement....
Definition fe_base.cpp:171
IntegrationRule Nodes
Definition fe_base.hpp:259
virtual void GetFaceMap(const int face_id, Array< int > &face_map) const
Return the mapping from lexicographic face DOFs to lexicographic element DOFs for the given local fac...
Definition fe_base.cpp:517
virtual const StatelessDofTransformation * GetDofTransformation() const
Return a DoF transformation object for this particular type of basis.
Definition fe_base.hpp:613
int GetDim() const
Returns the reference space dimension for the finite element.
Definition fe_base.hpp:324
static int VerifyClosed(int b_type)
Ensure that the BasisType of b_type is closed (has Quadrature1D points on the boundary).
Definition fe_base.hpp:639
MapType
Enumeration for MapType: defines how reference functions are mapped to physical space.
Definition fe_base.hpp:283
int vdim
Vector dimension of vector-valued basis functions.
Definition fe_base.hpp:250
void CalcPhysHessian(ElementTransformation &Trans, DenseMatrix &Hessian) const
Evaluate the Hessian of all shape functions of a scalar finite element in physical space at the given...
Definition fe_base.cpp:298
FiniteElement(int D, Geometry::Type G, int Do, int O, int F=FunctionSpace::Pk)
Construct FiniteElement with given.
Definition fe_base.cpp:33
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_base.cpp:160
int orders[Geometry::MaxDim]
Anisotropic orders.
Definition fe_base.hpp:258
virtual void GetTransferMatrix(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &I) const
Return interpolation matrix, I, which maps dofs from a coarse element, fe, to the fine dofs on this f...
Definition fe_base.cpp:129
static bool IsClosedType(int b_type)
Return true if the BasisType of b_type is closed (has Quadrature1D points on the boundary).
Definition fe_base.hpp:621
int GetMapType() const
Returns the FiniteElement::MapType of the element describing how reference functions are mapped to ph...
Definition fe_base.hpp:363
int GetRangeType() const
Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
Definition fe_base.hpp:354
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_base.cpp:123
const int * GetAnisotropicOrders() const
Returns an array containing the anisotropic orders/degrees.
Definition fe_base.hpp:348
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
Definition fe_base.hpp:403
static int VerifyOpen(int b_type)
Ensure that the BasisType of b_type is open (doesn't have Quadrature1D points on the boundary).
Definition fe_base.hpp:648
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const =0
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
bool HasAnisotropicOrders() const
Returns true if the FiniteElement basis may be using different orders/degrees in different spatial di...
Definition fe_base.hpp:345
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
Definition fe_base.hpp:334
int cdim
Dimension of curl for vector-valued basis functions.
Definition fe_base.hpp:251
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...
Definition fe_base.cpp:62
virtual void GetLocalInterpolation(ElementTransformation &Trans, DenseMatrix &I) const
Return the local interpolation matrix I (Dof x Dof) where the fine element is the image of the base g...
Definition fe_base.cpp:117
int Space() const
Returns the type of FunctionSpace on the element.
Definition fe_base.hpp:351
DerivType
Enumeration for DerivType: defines which derivative method is implemented.
Definition fe_base.hpp:306
@ DIV
Implements CalcDivShape methods.
Definition fe_base.hpp:309
@ NONE
No derivatives implemented.
Definition fe_base.hpp:307
@ CURL
Implements CalcCurlShape methods.
Definition fe_base.hpp:310
@ GRAD
Implements CalcDShape methods.
Definition fe_base.hpp:308
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:136
Geometry::Type geom_type
Geometry::Type of the reference element.
Definition fe_base.hpp:252
void CalcPhysDivShape(ElementTransformation &Trans, Vector &divshape) const
Evaluate the divergence of all shape functions of a vector finite element in physical space at the po...
Definition fe_base.cpp:68
Array< DofToQuad * > dof2quad_array
Container for all DofToQuad objects created by the FiniteElement.
Definition fe_base.hpp:266
void CalcPhysLaplacian(ElementTransformation &Trans, Vector &Laplacian) const
Evaluate the Laplacian of all shape functions of a scalar finite element in physical space at the giv...
Definition fe_base.cpp:213
void CalcPhysVShape(ElementTransformation &Trans, DenseMatrix &shape) const
Equivalent to the CalcVShape() method with the same arguments.
Definition fe_base.hpp:450
DenseMatrix vshape
Definition fe_base.hpp:261
int GetCurlDim() const
Returns the dimension of the curl for vector-valued finite elements.
Definition fe_base.hpp:331
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
virtual void ProjectCurl(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Compute the discrete curl matrix from the given FiniteElement onto 'this' FiniteElement....
Definition fe_base.cpp:178
virtual void CalcPhysCurlShape(ElementTransformation &Trans, DenseMatrix &curl_shape) const
Evaluate the curl of all shape functions of a vector finite element in physical space at the point de...
Definition fe_base.cpp:81
int GetDerivRangeType() const
Returns the FiniteElement::RangeType of the element derivative, either SCALAR or VECTOR.
Definition fe_base.hpp:358
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Definition fe_base.hpp:337
int order
Order/degree of the shape functions.
Definition fe_base.hpp:257
void CalcPhysLinLaplacian(ElementTransformation &Trans, Vector &Laplacian) const
Evaluate the Laplacian of all shape functions of a scalar finite element in physical space at the giv...
Definition fe_base.cpp:254
int dim
Dimension of reference space.
Definition fe_base.hpp:249
void CalcPhysShape(ElementTransformation &Trans, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in physical space at the point ...
Definition fe_base.cpp:192
Describes the function space on each element.
Definition fe_base.hpp:229
@ Pk
Polynomials of order k.
Definition fe_base.hpp:233
@ Qk
Tensor products of polynomials of order k.
Definition fe_base.hpp:234
@ Uk
Rational polynomials of order k.
Definition fe_base.hpp:236
@ rQk
Refined tensor products of polynomials of order k.
Definition fe_base.hpp:235
static const int MaxDim
Definition geom.hpp:47
Class for integration point with weight.
Definition intrules.hpp:35
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:100
Base class for Matrix Coefficients that optionally depend on time and space.
Class for standard nodal finite elements.
Definition fe_base.hpp:724
NodalFiniteElement(int D, Geometry::Type G, int Do, int O, int F=FunctionSpace::Pk)
Construct NodalFiniteElement with given.
Definition fe_base.hpp:742
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_base.cpp:819
const Array< int > & GetLexicographicOrdering() const
Get an Array<int> that maps lexicographically ordered indices to the indices of the respective nodes/...
Definition fe_base.hpp:804
void GetTransferMatrix(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &I) const override
Return interpolation matrix, I, which maps dofs from a coarse element, fe, to the fine dofs on this f...
Definition fe_base.hpp:756
void ProjectCurl_2D(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Definition fe_base.cpp:747
void ReorderLexToNative(int ncomp, Vector &dofs) const
Definition fe_base.cpp:999
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_base.cpp:968
void GetLocalInterpolation(ElementTransformation &Trans, DenseMatrix &I) const override
Return the local interpolation matrix I (Dof x Dof) where the fine element is the image of the base g...
Definition fe_base.hpp:749
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_base.cpp:787
void ProjectGrad(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const override
Compute the discrete gradient matrix from the given FiniteElement onto 'this' FiniteElement....
Definition fe_base.cpp:939
void ProjectMatrixCoefficient(MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const override
Given a matrix coefficient and a transformation, compute an approximation ("projection") in the local...
Definition fe_base.cpp:858
Array< int > lex_ordering
Definition fe_base.hpp:729
const DofToQuad & GetDofToQuad(const IntegrationRule &ir, DofToQuad::Mode mode) const override
Return a DofToQuad structure corresponding to the given IntegrationRule using the given DofToQuad::Mo...
Definition fe_base.cpp:719
void GetFaceMap(const int face_id, Array< int > &face_map) const override
Return the mapping from lexicographic face DOFs to lexicographic element DOFs for the given local fac...
Definition fe_base.cpp:2713
NodalTensorFiniteElement(const int dims, const int p, const int btype, const DofMapType dmtype)
Definition fe_base.cpp:2675
const DofToQuad & GetDofToQuad(const IntegrationRule &ir, DofToQuad::Mode mode) const override
Return a DofToQuad structure corresponding to the given IntegrationRule using the given DofToQuad::Mo...
Definition fe_base.cpp:2699
void SetMapType(const int map_type_) override
Set the FiniteElement::MapType of the element to either VALUE or INTEGRAL. Also sets the FiniteElemen...
Definition fe_base.cpp:2686
void GetTransferMatrix(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &I) const override
Return interpolation matrix, I, which maps dofs from a coarse element, fe, to the fine dofs on this f...
Definition fe_base.hpp:1321
Class for evaluating 1D nodal, positive (Bernstein), or integrated (Gerritsma) bases.
Definition fe_base.hpp:1006
void Eval(const real_t x, Vector &u) const
Evaluate the basis functions at point x in [0,1].
Definition fe_base.cpp:1800
bool IsIntegratedType() const
Returns true if the basis is "integrated", false otherwise.
Definition fe_base.hpp:1050
void ScaleIntegrated(bool scale_integrated_)
Set whether the "integrated" basis should be scaled by the subcell sizes. Has no effect for non-integ...
Definition fe_base.cpp:2057
void EvalIntegrated(const Vector &d, Vector &i) const
Evaluate the "integrated" basis type using pre-computed closed basis derivatives.
Definition fe_base.cpp:2032
Basis(const int p, const real_t *nodes, EvalType etype=Barycentric)
Create a nodal or positive (Bernstein) basis of degree p.
Definition fe_base.cpp:1736
Class for computing 1D special polynomials and their associated basis functions.
Definition fe_base.hpp:991
static void CalcBasis(const int p, const real_t x, Vector &u, Vector &d, Vector &dd)
Evaluate the values, derivatives and second derivatives of a hierarchical 1D basis at point x.
Definition fe_base.hpp:1178
static void CalcDBinomTerms(const int p, const real_t x, const real_t y, real_t *d)
Compute the derivatives (w.r.t. x) of the terms in the expansion of the binomial (x + y)^p assuming t...
Definition fe_base.cpp:2180
static void CalcBernstein(const int p, const real_t x, real_t *u, real_t *d)
Compute the values and derivatives of the Bernstein basis functions of order p at coordinate x and st...
Definition fe_base.hpp:1230
const real_t * GetPoints(const int p, const int btype, bool on_device=false)
Get the coordinates of the points of the given BasisType, btype.
Definition fe_base.hpp:1109
static void CalcBasis(const int p, const real_t x, real_t *u, real_t *d, real_t *dd)
Evaluate the values, derivatives and second derivatives of a hierarchical 1D basis at point x.
Definition fe_base.hpp:1169
static void CalcBernstein(const int p, const real_t x, Vector &u)
Compute the values of the Bernstein basis functions of order p at coordinate x and store the results ...
Definition fe_base.hpp:1224
static const int * Binom(const int p)
Get a pointer to an array containing the binomial coefficients "pchoose k" for k=0,...
Definition fe_base.cpp:2067
Basis & GetBasis(const int p, const int btype)
Get a Poly_1D::Basis object of the given degree and BasisType, btype.
Definition fe_base.cpp:2395
const Array< real_t > * GetPointsArray(const int p, const int btype)
Get the coordinates of the points of the given BasisType, btype.
Definition fe_base.cpp:2367
static void CalcDyBinomTerms(const int p, const real_t x, const real_t y, real_t *d)
Compute the derivatives (w.r.t. y) of the terms in the expansion of the binomial (x + y)^p....
Definition fe_base.cpp:2239
static real_t CalcDelta(const int p, const real_t x)
Evaluate a representation of a Delta function at point x.
Definition fe_base.hpp:1183
static void CalcLegendre(const int p, const real_t x, real_t *u)
Definition fe_base.cpp:2268
static void CalcBernstein(const int p, const real_t x, real_t *u)
Compute the values of the Bernstein basis functions of order p at coordinate x and store the results ...
Definition fe_base.hpp:1218
EvalType
One-dimensional basis evaluation type.
Definition fe_base.hpp:995
@ ChangeOfBasis
Use change of basis, O(p^2) Evals.
Definition fe_base.hpp:996
@ Integrated
Integrated indicator functions (cf. Gerritsma)
Definition fe_base.hpp:999
@ Positive
Fast evaluation of Bernstein polynomials.
Definition fe_base.hpp:998
@ NumEvalTypes
Keep count of the number of eval types.
Definition fe_base.hpp:1000
@ Barycentric
Use barycentric Lagrangian interpolation, O(p) Evals.
Definition fe_base.hpp:997
static void CalcBasis(const int p, const real_t x, real_t *u, real_t *d)
Evaluate the values and derivatives of a hierarchical 1D basis at point x.
Definition fe_base.hpp:1157
static void ChebyshevPoints(const int p, real_t *x)
Compute the points for the Chebyshev polynomials of order p and place them in the already allocated x...
Definition fe_base.cpp:2084
const real_t * ClosedPoints(const int p, const int btype=BasisType::GaussLobatto, bool on_device=false)
Get coordinates of a closed (GaussLegendre) set of points if degree p.
Definition fe_base.hpp:1124
const real_t * OpenPoints(const int p, const int btype=BasisType::GaussLegendre, bool on_device=false)
Get coordinates of an open (GaussLegendre) set of points if degree p.
Definition fe_base.hpp:1116
~Poly_1D()=default
static void CalcBasis(const int p, const real_t x, Vector &u, Vector &d)
Evaluate the values and derivatives of a hierarchical 1D basis at point x.
Definition fe_base.hpp:1165
static void CalcBernstein(const int p, const real_t x, Vector &u, Vector &d)
Compute the values and derivatives of the Bernstein basis functions of order p at coordinate x and st...
Definition fe_base.hpp:1236
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...
Definition fe_base.hpp:1143
static void CalcBinomTerms(const int p, const real_t x, const real_t y, real_t *u)
Compute the p terms in the expansion of the binomial (x + y)^p and store them in the already allocate...
Definition fe_base.cpp:2116
static void CalcBasis(const int p, const real_t x, Vector &u)
Evaluate the values of a hierarchical 1D basis at point x hierarchical = k-th basis function is degre...
Definition fe_base.hpp:1153
static void CalcDxBinomTerms(const int p, const real_t x, const real_t y, real_t *d)
Compute the derivatives (w.r.t. x) of the terms in the expansion of the binomial (x + y)^p....
Definition fe_base.cpp:2210
static int CheckOpen(int type)
If the Quadrature1D type is not open return Invalid; otherwise return type.
Definition intrules.cpp:941
@ ClosedUniform
aka closed Newton-Cotes
Definition intrules.hpp:408
@ ClosedGL
aka closed Gauss Legendre
Definition intrules.hpp:410
@ OpenHalfUniform
aka "open half" Newton-Cotes
Definition intrules.hpp:409
@ OpenUniform
aka open Newton-Cotes
Definition intrules.hpp:407
static int CheckClosed(int type)
If the Quadrature1D type is not closed return Invalid; otherwise return type.
Definition intrules.cpp:928
A Class that defines 1-D numerical quadrature rules on [0,1].
Definition intrules.hpp:376
Class for finite elements with basis functions that return scalar values.
Definition fe_base.hpp:665
ScalarFiniteElement(int D, Geometry::Type G, int Do, int O, int F=FunctionSpace::Pk)
Construct ScalarFiniteElement with given.
Definition fe_base.hpp:682
void NodalLocalInterpolation(ElementTransformation &Trans, DenseMatrix &I, const ScalarFiniteElement &fine_fe) const
Get the matrix I that defines nodal interpolation between this element and the refined element fine_f...
Definition fe_base.cpp:532
virtual void SetMapType(int M)
Set the FiniteElement::MapType of the element to either VALUE or INTEGRAL. Also sets the FiniteElemen...
Definition fe_base.hpp:690
void ScalarLocalInterpolation(ElementTransformation &Trans, DenseMatrix &I, const ScalarFiniteElement &fine_fe) const
Get matrix I "Interpolation" defined through local L2-projection in the space defined by the fine_fe.
Definition fe_base.cpp:571
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:612
static const ScalarFiniteElement & CheckScalarFE(const FiniteElement &fe)
Definition fe_base.hpp:667
const Array< int > & GetDofMap() const
Get an Array<int> that maps lexicographically ordered indices to the indices of the respective nodes/...
Definition fe_base.hpp:1276
const Poly_1D::Basis & GetBasis1D() const
Definition fe_base.hpp:1270
static Geometry::Type GetTensorProductGeometry(int dim)
Definition fe_base.hpp:1278
Poly_1D::Basis & basis1d
Definition fe_base.hpp:1254
static const DofToQuad & GetTensorDofToQuad(const FiniteElement &fe, const IntegrationRule &ir, DofToQuad::Mode mode, const Poly_1D::Basis &basis, bool closed, Array< DofToQuad * > &dof2quad_array)
Definition fe_base.cpp:2622
TensorBasisElement(const int dims, const int p, const int btype, const DofMapType dmtype)
Definition fe_base.cpp:2422
static int Pow(int base, int dim)
Return base raised to the power dim.
Definition fe_base.hpp:1292
Base class for vector Coefficients that optionally depend on time and space.
Intermediate class for finite elements whose basis functions return vector values.
Definition fe_base.hpp:816
void ProjectGrad_RT(const real_t *nk, const Array< int > &d2n, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
Definition fe_base.cpp:1245
void LocalRestriction_RT(const real_t *nk, const Array< int > &d2n, ElementTransformation &Trans, DenseMatrix &R) const
Definition fe_base.cpp:1651
void Project_ND(const real_t *tk, const Array< int > &d2t, VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
Project a vector coefficient onto the ND basis functions.
Definition fe_base.cpp:1329
void Project_RT(const real_t *nk, const Array< int > &d2n, VectorCoefficient &vc, ElementTransformation &Trans, Vector &dofs) const
Project a vector coefficient onto the RT basis functions.
Definition fe_base.cpp:1105
void LocalInterpolation_RT(const VectorFiniteElement &cfe, const real_t *nk, const Array< int > &d2n, ElementTransformation &Trans, DenseMatrix &I) const
Definition fe_base.cpp:1525
void ProjectMatrixCoefficient_ND(const real_t *tk, const Array< int > &d2t, MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
Project the rows of the matrix coefficient in an ND space.
Definition fe_base.cpp:1358
void LocalRestriction_ND(const real_t *tk, const Array< int > &d2t, ElementTransformation &Trans, DenseMatrix &R) const
Definition fe_base.cpp:1694
void LocalL2Projection_RT(const VectorFiniteElement &cfe, ElementTransformation &Trans, DenseMatrix &I) const
Definition fe_base.cpp:1478
void ProjectGrad_ND(const real_t *tk, const Array< int > &d2t, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
Definition fe_base.cpp:1457
void CalcVShape_ND(ElementTransformation &Trans, DenseMatrix &shape) const
Definition fe_base.cpp:1094
void CalcVShape_RT(ElementTransformation &Trans, DenseMatrix &shape) const
Definition fe_base.cpp:1082
VectorFiniteElement(int D, Geometry::Type G, int Do, int O, int M, int F=FunctionSpace::Pk)
Definition fe_base.cpp:1016
void LocalInterpolation_ND(const VectorFiniteElement &cfe, const real_t *tk, const Array< int > &d2t, ElementTransformation &Trans, DenseMatrix &I) const
Definition fe_base.cpp:1612
void ProjectCurl_RT(const real_t *nk, const Array< int > &d2n, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Definition fe_base.cpp:1310
static const VectorFiniteElement & CheckVectorFE(const FiniteElement &fe)
Definition fe_base.hpp:976
void LocalL2Projection_ND(const VectorFiniteElement &cfe, ElementTransformation &Trans, DenseMatrix &I) const
Definition fe_base.cpp:1566
void ProjectCurl_ND(const real_t *tk, const Array< int > &d2t, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Definition fe_base.cpp:1272
void ProjectMatrixCoefficient_RT(const real_t *nk, const Array< int > &d2n, MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const
Project the rows of the matrix coefficient in an RT space.
Definition fe_base.cpp:1142
const DofToQuad & GetDofToQuadOpen(const IntegrationRule &ir, DofToQuad::Mode mode) const
Definition fe_base.hpp:1365
VectorTensorFiniteElement(const int dims, const int d, const int p, const int cbtype, const int obtype, const int M, const DofMapType dmtype)
Definition fe_base.cpp:2719
const DofToQuad & GetDofToQuad(const IntegrationRule &ir, DofToQuad::Mode mode) const override
Return a DofToQuad structure corresponding to the given IntegrationRule using the given DofToQuad::Mo...
Definition fe_base.hpp:1357
Vector data type.
Definition vector.hpp:82
real_t * GetData() const
Return a pointer to the beginning of the Vector data.
Definition vector.hpp:243
int dim
Definition ex24.cpp:53
void trans(const Vector &u, Vector &x)
Definition ex27.cpp:412
real_t u(const Vector &xvec)
Definition lor_mms.hpp:22
void mfem_error(const char *msg)
Definition error.cpp:154
float real_t
Definition config.hpp:46
MemoryType
Memory types supported by MFEM.
@ HOST
Host memory; using new[] and delete[].
Poly_1D poly1d
Definition fe.cpp:28
void InvertLinearTrans(ElementTransformation &trans, const IntegrationPoint &pt, Vector &x)
Definition fe_base.cpp:771
real_t p(const Vector &x, real_t t)
Helper class for hashing std::pair. Usable in place of std::hash<std::pair<T,U>>
Definition hash.hpp:497
std::array< int, NCMesh::MaxFaceNodes > nodes