MFEM  v4.5.2
Finite element discretization library
transfermap.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, 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_TRANSFERMAP
13 #define MFEM_TRANSFERMAP
14 
15 #include "../../fem/gridfunc.hpp"
16 #include "transfer_category.hpp"
17 #include <memory>
18 
19 namespace mfem
20 {
21 
22 /**
23  * @brief TransferMap represents a mapping of degrees of freedom from a source
24  * GridFunction to a destination GridFunction.
25  *
26  * This map can be constructed from a parent Mesh to a SubMesh or vice versa.
27  * Additionally one can create it between two SubMeshes that share the same root
28  * parent. In this case, a supplemental FiniteElementSpace is created on the
29  * root parent Mesh to transfer degrees of freedom.
30  */
32 {
33 public:
34  /**
35  * @brief Construct a new TransferMap object which transfers degrees of
36  * freedom from the source GridFunction to the destination GridFunction.
37  *
38  * @param src The source GridFunction
39  * @param dst The destination Gridfunction
40  */
41  TransferMap(const GridFunction &src,
42  const GridFunction &dst);
43 
44  /**
45  * @brief Transfer the source GridFunction to the destination GridFunction.
46  *
47  * Uses the precomputed maps for the transfer.
48  *
49  * @param src The source GridFunction
50  * @param dst The destination Gridfunction
51  */
52  void Transfer(const GridFunction &src, GridFunction &dst) const;
53 
54 private:
55  TransferCategory category_;
56 
57  /// Mapping of the GridFunction defined on the SubMesh to the Gridfunction
58  /// of its parent Mesh.
59  Array<int> sub1_to_parent_map_;
60 
61  /// Mapping of the GridFunction defined on the second SubMesh to the
62  /// GridFunction of its parent Mesh. This is only used if this TransferMap
63  /// represents a SubMesh to SubMesh transfer.
64  Array<int> sub2_to_parent_map_;
65 
66  /// Pointer to the supplemental FiniteElementSpace on the common root parent
67  /// Mesh. This is only used if this TransferMap represents a SubMesh to
68  /// SubMesh transfer.
69  std::unique_ptr<const FiniteElementSpace> root_fes_;
70 
71  /// Temporary vector
72  mutable Vector z_;
73 };
74 
75 } // namespace mfem
76 
77 #endif // MFEM_TRANSFERMAP
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:30
TransferCategory
TransferCategory describes the type of transfer.
void Transfer(const GridFunction &src, GridFunction &dst) const
Transfer the source GridFunction to the destination GridFunction.
Definition: transfermap.cpp:90
TransferMap represents a mapping of degrees of freedom from a source GridFunction to a destination Gr...
Definition: transfermap.hpp:31
Vector data type.
Definition: vector.hpp:60
TransferMap(const GridFunction &src, const GridFunction &dst)
Construct a new TransferMap object which transfers degrees of freedom from the source GridFunction to...
Definition: transfermap.cpp:18