MFEM  v4.2.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-2020, 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
24  byVDIM ///< VDIM x NQPT x NE
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;
47 
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 
56 public:
57  enum EvalFlags
58  {
59  VALUES = 1 << 0, ///< Evaluate the values at quadrature points
60  DERIVATIVES = 1 << 1, ///< Evaluate the derivatives at quadrature points
61  /** @brief Assuming the derivative at quadrature points form a matrix,
62  this flag can be used to compute and store their determinants. This
63  flag can only be used in Mult(). */
64  DETERMINANTS = 1 << 2
65  };
66 
68  const IntegrationRule &ir);
69 
71  const QuadratureSpace &qs);
72 
73  /** @brief Disable the use of tensor product evaluations, for tensor-product
74  elements, e.g. quads and hexes. */
75  /** Currently, tensor product evaluations are not implemented and this method
76  has no effect. */
77  void DisableTensorProducts(bool disable = true) const
78  { use_tensor_products = !disable; }
79 
80  /** @brief Query the current output Q-vector layout. The default value is
81  QVectorLayout::byNODES. */
83 
84  /** @brief Set the desired output Q-vector layout. The default value is
85  QVectorLayout::byNODES. */
86  void SetOutputLayout(QVectorLayout out_layout) const
87  { q_layout = out_layout; }
88 
89  /// Interpolate the E-vector @a e_vec to quadrature points.
90  /** The @a eval_flags are a bitwise mask of constants from the EvalFlags
91  enumeration. When the VALUES flag is set, the values at quadrature points
92  are computed and stored in the Vector @a q_val. Similarly, when the flag
93  DERIVATIVES is set, the derivatives are computed and stored in @a q_der.
94  When the DETERMINANTS flags is set, it is assumed that the derivatives
95  form a matrix at each quadrature point (i.e. the associated
96  FiniteElementSpace is a vector space) and their determinants are computed
97  and stored in @a q_det. */
98  void Mult(const Vector &e_vec, unsigned eval_flags,
99  Vector &q_val, Vector &q_der, Vector &q_det) const;
100 
101  /// Interpolate the values of the E-vector @a e_vec at quadrature points.
102  void Values(const Vector &e_vec, Vector &q_val) const;
103 
104  /** @brief Interpolate the derivatives of the E-vector @a e_vec at quadrature
105  points. */
106  void Derivatives(const Vector &e_vec, Vector &q_der) const;
107 
108  /** @brief Interpolate the derivatives in physical space of the E-vector
109  @a e_vec at quadrature points. */
110  void PhysDerivatives(const Vector &e_vec, Vector &q_der) const;
111 
112  /// Perform the transpose operation of Mult(). (TODO)
113  void MultTranspose(unsigned eval_flags, const Vector &q_val,
114  const Vector &q_der, Vector &e_vec) const;
115 
116  // Compute kernels follow (cannot be private or protected with nvcc)
117 
118  /// Template compute kernel for 2D.
119  template<const int T_VDIM = 0, const int T_ND = 0, const int T_NQ = 0>
120  static void Eval2D(const int NE,
121  const int vdim,
122  const DofToQuad &maps,
123  const Vector &e_vec,
124  Vector &q_val,
125  Vector &q_der,
126  Vector &q_det,
127  const int eval_flags);
128 
129  /// Template compute kernel for 3D.
130  template<const int T_VDIM = 0, const int T_ND = 0, const int T_NQ = 0>
131  static void Eval3D(const int NE,
132  const int vdim,
133  const DofToQuad &maps,
134  const Vector &e_vec,
135  Vector &q_val,
136  Vector &q_der,
137  Vector &q_det,
138  const int eval_flags);
139 };
140 
141 }
142 
143 #endif
Class for an integration rule - an Array of IntegrationPoint.
Definition: intrules.hpp:90
const FiniteElementSpace * fespace
Not owned.
Evaluate the derivatives at quadrature points.
void SetOutputLayout(QVectorLayout out_layout) const
Set the desired output Q-vector layout. The default value is QVectorLayout::byNODES.
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.
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:87
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...
static void Eval2D(const int NE, const int vdim, const DofToQuad &maps, const Vector &e_vec, Vector &q_val, Vector &q_der, Vector &q_det, const int eval_flags)
Template compute kernel for 2D.
Structure representing the matrices/tensors needed to evaluate (in reference space) the values...
Definition: fe.hpp:131
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.
static void Eval3D(const int NE, const int vdim, const DofToQuad &maps, const Vector &e_vec, Vector &q_val, Vector &q_der, Vector &q_det, const int eval_flags)
Template compute kernel for 3D.
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 of the E-vector e_vec at quadrature points.
Vector data type.
Definition: vector.hpp:51
Class representing the storage layout of a QuadratureFunction.
Definition: fespace.hpp:728
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.
Evaluate the values at quadrature points.
const QuadratureSpace * qspace
Not owned.