Loading...
Searching...
No Matches
adaption.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_ADAPTION_HPP__
26#define __BITPIT_ADAPTION_HPP__
27
28#include <vector>
29#include <unordered_map>
30#include <unordered_set>
31
32namespace bitpit {
33
34namespace adaption
35{
36 enum Marker {
37 MARKER_REFINE,
38 MARKER_NONE,
39 MARKER_COARSEN,
40 MARKER_UNDEFINED
41 };
42
43 enum Type {
44 TYPE_UNKNOWN = -2,
45 TYPE_NONE = -1,
46 TYPE_CREATION = 0,
47 TYPE_DELETION,
48 TYPE_REFINEMENT,
49 TYPE_COARSENING,
50 TYPE_RENUMBERING,
51 TYPE_PARTITION_SEND,
52 TYPE_PARTITION_RECV,
53 TYPE_PARTITION_NOTICE
54 };
55
56 enum Entity {
57 ENTITY_UNKNOWN = -1,
58 ENTITY_CELL,
59 ENTITY_INTERFACE
60 };
61
62 struct Info
63 {
64 Info()
65 : type(TYPE_UNKNOWN), entity(ENTITY_UNKNOWN), rank(-1)
66 {
67 }
68
69 Info(Type user_type, Entity user_entity, int user_rank = -1)
70 : type(user_type), entity(user_entity), rank(user_rank)
71 {
72 }
73
74 Type type;
75 Entity entity;
76 int rank;
77 std::vector<long> previous;
78 std::vector<long> current;
79 };
80
82 {
83
84 public:
86
87 std::size_t create();
88 std::size_t create(Type type, Entity entity, int rank = -1);
89
90 Info & at(std::size_t id);
91 const Info & at(std::size_t id) const;
92
93 const std::vector<Info> & data() const noexcept;
94 std::vector<Info> & data() noexcept;
95
96 Info & operator[](std::size_t id);
97 const Info & operator[](std::size_t id) const;
98
99 std::vector<Info> dump();
100
101 private:
102 typedef std::tuple<int, int, int> infoData_t;
103
104 std::unordered_map<infoData_t, std::size_t, utils::hashing::hash<infoData_t>> m_cache;
105 std::unordered_set<int> m_cachedTypes;
106 std::vector<Info> m_collection;
107 };
108}
109
110class PatchKernel;
111
113{
114
115public:
116 FlatMapping();
117 FlatMapping(PatchKernel *patch);
118
119 virtual ~FlatMapping() = default;
120
121 virtual void update(const std::vector<adaption::Info> &adaptionData) = 0;
122
123 const std::vector<long> & getNumbering() const;
124 const std::vector<long> & getMapping() const;
125
126protected:
127 PatchKernel *m_patch;
128 std::vector<long> m_numbering;
129 std::vector<long> m_mapping;
130
131};
132
133
135{
136
137public:
140
141 void update(const std::vector<adaption::Info> &adaptionData) override;
142
143};
144
145}
146
147#endif
The CellFlatMapping class allows to generate a cell mapping between an id-base numeration to a contin...
Definition adaption.hpp:135
void update(const std::vector< adaption::Info > &adaptionData) override
Definition adaption.cpp:322
The FlatMapping class allows to generate a mapping between an id-base numeration to a continuous-inde...
Definition adaption.hpp:113
const std::vector< long > & getMapping() const
Definition adaption.cpp:270
const std::vector< long > & getNumbering() const
Definition adaption.cpp:260
The PatchKernel class provides an interface for defining patches.
The InfoCollection class is a container that holds one or more adaption info items.
Definition adaption.hpp:82
const std::vector< Info > & data() const noexcept
Definition adaption.cpp:93
Info & operator[](std::size_t id)
Definition adaption.cpp:193
std::vector< Info > dump()
Definition adaption.cpp:217
Info & at(std::size_t id)
Definition adaption.cpp:162
The Info struct defines the information associated to an adaption.
Definition adaption.hpp:63
--- layout: doxygen_footer ---