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