Loading...
Searching...
No Matches
PABLO_example_00002.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 std;
32using namespace bitpit;
33
34// =================================================================================== //
62// =================================================================================== //
63
67void run()
68{
69 int iter = 0;
70
72 PabloUniform pablo2(2);
73
75 uint32_t idx=0;
76 pablo2.setBalance(idx,true);
77
79 pablo2.computeConnectivity();
80 pablo2.write("pablo00002_iter"+to_string(static_cast<unsigned long long>(iter)));
81
83 for (iter=1; iter<3; iter++){
84 pablo2.adaptGlobalRefine();
85 pablo2.updateConnectivity();
86 pablo2.write("pablo00002_iter"+to_string(static_cast<unsigned long long>(iter)));
87 }
88
90 double xc, yc;
91 xc = yc = 0.5;
92 double radius = 0.4;
93
95 for (iter=3; iter<9; iter++){
96 uint32_t nocts = pablo2.getNumOctants();
97 for (unsigned int i=0; i<nocts; i++){
99 vector<array<double,3> > nodes = pablo2.getNodes(i);
100 for (int j=0; j<4; j++){
101 double x = nodes[j][0];
102 double y = nodes[j][1];
103 if ((pow((x-xc),2.0)+pow((y-yc),2.0) <= pow(radius,2.0))){
104 pablo2.setMarker(i, 1);
105 }
106 }
107 }
109 pablo2.adapt();
110
112 pablo2.updateConnectivity();
113 pablo2.write("pablo00002_iter"+to_string(static_cast<unsigned long long>(iter)));
114 }
115
117 pablo2.adaptGlobalCoarse();
118 pablo2.updateConnectivity();
119 pablo2.write("pablo00002_iter"+to_string(static_cast<unsigned long long>(iter)));
120
121
123 xc = yc = 0.35;
124 radius = 0.15;
125
127 for (iter=10; iter<15; iter++){
128 uint32_t nocts = pablo2.getNumOctants();
129 for (unsigned int i=0; i<nocts; i++){
131 vector<array<double,3> > nodes = pablo2.getNodes(i);
132 for (int j=0; j<4; j++){
133 double x = nodes[j][0];
134 double y = nodes[j][1];
136 if ((pow((x-xc),2.0)+pow((y-yc),2.0) <= pow(radius,2.0))){
137 pablo2.setMarker(i, -1);
138 }
139 }
140 }
142 pablo2.adapt();
143 pablo2.updateConnectivity();
144 pablo2.write("pablo00002_iter"+to_string(static_cast<unsigned long long>(iter)));
145 }
146}
147
151int main(int argc, char *argv[])
152{
153#if BITPIT_ENABLE_MPI==1
154 MPI_Init(&argc,&argv);
155#else
156 BITPIT_UNUSED(argc);
157 BITPIT_UNUSED(argv);
158#endif
159
160 int nProcs;
161 int rank;
162#if BITPIT_ENABLE_MPI==1
163 MPI_Comm_size(MPI_COMM_WORLD, &nProcs);
164 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
165#else
166 nProcs = 1;
167 rank = 0;
168#endif
169
170 // Initialize the logger
171 log::manager().initialize(log::MODE_SEPARATE, false, nProcs, rank);
172 log::cout() << log::fileVerbosity(log::LEVEL_INFO);
174
175 // Run the example
176 try {
177 run();
178 } catch (const std::exception &exception) {
179 log::cout() << exception.what();
180 exit(1);
181 }
182
183#if BITPIT_ENABLE_MPI==1
184 MPI_Finalize();
185#endif
186}
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/...
std::array< T, d > pow(std::array< T, d > &x, double p)
#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 ---