MFEM  v4.5.2
Finite element discretization library
ptransfermap.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_PTRANSFERMAP
13 #define MFEM_PTRANSFERMAP
14 
15 #include "../../fem/pgridfunc.hpp"
16 #include "transfer_category.hpp"
17 #include <memory>
18 
19 namespace mfem
20 {
21 
22 /**
23  * @brief ParTransferMap represents a mapping of degrees of freedom from a
24  * source ParGridFunction to a destination ParGridFunction.
25  *
26  * This map can be constructed from a parent ParMesh to a ParSubMesh or vice
27  * versa. Additionally one can create it between two ParSubMeshes that share the
28  * same root parent. In this case, a supplemental ParFiniteElementSpace is
29  * created on the root parent ParMesh to transfer degrees of freedom.
30  */
32 {
33 public:
34  /**
35  * @brief Construct a new ParTransferMap object which transfers degrees of
36  * freedom from the source ParGridFunction to the destination
37  * ParGridFunction.
38  *
39  * @param src The source ParGridFunction
40  * @param dst The destination ParGridFunction
41  */
43  const ParGridFunction &dst);
44 
45  /**
46  * @brief Transfer the source ParGridFunction to the destination
47  * ParGridFunction.
48  *
49  * Uses the precomputed maps for the transfer.
50  *
51  * @param src The source ParGridFunction
52  * @param dst The destination ParGridFunction
53  */
54  void Transfer(const ParGridFunction &src, ParGridFunction &dst) const;
55 
56 private:
57  /**
58  * @brief Communicate from each local processor which index in map is set.
59  *
60  * The result is accumulated in the member variable indices_set_global_ and
61  * indicates which and how many processors in total will set a certain degree
62  * of freedom.
63  *
64  * Convenience method for tidyness. Uses and changes member variables.
65  */
66  void CommunicateIndicesSet(Array<int> &map, int dst_sz);
67 
68  /**
69  * @brief Communicate shared vdofs in Vector f.
70  *
71  * Guarantees that all ranks have the appropriate dofs set. See comments in
72  * implementation for more details.
73  *
74  * Convenience method for tidyness. Uses and changes member variables.
75  */
76  void CommunicateSharedVdofs(Vector &f) const;
77 
78  TransferCategory category_;
79 
80  /// Mapping of the ParGridFunction defined on the SubMesh to the
81  /// ParGridFunction of its parent ParMesh.
82  Array<int> sub1_to_parent_map_;
83 
84  /// Mapping of the ParGridFunction defined on the second SubMesh to the
85  /// ParGridFunction of its parent ParMesh. This is only used if this
86  /// ParTransferMap represents a ParSubMesh to ParSubMesh transfer.
87  Array<int> sub2_to_parent_map_;
88 
89  /// Set of indices in the dof map that are set by the local rank.
90  Array<int> indices_set_local_;
91 
92  /// Set of indices in the dof map that are set by all ranks. The number is
93  /// accumulated by summation.
94  Array<int> indices_set_global_;
95 
96  /// Pointer to the supplemental ParFiniteElementSpace on the common root
97  /// parent ParMesh. This is only used if this ParTransferMap represents a
98  /// ParSubMesh to ParSubMesh transfer.
99  std::unique_ptr<const ParFiniteElementSpace> root_fes_;
100 
101  const GroupCommunicator *root_gc_ = nullptr;
102 
103  /// Temporary vector
104  mutable Vector z_;
105 };
106 
107 } // namespace mfem
108 
109 #endif // MFEM_PTRANSFERMAP
TransferCategory
TransferCategory describes the type of transfer.
Communicator performing operations within groups defined by a GroupTopology with arbitrary-size data ...
double f(const Vector &xvec)
Definition: lor_mms.hpp:32
ParTransferMap represents a mapping of degrees of freedom from a source ParGridFunction to a destinat...
void Transfer(const ParGridFunction &src, ParGridFunction &dst) const
Transfer the source ParGridFunction to the destination ParGridFunction.
ParTransferMap(const ParGridFunction &src, const ParGridFunction &dst)
Construct a new ParTransferMap object which transfers degrees of freedom from the source ParGridFunct...
Vector data type.
Definition: vector.hpp:60
Class for parallel grid function.
Definition: pgridfunc.hpp:32