MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
quadinterpolator.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, 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
17namespace mfem
18{
19
20/** @brief A class that performs interpolation from an E-vector to quadrature
21 point values and/or derivatives (Q-vectors). */
22/** An E-vector represents the element-wise discontinuous version of the FE
23 space and can be obtained, for example, from a GridFunction using the
24 Operator returned by FiniteElementSpace::GetElementRestriction().
25
26 The target quadrature points in the elements can be described either by an
27 IntegrationRule (all mesh elements must be of the same type in this case) or
28 by a QuadratureSpace. */
30{
31protected:
32 friend class FiniteElementSpace; // Needs access to qspace and IntRule
33
34 const FiniteElementSpace *fespace; ///< Not owned
35 const QuadratureSpace *qspace; ///< Not owned
36 const IntegrationRule *IntRule; ///< Not owned
37 mutable QVectorLayout q_layout; ///< Output Q-vector layout
38
39 mutable bool use_tensor_products; ///< Tensor product evaluation mode
40 mutable Vector d_buffer; ///< Auxiliary device buffer
41
42public:
43 static const int MAX_NQ2D = 100;
44 static const int MAX_ND2D = 100;
45 static const int MAX_VDIM2D = 3;
46
47 static const int MAX_NQ3D = 1000;
48 static const int MAX_ND3D = 1000;
49 static const int MAX_VDIM3D = 3;
50
52 {
53 VALUES = 1 << 0, ///< Evaluate the values at quadrature points
54 DERIVATIVES = 1 << 1, ///< Evaluate the derivatives at quadrature points
55 /** @brief Assuming the derivative at quadrature points form a matrix,
56 this flag can be used to compute and store their determinants. This
57 flag can only be used in Mult(). */
58 DETERMINANTS = 1 << 2,
59 PHYSICAL_DERIVATIVES = 1 << 3 ///< Evaluate the physical derivatives
60 };
61
63 const IntegrationRule &ir);
64
66 const QuadratureSpace &qs);
67
68 /** @brief Disable the use of tensor product evaluations, for tensor-product
69 elements, e.g. quads and hexes. By default, tensor product evaluations
70 are enabled. */
71 /** @sa EnableTensorProducts(), UsesTensorProducts(). */
72 void DisableTensorProducts(bool disable = true) const
73 { use_tensor_products = !disable; }
74
75 /** @brief Enable the use of tensor product evaluations, for tensor-product
76 elements, e.g. quads and hexes. By default, this option is enabled. */
77 /** @sa DisableTensorProducts(), UsesTensorProducts(). */
79
80 /** @brief Query the current tensor product evaluation mode. */
81 /** @sa DisableTensorProducts(), EnableTensorProducts(). */
82 bool UsesTensorProducts() const { return use_tensor_products; }
83
84 /** @brief Query the current output Q-vector layout. The default value is
85 QVectorLayout::byNODES. */
86 /** @sa SetOutputLayout(). */
88
89 /** @brief Set the desired output Q-vector layout. The default value is
90 QVectorLayout::byNODES. */
91 /** @sa GetOutputLayout(). */
92 void SetOutputLayout(QVectorLayout layout) const { q_layout = layout; }
93
94 /// Interpolate the E-vector @a e_vec to quadrature points.
95 /** The @a eval_flags are a bitwise mask of constants from the EvalFlags
96 enumeration. When the VALUES flag is set, the values at quadrature points
97 are computed and stored in the Vector @a q_val. Similarly, when one of
98 the flags DERIVATIVES or PHYSICAL_DERIVATIVES is set, the derivatives
99 (with respect to reference or physical coordinates, respectively) are
100 computed and stored in @a q_der. Only one of the flags DERIVATIVES or
101 PHYSICAL_DERIVATIVES can be set in a call. When the DETERMINANTS flag is
102 set, it is assumed that the derivatives (with respect to reference
103 coordinates) form a matrix at each quadrature point (i.e. the associated
104 FiniteElementSpace is a vector space) and their determinants are computed
105 and stored in @a q_det.
106
107 The layout of the input E-vector, @a e_vec, must be consistent with the
108 evaluation mode: if tensor-product evaluations are enabled, then
109 tensor-product elements, must use the ElementDofOrdering::LEXICOGRAPHIC
110 layout; otherwise -- ElementDofOrdering::NATIVE layout. See
111 FiniteElementSpace::GetElementRestriction(). */
112 void Mult(const Vector &e_vec, unsigned eval_flags,
113 Vector &q_val, Vector &q_der, Vector &q_det) const;
114
115 /// Interpolate the values of the E-vector @a e_vec at quadrature points.
116 void Values(const Vector &e_vec, Vector &q_val) const;
117
118 /** @brief Interpolate the derivatives (with respect to reference
119 coordinates) of the E-vector @a e_vec at quadrature points. */
120 void Derivatives(const Vector &e_vec, Vector &q_der) const;
121
122 /** @brief Interpolate the derivatives in physical space of the E-vector
123 @a e_vec at quadrature points. */
124 void PhysDerivatives(const Vector &e_vec, Vector &q_der) const;
125
126 /** @brief Compute the determinants of the derivatives (with respect to
127 reference coordinates) of the E-vector @a e_vec at quadrature points. */
128 void Determinants(const Vector &e_vec, Vector &q_det) const;
129
130 /// Perform the transpose operation of Mult(). (TODO)
131 void MultTranspose(unsigned eval_flags, const Vector &q_val,
132 const Vector &q_der, Vector &e_vec) const;
133};
134
135}
136
137#endif
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:220
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...
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...
QuadratureInterpolator(const FiniteElementSpace &fes, const IntegrationRule &ir)
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 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 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....
void Values(const Vector &e_vec, Vector &q_val) const
Interpolate the values of the E-vector e_vec at quadrature points.
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.
Vector d_buffer
Auxiliary device buffer.
const FiniteElementSpace * fespace
Not owned.
const QuadratureSpace * qspace
Not owned.
Class representing the storage layout of a QuadratureFunction.
Definition qspace.hpp:120
Vector data type.
Definition vector.hpp:80
QVectorLayout
Type describing possible layouts for Q-vectors.
Definition fespace.hpp:53