MFEM v4.8.0
Finite element discretization library
Loading...
Searching...
No Matches
transfermap.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_TRANSFERMAP
13#define MFEM_TRANSFERMAP
14
16#include "transfer_category.hpp"
17#include <memory>
18
19namespace 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{
33public:
34 /**
35 * @brief Construct a new TransferMap object which transfers degrees of
36 * freedom from the source FiniteElementSpace to the destination
37 * FiniteElementSpace.
38 *
39 * @param src The source FiniteElementSpace
40 * @param dst The destination FiniteElementSpace
41 */
43
44 /**
45 * @brief Construct a new TransferMap object which transfers degrees of
46 * freedom from the source GridFunction to the destination GridFunction.
47 *
48 * Equivalent to creating the TransferMap from the finite element spaces of
49 * each of the GridFunction%s.
50 *
51 * @param src The source GridFunction
52 * @param dst The destination GridFunction
53 */
54 TransferMap(const GridFunction &src, const GridFunction &dst);
55
56 /**
57 * @brief Transfer the source GridFunction to the destination GridFunction.
58 *
59 * Uses the precomputed maps for the transfer.
60 *
61 * @param src The source GridFunction
62 * @param dst The destination GridFunction
63 */
64 void Transfer(const GridFunction &src, GridFunction &dst) const;
65
66private:
67
68 static void CorrectFaceOrientations(const FiniteElementSpace &fes,
69 const Vector &src,
70 Vector &dst,
71 const Array<int> *s2p_map = NULL);
72
73 TransferCategory category_;
74
75 /// Mapping of the GridFunction defined on the SubMesh to the GridFunction
76 /// of its parent Mesh.
77 Array<int> sub_to_parent_map_;
78
79 /// Pointer to the finite element space defined on the SubMesh.
80 const FiniteElementSpace *sub_fes_ = nullptr;
81
82 /// @name Needed for SubMesh-to-SubMesh transfer
83 ///@{
84
85 /// Pointer to the supplemental FiniteElementSpace on the common root parent
86 /// Mesh. This is only used if this TransferMap represents a SubMesh to
87 /// SubMesh transfer.
88 std::unique_ptr<FiniteElementSpace> root_fes_;
89
90 /// Pointer to the supplemental FiniteElementCollection used with root_fes_.
91 /// This is only used if this TransferMap represents a SubMesh to SubMesh
92 /// transfer where the root requires a different type of collection than the
93 /// SubMesh objects. For example, when the subpaces are L2 on boundaries of
94 /// the parent mesh and the root space can be RT.
95 std::unique_ptr<const FiniteElementCollection> root_fec_;
96
97 /// Transfer mapping from the source to the parent (root).
98 std::unique_ptr<TransferMap> src_to_parent;
99
100 /// @brief Transfer mapping from the destination to the parent (root).
101 ///
102 /// SubMesh-to-SubMesh transfer works by bringing both the source and
103 /// destination data to their common parent, and then transferring back to
104 /// the destination.
105 std::unique_ptr<TransferMap> dst_to_parent;
106
107 /// Transfer mapping from the parent to the destination.
108 std::unique_ptr<TransferMap> parent_to_dst;
109
110 ///@}
111
112 /// Temporary vector
113 mutable GridFunction z_;
114};
115
116} // namespace mfem
117
118#endif // MFEM_TRANSFERMAP
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition fespace.hpp:244
Class for grid function - Vector with associated FE space.
Definition gridfunc.hpp:31
TransferMap represents a mapping of degrees of freedom from a source GridFunction to a destination Gr...
void Transfer(const GridFunction &src, GridFunction &dst) const
Transfer the source GridFunction to the destination GridFunction.
TransferMap(const FiniteElementSpace &src, const FiniteElementSpace &dst)
Construct a new TransferMap object which transfers degrees of freedom from the source FiniteElementSp...
Vector data type.
Definition vector.hpp:82
TransferCategory
TransferCategory describes the type of transfer.