MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
ptransfermap.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2025, 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
16#include "transfer_category.hpp"
17#include <memory>
18
19namespace 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{
33public:
34 /**
35 * @brief Construct a new ParTransferMap object which transfers degrees of
36 * freedom from the source ParFiniteElementSpace to the destination
37 * ParFiniteElementSpace.
38 *
39 * @param src The source ParFiniteElementSpace
40 * @param dst The destination ParFiniteElementSpace
41 */
43 const ParFiniteElementSpace &dst);
44
45 /**
46 * @brief Construct a new ParTransferMap object which transfers degrees of
47 * freedom from the source ParGridFunction to the destination
48 * ParGridFunction.
49 *
50 * Equivalent to creating the ParTransferMap using the spaces on which the
51 * ParGridFunction%s are defined.
52 *
53 * @param src The source ParGridFunction
54 * @param dst The destination ParGridFunction
55 */
56 ParTransferMap(const ParGridFunction &src, const ParGridFunction &dst);
57
58 /**
59 * @brief Transfer the source ParGridFunction to the destination
60 * ParGridFunction.
61 *
62 * Uses the precomputed maps for the transfer.
63 *
64 * @param src The source ParGridFunction
65 * @param dst The destination ParGridFunction
66 */
67 void Transfer(const ParGridFunction &src, ParGridFunction &dst) const;
68
69private:
70 /**
71 * @brief Communicate from each local processor which index in map is set.
72 *
73 * The result is accumulated in the member variable indices_set_global_ and
74 * indicates which and how many processors in total will set a certain degree
75 * of freedom.
76 *
77 * Convenience method for tidyness. Uses and changes member variables.
78 */
79 void CommunicateIndicesSet(Array<int> &map, int dst_sz);
80
81 /**
82 * @brief Communicate shared vdofs in Vector f.
83 *
84 * Guarantees that all ranks have the appropriate dofs set. See comments in
85 * implementation for more details.
86 *
87 * Convenience method for tidyness. Uses and changes member variables.
88 */
89 void CommunicateSharedVdofs(Vector &f) const;
90
91 static void CorrectFaceOrientations(const ParFiniteElementSpace &fes,
92 const Vector &src,
93 Vector &dst,
94 const Array<int> *s2p_map = NULL);
95
96 TransferCategory category_;
97
98 /// Mapping of the ParGridFunction defined on the SubMesh to the
99 /// ParGridFunction of its parent ParMesh.
100 Array<int> sub_to_parent_map_;
101
102 /// Set of indices in the dof map that are set by the local rank.
103 Array<int> indices_set_local_;
104
105 /// Set of indices in the dof map that are set by all ranks. The number is
106 /// accumulated by summation.
107 Array<int> indices_set_global_;
108
109 /// Pointer to the finite element space defined on the SubMesh.
110 const ParFiniteElementSpace *sub_fes_ = nullptr;
111
112 /// @name Needed for ParSubMesh-to-ParSubMesh transfer
113 ///@{
114
115 /// Pointer to the supplemental ParFiniteElementSpace on the common root
116 /// parent ParMesh. This is only used if this ParTransferMap represents a
117 /// ParSubMesh to ParSubMesh transfer.
118 std::unique_ptr<ParFiniteElementSpace> root_fes_;
119
120 /// Pointer to the supplemental FiniteElementCollection used with root_fes_.
121 /// This is only used if this TransferMap represents a SubMesh to SubMesh
122 /// transfer where the root requires a different type of collection than the
123 /// SubMesh objects. For example, when the subpaces are L2 on boundaries of
124 /// the parent mesh and the root space can be RT.
125 std::unique_ptr<const FiniteElementCollection> root_fec_;
126
127 const GroupCommunicator *root_gc_ = nullptr;
128
129 /// Transfer mapping from the source to the parent (root).
130 std::unique_ptr<ParTransferMap> src_to_parent;
131
132 /// @brief Transfer mapping from the destination to the parent (root).
133 ///
134 /// ParSubMesh-to-ParSubMesh transfer works by bringing both the source and
135 /// destination data to their common parent, and then transferring back to
136 /// the destination.
137 std::unique_ptr<ParTransferMap> dst_to_parent;
138
139 /// Transfer mapping from the parent to the destination.
140 std::unique_ptr<ParTransferMap> parent_to_dst;
141
142 ///@}
143
144 /// Temporary vector
145 mutable ParGridFunction z_;
146};
147
148} // namespace mfem
149
150#endif // MFEM_PTRANSFERMAP
Communicator performing operations within groups defined by a GroupTopology with arbitrary-size data ...
Abstract parallel finite element space.
Definition pfespace.hpp:29
Class for parallel grid function.
Definition pgridfunc.hpp:50
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 ParFiniteElementSpace &src, const ParFiniteElementSpace &dst)
Construct a new ParTransferMap object which transfers degrees of freedom from the source ParFiniteEle...
Vector data type.
Definition vector.hpp:82
TransferCategory
TransferCategory describes the type of transfer.
std::function< real_t(const Vector &)> f(real_t mass_coeff)
Definition lor_mms.hpp:30