MFEM v4.10.0
Finite element discretization library
Loading...
Searching...
No Matches
fe_base.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2026, 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 represent 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 represent 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 /** @brief Ragged tensor product representation using 1D matrices/tensors
173 with dimensions using 1D number of quadrature points and ragged tensor degrees of
174 freedom. */
175 /** Used only for partial assembly of the H1 positive basis. The
176 size of B is d1d x qnpt x dim. Since different Gauss-Jacobi quadrature rules
177 are employed in each dimension, we need to store dim arrays. */
179 };
180
181 /// Describes the contents of the #B, #Bt, #G, and #Gt arrays, see #Mode.
183
184 /** @brief Number of degrees of freedom = number of basis functions. When
185 #mode is TENSOR, this is the 1D number. */
186 int ndof;
187
188 /** @brief Number of quadrature points. When #mode is TENSOR, this is the 1D
189 number. */
190 int nqpt;
191
192 /// Basis functions evaluated at quadrature points.
193 /** The storage layout is column-major with dimensions:
194 - #nqpt x #ndof, for scalar elements, or
195 - #nqpt x dim x #ndof, for vector elements,
196
197 where
198
199 - dim = dimension of the finite element reference space when #mode is
200 FULL, and dim = 1 when #mode is TENSOR. */
202
203 /// Transpose of #B.
204 /** The storage layout is column-major with dimensions:
205 - #ndof x #nqpt, for scalar elements, or
206 - #ndof x #nqpt x dim, for vector elements. */
208
209 /** @brief Gradients/divergences/curls of basis functions evaluated at
210 quadrature points. */
211 /** The storage layout is column-major with dimensions:
212 - #nqpt x dim x #ndof, for scalar elements, or
213 - #nqpt x #ndof, for H(div) vector elements, or
214 - #nqpt x cdim x #ndof, for H(curl) vector elements,
215
216 where
217
218 - dim = dimension of the finite element reference space when #mode is
219 FULL, and 1 when #mode is TENSOR,
220 - cdim = 1/1/3 in 1D/2D/3D, respectively, when #mode is FULL, and cdim =
221 1 when #mode is TENSOR. */
223
224 /// Transpose of #G.
225 /** The storage layout is column-major with dimensions:
226 - #ndof x #nqpt x dim, for scalar elements, or
227 - #ndof x #nqpt, for H(div) vector elements, or
228 - #ndof x #nqpt x cdim, for H(curl) vector elements. */
230
231 /// Returns absolute value of the maps
232 DofToQuad Abs() const;
233
234 /// Auxiliary function for searching DofToQuad arrays.
235 static inline DofToQuad *SearchArray(
236 const Array<DofToQuad*> &dof2quad_array,
237 const IntegrationRule &ir,
239
240 virtual ~DofToQuad() = default;
241};
242
243/** @brief Structure representing the matrices/tensors needed to evaluate (in
244 reference space) the values, gradients, divergences, or curls of a positive
245 FiniteElement on simplices at the quadrature points of Stroud conical quadrature. */
247{
248public:
249 /** @brief Special basis function structures for positive (Bernstein) basis with
250 partial assembly. The storage layout of Ba1 is ndof x nqpt for scalar elements.
251 The storage layout of Ba2 is ndof x ndof x nqpt. In particular, we have
252 Ba2(iqpt, a1, a2) = B^{p-a1}_{a2}(x_{iqpt}). */
255
256 /** @brief Special structures for gradients of positive basis with partial assembly.
257 The gradient arrays exploit properties of the Bernstein basis which allow grad(B^p_alpha)
258 to be expressed as the sum of products of B^{p-1}_alpha and the barycentric coordinates.
259 Thus, Ga1 and Ga2 simply contain the ragged tensor product components of B^{p-1}_alpha */
262
263 /** @brief Mapping from the Bernstein multi-index (a_1, ..., a_d) to the lexicographic
264 dof index. */
266
269
272};
273
274/// Describes the function space on each element
276{
277public:
278 enum
279 {
280 Pk, ///< Polynomials of order k
281 Qk, ///< Tensor products of polynomials of order k
282 rQk, ///< Refined tensor products of polynomials of order k
283 Uk ///< Rational polynomials of order k
284 };
285};
286
287class ElementTransformation;
288class Coefficient;
289class VectorCoefficient;
290class MatrixCoefficient;
291
292/// Abstract class for all finite elements.
294{
295protected:
296 int dim; ///< Dimension of reference space
297 int vdim; ///< Vector dimension of vector-valued basis functions
298 int cdim; ///< Dimension of curl for vector-valued basis functions
299 Geometry::Type geom_type; ///< Geometry::Type of the reference element
302 mutable
303 int dof, ///< Number of degrees of freedom
304 order; ///< Order/degree of the shape functions
305 mutable int orders[Geometry::MaxDim]; ///< Anisotropic orders
307#ifndef MFEM_THREAD_SAFE
308 mutable DenseMatrix vshape; // Dof x Dim
309#endif
310 /// Container for all DofToQuad objects created by the FiniteElement.
311 /** Multiple DofToQuad objects may be needed when different quadrature rules
312 or different DofToQuad::Mode are used. */
314
315public:
316 /// Enumeration for range_type and deriv_range_type
318
319 /** @brief Enumeration for MapType: defines how reference functions are
320 mapped to physical space.
321
322 A reference function $ \hat u(\hat x) $ can be mapped to a function
323 $ u(x) $ on a general physical element in following ways:
324 - $ x = T(\hat x) $ is the image of the reference point $ \hat x $
325 - $ J = J(\hat x) $ is the Jacobian matrix of the transformation T
326 - $ w = w(\hat x) = det(J) $ is the transformation weight factor for square J
327 - $ w = w(\hat x) = det(J^t J)^{1/2} $ is the transformation weight factor in general
328 */
330 {
331 UNKNOWN_MAP_TYPE = -1, /**< Used to distinguish an unset MapType variable
332 from the known values below. */
333 VALUE, /**< For scalar fields; preserves point values
334 $ u(x) = \hat u(\hat x) $ @anchor map_type_value */
335 INTEGRAL, /**< For scalar fields; preserves volume integrals
336 $ u(x) = (1/w) \hat u(\hat x) $ */
337 H_DIV, /**< For vector fields; preserves surface integrals of the
338 normal component $ u(x) = (J/w) \hat u(\hat x) $ */
339 H_CURL, /**< For vector fields; preserves line integrals of the
340 tangential component
341 $ u(x) = J^{-t} \hat u(\hat x) $ (square J),
342 $ u(x) = J(J^t J)^{-1} \hat u(\hat x) $ (general J) */
343 H_DIV_R2D, /**< For 3-component vector fields in 2D; equivalent to a
344 direct sum of an H_DIV basis and an INTEGRAL basis */
345 H_CURL_R2D,/**< For 3-component vector fields in 2D; equivalent to a
346 direct sum of an H_CURL basis and a VALUE basis */
347 H_DIV_R1D, /**< For 3-component vector fields in 1D; equivalent to a
348 direct sum of a VALUE basis and a pair of INTEGRAL
349 bases */
350 H_CURL_R1D /**< For 3-component vector fields in 1D; equivalent to a
351 direct sum of an INTEGRAL basis and a pair of VALUE
352 bases */
353 };
354
355 /** @brief Enumeration for DerivType: defines which derivative method
356 is implemented.
357
358 Each FiniteElement class implements up to one type of derivative. The
359 value returned by GetDerivType() indicates which derivative method is
360 implemented.
361 */
363 {
364 NONE, ///< No derivatives implemented
365 GRAD, ///< Implements CalcDShape methods
366 DIV, ///< Implements CalcDivShape methods
367 CURL ///< Implements CalcCurlShape methods
368 };
369
370 /** @brief Construct FiniteElement with given
371 @param D Reference space dimension
372 @param G Geometry type (of type Geometry::Type)
373 @param Do Number of degrees of freedom in the FiniteElement
374 @param O Order/degree of the FiniteElement
375 @param F FunctionSpace type of the FiniteElement
376 */
377 FiniteElement(int D, Geometry::Type G, int Do, int O,
378 int F = FunctionSpace::Pk);
379
380 /// Returns the reference space dimension for the finite element.
381 int GetDim() const { return dim; }
382
383 /** @brief Returns the vector dimension for vector-valued finite elements,
384 which is also the dimension of the interpolation operation and the
385 width of the DenseMatrix argument in
386 CalcVShape(const IntegrationPoint &ip, DenseMatrix &shape). */
387 int GetRangeDim() const { return vdim; }
388
389 /** @brief Returns the vector dimension, in physical space, for
390 vector-valued finite elements, which is also the width of the
391 DenseMatrix argument in
392 CalcPhysVShape(ElementTransformation &Trans, DenseMatrix &shape). */
393 virtual int GetPhysRangeDim(int /* space_dim */) const { return vdim; }
394
395 /** Returns the dimension of the curl for vector-valued finite elements,
396 which is also the width of the DenseMatrix argument in
397 CalcCurlShape(const IntegrationPoint &ip, DenseMatrix &curl_shape). */
398 int GetCurlDim() const { return cdim; }
399
400 /** Returns the dimension, in physical space, of the curl for vector-valued
401 finite elements, which is also the width of the DenseMatrix argument in
402 CalcPhysCurlShape(ElementTransformation &Trans, DenseMatrix &curl_shape).
403 */
404 virtual int GetPhysCurlDim(int /* space_dim */) const { return cdim; }
405
406 /// Returns the Geometry::Type of the reference element.
408
409 /// Returns the number of degrees of freedom in the finite element.
410 int GetDof() const { return dof; }
411
412 /** @brief Returns the order of the finite element. In the case of
413 anisotropic orders, returns the maximum order. */
414 int GetOrder() const { return order; }
415
416 /** @brief Returns true if the FiniteElement basis *may be using* different
417 orders/degrees in different spatial directions. */
418 bool HasAnisotropicOrders() const { return orders[0] != -1; }
419
420 /// Returns an array containing the anisotropic orders/degrees.
421 const int *GetAnisotropicOrders() const { return orders; }
422
423 /// Returns the type of FunctionSpace on the element.
424 int Space() const { return func_space; }
425
426 /// Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
427 int GetRangeType() const { return range_type; }
428
429 /** @brief Returns the FiniteElement::RangeType of the element derivative, either
430 SCALAR or VECTOR. */
431 int GetDerivRangeType() const { return deriv_range_type; }
432
433 /** @brief Returns the FiniteElement::MapType of the element describing how reference
434 functions are mapped to physical space, one of {VALUE, INTEGRAL
435 H_DIV, H_CURL}. */
436 int GetMapType() const { return map_type; }
437
438 /** @brief Returns the FiniteElement::DerivType of the element describing the
439 spatial derivative method implemented, one of {NONE, GRAD,
440 DIV, CURL}. */
441 int GetDerivType() const { return deriv_type; }
442
443 /** @brief Returns the FiniteElement::DerivType of the element describing how
444 reference function derivatives are mapped to physical space, one of {VALUE,
445 INTEGRAL, H_DIV, H_CURL}. */
446 int GetDerivMapType() const { return deriv_map_type; }
447
448 /** @brief Evaluate the values of all shape functions of a scalar finite
449 element in reference space at the given point @a ip. */
450 /** The size (#dof) of the result Vector @a shape must be set in advance. */
451 virtual void CalcShape(const IntegrationPoint &ip,
452 Vector &shape) const = 0;
453
454 /** @brief Evaluate the values of all shape functions of a scalar finite
455 element in physical space at the point described by @a Trans. */
456 /** The size (#dof) of the result Vector @a shape must be set in advance. */
457 void CalcPhysShape(ElementTransformation &Trans, Vector &shape) const;
458
459 /** @brief Evaluate the gradients of all shape functions of a scalar finite
460 element in reference space at the given point @a ip. */
461 /** Each row of the result DenseMatrix @a dshape contains the derivatives of
462 one shape function. The size (#dof x #dim) of @a dshape must be set in
463 advance. */
464 virtual void CalcDShape(const IntegrationPoint &ip,
465 DenseMatrix &dshape) const = 0;
466
467 /** @brief Evaluate the gradients of all shape functions of a scalar finite
468 element in physical space at the point described by @a Trans. */
469 /** Each row of the result DenseMatrix @a dshape contains the derivatives of
470 one shape function. The size (#dof x SDim) of @a dshape must be set in
471 advance, where SDim >= #dim is the physical space dimension as described
472 by @a Trans. */
473 void CalcPhysDShape(ElementTransformation &Trans, DenseMatrix &dshape) const;
474
475 /// Get a const reference to the nodes of the element
476 const IntegrationRule & GetNodes() const { return Nodes; }
477
478 /** @brief Evaluate the Hessians of all shape functions of a scalar finite
479 element in reference space at the given point @a ip. */
480 /** Each row of the result DenseMatrix @a Hessian contains upper triangular
481 part of the Hessian of one shape function.
482 The order in 2D is {u_xx, u_xy, u_yy}.
483 The order in 3D is {u_xx, u_xy, u_xz, u_yy, u_yz, u_zz}.
484 The size (#dof x (#dim (#dim+1)/2) of @a Hessian must be set in advance.*/
485 virtual void CalcHessian(const IntegrationPoint &ip,
486 DenseMatrix &Hessian) const;
487
488 /** @brief Evaluate the Hessian of all shape functions of a scalar finite
489 element in physical space at the given point @a ip. */
490 /** The size (#dof, #dim*(#dim+1)/2) of @a Hessian must be set in advance. */
492 DenseMatrix& Hessian) const;
493
494 /** @brief Evaluate the Laplacian of all shape functions of a scalar finite
495 element in physical space at the given point @a ip. */
496 /** The size (#dof) of @a Laplacian must be set in advance. */
498 Vector& Laplacian) const;
499
500 /** @brief Evaluate the Laplacian of all shape functions of a scalar finite
501 element in physical space at the given point @a ip. */
502 /** The size (#dof) of @a Laplacian must be set in advance. */
504 Vector& Laplacian) const;
505
506 /** @brief Evaluate the values of all shape functions of a *vector* finite
507 element in reference space at the given point @a ip. */
508 /** Each row of the result DenseMatrix @a shape contains the components of
509 one vector shape function. The size (#dof x #dim) of @a shape must be set
510 in advance. */
511 virtual void CalcVShape(const IntegrationPoint &ip,
512 DenseMatrix &shape) const;
513
514 /** @brief Evaluate the values of all shape functions of a *vector* finite
515 element in physical space at the point described by @a Trans. */
516 /** Each row of the result DenseMatrix @a shape contains the components of
517 one vector shape function. The size (#dof x SDim) of @a shape must be set
518 in advance, where SDim >= #dim is the physical space dimension as
519 described by @a Trans. */
520 virtual void CalcVShape(ElementTransformation &Trans,
521 DenseMatrix &shape) const;
522
523 /// Equivalent to the CalcVShape() method with the same arguments.
525 { CalcVShape(Trans, shape); }
526
527 /** @brief Evaluate the divergence of all shape functions of a *vector*
528 finite element in reference space at the given point @a ip. */
529 /** The size (#dof) of the result Vector @a divshape must be set in advance.
530 */
531 virtual void CalcDivShape(const IntegrationPoint &ip,
532 Vector &divshape) const;
533
534 /** @brief Evaluate the divergence of all shape functions of a *vector*
535 finite element in physical space at the point described by @a Trans. */
536 /** The size (#dof) of the result Vector @a divshape must be set in advance.
537 */
538 void CalcPhysDivShape(ElementTransformation &Trans, Vector &divshape) const;
539
540 /** @brief Evaluate the curl of all shape functions of a *vector* finite
541 element in reference space at the given point @a ip. */
542 /** Each row of the result DenseMatrix @a curl_shape contains the components
543 of the curl of one vector shape function. The size (#dof x CDim) of
544 @a curl_shape must be set in advance, where CDim = 3 for #dim = 3 and
545 CDim = 1 for #dim = 2. */
546 virtual void CalcCurlShape(const IntegrationPoint &ip,
547 DenseMatrix &curl_shape) const;
548
549 /** @brief Evaluate the curl of all shape functions of a *vector* finite
550 element in physical space at the point described by @a Trans. */
551 /** Each row of the result DenseMatrix @a curl_shape contains the components
552 of the curl of one vector shape function. The size (#dof x CDim) of
553 @a curl_shape must be set in advance, where CDim = 3 for #dim = 3 and
554 CDim = 1 for #dim = 2. */
555 virtual void CalcPhysCurlShape(ElementTransformation &Trans,
556 DenseMatrix &curl_shape) const;
557
558 /** @brief Get the dofs associated with the given @a face.
559 @a *dofs is set to an internal array of the local dofc on the
560 face, while *ndofs is set to the number of dofs on that face.
561 */
562 virtual void GetFaceDofs(int face, int **dofs, int *ndofs) const;
563
564 /** @brief Return the local interpolation matrix @a I (Dof x Dof) where the
565 fine element is the image of the base geometry under the given
566 transformation. */
568 DenseMatrix &I) const;
569
570 /** @brief Return a local restriction matrix @a R (Dof x Dof) mapping fine
571 dofs to coarse dofs.
572
573 The fine element is the image of the base geometry under the given
574 transformation, @a Trans.
575
576 The assumption in this method is that a subset of the coarse dofs can be
577 expressed only in terms of the dofs of the given fine element.
578
579 Rows in @a R corresponding to coarse dofs that cannot be expressed in
580 terms of the fine dofs will be marked as invalid by setting the first
581 entry (column 0) in the row to infinity().
582
583 This method assumes that the dimensions of @a R are set before it is
584 called. */
585 virtual void GetLocalRestriction(ElementTransformation &Trans,
586 DenseMatrix &R) const;
587
588 /** @brief Return interpolation matrix, @a I, which maps dofs from a coarse
589 element, @a fe, to the fine dofs on @a this finite element. */
590 /** @a Trans represents the mapping from the reference element of @a this
591 element into a subset of the reference space of the element @a fe, thus
592 allowing the "coarse" FiniteElement to be different from the "fine"
593 FiniteElement as when h-refinement is combined with p-refinement or
594 p-derefinement. It is assumed that both finite elements use the same
595 FiniteElement::MapType. */
596 virtual void GetTransferMatrix(const FiniteElement &fe,
598 DenseMatrix &I) const;
599
600 /** @brief Given a coefficient and a transformation, compute its projection
601 (approximation) in the local finite dimensional space in terms
602 of the degrees of freedom. */
603 /** The approximation used to project is usually local interpolation of
604 degrees of freedom. The derived class could use other methods not
605 implemented yet, e.g. local L2 projection. */
606 virtual void Project(Coefficient &coeff,
607 ElementTransformation &Trans, Vector &dofs) const;
608
609 /** @brief Given a vector coefficient and a transformation, compute its
610 projection (approximation) in the local finite dimensional space
611 in terms of the degrees of freedom. (VectorFiniteElements) */
612 /** The approximation used to project is usually local interpolation of
613 degrees of freedom. The derived class could use other methods not
614 implemented yet, e.g. local L2 projection. */
615 virtual void Project(VectorCoefficient &vc,
616 ElementTransformation &Trans, Vector &dofs) const;
617
618 /** @brief Given a vector of values at the finite element nodes and a
619 transformation, compute its projection (approximation) in the local
620 finite dimensional space in terms of the degrees of freedom. Valid for
621 VectorFiniteElements. */
622 virtual void ProjectFromNodes(Vector &vc, ElementTransformation &Trans,
623 Vector &dofs) const;
624
625 /** @brief Given a matrix coefficient and a transformation, compute an
626 approximation ("projection") in the local finite dimensional space in
627 terms of the degrees of freedom. For VectorFiniteElements, the rows of
628 the coefficient are projected in the vector space. */
629 virtual void ProjectMatrixCoefficient(
630 MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const;
631
632 /** @brief Project a delta function centered on the given @a vertex in
633 the local finite dimensional space represented by the @a dofs. */
634 virtual void ProjectDelta(int vertex, Vector &dofs) const;
635
636 /** @brief Compute the embedding/projection matrix from the given
637 FiniteElement onto 'this' FiniteElement. The ElementTransformation is
638 included to support cases when the projection depends on it. */
639 virtual void Project(const FiniteElement &fe, ElementTransformation &Trans,
640 DenseMatrix &I) const;
641
642 /** @brief Compute the discrete gradient matrix from the given FiniteElement
643 onto 'this' FiniteElement. The ElementTransformation is included to
644 support cases when the matrix depends on it. */
645 virtual void ProjectGrad(const FiniteElement &fe,
647 DenseMatrix &grad) const;
648
649 /** @brief Compute the discrete curl matrix from the given FiniteElement onto
650 'this' FiniteElement. The ElementTransformation is included to support
651 cases when the matrix depends on it. */
652 virtual void ProjectCurl(const FiniteElement &fe,
654 DenseMatrix &curl) const;
655
656 /** @brief Compute the discrete divergence matrix from the given
657 FiniteElement onto 'this' FiniteElement. The ElementTransformation is
658 included to support cases when the matrix depends on it. */
659 virtual void ProjectDiv(const FiniteElement &fe,
661 DenseMatrix &div) const;
662
663 /** @brief Return a DofToQuad structure corresponding to the given
664 IntegrationRule using the given DofToQuad::Mode. */
665 /** See the documentation for DofToQuad for more details. */
666 virtual const DofToQuad &GetDofToQuad(const IntegrationRule &ir,
667 DofToQuad::Mode mode) const;
668
669
670 /** @brief Return the mapping from lexicographic face DOFs to lexicographic
671 element DOFs for the given local face @a face_id. */
672 /** Given the @a ith DOF (lexicographically ordered) on the face referenced
673 by @a face_id, face_map[i] gives the corresponding index of the DOF in
674 the element (also lexicographically ordered).
675
676 @note For L2 spaces, this is only well-defined for "closed" bases such as
677 the Gauss-Lobatto or Bernstein (positive) bases.
678
679 @warning GetFaceMap() is currently only implemented for tensor-product
680 (quadrilateral and hexahedral) elements. Its functionality may change
681 when simplex elements are supported in the future. */
682 virtual void GetFaceMap(const int face_id, Array<int> &face_map) const;
683
684 /** @brief Return a DoF transformation object for this particular type of
685 basis.
686 */
688 { return NULL; }
689
690 /// Deconstruct the FiniteElement
691 virtual ~FiniteElement();
692
693 /** @brief Return true if the BasisType of @a b_type is closed
694 (has Quadrature1D points on the boundary). */
695 static bool IsClosedType(int b_type)
696 {
697 const int q_type = BasisType::GetQuadrature1D(b_type);
698 return ((q_type != Quadrature1D::Invalid) &&
700 }
701
702 /** @brief Return true if the BasisType of @a b_type is open
703 (doesn't have Quadrature1D points on the boundary). */
704 static bool IsOpenType(int b_type)
705 {
706 const int q_type = BasisType::GetQuadrature1D(b_type);
707 return ((q_type != Quadrature1D::Invalid) &&
709 }
710
711 /** @brief Ensure that the BasisType of @a b_type is closed
712 (has Quadrature1D points on the boundary). */
713 static int VerifyClosed(int b_type)
714 {
715 MFEM_VERIFY(IsClosedType(b_type),
716 "invalid closed basis type: " << b_type);
717 return b_type;
718 }
719
720 /** @brief Ensure that the BasisType of @a b_type is open
721 (doesn't have Quadrature1D points on the boundary). */
722 static int VerifyOpen(int b_type)
723 {
724 MFEM_VERIFY(IsOpenType(b_type), "invalid open basis type: " << b_type);
725 return b_type;
726 }
727
728 /** @brief Ensure that the BasisType of @a b_type nodal
729 (satisfies the interpolation property). */
730 static int VerifyNodal(int b_type)
731 {
732 return BasisType::CheckNodal(b_type);
733 }
734};
735
736/** @brief Class for finite elements with basis functions
737 that return scalar values. */
739{
740protected:
742 {
743 MFEM_VERIFY(fe.GetRangeType() == SCALAR,
744 "'fe' must be a ScalarFiniteElement");
745 return static_cast<const ScalarFiniteElement &>(fe);
746 }
747
748public:
749 /** @brief Construct ScalarFiniteElement with given
750 @param D Reference space dimension
751 @param G Geometry type (of type Geometry::Type)
752 @param Do Number of degrees of freedom in the FiniteElement
753 @param O Order/degree of the FiniteElement
754 @param F FunctionSpace type of the FiniteElement
755 */
756 ScalarFiniteElement(int D, Geometry::Type G, int Do, int O,
757 int F = FunctionSpace::Pk)
758 : FiniteElement(D, G, Do, O, F)
760
761 /** @brief Set the FiniteElement::MapType of the element to either VALUE or
762 INTEGRAL. Also sets the FiniteElement::DerivType to GRAD if the
763 FiniteElement::MapType is VALUE. */
764 virtual void SetMapType(int M)
765 {
766 MFEM_VERIFY(M == VALUE || M == INTEGRAL, "unknown MapType");
767 map_type = M;
768 deriv_type = (M == VALUE) ? GRAD : NONE;
769 }
770
771 /** @brief Get the matrix @a I that defines nodal interpolation
772 @a between this element and the refined element @a fine_fe. */
774 DenseMatrix &I,
775 const ScalarFiniteElement &fine_fe) const;
776
777 /** @brief Get matrix @a I "Interpolation" defined through local
778 L2-projection in the space defined by the @a fine_fe. */
779 /** If the "fine" elements cannot represent all basis functions of the
780 "coarse" element, then boundary values from different sub-elements are
781 generally different. */
783 DenseMatrix &I,
784 const ScalarFiniteElement &fine_fe) const;
785
786 /** @brief Get restriction matrix @a R defined through local L2-projection
787 in the space defined by the @a coarse_fe. */
788 /** If the "fine" elements cannot represent all basis functions of the
789 "coarse" element, then boundary values from different sub-elements are
790 generally different. */
792 DenseMatrix &R,
793 const ScalarFiniteElement &coarse_fe) const;
794};
795
796/// Class for standard nodal finite elements.
798{
799private:
800 /// Create and cache the LEXICOGRAPHIC_FULL DofToQuad maps.
801 void CreateLexicographicFullMap(const IntegrationRule &ir) const;
802protected:
804 void ProjectCurl_2D(const FiniteElement &fe,
806 DenseMatrix &curl) const;
807
808public:
809 /** @brief Construct NodalFiniteElement with given
810 @param D Reference space dimension
811 @param G Geometry type (of type Geometry::Type)
812 @param Do Number of degrees of freedom in the FiniteElement
813 @param O Order/degree of the FiniteElement
814 @param F FunctionSpace type of the FiniteElement
815 */
816 NodalFiniteElement(int D, Geometry::Type G, int Do, int O,
817 int F = FunctionSpace::Pk)
818 : ScalarFiniteElement(D, G, Do, O, F) { }
819
820 const DofToQuad &GetDofToQuad(const IntegrationRule &ir,
821 DofToQuad::Mode mode) const override;
822
824 DenseMatrix &I) const override
825 { NodalLocalInterpolation(Trans, I, *this); }
826
828 DenseMatrix &R) const override;
829
832 DenseMatrix &I) const override
833 { CheckScalarFE(fe).NodalLocalInterpolation(Trans, I, *this); }
834
835 void Project(Coefficient &coeff,
836 ElementTransformation &Trans, Vector &dofs) const override;
837
838 void Project(VectorCoefficient &vc,
839 ElementTransformation &Trans, Vector &dofs) const override;
840
841 // (mc.height x mc.width) @ DOFs -> (Dof x mc.width x mc.height) in dofs
843 MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const override;
844
845 void Project(const FiniteElement &fe, ElementTransformation &Trans,
846 DenseMatrix &I) const override;
847
848 void ProjectGrad(const FiniteElement &fe,
850 DenseMatrix &grad) const override;
851
852 void ProjectDiv(const FiniteElement &fe,
854 DenseMatrix &div) const override;
855
856 /** @brief Get an Array<int> that maps lexicographically ordered indices to
857 the indices of the respective nodes/dofs/basis functions.
858
859 Lexicographic ordering of nodes is defined in terms of reference-space
860 coordinates (x,y,z). Lexicographically ordered nodes are listed first in
861 order of increasing x-coordinate, and then in order of increasing
862 y-coordinate, and finally in order of increasing z-coordinate.
863
864 For example, the six nodes of a quadratic triangle are lexicographically
865 ordered as follows:
866
867 5
868 |\
869 3 4
870 | \
871 0-1-2
872
873 The resulting array may be empty if the DOFs are already ordered
874 lexicographically, or if the finite element does not support creating
875 this permutation. The array returned is the same as the array given by
876 TensorBasisElement::GetDofMap, but it is also available for non-tensor
877 elements. */
879
880 /// Given a lexicographically ordered Vector @a dofs, containing @a ncomp
881 /// components of the size of the scalar FiniteElement, reorder its entries
882 /// into native (H1) ordering.
883 /// The function assumes that GetLexicographicOrdering() is not empty.
884 void ReorderLexToNative(int ncomp, Vector &dofs) const;
885};
886
887/** @brief Intermediate class for finite elements whose basis functions return
888 vector values. */
890{
891 // Hide the scalar functions CalcShape and CalcDShape.
892private:
893 /// Overrides the scalar CalcShape function to print an error.
894 void CalcShape(const IntegrationPoint &ip,
895 Vector &shape) const override;
896
897 /// Overrides the scalar CalcDShape function to print an error.
898 void CalcDShape(const IntegrationPoint &ip,
899 DenseMatrix &dshape) const override;
900
901protected:
903#ifndef MFEM_THREAD_SAFE
906#endif
907 void SetDerivMembers();
908
910 DenseMatrix &shape) const;
911
913 DenseMatrix &shape) const;
914
915 /** @brief Project a vector coefficient onto the RT basis functions
916 @param nk Face normal vectors for this element type
917 @param d2n Offset into nk for each degree of freedom
918 @param vc Vector coefficient to be projected
919 @param Trans Transformation from reference to physical coordinates
920 @param dofs Expansion coefficients for the approximation of vc
921 */
922 void Project_RT(const real_t *nk, const Array<int> &d2n,
924 Vector &dofs) const;
925
926 /// Projects the vector of values given at FE nodes to RT space
927 /** Project vector values onto the RT basis functions
928 @param nk Face normal vectors for this element type
929 @param d2n Offset into nk for each degree of freedom
930 @param vc Vector values at each interpolation point
931 @param Trans Transformation from reference to physical coordinates
932 @param dofs Expansion coefficients for the approximation of vc
933 */
934 void Project_RT(const real_t *nk, const Array<int> &d2n,
935 Vector &vc, ElementTransformation &Trans,
936 Vector &dofs) const;
937
938 /// Project the rows of the matrix coefficient in an RT space
940 const real_t *nk, const Array<int> &d2n,
941 MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const;
942
943 /** @brief Project vector-valued basis functions onto the RT basis functions
944 @param nk Face normal vectors for this element type
945 @param d2n Offset into nk for each degree of freedom
946 @param fe Vector-valued finite element basis
947 @param Trans Transformation from reference to physical coordinates
948 @param I Expansion coefficients for the approximation of each basis
949 function
950
951 Note: If the FiniteElement, fe, is scalar-valued the projection will
952 assume that a FiniteElementSpace is being used to define a vector
953 field using the scalar basis functions for each component of the
954 vector field.
955 */
956 void Project_RT(const real_t *nk, const Array<int> &d2n,
957 const FiniteElement &fe, ElementTransformation &Trans,
958 DenseMatrix &I) const;
959
960 // Input is a scalar representing the Z (out of plane) component, Output is
961 // the X-Y (in-plane) RT curl
962 void ProjectCurl2D_RT(const real_t *nk, const Array<int> &d2n,
963 const FiniteElement &fe, ElementTransformation &Trans,
964 DenseMatrix &grad) const;
965
966 // Compute the curl as a discrete operator from ND FE (fe) to ND FE (this).
967 // The natural FE for the range is RT, so this is an approximation.
968 void ProjectCurl_ND(const real_t *tk, const Array<int> &d2t,
969 const FiniteElement &fe, ElementTransformation &Trans,
970 DenseMatrix &curl) const;
971
972 void ProjectCurl3D_RT(const real_t *nk, const Array<int> &d2n,
973 const FiniteElement &fe, ElementTransformation &Trans,
974 DenseMatrix &curl) const;
975
976 /** @brief Project a vector coefficient onto the ND basis functions
977 @param tk Edge tangent vectors for this element type
978 @param d2t Offset into tk for each degree of freedom
979 @param vc Vector coefficient to be projected
980 @param Trans Transformation from reference to physical coordinates
981 @param dofs Expansion coefficients for the approximation of vc
982 */
983 void Project_ND(const real_t *tk, const Array<int> &d2t,
985 Vector &dofs) const;
986
987 /// Projects the vector of values given at FE nodes to ND space
988 /** Project vector values onto the ND basis functions
989 @param tk Edge tangent vectors for this element type
990 @param d2t Offset into tk for each degree of freedom
991 @param vc Vector values at each interpolation point
992 @param Trans Transformation from reference to physical coordinates
993 @param dofs Expansion coefficients for the approximation of vc
994 */
995 void Project_ND(const real_t *tk, const Array<int> &d2t,
996 Vector &vc, ElementTransformation &Trans,
997 Vector &dofs) const;
998
999 /// Project the rows of the matrix coefficient in an ND space
1001 const real_t *tk, const Array<int> &d2t,
1002 MatrixCoefficient &mc, ElementTransformation &T, Vector &dofs) const;
1003
1004 /** @brief Project vector-valued basis functions onto the ND basis functions
1005 @param tk Edge tangent vectors for this element type
1006 @param d2t Offset into tk for each degree of freedom
1007 @param fe Vector-valued finite element basis
1008 @param Trans Transformation from reference to physical coordinates
1009 @param I Expansion coefficients for the approximation of each basis
1010 function
1011
1012 Note: If the FiniteElement, fe, is scalar-valued the projection will
1013 assume that a FiniteElementSpace is being used to define a vector
1014 field using the scalar basis functions for each component of the
1015 vector field.
1016 */
1017 void Project_ND(const real_t *tk, const Array<int> &d2t,
1018 const FiniteElement &fe, ElementTransformation &Trans,
1019 DenseMatrix &I) const;
1020
1021 void ProjectGrad_ND(const real_t *tk, const Array<int> &d2t,
1022 const FiniteElement &fe, ElementTransformation &Trans,
1023 DenseMatrix &grad) const;
1024
1026 ElementTransformation &Trans,
1027 DenseMatrix &I) const;
1028
1030 const real_t *nk, const Array<int> &d2n,
1031 ElementTransformation &Trans,
1032 DenseMatrix &I) const;
1033
1035 ElementTransformation &Trans,
1036 DenseMatrix &I) const;
1037
1039 const real_t *tk, const Array<int> &d2t,
1040 ElementTransformation &Trans,
1041 DenseMatrix &I) const;
1042
1043 void LocalRestriction_RT(const real_t *nk, const Array<int> &d2n,
1044 ElementTransformation &Trans,
1045 DenseMatrix &R) const;
1046
1047 void LocalRestriction_ND(const real_t *tk, const Array<int> &d2t,
1048 ElementTransformation &Trans,
1049 DenseMatrix &R) const;
1050
1052 {
1053 if (fe.GetRangeType() != VECTOR)
1054 { mfem_error("'fe' must be a VectorFiniteElement"); }
1055 return static_cast<const VectorFiniteElement &>(fe);
1056 }
1057
1058public:
1059 VectorFiniteElement(int D, Geometry::Type G, int Do, int O, int M,
1060 int F = FunctionSpace::Pk);
1061
1062 int GetPhysRangeDim(int space_dim) const override { return space_dim; }
1063};
1064
1065/// @brief Class for computing 1D special polynomials and their associated basis
1066/// functions
1068{
1069public:
1070 /// One-dimensional basis evaluation type
1072 {
1073 ChangeOfBasis = 0, ///< Use change of basis, O(p^2) Evals
1074 Barycentric = 1, ///< Use barycentric Lagrangian interpolation, O(p) Evals
1075 Positive = 2, ///< Fast evaluation of Bernstein polynomials
1076 Integrated = 3, ///< Integrated indicator functions (cf. Gerritsma)
1077 NumEvalTypes = 4 ///< Keep count of the number of eval types
1079
1080 /// @brief Class for evaluating 1D nodal, positive (Bernstein), or integrated
1081 /// (Gerritsma) bases.
1082 class Basis
1083 {
1084 private:
1085 EvalType etype; ///< Determines how the basis functions should be evaluated.
1087 mutable Vector x, w;
1088 /// The following data members are used for "integrated basis type", which
1089 /// is defined in terms of nodal basis of one degree higher.
1090 ///@{
1091 mutable Vector u_aux, d_aux, d2_aux;
1092 ///@}
1093 /// @brief An auxiliary nodal basis used to evaluate the integrated basis.
1094 /// This member variable is NULL whenever etype != Integrated.
1095 Basis *auxiliary_basis;
1096 /// Should the integrated basis functions be scaled? See ScaleIntegrated.
1097 bool scale_integrated;
1098
1099 public:
1100 /// Create a nodal or positive (Bernstein) basis of degree @a p
1101 Basis(const int p, const real_t *nodes, EvalType etype = Barycentric);
1102 /// Evaluate the basis functions at point @a x in [0,1]
1103 void Eval(const real_t x, Vector &u) const;
1104 /// @brief Evaluate the basis functions and their derivatives at point @a
1105 /// x in [0,1]
1106 void Eval(const real_t x, Vector &u, Vector &d) const;
1107 /// @brief Evaluate the basis functions and their first two derivatives at
1108 /// point @a x in [0,1]
1109 void Eval(const real_t x, Vector &u, Vector &d, Vector &d2) const;
1110 /// @brief Evaluate the "integrated" basis type using pre-computed closed
1111 /// basis derivatives.
1112 ///
1113 /// This basis is given by the negative partial sum of the corresponding
1114 /// closed basis derivatives. The closed basis derivatives are given by @a
1115 /// d, and the result is stored in @a i.
1116 void EvalIntegrated(const Vector &d, Vector &i) const;
1117 /// @brief Set whether the "integrated" basis should be scaled by the
1118 /// subcell sizes. Has no effect for non-integrated bases.
1119 ///
1120 /// Generally, this should be true for mfem::FiniteElement::MapType VALUE
1121 /// and false for all other map types. If this option is enabled, the
1122 /// basis functions will be scaled by the widths of the subintervals, so
1123 /// that the basis functions represent mean values. Otherwise, the basis
1124 /// functions represent integrated values.
1125 void ScaleIntegrated(bool scale_integrated_);
1126 /// Returns true if the basis is "integrated", false otherwise.
1127 bool IsIntegratedType() const { return etype == Integrated; }
1128 ~Basis();
1129 };
1130
1131private:
1132 /// key: (btype, p), value: underlying storage Array
1133 typedef std::unordered_map<std::pair<int, int>,
1134 std::unique_ptr<Basis>, PairHasher>
1135 BasisMap;
1136 /// key: (btype, p), value: underlying storage Array
1137 typedef std::unordered_map<std::pair<int, int>,
1138 std::unique_ptr<Array<real_t>>, PairHasher>
1139 PointsMap;
1140
1141 MemoryType h_mt;
1142 PointsMap points_container;
1143 BasisMap bases_container;
1144
1145 static Array2D<int> binom;
1146
1147 static void CalcMono(const int p, const real_t x, real_t *u);
1148 static void CalcMono(const int p, const real_t x, real_t *u, real_t *d);
1149
1150 static void CalcChebyshev(const int p, const real_t x, real_t *u);
1151 static void CalcChebyshev(const int p, const real_t x, real_t *u, real_t *d);
1152 static void CalcChebyshev(const int p, const real_t x, real_t *u, real_t *d,
1153 real_t *dd);
1154
1155 QuadratureFunctions1D quad_func;
1156
1157public:
1159
1160 /** @brief Get a pointer to an array containing the binomial coefficients "p
1161 choose k" for k=0,...,p for the given p. */
1162 static const int *Binom(const int p);
1163
1164 /** @brief Get the coordinates of the points of the given BasisType,
1165 @a btype.
1166
1167 @param[in] p The polynomial degree; the number of points is `p+1`.
1168 @param[in] btype The BasisType.
1169
1170 @return A pointer to an array containing the `p+1` coordinates of the
1171 points. Returns NULL if the BasisType has no associated set of
1172 points. */
1173 const Array<real_t>* GetPointsArray(const int p, const int btype);
1174
1175 /** @brief Get the coordinates of the points of the given BasisType,
1176 @a btype.
1177
1178 @param[in] p The polynomial degree; the number of points is `p+1`.
1179 @param[in] btype The BasisType.
1180 @param[in] on_device true if the requested pointer should be accessible
1181 from the device.
1182
1183 @return A pointer to an array containing the `p+1` coordinates of the
1184 points. Returns NULL if the BasisType has no associated set of
1185 points. */
1186 const real_t *GetPoints(const int p, const int btype,
1187 bool on_device = false)
1188 {
1189 return GetPointsArray(p, btype)->Read(on_device);
1190 }
1191
1192 /// Get coordinates of an open (GaussLegendre) set of points if degree @a p
1193 const real_t *OpenPoints(const int p,
1194 const int btype = BasisType::GaussLegendre,
1195 bool on_device = false)
1196 {
1197 return GetPoints(p, btype, on_device);
1198 }
1199
1200 /// Get coordinates of a closed (GaussLobatto) set of points if degree @a p
1201 const real_t *ClosedPoints(const int p,
1202 const int btype = BasisType::GaussLobatto,
1203 bool on_device = false)
1204 {
1205 return GetPoints(p, btype, on_device);
1206 }
1207
1208 /** @brief Get a Poly_1D::Basis object of the given degree and BasisType,
1209 @a btype.
1210
1211 @param[in] p The polynomial degree of the basis.
1212 @param[in] btype The BasisType.
1213
1214 @return A reference to an object of type Poly_1D::Basis that represents
1215 the requested basis type. */
1216 Basis &GetBasis(const int p, const int btype);
1217
1218 /** @brief Evaluate the values of a hierarchical 1D basis at point x
1219 hierarchical = k-th basis function is degree k polynomial */
1220 static void CalcBasis(const int p, const real_t x, real_t *u)
1221 // { CalcMono(p, x, u); }
1222 // Bernstein basis is not hierarchical --> does not work for triangles
1223 // and tetrahedra
1224 // { CalcBernstein(p, x, u); }
1225 // { CalcLegendre(p, x, u); }
1226 { CalcChebyshev(p, x, u); }
1227
1228 /** @brief Evaluate the values of a hierarchical 1D basis at point x
1229 hierarchical = k-th basis function is degree k polynomial */
1230 static void CalcBasis(const int p, const real_t x, Vector &u)
1231 { CalcBasis(p, x, u.GetData()); }
1232
1233 /// Evaluate the values and derivatives of a hierarchical 1D basis at point @a x
1234 static void CalcBasis(const int p, const real_t x, real_t *u, real_t *d)
1235 // { CalcMono(p, x, u, d); }
1236 // { CalcBernstein(p, x, u, d); }
1237 // { CalcLegendre(p, x, u, d); }
1238 { CalcChebyshev(p, x, u, d); }
1239
1240 /** @brief Evaluate the values and derivatives of a hierarchical 1D basis at
1241 point @a x. */
1242 static void CalcBasis(const int p, const real_t x, Vector &u, Vector &d)
1243 { CalcBasis(p, x, u.GetData(), d.GetData()); }
1244
1245 /// Evaluate the values, derivatives and second derivatives of a hierarchical 1D basis at point x
1246 static void CalcBasis(const int p, const real_t x, real_t *u, real_t *d,
1247 real_t *dd)
1248 // { CalcMono(p, x, u, d); }
1249 // { CalcBernstein(p, x, u, d); }
1250 // { CalcLegendre(p, x, u, d); }
1251 { CalcChebyshev(p, x, u, d, dd); }
1252
1253 /** @brief Evaluate the values, derivatives and second derivatives of a
1254 hierarchical 1D basis at point @a x. */
1255 static void CalcBasis(const int p, const real_t x, Vector &u, Vector &d,
1256 Vector &dd)
1257 { CalcBasis(p, x, u.GetData(), d.GetData(), dd.GetData()); }
1258
1259 /// Evaluate a representation of a Delta function at point x
1260 static real_t CalcDelta(const int p, const real_t x)
1261 { return pow(x, (real_t) p); }
1262
1263 /** @brief Compute the points for the Chebyshev polynomials of order @a p
1264 and place them in the already allocated @a x array. */
1265 static void ChebyshevPoints(const int p, real_t *x);
1266
1267 /** @brief Compute the @a p terms in the expansion of the binomial (x + y)^p
1268 and store them in the already allocated @a u array. */
1269 static void CalcBinomTerms(const int p, const real_t x, const real_t y,
1270 real_t *u);
1271 /** @brief Compute the terms in the expansion of the binomial (x + y)^p and
1272 their derivatives with respect to x assuming that dy/dx = -1. Store the
1273 results in the already allocated @a u and @a d arrays.*/
1274 static void CalcBinomTerms(const int p, const real_t x, const real_t y,
1275 real_t *u, real_t *d);
1276 /** @brief Compute the derivatives (w.r.t. x) of the terms in the expansion
1277 of the binomial (x + y)^p assuming that dy/dx = -1. Store the results
1278 in the already allocated @a d array.*/
1279 static void CalcDBinomTerms(const int p, const real_t x, const real_t y,
1280 real_t *d);
1281 /** @brief Compute the derivatives (w.r.t. x) of the terms in the expansion
1282 of the binomial (x + y)^p. Store the results in the already allocated
1283 @a d array.*/
1284 static void CalcDxBinomTerms(const int p, const real_t x, const real_t y,
1285 real_t *d);
1286 /** @brief Compute the derivatives (w.r.t. y) of the terms in the expansion
1287 of the binomial (x + y)^p. Store the results in the already allocated
1288 @a d array.*/
1289 static void CalcDyBinomTerms(const int p, const real_t x, const real_t y,
1290 real_t *d);
1291
1292 /** @brief Compute the values of the Bernstein basis functions of order
1293 @a p at coordinate @a x and store the results in the already allocated
1294 @a u array. */
1295 static void CalcBernstein(const int p, const real_t x, real_t *u)
1296 { CalcBinomTerms(p, x, 1. - x, u); }
1297
1298 /** @brief Compute the values of the Bernstein basis functions of order
1299 @a p at coordinate @a x and store the results in the already allocated
1300 @a u array. */
1301 static void CalcBernstein(const int p, const real_t x, Vector &u)
1302 { CalcBernstein(p, x, u.GetData()); }
1303
1304 /** @brief Compute the values and derivatives of the Bernstein basis functions
1305 of order @a p at coordinate @a x and store the results in the already allocated
1306 @a u and @a d arrays. */
1307 static void CalcBernstein(const int p, const real_t x, real_t *u, real_t *d)
1308 { CalcBinomTerms(p, x, 1. - x, u, d); }
1309
1310 /** @brief Compute the values and derivatives of the Bernstein basis
1311 functions of order @a p at coordinate @a x and store the results in the
1312 already allocated @a u and @a d arrays. */
1313 static void CalcBernstein(const int p, const real_t x, Vector &u, Vector &d)
1314 { CalcBernstein(p, x, u.GetData(), d.GetData()); }
1315
1316 static void CalcLegendre(const int p, const real_t x, real_t *u);
1317 static void CalcLegendre(const int p, const real_t x, real_t *u, real_t *d);
1318
1319 ~Poly_1D() = default;
1320};
1321
1322extern MFEM_EXPORT Poly_1D poly1d;
1323
1324/// An element defined as an ND tensor product of 1D elements on a segment,
1325/// square, or cube
1327{
1328protected:
1333
1334public:
1336 {
1339 Sr_DOF_MAP = 2, // Sr = Serendipity
1340 };
1341
1342 TensorBasisElement(const int dims, const int p, const int btype,
1343 const DofMapType dmtype);
1344
1345 int GetBasisType() const { return b_type; }
1346
1347 const Poly_1D::Basis &GetBasis1D() const { return basis1d; }
1348
1349 /** @brief Get an Array<int> that maps lexicographically ordered indices to
1350 the indices of the respective nodes/dofs/basis functions. If the dofs are
1351 ordered lexicographically, i.e. the mapping is identity, the returned
1352 Array will be empty. */
1353 const Array<int> &GetDofMap() const { return dof_map; }
1354
1356 {
1357 switch (dim)
1358 {
1359 case 1: return Geometry::SEGMENT;
1360 case 2: return Geometry::SQUARE;
1361 case 3: return Geometry::CUBE;
1362 default:
1363 MFEM_ABORT("invalid dimension: " << dim);
1364 return Geometry::INVALID;
1365 }
1366 }
1367
1368 /// Return @a base raised to the power @a dim.
1369 static int Pow(int base, int dim)
1370 {
1371 switch (dim)
1372 {
1373 case 1: return base;
1374 case 2: return base*base;
1375 case 3: return base*base*base;
1376 default: MFEM_ABORT("invalid dimension: " << dim); return -1;
1377 }
1378 }
1379
1380 static const DofToQuad &GetTensorDofToQuad(
1381 const FiniteElement &fe, const IntegrationRule &ir,
1382 DofToQuad::Mode mode, const Poly_1D::Basis &basis, bool closed,
1383 Array<DofToQuad*> &dof2quad_array);
1384};
1385
1387 public TensorBasisElement
1388{
1389public:
1390 NodalTensorFiniteElement(const int dims, const int p, const int btype,
1391 const DofMapType dmtype);
1392
1393 const DofToQuad &GetDofToQuad(const IntegrationRule &ir,
1394 DofToQuad::Mode mode) const override;
1395
1396 void SetMapType(const int map_type_) override;
1397
1399 ElementTransformation &Trans,
1400 DenseMatrix &I) const override
1401 {
1403 {
1404 CheckScalarFE(fe).ScalarLocalInterpolation(Trans, I, *this);
1405 }
1406 else
1407 {
1409 }
1410 }
1411
1412 void GetFaceMap(const int face_id, Array<int> &face_map) const override;
1413};
1414
1416 public TensorBasisElement
1417{
1418private:
1419 mutable Array<DofToQuad*> dof2quad_array_open;
1420
1421protected:
1423
1424public:
1425 VectorTensorFiniteElement(const int dims, const int d, const int p,
1426 const int cbtype, const int obtype,
1427 const int M, const DofMapType dmtype);
1428
1429 // For 1D elements: there is only an "open basis", no "closed basis"
1430 VectorTensorFiniteElement(const int dims, const int d, const int p,
1431 const int obtype, const int M,
1432 const DofMapType dmtype);
1433
1435 DofToQuad::Mode mode) const override
1436 {
1437 return (mode == DofToQuad::TENSOR) ?
1438 GetTensorDofToQuad(*this, ir, mode, basis1d, true, dof2quad_array) :
1440 }
1441
1443 DofToQuad::Mode mode) const
1444 {
1445 MFEM_VERIFY(mode == DofToQuad::TENSOR, "invalid mode requested");
1446 return GetTensorDofToQuad(*this, ir, mode, obasis1d, false,
1447 dof2quad_array_open);
1448 }
1449
1450 const Poly_1D::Basis &GetOpenBasis1D() const { return obasis1d; }
1451
1453};
1454
1455void InvertLinearTrans(ElementTransformation &trans,
1456 const IntegrationPoint &pt, Vector &x);
1457
1458
1459// static inline method
1461 const Array<DofToQuad*> &dof2quad_array,
1462 const IntegrationRule &ir,
1463 DofToQuad::Mode mode)
1464{
1465 for (int i = 0; i < dof2quad_array.Size(); i++)
1466 {
1467 DofToQuad *d2q = dof2quad_array[i];
1468 if (d2q->IntRule == &ir && d2q->mode == mode) { return d2q; }
1469 }
1470 return nullptr;
1471}
1472
1473} // namespace mfem
1474
1475#endif
Dynamic 2D array using row-major layout.
Definition array.hpp:459
int Size() const
Return the logical size of the array.
Definition array.hpp:192
const T * Read(bool on_dev=true) const
Shortcut for mfem::Read(a.GetMemory(), a.Size(), on_dev).
Definition array.hpp:410
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 represent 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
static int CheckNodal(int b_type)
If the input does not represent a valid nodal BasisType, abort with an error; otherwise return the in...
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
@ 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
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:182
const IntegrationRule * IntRule
IntegrationRule that defines the quadrature points at which the basis functions of the FE are evaluat...
Definition fe_base.hpp:150
virtual ~DofToQuad()=default
Array< real_t > G
Gradients/divergences/curls of basis functions evaluated at quadrature points.
Definition fe_base.hpp:222
Mode
Type of data stored in the arrays B, Bt, G, and Gt.
Definition fe_base.hpp:154
@ RAGGED_TENSOR
Ragged tensor product representation using 1D matrices/tensors with dimensions using 1D number of qua...
Definition fe_base.hpp:178
@ 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:201
static DofToQuad * SearchArray(const Array< DofToQuad * > &dof2quad_array, const IntegrationRule &ir, DofToQuad::Mode mode)
Auxiliary function for searching DofToQuad arrays.
Definition fe_base.hpp:1460
int ndof
Number of degrees of freedom = number of basis functions. When mode is TENSOR, this is the 1D number.
Definition fe_base.hpp:186
Array< real_t > Gt
Transpose of G.
Definition fe_base.hpp:229
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:190
Array< real_t > Bt
Transpose of B.
Definition fe_base.hpp:207
DofToQuad Abs() const
Returns absolute value of the maps.
Definition fe_base.cpp:23
Abstract class for all finite elements.
Definition fe_base.hpp:294
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:730
int dof
Number of degrees of freedom.
Definition fe_base.hpp:303
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:517
int GetDerivMapType() const
Returns the FiniteElement::DerivType of the element describing how reference function derivatives are...
Definition fe_base.hpp:446
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:373
RangeType
Enumeration for range_type and deriv_range_type.
Definition fe_base.hpp:317
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:704
int GetRangeDim() const
Returns the vector dimension for vector-valued finite elements, which is also the dimension of the in...
Definition fe_base.hpp:387
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Definition fe_base.hpp:414
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:441
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:306
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:511
virtual const StatelessDofTransformation * GetDofTransformation() const
Return a DoF transformation object for this particular type of basis.
Definition fe_base.hpp:687
int GetDim() const
Returns the reference space dimension for the finite element.
Definition fe_base.hpp:381
virtual int GetPhysRangeDim(int) const
Returns the vector dimension, in physical space, for vector-valued finite elements,...
Definition fe_base.hpp:393
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:713
MapType
Enumeration for MapType: defines how reference functions are mapped to physical space.
Definition fe_base.hpp:330
int vdim
Vector dimension of vector-valued basis functions.
Definition fe_base.hpp:297
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:296
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:305
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:695
int GetMapType() const
Returns the FiniteElement::MapType of the element describing how reference functions are mapped to ph...
Definition fe_base.hpp:436
int GetRangeType() const
Returns the FiniteElement::RangeType of the element, one of {SCALAR, VECTOR}.
Definition fe_base.hpp:427
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:421
const IntegrationRule & GetNodes() const
Get a const reference to the nodes of the element.
Definition fe_base.hpp:476
virtual int GetPhysCurlDim(int) const
Definition fe_base.hpp:404
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:722
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:418
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
Definition fe_base.hpp:407
int cdim
Dimension of curl for vector-valued basis functions.
Definition fe_base.hpp:298
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:424
DerivType
Enumeration for DerivType: defines which derivative method is implemented.
Definition fe_base.hpp:363
@ DIV
Implements CalcDivShape methods.
Definition fe_base.hpp:366
@ NONE
No derivatives implemented.
Definition fe_base.hpp:364
@ CURL
Implements CalcCurlShape methods.
Definition fe_base.hpp:367
@ GRAD
Implements CalcDShape methods.
Definition fe_base.hpp:365
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:299
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:313
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:524
DenseMatrix vshape
Definition fe_base.hpp:308
int GetCurlDim() const
Definition fe_base.hpp:398
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:431
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Definition fe_base.hpp:410
int order
Order/degree of the shape functions.
Definition fe_base.hpp:304
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:296
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:276
@ Pk
Polynomials of order k.
Definition fe_base.hpp:280
@ Qk
Tensor products of polynomials of order k.
Definition fe_base.hpp:281
@ Uk
Rational polynomials of order k.
Definition fe_base.hpp:283
@ rQk
Refined tensor products of polynomials of order k.
Definition fe_base.hpp:282
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:96
Class for standard nodal finite elements.
Definition fe_base.hpp:798
NodalFiniteElement(int D, Geometry::Type G, int Do, int O, int F=FunctionSpace::Pk)
Construct NodalFiniteElement with given.
Definition fe_base.hpp:816
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:816
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:878
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:830
void ProjectCurl_2D(const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Definition fe_base.cpp:744
void ReorderLexToNative(int ncomp, Vector &dofs) const
Definition fe_base.cpp:996
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:965
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:823
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:784
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:936
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:855
Array< int > lex_ordering
Definition fe_base.hpp:803
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:722
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:2780
NodalTensorFiniteElement(const int dims, const int p, const int btype, const DofMapType dmtype)
Definition fe_base.cpp:2742
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:2766
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:2753
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:1398
Class for evaluating 1D nodal, positive (Bernstein), or integrated (Gerritsma) bases.
Definition fe_base.hpp:1083
void Eval(const real_t x, Vector &u) const
Evaluate the basis functions at point x in [0,1].
Definition fe_base.cpp:1875
bool IsIntegratedType() const
Returns true if the basis is "integrated", false otherwise.
Definition fe_base.hpp:1127
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:2132
void EvalIntegrated(const Vector &d, Vector &i) const
Evaluate the "integrated" basis type using pre-computed closed basis derivatives.
Definition fe_base.cpp:2107
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:1811
Class for computing 1D special polynomials and their associated basis functions.
Definition fe_base.hpp:1068
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:1255
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:2255
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:1307
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:1186
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:1246
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:1301
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:2142
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:2470
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:2442
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:2314
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:1260
static void CalcLegendre(const int p, const real_t x, real_t *u)
Definition fe_base.cpp:2343
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:1295
EvalType
One-dimensional basis evaluation type.
Definition fe_base.hpp:1072
@ ChangeOfBasis
Use change of basis, O(p^2) Evals.
Definition fe_base.hpp:1073
@ Integrated
Integrated indicator functions (cf. Gerritsma)
Definition fe_base.hpp:1076
@ Positive
Fast evaluation of Bernstein polynomials.
Definition fe_base.hpp:1075
@ NumEvalTypes
Keep count of the number of eval types.
Definition fe_base.hpp:1077
@ Barycentric
Use barycentric Lagrangian interpolation, O(p) Evals.
Definition fe_base.hpp:1074
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:1234
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:2159
const real_t * ClosedPoints(const int p, const int btype=BasisType::GaussLobatto, bool on_device=false)
Get coordinates of a closed (GaussLobatto) set of points if degree p.
Definition fe_base.hpp:1201
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:1193
~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:1242
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:1313
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:1220
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:2191
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:1230
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:2285
static int CheckOpen(int type)
If the Quadrature1D type is not open return Invalid; otherwise return type.
@ ClosedUniform
aka closed Newton-Cotes
Definition intrules.hpp:416
@ ClosedGL
aka closed Gauss Legendre
Definition intrules.hpp:418
@ OpenHalfUniform
aka "open half" Newton-Cotes
Definition intrules.hpp:417
@ OpenUniform
aka open Newton-Cotes
Definition intrules.hpp:415
static int CheckClosed(int type)
If the Quadrature1D type is not closed return Invalid; otherwise return type.
A Class that defines 1-D numerical quadrature rules on [0,1].
Definition intrules.hpp:382
Structure representing the matrices/tensors needed to evaluate (in reference space) the values,...
Definition fe_base.hpp:247
Array< real_t > Ba3t
Definition fe_base.hpp:254
Array< int > inverse_map2d_mass
Definition fe_base.hpp:271
Array< real_t > Ga2
Definition fe_base.hpp:260
Array< int > forward_map3d_mass
Definition fe_base.hpp:270
Array< real_t > Ba1
Special basis function structures for positive (Bernstein) basis with partial assembly....
Definition fe_base.hpp:253
Array< int > inverse_map3d_mass
Definition fe_base.hpp:271
Array< real_t > Ba2
Definition fe_base.hpp:253
Array< real_t > Ba3
Definition fe_base.hpp:253
Array< real_t > Ba1t
Definition fe_base.hpp:254
Array< real_t > Ga1
Special structures for gradients of positive basis with partial assembly. The gradient arrays exploit...
Definition fe_base.hpp:260
Array< real_t > Ga3t
Definition fe_base.hpp:261
Array< real_t > Ba2t
Definition fe_base.hpp:254
Array< int > forward_map2d_mass
Definition fe_base.hpp:270
Array< real_t > Ga1t
Definition fe_base.hpp:261
Array< int > inverse_map3d_diff
Definition fe_base.hpp:268
Array< int > forward_map3d_diff
Definition fe_base.hpp:267
Array< int > inverse_map2d_diff
Definition fe_base.hpp:268
Array< real_t > Ga3
Definition fe_base.hpp:260
Array< int > forward_map2d_diff
Definition fe_base.hpp:267
Array< int > lex_map
Mapping from the Bernstein multi-index (a_1, ..., a_d) to the lexicographic dof index.
Definition fe_base.hpp:265
Array< real_t > Ga2t
Definition fe_base.hpp:261
Class for finite elements with basis functions that return scalar values.
Definition fe_base.hpp:739
ScalarFiniteElement(int D, Geometry::Type G, int Do, int O, int F=FunctionSpace::Pk)
Construct ScalarFiniteElement with given.
Definition fe_base.hpp:756
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:526
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:764
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:565
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:606
static const ScalarFiniteElement & CheckScalarFE(const FiniteElement &fe)
Definition fe_base.hpp:741
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:1353
const Poly_1D::Basis & GetBasis1D() const
Definition fe_base.hpp:1347
static Geometry::Type GetTensorProductGeometry(int dim)
Definition fe_base.hpp:1355
Poly_1D::Basis & basis1d
Definition fe_base.hpp:1331
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:2697
TensorBasisElement(const int dims, const int p, const int btype, const DofMapType dmtype)
Definition fe_base.cpp:2497
static int Pow(int base, int dim)
Return base raised to the power dim.
Definition fe_base.hpp:1369
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:890
void ProjectCurl2D_RT(const real_t *nk, const Array< int > &d2n, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
Definition fe_base.cpp:1319
void LocalRestriction_RT(const real_t *nk, const Array< int > &d2n, ElementTransformation &Trans, DenseMatrix &R) const
Definition fe_base.cpp:1726
int GetPhysRangeDim(int space_dim) const override
Returns the vector dimension, in physical space, for vector-valued finite elements,...
Definition fe_base.hpp:1062
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:1404
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:1179
void LocalInterpolation_RT(const VectorFiniteElement &cfe, const real_t *nk, const Array< int > &d2n, ElementTransformation &Trans, DenseMatrix &I) const
Definition fe_base.cpp:1600
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:1433
void LocalRestriction_ND(const real_t *tk, const Array< int > &d2t, ElementTransformation &Trans, DenseMatrix &R) const
Definition fe_base.cpp:1769
void LocalL2Projection_RT(const VectorFiniteElement &cfe, ElementTransformation &Trans, DenseMatrix &I) const
Definition fe_base.cpp:1553
void ProjectGrad_ND(const real_t *tk, const Array< int > &d2t, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &grad) const
Definition fe_base.cpp:1532
void CalcVShape_ND(ElementTransformation &Trans, DenseMatrix &shape) const
Definition fe_base.cpp:1168
void CalcVShape_RT(ElementTransformation &Trans, DenseMatrix &shape) const
Definition fe_base.cpp:1156
VectorFiniteElement(int D, Geometry::Type G, int Do, int O, int M, int F=FunctionSpace::Pk)
Definition fe_base.cpp:1013
void LocalInterpolation_ND(const VectorFiniteElement &cfe, const real_t *tk, const Array< int > &d2t, ElementTransformation &Trans, DenseMatrix &I) const
Definition fe_base.cpp:1687
static const VectorFiniteElement & CheckVectorFE(const FiniteElement &fe)
Definition fe_base.hpp:1051
void LocalL2Projection_ND(const VectorFiniteElement &cfe, ElementTransformation &Trans, DenseMatrix &I) const
Definition fe_base.cpp:1641
void ProjectCurl_ND(const real_t *tk, const Array< int > &d2t, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Definition fe_base.cpp:1347
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:1216
void ProjectCurl3D_RT(const real_t *nk, const Array< int > &d2n, const FiniteElement &fe, ElementTransformation &Trans, DenseMatrix &curl) const
Definition fe_base.cpp:1385
const DofToQuad & GetDofToQuadOpen(const IntegrationRule &ir, DofToQuad::Mode mode) const
Definition fe_base.hpp:1442
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:2786
const Poly_1D::Basis & GetOpenBasis1D() const
Definition fe_base.hpp:1450
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:1434
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:768
real_t p(const Vector &x, real_t t)
Helper class for hashing std::pair of hashable types.
std::array< int, NCMesh::MaxFaceNodes > nodes