36#if BITPIT_ENABLE_MPI==1
40#include "bitpit_patchkernel.hpp"
42using namespace bitpit;
46 std::cout << std::endl <<
" List of cell ids:" << std::endl;
49 std::cout << std::endl <<
" Vector is empty!" << std::endl;
53 for (
auto const &cell : cells) {
54 std::cout <<
" > id = " << cell.getId() << std::endl;
60 for (
int i = 0; i < nCells; i++) {
61 cells.
emplace(i, i, ElementType::TRIANGLE);
71 std::cout << std::endl <<
"::: Creating an empty PiercedVector :::" << std::endl;
72 std::cout << std::endl;
74 std::cout <<
" Pierced vector created" << std::endl;
79 std::cout << std::endl <<
"::: Filling the vector :::" << std::endl;
82 fillCellList(nCells, cells);
87 std::cout << std::endl <<
"::: Marker :::" << std::endl;
88 std::cout << std::endl;
90 std::cout <<
" Element id before which there are 4 elements: " << cells.
getSizeMarker(4) << std::endl;
95 std::cout << std::endl <<
"::: Deleting cells :::" << std::endl;
96 std::cout << std::endl;
98 nCells = cells.
size();
99 for (
int id_erase = 0; id_erase < nCells; id_erase += 2) {
100 if (!cells.
exists(id_erase)) {
104 std::cout <<
" Deleting element with id = " << id_erase << std::endl;
105 cells.
erase(id_erase);
111 std::cout << std::endl <<
"::: Marker :::" << std::endl;
112 std::cout << std::endl;
114 for (
int i = 0; i < 10; ++i) {
115 std::cout <<
" Element id before which there are " << i <<
" elements: " << cells.
getSizeMarker(i) << std::endl;
119 std::cout << std::endl <<
"::: Resizing the cell container :::" << std::endl;
120 std::cout << std::endl;
123 std::cout <<
" Resizing the cell container to " << size <<
" elements" << std::endl;
130 std::cout << std::endl <<
"::: Marker :::" << std::endl;
131 std::cout << std::endl;
133 std::cout <<
" Element id before which there are 4 elements: " << cells.
getSizeMarker(4) << std::endl;
138 std::cout << std::endl <<
"::: Inserting cells :::" << std::endl;
139 std::cout << std::endl;
142 if (!cells.
exists(id_insert)) {
143 std::cout <<
" Inserting (at first avilable position) element with id = " << id_insert << std::endl;
144 cells.
emplace(id_insert, id_insert, ElementType::TRIANGLE);
148 if (!cells.
exists(id_insert)) {
149 std::cout <<
" Inserting (at the end) element with id = " << id_insert << std::endl;
150 cells.
emplaceBack(id_insert, id_insert, ElementType::TRIANGLE);
154 if (!cells.
exists(id_insert)) {
155 std::cout <<
" Inserting (at first avilable position) element with id = " << id_insert << std::endl;
156 cells.
emplace(id_insert, id_insert, ElementType::TRIANGLE);
160 if (!cells.
exists(id_insert)) {
161 std::cout <<
" Inserting (at the end) element with id = " << id_insert << std::endl;
162 cells.
emplaceBack(id_insert, id_insert, ElementType::TRIANGLE);
166 if (!cells.
exists(id_insert)) {
167 std::cout <<
" Inserting (at first avilable position) element with id = " << id_insert << std::endl;
168 cells.
emplace(id_insert, id_insert, ElementType::TRIANGLE);
172 if (!cells.
exists(id_insert)) {
173 std::cout <<
" Inserting (at the end) element with id = " << id_insert << std::endl;
174 cells.
emplaceBack(id_insert, id_insert, ElementType::TRIANGLE);
180 std::cout << std::endl <<
"::: Marker :::" << std::endl;
181 std::cout << std::endl;
183 std::cout <<
" Element id before which there are 4 elements: " << cells.
getSizeMarker(4) << std::endl;
185 std::cout << std::endl <<
"::: Inserting cells after/before :::" << std::endl;
186 std::cout << std::endl;
192 if (!cells.
exists(id_insert)) {
193 std::cout <<
" Inserting (before the element with id = " << id_reference <<
") element with id = " << id_insert << std::endl;
194 cells.
emplaceBefore(id_reference, id_insert, id_insert, ElementType::TRIANGLE);
199 if (!cells.
exists(id_insert)) {
200 std::cout <<
" Inserting (before the element with id = " << id_reference <<
") element with id = " << id_insert << std::endl;
201 cells.
emplaceBefore(id_reference, id_insert, id_insert, ElementType::TRIANGLE);
207 if (!cells.
exists(id_insert)) {
208 std::cout <<
" Inserting (before the element with id = " << id_reference <<
") element with id = " << id_insert << std::endl;
209 cells.
emplaceBefore(id_reference, id_insert, id_insert, ElementType::TRIANGLE);
214 if (!cells.
exists(id_insert)) {
215 std::cout <<
" Inserting (after the element with id = " << id_reference <<
") element with id = " << id_insert << std::endl;
216 cells.
emplaceAfter(id_reference, id_insert, id_insert, ElementType::TRIANGLE);
221 if (!cells.
exists(id_insert)) {
222 std::cout <<
" Inserting (after the element with id = " << id_reference <<
") element with id = " << id_insert << std::endl;
223 cells.
emplaceAfter(id_reference, id_insert, id_insert, ElementType::TRIANGLE);
228 if (!cells.
exists(id_insert)) {
229 std::cout <<
" Inserting (after the element with id = " << id_reference <<
") element with id = " << id_insert << std::endl;
230 cells.
emplaceAfter(id_reference, id_insert, id_insert, ElementType::TRIANGLE);
236 std::cout << std::endl <<
"::: Marker :::" << std::endl;
237 std::cout << std::endl;
239 std::cout <<
" Element id before which there are 4 elements: " << cells.
getSizeMarker(4) << std::endl;
242 std::cout << std::endl <<
"::: List of cells id :::" << std::endl;
243 std::cout << std::endl;
245 std::cout <<
" List of the ids (not ordered)" << std::endl;
246 for (
auto const &
id : cells.getIds(false)) {
247 std::cout <<
" > id = " <<
id << std::endl;
250 std::cout << std::endl;
251 std::cout <<
" List of the ids (ordered)" << std::endl;
252 for (
auto const &
id : cells.getIds(true)) {
253 std::cout <<
" > id = " <<
id << std::endl;
257 std::cout << std::endl <<
"::: Sort cells by ids :::" << std::endl;
264 std::cout << std::endl <<
"::: Deleting all cells :::" << std::endl;
266 while (!cells.
empty()) {
273 std::cout << std::endl <<
"::: Marker :::" << std::endl;
274 std::cout << std::endl;
276 std::cout <<
" Element id before which there are 4 elements: " << cells.
getSizeMarker(4) << std::endl;
279 std::cout << std::endl <<
"::: Filling the vector :::" << std::endl;
281 fillCellList(nCells, cells);
286 std::cout << std::endl <<
"::: Marker :::" << std::endl;
287 std::cout << std::endl;
289 std::cout <<
" Element id before which there are 4 elements: " << cells.
getSizeMarker(4) << std::endl;
292 std::cout << std::endl <<
"::: Deleting cells :::" << std::endl;
293 std::cout << std::endl;
296 std::cout <<
" Deleting element with id = " << id_erase << std::endl;
297 cells.
erase(id_erase);
300 std::cout <<
" Deleting element with id = " << id_erase << std::endl;
301 cells.
erase(id_erase);
304 std::cout <<
" Deleting element with id = " << id_erase << std::endl;
305 cells.
erase(id_erase);
308 std::cout <<
" Deleting element with id = " << id_erase << std::endl;
309 cells.
erase(id_erase);
312 std::cout <<
" Deleting element with id = " << id_erase << std::endl;
313 cells.
erase(id_erase);
316 std::cout <<
" Deleting element with id = " << id_erase << std::endl;
317 cells.
erase(id_erase);
320 std::cout <<
" Deleting element with id = " << id_erase << std::endl;
321 cells.
erase(id_erase);
324 std::cout << std::endl <<
"::: Inserting cells :::" << std::endl;
325 std::cout << std::endl;
328 std::cout <<
" Emplacing element with id = " << id_insert << std::endl;
329 cells.
emplace(id_insert, id_insert, ElementType::TRIANGLE);
332 std::cout <<
" Emplacing element with id = " << id_insert << std::endl;
333 cells.
emplace(id_insert, id_insert, ElementType::TRIANGLE);
336 std::cout <<
" Emplacing element with id = " << id_insert << std::endl;
337 cells.
emplace(id_insert, id_insert, ElementType::TRIANGLE);
342 std::cout << std::endl <<
"::: Moving cells :::" << std::endl;
343 std::cout << std::endl;
349 std::cout << std::endl;
350 std::cout <<
" Moving element with id = " << id_move <<
" before element with id = " << id_reference << std::endl;
357 std::cout << std::endl;
358 std::cout <<
" Moving element with id = " << id_move <<
" after element with id = " << id_reference << std::endl;
365 std::cout << std::endl;
366 std::cout <<
" Moving element with id = " << id_move <<
" after element with id = " << id_reference << std::endl;
372 std::cout << std::endl <<
"::: Marker :::" << std::endl;
373 std::cout << std::endl;
375 std::cout <<
" Element id before which there are 4 elements: " << cells.
getSizeMarker(4) << std::endl;
378 std::cout << std::endl <<
"::: Squeeze :::" << std::endl;
379 std::cout << std::endl;
381 std::cout <<
" Capacity before squeeze = " << cells.
capacity() << std::endl;
385 std::cout <<
" Capacity after squeeze = " << cells.
capacity() << std::endl;
390 std::cout << std::endl <<
"::: Marker :::" << std::endl;
391 std::cout << std::endl;
393 std::cout <<
" Element id before which there are 4 elements: " << cells.
getSizeMarker(4) << std::endl;
396 std::cout << std::endl <<
"::: Clear the vector :::" << std::endl;
403 std::cout << std::endl <<
"::: Filling the vector :::" << std::endl;
405 fillCellList(nCells, cells);
410 std::cout << std::endl <<
"::: Marker :::" << std::endl;
411 std::cout << std::endl;
413 std::cout <<
" Element id before which there are 4 elements: " << cells.
getSizeMarker(4) << std::endl;
416 std::cout << std::endl <<
"::: Done :::" << std::endl;
417 std::cout << std::endl;
424int main(
int argc,
char *argv[])
426#if BITPIT_ENABLE_MPI==1
427 MPI_Init(&argc,&argv);
435#if BITPIT_ENABLE_MPI==1
436 MPI_Comm_size(MPI_COMM_WORLD, &nProcs);
437 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
451 }
catch (
const std::exception &exception) {
456#if BITPIT_ENABLE_MPI==1
void initialize(log::Mode mode, bool reset, int nProcesses, int rank)
id_t getSizeMarker(std::size_t targetSize, const id_t &fallback=-1)
std::size_t capacity() const
bool exists(id_t id) const
Metafunction for generating a pierced vector.
iterator emplaceBefore(const id_t &referenceId, id_t id, Args &&... args)
iterator emplace(id_t id, Args &&... args)
void clear(bool release=true)
iterator erase(id_t id, bool delayed=false)
iterator moveAfter(const id_t &referenceId, id_t id, bool delayed=false)
void emplaceBack(id_t id, Args &&... args)
void resize(std::size_t n)
iterator moveBefore(const id_t &referenceId, id_t id, bool delayed=false)
iterator emplaceAfter(const id_t &referenceId, id_t id, Args &&... args)
#define BITPIT_UNUSED(variable)
Logger & cout(log::Level defaultSeverity, log::Visibility defaultVisibility)
LoggerManipulator< log::Level > fileVerbosity(const log::Level &threshold)
Logger & disableConsole(Logger &logger, const log::Level &level)
LoggerManager & manager()