25#include "bitpit_PABLO.hpp"
27#if BITPIT_ENABLE_MPI==1
28#include "PABLO_userDataComm.hpp"
29#include "PABLO_userDataLB.hpp"
34using namespace bitpit;
74 pabloBB.setBalanceCodimension(1);
76 pabloBB.setBalance(idx,
true);
79 for (iter=1; iter<4; iter++){
80 pabloBB.adaptGlobalRefine();
83#if BITPIT_ENABLE_MPI==1
85 pabloBB.loadBalance();
91#if BITPIT_ENABLE_MPI==1
102 for (
int i=0; i<nb; i++){
104 randc[0] = 0.8 * double(rand()) / RAND_MAX + 0.1;
105 randc[1] = double(rand()) / RAND_MAX - 0.5;
106 double randr = 0.1 * double(rand()) / RAND_MAX + 0.02;
107 double dy = 0.005 + 0.05 * double(rand()) / RAND_MAX;
108 double omega = 0.5 * double(rand()) / RAND_MAX;
109 double aa = 0.15 * double(rand()) / RAND_MAX;
130 for (iter=itstart; iter<iterend; iter++){
131 if(pabloBB.getRank()==0)
cout <<
"iter " << iter << endl;
135 for (
int i=0; i<nb; i++){
136 BB[i].c[0] = BB0[i].c[0] + AA[i]*cos(OM[i]*t);
137 BB[i].c[1] = BB[i].c[1]+ Dt*DY[i];
143 octantIterator it, itend = pabloBB.getInternalOctantsEnd();
144 for (it=pabloBB.getInternalOctantsBegin(); it!=itend; ++it){
147 vector<array<double,3> > nodes = pabloBB.getNodes((*it));
149 array<double,3> center = pabloBB.getCenter((*it));
151 while (!inside && ib<nb){
152 double xc = BB[ib].c[0];
153 double yc = BB[ib].c[1];
154 double radius = BB[ib].r;
156 for (
int j=0; j<4; j++){
157 double x = nodes[j][0];
158 double y = nodes[j][1];
160 (
pow((x-xc),2.0)+
pow((y-yc),2.0) <= 1.25*
pow(radius,2.0) &&
161 pow((x-xc),2.0)+
pow((y-yc),2.0) >= 0.75*
pow(radius,2.0)))
162 || ((!inside) && (
pow((center[0]-xc),2.0)+
pow((center[1]-yc),2.0) <= 1.25*
pow(radius,2.0) &&
163 pow((center[0]-xc),2.0)+
pow((center[1]-yc),2.0) >= 0.75*
pow(radius,2.0)))){
164 if (
int(pabloBB.getLevel((*it))) < 9){
166 pabloBB.setMarker((*it),1);
169 pabloBB.setMarker((*it),0);
176 if (
int(pabloBB.getLevel((*it))) > 0 && !inside){
178 pabloBB.setMarker((*it),5-pabloBB.getLevel((*it)));
182 itend = pabloBB.getPboundOctantsEnd();
183 for (it=pabloBB.getPboundOctantsBegin(); it!=itend; ++it){
186 vector<array<double,3> > nodes = pabloBB.getNodes((*it));
188 array<double,3> center = pabloBB.getCenter((*it));
190 while (!inside && ib<nb){
191 double xc = BB[ib].c[0];
192 double yc = BB[ib].c[1];
193 double radius = BB[ib].r;
195 for (
int j=0; j<4; j++){
196 double x = nodes[j][0];
197 double y = nodes[j][1];
199 (
pow((x-xc),2.0)+
pow((y-yc),2.0) <= 1.25*
pow(radius,2.0) &&
200 pow((x-xc),2.0)+
pow((y-yc),2.0) >= 0.75*
pow(radius,2.0)))
201 || ((!inside) && (
pow((center[0]-xc),2.0)+
pow((center[1]-yc),2.0) <= 1.25*
pow(radius,2.0) &&
202 pow((center[0]-xc),2.0)+
pow((center[1]-yc),2.0) >= 0.75*
pow(radius,2.0)))){
203 if (pabloBB.getLevel((*it)) < 9){
205 pabloBB.setMarker((*it),1);
208 pabloBB.setMarker((*it),0);
215 if (pabloBB.getLevel((*it)) > 0 && !inside){
217 pabloBB.setMarker((*it),5-pabloBB.getLevel((*it)));
222 adapt = pabloBB.adapt();
226#if BITPIT_ENABLE_MPI==1
228 pabloBB.loadBalance();
232 pabloBB.updateConnectivity();
233 pabloBB.write(
"PabloBubble_iter"+to_string(
static_cast<unsigned long long>(iter)));
241int main(
int argc,
char *argv[])
243#if BITPIT_ENABLE_MPI==1
244 MPI_Init(&argc,&argv);
252#if BITPIT_ENABLE_MPI==1
253 MPI_Comm_size(MPI_COMM_WORLD, &nProcs);
254 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
268 }
catch (
const std::exception &exception) {
273#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()