MFEM  v4.2.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
transfer.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_TRANSFER_HPP
13 #define MFEM_TRANSFER_HPP
14 
15 #include "../linalg/linalg.hpp"
16 #include "fespace.hpp"
17 
18 #ifdef MFEM_USE_MPI
19 #include "pfespace.hpp"
20 #endif
21 
22 namespace mfem
23 {
24 
25 /// Matrix-free transfer operator between finite element spaces
26 class TransferOperator : public Operator
27 {
28 private:
29  Operator* opr;
30 
31 public:
32  /// Constructs a transfer operator from \p lFESpace to \p hFESpace.
33  /** No matrices are assembled, only the action to a vector is being computed.
34  If both spaces' FE collection pointers are pointing to the same collection
35  we assume that the grid was refined while keeping the order constant. If
36  the FE collections are different, it is assumed that both spaces have are
37  using the same mesh. If the first element of the high-order space is a
38  `TensorBasisElement`, the optimized tensor-product transfers are used. If
39  not, the general transfers used. */
40  TransferOperator(const FiniteElementSpace& lFESpace,
41  const FiniteElementSpace& hFESpace);
42 
43  /// Destructor
44  virtual ~TransferOperator();
45 
46  /// @brief Interpolation or prolongation of a vector \p x corresponding to the
47  /// coarse space to the vector \p y corresponding to the fine space.
48  virtual void Mult(const Vector& x, Vector& y) const override;
49 
50  /// Restriction by applying the transpose of the Mult method.
51  /** The vector \p x corresponding to the fine space is restricted to the vector
52  \p y corresponding to the coarse space. */
53  virtual void MultTranspose(const Vector& x, Vector& y) const override;
54 };
55 
56 /// Matrix-free transfer operator between finite element spaces on the same mesh
58 {
59 private:
60  const FiniteElementSpace& lFESpace;
61  const FiniteElementSpace& hFESpace;
62 
63 public:
64  /// @brief Constructs a transfer operator from \p lFESpace to \p hFESpace
65  /// which have different FE collections.
66  /** No matrices are assembled, only the action to a vector is being computed.
67  The underlying finite elements need to implement the GetTransferMatrix
68  methods. */
70  const FiniteElementSpace& hFESpace_);
71 
72  /// Destructor
74 
75  /// @brief Interpolation or prolongation of a vector \p x corresponding to the
76  /// coarse space to the vector \p y corresponding to the fine space.
77  virtual void Mult(const Vector& x, Vector& y) const override;
78 
79  /// Restriction by applying the transpose of the Mult method.
80  /** The vector \p x corresponding to the fine space is restricted to the vector
81  \p y corresponding to the coarse space. */
82  virtual void MultTranspose(const Vector& x, Vector& y) const override;
83 };
84 
85 /// @brief Matrix-free transfer operator between finite element spaces on the same
86 /// mesh exploiting the tensor product structure of the finite elements
88 {
89 private:
90  const FiniteElementSpace& lFESpace;
91  const FiniteElementSpace& hFESpace;
92  int dim;
93  int NE;
94  int D1D;
95  int Q1D;
96  Array<double> B;
97  Array<double> Bt;
98  const Operator* elem_restrict_lex_l;
99  const Operator* elem_restrict_lex_h;
100  Vector mask;
101  mutable Vector localL;
102  mutable Vector localH;
103 
104 public:
105  /// @brief Constructs a transfer operator from \p lFESpace to \p hFESpace which
106  /// have different FE collections.
107  /** No matrices are assembled, only the action to a vector is being computed.
108  The underlying finite elements need to be of the type `TensorBasisElement`. It
109  is also assumed that all the elements in the spaces are of the same type. */
111  const FiniteElementSpace& lFESpace_,
112  const FiniteElementSpace& hFESpace_);
113 
114  /// Destructor
116 
117  /// @brief Interpolation or prolongation of a vector \p x corresponding to the
118  /// coarse space to the vector \p y corresponding to the fine space.
119  virtual void Mult(const Vector& x, Vector& y) const override;
120 
121  /// Restriction by applying the transpose of the Mult method.
122  /** The vector \p x corresponding to the fine space is restricted to the vector
123  \p y corresponding to the coarse space. */
124  virtual void MultTranspose(const Vector& x, Vector& y) const override;
125 };
126 
127 #ifdef MFEM_USE_MPI
128 /// @brief Matrix-free transfer operator between finite element spaces working on
129 /// true degrees of freedom
131 {
132 private:
133  const ParFiniteElementSpace& lFESpace;
134  const ParFiniteElementSpace& hFESpace;
135  TransferOperator* localTransferOperator;
136  mutable Vector tmpL;
137  mutable Vector tmpH;
138 
139 public:
140  /// @brief Constructs a transfer operator working on true degrees of freedom from
141  /// from \p lFESpace to \p hFESpace
143  const ParFiniteElementSpace& hFESpace_);
144 
145  /// Destructor
147 
148  /// @brief Interpolation or prolongation of a true dof vector \p x to a true dof
149  /// vector \p y.
150  /** The true dof vector \p x corresponding to the coarse space is restricted to
151  the true dof vector \p y corresponding to the fine space. */
152  virtual void Mult(const Vector& x, Vector& y) const override;
153 
154  /// Restriction by applying the transpose of the Mult method.
155  /** The true dof vector \p x corresponding to the fine space is restricted to
156  the true dof vector \p y corresponding to the coarse space. */
157  virtual void MultTranspose(const Vector& x, Vector& y) const override;
158 };
159 #endif
160 
161 } // namespace mfem
162 
163 #endif
virtual void MultTranspose(const Vector &x, Vector &y) const override
Restriction by applying the transpose of the Mult method.
Definition: transfer.cpp:493
virtual ~TensorProductPRefinementTransferOperator()
Destructor.
Definition: transfer.cpp:463
Matrix-free transfer operator between finite element spaces on the same mesh.
Definition: transfer.hpp:57
virtual void MultTranspose(const Vector &x, Vector &y) const override
Restriction by applying the transpose of the Mult method.
Definition: transfer.cpp:547
virtual ~TransferOperator()
Destructor.
Definition: transfer.cpp:42
~TrueTransferOperator()
Destructor.
Definition: transfer.cpp:535
virtual void Mult(const Vector &x, Vector &y) const override
Interpolation or prolongation of a vector x corresponding to the coarse space to the vector y corresp...
Definition: transfer.cpp:44
Abstract parallel finite element space.
Definition: pfespace.hpp:28
virtual ~PRefinementTransferOperator()
Destructor.
Definition: transfer.cpp:61
virtual void MultTranspose(const Vector &x, Vector &y) const override
Restriction by applying the transpose of the Mult method.
Definition: transfer.cpp:49
TrueTransferOperator(const ParFiniteElementSpace &lFESpace_, const ParFiniteElementSpace &hFESpace_)
Constructs a transfer operator working on true degrees of freedom from from lFESpace to hFESpace...
Definition: transfer.cpp:520
TensorProductPRefinementTransferOperator(const FiniteElementSpace &lFESpace_, const FiniteElementSpace &hFESpace_)
Constructs a transfer operator from lFESpace to hFESpace which have different FE collections.
Definition: transfer.cpp:171
virtual void MultTranspose(const Vector &x, Vector &y) const override
Restriction by applying the transpose of the Mult method.
Definition: transfer.cpp:106
Matrix-free transfer operator between finite element spaces.
Definition: transfer.hpp:26
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:87
Matrix-free transfer operator between finite element spaces on the same mesh exploiting the tensor pr...
Definition: transfer.hpp:87
virtual void Mult(const Vector &x, Vector &y) const override
Interpolation or prolongation of a vector x corresponding to the coarse space to the vector y corresp...
Definition: transfer.cpp:467
virtual void Mult(const Vector &x, Vector &y) const override
Interpolation or prolongation of a vector x corresponding to the coarse space to the vector y corresp...
Definition: transfer.cpp:63
PRefinementTransferOperator(const FiniteElementSpace &lFESpace_, const FiniteElementSpace &hFESpace_)
Constructs a transfer operator from lFESpace to hFESpace which have different FE collections.
Definition: transfer.cpp:54
virtual void Mult(const Vector &x, Vector &y) const override
Interpolation or prolongation of a true dof vector x to a true dof vector y.
Definition: transfer.cpp:540
Vector data type.
Definition: vector.hpp:51
Abstract operator.
Definition: operator.hpp:24
TransferOperator(const FiniteElementSpace &lFESpace, const FiniteElementSpace &hFESpace)
Constructs a transfer operator from lFESpace to hFESpace.
Definition: transfer.cpp:18
Matrix-free transfer operator between finite element spaces working on true degrees of freedom...
Definition: transfer.hpp:130