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