Loading...
Searching...
No Matches
volume_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_VOLUME_MAPPER_HPP__
26#define __BITPIT_VOLUME_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_kernel.hpp"
36
37namespace bitpit {
38
43namespace mapping
44{
45
49enum Type {
50 TYPE_UNKNOWN = 0,
51 TYPE_REFINEMENT,
52 TYPE_COARSENING,
53 TYPE_RENUMBERING
54};
55
59enum Entity {
60 ENTITY_UNKNOWN = -1,
61 ENTITY_CELL,
62};
63
71struct Info
72{
77 : type(TYPE_UNKNOWN), entity(ENTITY_UNKNOWN)
78 {
79 }
80
86 Info(Type user_type, Entity user_entity)
87 : type(user_type), entity(user_entity)
88 {
89 }
90
93 std::vector<long> ids;
94#if BITPIT_ENABLE_MPI
95 std::vector<int> ranks;
96#endif
97
98};
99
100}
101
103
104public:
105 virtual ~VolumeMapper() = default;
106
107 void clear();
108 void clearMapping();
109 void clearInverseMapping();
110
111 const VolumeKernel *getReferencePatch() const;
112 const VolumeKernel *getMappedPatch() const;
113
116
117 void initialize(bool fillInv = false);
118
119 virtual void adaptionPrepare(const std::vector<adaption::Info> &infoAdapt, bool reference = true) = 0;
120 virtual void adaptionAlter(const std::vector<adaption::Info> &infoAdapt, bool reference = true, bool fillInv = false) = 0;
121 virtual void adaptionCleanup() = 0;
122
123#if BITPIT_ENABLE_MPI
124 virtual bool checkPartition() = 0;
125 virtual std::unordered_map<int, std::vector<long> > getReceivedMappedIds() const = 0;
126 virtual std::unordered_map<int, std::vector<long> > getSentMappedIds() const = 0;
127 virtual std::unordered_map<int, std::vector<long> > getReceivedReferenceIds() const = 0;
128 virtual std::unordered_map<int, std::vector<long> > getSentReferenceIds() const = 0;
129#endif
130
131protected:
141 std::unordered_map<long, mapping::Info> m_previousMapping;
143#if BITPIT_ENABLE_MPI
144 MPI_Comm m_communicator;
145 int m_rank;
147#endif
148
149#if BITPIT_ENABLE_MPI
150 VolumeMapper(const VolumeKernel *referencePatch, const VolumeKernel *mappedPatch, MPI_Comm communicator);
151#else
152 VolumeMapper(const VolumeKernel *referencePatch, const VolumeKernel *mappedPatch);
153#endif
154
155 virtual void _mapMeshes(bool fillInverse) = 0;
156
157#if BITPIT_ENABLE_MPI
158 void initializeCommunicator(MPI_Comm communicator);
159 MPI_Comm getCommunicator() const;
160 bool isCommunicatorSet() const;
161 void freeCommunicator();
162#endif
163
164};
165
166}
167#endif
Metafunction for generating a pierced storage.
The VolumeKernel class provides an interface for defining volume patches.
The VolumeMapper is the class to map two meshes.
VolumeMapper(const VolumeKernel *referencePatch, const VolumeKernel *mappedPatch, MPI_Comm communicator)
const VolumeKernel * getMappedPatch() const
MPI_Comm getCommunicator() const
const VolumeKernel * m_mappedPatch
std::unordered_map< long, mapping::Info > m_previousMapping
void initialize(bool fillInv=false)
void initializeCommunicator(MPI_Comm communicator)
PiercedStorage< mapping::Info > m_inverseMapping
PiercedStorage< mapping::Info > m_mapping
const bitpit::PiercedStorage< mapping::Info > & getInverseMapping() const
const bitpit::PiercedStorage< mapping::Info > & getMapping() const
const VolumeKernel * getReferencePatch() const
const VolumeKernel * m_referencePatch
bool isCommunicatorSet() const
The Info is the structure to store info about mapping between elements.
Info(Type user_type, Entity user_entity)
std::vector< int > ranks
std::vector< long > ids
--- layout: doxygen_footer ---