25#include "bitpit_PABLO.hpp"
27#if BITPIT_ENABLE_MPI==1
28#include "PABLO_userDataComm.hpp"
29#include "PABLO_userDataLB.hpp"
34using namespace bitpit;
73 pabloBB.setBalanceCodimension(1);
75 pabloBB.setBalance(idx,
true);
78 for (iter=1; iter<4; iter++){
79 pabloBB.adaptGlobalRefine();
82#if BITPIT_ENABLE_MPI==1
84 pabloBB.loadBalance();
88 uint32_t nocts = pabloBB.getNumOctants();
93#if BITPIT_ENABLE_MPI==1
104 for (
int i=0; i<nb; i++){
106 randc[0] = 0.8 * (double) (rand()) / RAND_MAX + 0.1;
107 randc[1] = 0.8 * (double) (rand()) / RAND_MAX + 0.1;
108 randc[2] = (double) (rand()) / RAND_MAX - 0.5;
109 double randr = (0.05 * (double) (rand()) / RAND_MAX + 0.04);
110 double dz = 0.005 + 0.05 * (double) (rand()) / RAND_MAX;
111 double omega = 0.5 * (double) (rand()) / RAND_MAX;
112 double aa = 0.15 * (double) (rand()) / RAND_MAX;
130 vector<double> oct_data(nocts, 0.0),oct_data_ghost;
131 vector<double> oct_data_new(nocts, 0.0);
138 for (iter=itstart; iter<itend; iter++){
139 if(pabloBB.getRank()==0)
cout <<
"iter " << iter << endl;
143 for (
int i=0; i<nb; i++){
144 BB[i].c[0] = BB0[i].c[0];
145 BB[i].c[1] = BB0[i].c[1];
146 BB[i].c[2] = BB[i].c[2]+ Dt*DZ[i];
153 for (
unsigned int i=0; i<nocts; i++){
156 vector<array<double,3> > nodes = pabloBB.getNodes(i);
158 array<double,3> center = pabloBB.getCenter(i);
160 while (!inside && ib<nb){
161 double xc = BB[ib].c[0];
162 double yc = BB[ib].c[1];
163 double zc = BB[ib].c[2];
164 double radius = BB[ib].r;
167 if (((
pow((center[0]-xc),2.0)+
pow((center[1]-yc),2.0)+
pow((center[2]-zc),2.0) <= 1.25*
pow(radius,2.0) &&
168 pow((center[0]-xc),2.0)+
pow((center[1]-yc),2.0)+
pow((center[2]-zc),2.0) >= 0.75*
pow(radius,2.0)))){
169 if (pabloBB.getLevel(i) < 7){
171 pabloBB.setMarker(i,1);
175 pabloBB.setMarker(i,0);
181 for (
int j=0; j<8; j++){
182 double x = nodes[j][0];
183 double y = nodes[j][1];
184 double z = nodes[j][2];
186 if (((
pow((x-xc),2.0)+
pow((y-yc),2.0)+
pow((z-zc),2.0) <= 1.25*
pow(radius,2.0) &&
187 pow((x-xc),2.0)+
pow((y-yc),2.0)+
pow((z-zc),2.0) >= 0.75*
pow(radius,2.0)))){
188 if (pabloBB.getLevel(i) < 7){
190 pabloBB.setMarker(i,1);
194 pabloBB.setMarker(i,0);
205 if (pabloBB.getLevel(i) > 3){
207 pabloBB.setMarker(i,3-pabloBB.getLevel(i));
213 vector<uint32_t> mapidx;
214 vector<bool> isghost;
215 adapt = pabloBB.adapt(
true);
218 nocts = pabloBB.getNumOctants();
221 oct_data_new.resize(nocts, 0);
222 for (uint32_t i=0; i<nocts; i++){
223 pabloBB.getMapping(i, mapidx, isghost);
224 oct_data_new[i] = oct_data[mapidx[0]];
226 oct_data = oct_data_new;
227 vector<double>().swap(oct_data_new);
231#if BITPIT_ENABLE_MPI==1
234 UserDataLB<vector<double> > data_lb(oct_data,oct_data_ghost);
235 pabloBB.loadBalance(data_lb);
237 nocts = pabloBB.getNumOctants();
241 pabloBB.updateConnectivity();
242 pabloBB.writeTest(
"PabloBubble3D_iter"+to_string(
static_cast<unsigned long long>(iter)), oct_data);
249int main(
int argc,
char *argv[])
251#if BITPIT_ENABLE_MPI==1
252 MPI_Init(&argc,&argv);
260#if BITPIT_ENABLE_MPI==1
261 MPI_Comm_size(MPI_COMM_WORLD, &nProcs);
262 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
276 }
catch (
const std::exception &exception) {
281#if BITPIT_ENABLE_MPI==1
void initialize(log::Mode mode, bool reset, int nProcesses, int rank)
std::array< T, d > pow(std::array< T, d > &x, double p)
#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()