MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
quadinterpolator.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_QUADINTERP
13#define MFEM_QUADINTERP
14
15#include "fespace.hpp"
16#include "kernel_dispatch.hpp"
17
18namespace mfem
19{
20
21/** @brief A class that performs interpolation from an E-vector to quadrature
22 point values and/or derivatives (Q-vectors). */
23/** An E-vector represents the element-wise discontinuous version of the FE
24 space and can be obtained, for example, from a GridFunction using the
25 Operator returned by FiniteElementSpace::GetElementRestriction().
26
27 The target quadrature points in the elements can be described either by an
28 IntegrationRule (all mesh elements must be of the same type in this case) or
29 by a QuadratureSpace. */
31{
32protected:
33 friend class FiniteElementSpace; // Needs access to qspace and IntRule
34
35 const FiniteElementSpace *fespace; ///< Not owned
36 const QuadratureSpace *qspace; ///< Not owned
37 const IntegrationRule *IntRule; ///< Not owned
38 mutable QVectorLayout q_layout; ///< Output Q-vector layout
39
40 mutable bool use_tensor_products; ///< Tensor product evaluation mode
41 mutable Vector d_buffer; ///< Auxiliary device buffer
42
43 /// Auxiliary method called by Mult() when using H(div)-conforming space
44 void MultHDiv(const Vector &e_vec, unsigned eval_flags,
45 Vector &q_val, Vector &q_div) const;
46
47public:
48 static const int MAX_NQ2D = 100;
49 static const int MAX_ND2D = 100;
50 static const int MAX_VDIM2D = 3;
51
52 static const int MAX_NQ3D = 1000;
53 static const int MAX_ND3D = 1000;
54 static const int MAX_VDIM3D = 3;
55
57 {
58 VALUES = 1 << 0, ///< Evaluate the values at quadrature points
59 DERIVATIVES = 1 << 1, ///< Evaluate the derivatives at quadrature points
60 /** @brief Assuming the derivative at quadrature points form a matrix,
61 this flag can be used to compute and store their determinants. This
62 flag can only be used in Mult(). */
63 DETERMINANTS = 1 << 2,
64 PHYSICAL_DERIVATIVES = 1 << 3, ///< Evaluate the physical derivatives
65 /** Evaluate the values in physical space; for fields with
66 FiniteElement::MapType other than FiniteElement::MapType::VALUE,
67 such as H(div) and H(curl) elements, the physical values are different
68 from the reference values. */
70 /** For vector-valued fields, evaluate the magnitudes of the physical
71 space vector values at quadrature points. */
72 PHYSICAL_MAGNITUDES = 1 << 5
73 };
74
76 const IntegrationRule &ir);
77
79 const QuadratureSpace &qs);
80
81 /** @brief Disable the use of tensor product evaluations, for tensor-product
82 elements, e.g. quads and hexes. By default, tensor product evaluations
83 are enabled. */
84 /** @sa EnableTensorProducts(), UsesTensorProducts(). */
85 void DisableTensorProducts(bool disable = true) const
86 { use_tensor_products = !disable; }
87
88 /** @brief Enable the use of tensor product evaluations, for tensor-product
89 elements, e.g. quads and hexes. By default, this option is enabled. */
90 /** @sa DisableTensorProducts(), UsesTensorProducts(). */
92
93 /** @brief Query the current tensor product evaluation mode. */
94 /** @sa DisableTensorProducts(), EnableTensorProducts(). */
95 bool UsesTensorProducts() const { return use_tensor_products; }
96
97 /** @brief Query the current output Q-vector layout. The default value is
98 QVectorLayout::byNODES. */
99 /** @sa SetOutputLayout(). */
101
102 /** @brief Set the desired output Q-vector layout. The default value is
103 QVectorLayout::byNODES. */
104 /** @sa GetOutputLayout(). */
105 void SetOutputLayout(QVectorLayout layout) const { q_layout = layout; }
106
107 /// Interpolate the E-vector @a e_vec to quadrature points.
108 /** The @a eval_flags are a bitwise mask of constants from the EvalFlags
109 enumeration. When the VALUES flag is set, the values at quadrature points
110 are computed and stored in the Vector @a q_val. Similarly, when one of
111 the flags DERIVATIVES or PHYSICAL_DERIVATIVES is set, the derivatives
112 (with respect to reference or physical coordinates, respectively) are
113 computed and stored in @a q_der. Only one of the flags DERIVATIVES or
114 PHYSICAL_DERIVATIVES can be set in a call. When the DETERMINANTS flag is
115 set, it is assumed that the derivatives (with respect to reference
116 coordinates) form a matrix at each quadrature point (i.e. the associated
117 FiniteElementSpace is a vector space) and their determinants are computed
118 and stored in @a q_det.
119
120 For H(div)-conforming spaces, the flags VALUES / PHYSICAL_VALUES request
121 the computation of the vector field values in reference or physical
122 space, respectively. The flag PHYSICAL_MAGNITUDES requests the
123 computation of the physical space magnitudes. In all 3 cases, the result
124 is stored in @a q_val and therefore only one of the 3 cases can be
125 requested in a single call.
126
127 The layout of the input E-vector, @a e_vec, must be consistent with the
128 evaluation mode: if tensor-product evaluations are enabled, then
129 tensor-product elements, must use the ElementDofOrdering::LEXICOGRAPHIC
130 layout; otherwise -- ElementDofOrdering::NATIVE layout. See
131 FiniteElementSpace::GetElementRestriction(). */
132 void Mult(const Vector &e_vec, unsigned eval_flags,
133 Vector &q_val, Vector &q_der, Vector &q_det) const;
134
135 /// Interpolate the values of the E-vector @a e_vec at quadrature points.
136 void Values(const Vector &e_vec, Vector &q_val) const;
137
138 /** @brief Interpolate the derivatives (with respect to reference
139 coordinates) of the E-vector @a e_vec at quadrature points. */
140 void Derivatives(const Vector &e_vec, Vector &q_der) const;
141
142 /** @brief Interpolate the derivatives in physical space of the E-vector
143 @a e_vec at quadrature points. */
144 void PhysDerivatives(const Vector &e_vec, Vector &q_der) const;
145
146 /** @brief Compute the determinants of the derivatives (with respect to
147 reference coordinates) of the E-vector @a e_vec at quadrature points. */
148 void Determinants(const Vector &e_vec, Vector &q_det) const;
149
150 /// Perform the transpose operation of Mult(). (TODO)
151 void MultTranspose(unsigned eval_flags, const Vector &q_val,
152 const Vector &q_der, Vector &e_vec) const;
153
154
155 using TensorEvalKernelType = void(*)(const int, const real_t *, const real_t *,
156 real_t *, const int, const int, const int);
157 using GradKernelType = void(*)(const int, const real_t *, const real_t *,
158 const real_t *, const real_t *, real_t *,
159 const int, const int, const int, const int);
160 using CollocatedGradKernelType = void(*)(const int, const real_t *,
161 const real_t *, const real_t *,
162 real_t *, const int, const int,
163 const int);
164 using DetKernelType = void(*)(const int NE, const real_t *, const real_t *,
165 const real_t *, real_t *, const int, const int,
166 Vector *);
167 using EvalKernelType = void(*)(const int, const int, const QVectorLayout,
168 const GeometricFactors *, const DofToQuad &,
169 const Vector &, Vector &, Vector &, Vector &,
170 const int);
172 void(*)(const int, const real_t *, const real_t *, const real_t *,
173 const real_t *, real_t *, const int, const int);
174
176 (int, QVectorLayout, int, int, int), (int));
178 (int, QVectorLayout, bool, int, int, int), (int));
179 MFEM_REGISTER_KERNELS(DetKernels, DetKernelType, (int, int, int, int));
180 MFEM_REGISTER_KERNELS(EvalKernels, EvalKernelType, (int, int, int, int));
182 (int, QVectorLayout, bool, int, int), (int));
184 (int, QVectorLayout, unsigned, int, int));
185};
186
187}
188
189#endif
Structure representing the matrices/tensors needed to evaluate (in reference space) the values,...
Definition fe_base.hpp:141
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:244
Structure for storing mesh geometric factors: coordinates, Jacobians, and determinants of the Jacobia...
Definition mesh.hpp:2937
Class for an integration rule - an Array of IntegrationPoint.
Definition intrules.hpp:100
A class that performs interpolation from an E-vector to quadrature point values and/or derivatives (Q...
void(*)(const int, const real_t *, const real_t *, const real_t *, real_t *, const int, const int, const int) CollocatedGradKernelType
bool use_tensor_products
Tensor product evaluation mode.
@ VALUES
Evaluate the values at quadrature points.
@ DERIVATIVES
Evaluate the derivatives at quadrature points.
@ PHYSICAL_DERIVATIVES
Evaluate the physical derivatives.
@ DETERMINANTS
Assuming the derivative at quadrature points form a matrix, this flag can be used to compute and stor...
void(*)(const int, const int, const QVectorLayout, const GeometricFactors *, const DofToQuad &, const Vector &, Vector &, Vector &, Vector &, const int) EvalKernelType
MFEM_REGISTER_KERNELS(TensorEvalKernels, TensorEvalKernelType,(int, QVectorLayout, int, int, int),(int))
QuadratureInterpolator(const FiniteElementSpace &fes, const IntegrationRule &ir)
void(*)(const int, const real_t *, const real_t *, const real_t *, const real_t *, real_t *, const int, const int, const int, const int) GradKernelType
MFEM_REGISTER_KERNELS(TensorEvalHDivKernels, TensorEvalHDivKernelType,(int, QVectorLayout, unsigned, int, int))
void Mult(const Vector &e_vec, unsigned eval_flags, Vector &q_val, Vector &q_der, Vector &q_det) const
Interpolate the E-vector e_vec to quadrature points.
void SetOutputLayout(QVectorLayout layout) const
Set the desired output Q-vector layout. The default value is QVectorLayout::byNODES.
void(*)(const int NE, const real_t *, const real_t *, const real_t *, real_t *, const int, const int, Vector *) DetKernelType
void Determinants(const Vector &e_vec, Vector &q_det) const
Compute the determinants of the derivatives (with respect to reference coordinates) of the E-vector e...
bool UsesTensorProducts() const
Query the current tensor product evaluation mode.
void MultTranspose(unsigned eval_flags, const Vector &q_val, const Vector &q_der, Vector &e_vec) const
Perform the transpose operation of Mult(). (TODO)
void(*)(const int, const real_t *, const real_t *, real_t *, const int, const int, const int) TensorEvalKernelType
void DisableTensorProducts(bool disable=true) const
Disable the use of tensor product evaluations, for tensor-product elements, e.g. quads and hexes....
void EnableTensorProducts() const
Enable the use of tensor product evaluations, for tensor-product elements, e.g. quads and hexes....
MFEM_REGISTER_KERNELS(EvalKernels, EvalKernelType,(int, int, int, int))
void Values(const Vector &e_vec, Vector &q_val) const
Interpolate the values of the E-vector e_vec at quadrature points.
void(*)(const int, const real_t *, const real_t *, const real_t *, const real_t *, real_t *, const int, const int) TensorEvalHDivKernelType
void Derivatives(const Vector &e_vec, Vector &q_der) const
Interpolate the derivatives (with respect to reference coordinates) of the E-vector e_vec at quadratu...
QVectorLayout q_layout
Output Q-vector layout.
QVectorLayout GetOutputLayout() const
Query the current output Q-vector layout. The default value is QVectorLayout::byNODES.
void PhysDerivatives(const Vector &e_vec, Vector &q_der) const
Interpolate the derivatives in physical space of the E-vector e_vec at quadrature points.
const IntegrationRule * IntRule
Not owned.
MFEM_REGISTER_KERNELS(DetKernels, DetKernelType,(int, int, int, int))
Vector d_buffer
Auxiliary device buffer.
const FiniteElementSpace * fespace
Not owned.
MFEM_REGISTER_KERNELS(CollocatedGradKernels, CollocatedGradKernelType,(int, QVectorLayout, bool, int, int),(int))
const QuadratureSpace * qspace
Not owned.
void MultHDiv(const Vector &e_vec, unsigned eval_flags, Vector &q_val, Vector &q_div) const
Auxiliary method called by Mult() when using H(div)-conforming space.
MFEM_REGISTER_KERNELS(GradKernels, GradKernelType,(int, QVectorLayout, bool, int, int, int),(int))
Class representing the storage layout of a QuadratureFunction.
Definition qspace.hpp:120
Vector data type.
Definition vector.hpp:82
QVectorLayout
Type describing possible layouts for Q-vectors.
Definition fespace.hpp:53
float real_t
Definition config.hpp:43