Loading...
Searching...
No Matches
PABLO_example_00011.cpp
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#if BITPIT_ENABLE_MPI==1
26#include <mpi.h>
27#endif
28
29#include "bitpit_PABLO.hpp"
30
31using namespace bitpit;
32
33// =================================================================================== //
49// =================================================================================== //
50
54void run()
55{
57 PabloUniform pablo11(3);
58
60 pablo11.setPeriodic(0);
61 pablo11.setPeriodic(2);
62 pablo11.setPeriodic(4);
63
65 pablo11.computeConnectivity();
66 pablo11.write("pablo000011.0");
67
69 pablo11.adaptGlobalRefine();
70 pablo11.updateConnectivity();
71 pablo11.write("pablo000011.1");
72
74 uint32_t nOct = pablo11.getNumOctants();
75 log::cout() << "Number of Octants : " << nOct << std::endl;
76 log::cout() << "Extracting the four face neighbours of each Octant " << std::endl;
77 for (uint32_t iOct = 0; iOct < nOct; ++iOct) {
78 std::vector<uint32_t> neigh;
79 std::vector<bool> isGhost;
80 log::cout() << ". Octant index : " << iOct << std::endl;
81 for (uint8_t iFace=0; iFace<pablo11.getNfaces(); ++iFace) {
82 pablo11.findNeighbours(iOct, iFace, 1, neigh, isGhost);
83 log::cout() << " - For face " << (int)iFace << "; " << neigh.size() << " neighbours: [ ";
84 for (auto iNeigh : neigh) {
85 log::cout() << iNeigh << " ";
86 }
87 log::cout() << "]" << std::endl;
88 }
89 }
90
92 log::cout() << "Extracting the four vertex neighbours of each Octant " << std::endl;
93 for (uint32_t iOct = 0; iOct < nOct; ++iOct) {
94 std::vector<uint32_t> neigh;
95 std::vector<bool> isGhost;
96 log::cout() << ". Octant index : " << iOct << std::endl;
97 for (uint8_t iVertex=0; iVertex<pablo11.getNnodes(); ++iVertex) {
98 pablo11.findNeighbours(iOct, iVertex, 3, neigh, isGhost);
99 log::cout() << " - For vertex " << (int)iVertex << "; " << neigh.size() << " neighbours: [ ";
100 for (auto iNeigh: neigh) {
101 log::cout() << iNeigh << " ";
102 }
103 log::cout() << "]" << std::endl;
104 }
105 }
106
108 log::cout() << "Extracting the four edge neighbours of each Octant " << std::endl;
109 for (uint32_t iOct=0; iOct < nOct; ++iOct) {
110 std::vector<uint32_t> neigh;
111 std::vector<bool> isGhost;
112 log::cout() << ". Octant index : " << iOct << std::endl;
113 for (uint8_t iEdge = 0; iEdge<pablo11.getNedges(); ++iEdge) {
114 pablo11.findNeighbours(iOct, iEdge, 2, neigh, isGhost);
115 log::cout() << " - For edge " << (int)iEdge << "; " << neigh.size() << " neighbours: [ ";
116 for (auto iNeigh: neigh) {
117 log::cout() << iNeigh << " ";
118 }
119 log::cout() << "]" << std::endl;
120 }
121 }
122}
123
127int main(int argc, char *argv[])
128{
129#if BITPIT_ENABLE_MPI==1
130 MPI_Init(&argc,&argv);
131#else
132 BITPIT_UNUSED(argc);
133 BITPIT_UNUSED(argv);
134#endif
135
136 int nProcs;
137 int rank;
138#if BITPIT_ENABLE_MPI==1
139 MPI_Comm_size(MPI_COMM_WORLD, &nProcs);
140 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
141#else
142 nProcs = 1;
143 rank = 0;
144#endif
145
146 // Initialize the logger
147 log::manager().initialize(log::MODE_SEPARATE, false, nProcs, rank);
148 log::cout() << log::fileVerbosity(log::LEVEL_INFO);
150
151 // Run the example
152 try {
153 run();
154 } catch (const std::exception &exception) {
155 log::cout() << exception.what();
156 exit(1);
157 }
158
159#if BITPIT_ENABLE_MPI==1
160 MPI_Finalize();
161#endif
162}
void initialize(log::Mode mode, bool reset, int nProcesses, int rank)
Definition logger.cpp:1268
PABLO Uniform is an example of user class derived from ParaTree to map ParaTree in a uniform (square/...
#define BITPIT_UNUSED(variable)
Definition compiler.hpp:63
Logger & cout(log::Level defaultSeverity, log::Visibility defaultVisibility)
Definition logger.cpp:1705
LoggerManipulator< log::Level > fileVerbosity(const log::Level &threshold)
Definition logger.cpp:2120
Logger & disableConsole(Logger &logger, const log::Level &level)
Definition logger.cpp:2165
LoggerManager & manager()
Definition logger.cpp:1685
--- layout: doxygen_footer ---