Loading...
Searching...
No Matches
voloctree_mapper.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_VOLOCTREE_MAPPER_HPP__
26#define __BITPIT_VOLOCTREE_MAPPER_HPP__
27
28#if BITPIT_ENABLE_MPI
29# include <mpi.h>
30#endif
31#include <string>
32#include <vector>
33#include <unordered_map>
34
35#include "volume_mapper.hpp"
36#include "voloctree.hpp"
37#include "voloctree_mapper.hpp"
38
39namespace bitpit {
40
42
43public:
44#if BITPIT_ENABLE_MPI
45 VolOctreeMapper(const VolOctree *referencePatch, const VolOctree *mappedPatch, MPI_Comm communicator);
46#else
47 VolOctreeMapper(const VolOctree *referencePatch, const VolOctree *mappedPatch);
48#endif
49
50 void adaptionPrepare(const std::vector<adaption::Info> &adaptionInfo, bool reference = true) override;
51 void adaptionAlter(const std::vector<adaption::Info> &adaptionInfo, bool reference = true, bool inverseFilled = false) override;
52 void adaptionCleanup() override;
53
54#if BITPIT_ENABLE_MPI
55 bool checkPartition() override;
57 std::unordered_map<int, std::vector<long>> getReceivedMappedIds() const override;
58 std::unordered_map<int, std::vector<long>> getSentMappedIds() const override;
59 std::unordered_map<int, std::vector<long>> getReceivedReferenceIds() const override;
60 std::unordered_map<int, std::vector<long>> getSentReferenceIds() const override;
61#endif
62
63private:
71 struct OctantIR {
72 Octant octant;
73 long id;
74 long globalId;
75 int rank;
80 OctantIR()
81 {
82 };
83
92 OctantIR(const Octant &_octant, long _id, long _globalId = -1, int _rank = -1)
93 {
94 octant = _octant;
95 id = _id;
96 globalId = _globalId;
97 rank = _rank;
98 };
99 };
100
101#if BITPIT_ENABLE_MPI
109 struct PartitionMapper {
110 std::vector<OctantIR> list_rec_octantIR_before;
111 std::vector<OctantIR> list_rec_octantIR_after;
113 std::unordered_map<int, std::unordered_map<long, OctantIR *>> map_rank_rec_octantIR;
114 std::unordered_map<int, std::unordered_map<long, mapping::Info>> map_rank_inverseMapping;
115 std::unordered_map<int, std::unordered_map<long, mapping::Info>> map_rank_previousMapping;
117 std::vector<OctantIR> list_sent_octantIR;
119 std::vector<uint64_t> partitionFDReference;
120 std::vector<uint64_t> partitionLDReference;
121 std::vector<uint64_t> partitionFDMapped;
122 std::vector<uint64_t> partitionLDMapped;
127 PartitionMapper(){};
128
132 void clear(){
133 list_rec_octantIR_before.clear();
134 list_rec_octantIR_after.clear();
135 list_sent_octantIR.clear();
136 map_rank_rec_octantIR.clear();
137 map_rank_inverseMapping.clear();
138 map_rank_previousMapping.clear();
139 partitionFDReference.clear();
140 partitionLDReference.clear();
141 partitionFDMapped.clear();
142 partitionLDMapped.clear();
143 }
144
148 void clearLists(){
149 list_rec_octantIR_before.clear();
150 list_rec_octantIR_after.clear();
151 list_sent_octantIR.clear();
152 }
153 };
154#endif
155
156#if BITPIT_ENABLE_MPI
157 PartitionMapper m_partitionIR;
158#endif
159
160 void _mapMeshes(bool fillInverse) override;
161 void _mapMeshesSamePartition(const std::vector<OctantIR> * octantsReference, const std::vector<OctantIR> * octantsMapped,
162 bool fillInverse, long *indRef);
163
164 void _mappingAdaptionReferenceUpdate(const std::vector<adaption::Info> &adaptionInfo, bool fillInverse = false);
165 void _mappingAdaptionMappedUpdate(const std::vector<adaption::Info> &adaptionInfo);
166
167#if BITPIT_ENABLE_MPI
168 void clearPartitionMappingLists();
169
170 void _mapMeshPartitioned(bool fillInverse);
171
172 bool _recoverPartition();
173
174 void _communicateInverseMapper(const std::vector<OctantIR> *octantsIRMapped,
175 const std::unordered_map<long, mapping::Info> &inverseGlobalMapping,
176 std::unordered_map<long, mapping::Info> *inverseLocalMapping);
177
178 void _communicateInverseMapperBack();
179
180 void _communicateMappedAdaptionInfo(const std::vector<adaption::Info> &adaptionInfoMap, std::vector<adaption::Info> *adaptionInfoRef);
181#endif
182
183};
184
185}
186
187#endif
Octant class definition.
Definition Octant.hpp:89
The VolOctreeMapper is the class to map two meshes of class VolOctree.
std::unordered_map< int, std::vector< long > > getReceivedReferenceIds() const override
std::unordered_map< int, std::vector< long > > getReceivedMappedIds() const override
std::unordered_map< int, std::vector< long > > getSentReferenceIds() const override
void adaptionPrepare(const std::vector< adaption::Info > &adaptionInfo, bool reference=true) override
void adaptionAlter(const std::vector< adaption::Info > &adaptionInfo, bool reference=true, bool inverseFilled=false) override
VolOctreeMapper(const VolOctree *referencePatch, const VolOctree *mappedPatch, MPI_Comm communicator)
std::unordered_map< int, std::vector< long > > getSentMappedIds() const override
The VolOctree defines a Octree patch.
Definition voloctree.hpp:37
The VolumeMapper is the class to map two meshes.
--- layout: doxygen_footer ---