Loading...
Searching...
No Matches
patch_info.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_PATCH_INFO_HPP__
26#define __BITPIT_PATCH_INFO_HPP__
27
28#include <unordered_map>
29#include <vector>
30
31namespace bitpit {
32
33class PatchKernel;
34
35class PatchInfo {
36
37public:
38 virtual ~PatchInfo() = default;
39
40 PatchKernel const & getPatch() const;
41 void setPatch(PatchKernel const *patch);
42
43 void reset();
44 void extract();
45 void update();
46
47protected:
48 PatchKernel const *m_patch;
49
50 PatchInfo(PatchKernel const *patch);
51
52 void setPatch(PatchKernel const *patch, bool initialize);
53
54 virtual void _init() = 0;
55 virtual void _reset() = 0;
56 virtual void _extract() = 0;
57
58};
59
61
62public:
63 PatchNumberingInfo(PatchKernel const *patch = nullptr);
64
65 long getCellConsecutiveOffset() const;
66 long getCellConsecutiveId(long id) const;
67 const std::unordered_map<long, long> & getCellConsecutiveMap() const;
68
69#if BITPIT_ENABLE_MPI==1
70 long getCellGlobalCount() const;
71 long getCellGlobalCountOffset() const;
72 long getCellGlobalCountOffset(int rank) const;
73
74 long getCellGlobalId(long id) const;
75 const std::unordered_map<long, long> & getCellGlobalMap() const;
76
77 int getCellOwnerFromLocal(long id) const;
78 int getCellOwnerFromConsecutive(long id) const;
79 int getCellOwnerFromGlobal(long id) const;
80#endif
81
82protected:
83 void _init() override;
84 void _reset() override;
85 void _extract() override;
86
87private:
88 long m_cellConsecutiveOffset;
89 std::unordered_map<long, long> m_cellLocalToConsecutiveMap;
90#if BITPIT_ENABLE_MPI==1
91 std::vector<long> m_nGlobalInternalCells;
92#endif
93
94};
95
96}
97
98#endif
The PatchInfo class provides an interface for defining patch info.
void setPatch(PatchKernel const *patch)
PatchKernel const & getPatch() const
PatchInfo(PatchKernel const *patch)
The PatchKernel class provides an interface for defining patches.
Numbering information about the patch.
const std::unordered_map< long, long > & getCellGlobalMap() const
long getCellGlobalCountOffset() const
PatchNumberingInfo(PatchKernel const *patch=nullptr)
int getCellOwnerFromLocal(long id) const
long getCellGlobalId(long id) const
const std::unordered_map< long, long > & getCellConsecutiveMap() const
long getCellConsecutiveOffset() const
int getCellOwnerFromGlobal(long id) const
int getCellOwnerFromConsecutive(long id) const
long getCellConsecutiveId(long id) const
--- layout: doxygen_footer ---