Parallel 3D dynamic adaptive mesh refinement (AMR) with data using PABLO.
Parallel 3D dynamic adaptive mesh refinement (AMR) with data using PABLOIn this example an Adaptive Mesh Refinement (AMR) around a moving sphere is performed.
#if BITPIT_ENABLE_MPI==1
#include <mpi.h>
#endif
#include "bitpit_PABLO.hpp"
#if BITPIT_ENABLE_MPI==1
#include "PABLO_userDataComm.hpp"
#include "PABLO_userDataLB.hpp"
#endif
using namespace std;
using namespace bitpit;
void run()
{
int iter = 0;
int idx = 0;
for (iter=1; iter<6; iter++){
}
#if BITPIT_ENABLE_MPI==1
#endif
double xc, yc, zc;
double radius = 0.15;
double Dt = 0.000025;
double omega = 2.0*3.14/0.001;
xc = 0.25*cos(omega* Dt) + 0.5 ;
yc = 0.25*sin(omega* Dt) + 0.5;
zc = 100*Dt;
vector<double> oct_data(nocts, 0.0);
int itstart = 1;
int itend = 460;
for (iter=itstart; iter<itend; iter++){
xc = 0.25*cos(omega* Dt* (double) iter) + 0.5 ;
yc = 0.25*sin(omega* Dt* (double) iter) + 0.5;
zc = 100*Dt*iter;
for (unsigned int i=0; i<nocts; i++){
bool inside = false;
vector<array<double,3> > nodes = pablo10.
getNodes(i);
array<double,3> center = pablo10.
getCenter(i);
oct_data[i] = sqrt((
pow((center[0]-xc),2.0)+
pow((center[1]-yc),2.0)+
pow((center[2]-zc),2.0)));
for (int j=0; j<8; j++){
double x = nodes[j][0];
double y = nodes[j][1];
double z = nodes[j][2];
if (
pow((x-xc),2.0)+
pow((y-yc),2.0)+
pow((z-zc),2.0) <=
pow(radius,2.0)){
}
else{
}
inside = true;
}
}
if (pablo10.
getLevel(i) > 5 && !inside){
}
}
#if BITPIT_ENABLE_MPI==1
#endif
vector<double> oct_data_new(nocts, 0.0);
for (unsigned int i=0; i<nocts; i++){
array<double,3> center = pablo10.
getCenter(i);
oct_data_new[i] = sqrt((
pow((center[0]-xc),2.0)+
pow((center[1]-yc),2.0)+
pow((center[2]-zc),2.0)));
}
oct_data.resize(nocts);
oct_data = oct_data_new;
oct_data_new.clear();
pablo10.
writeTest(
"pablo00010_iter"+to_string(
static_cast<unsigned long long>(iter)), oct_data);
}
}
int main(int argc, char *argv[])
{
#if BITPIT_ENABLE_MPI==1
MPI_Init(&argc,&argv);
#else
#endif
int nProcs;
int rank;
#if BITPIT_ENABLE_MPI==1
MPI_Comm_size(MPI_COMM_WORLD, &nProcs);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
#else
nProcs = 1;
rank = 0;
#endif
log::manager().initialize(log::MODE_SEPARATE, false, nProcs, rank);
log::cout() << log::fileVerbosity(log::LEVEL_INFO);
log::cout() << log::disableConsole();
try {
run();
} catch (const std::exception &exception) {
log::cout() << exception.what();
exit(1);
}
#if BITPIT_ENABLE_MPI==1
MPI_Finalize();
#endif
}
void setMarker(uint32_t idx, int8_t marker)
uint32_t getNumOctants() const
bool adapt(bool mapper_flag=false)
void loadBalance(const dvector *weight=NULL)
bool adaptGlobalRefine(bool mapper_flag=false)
void updateConnectivity()
uint8_t getLevel(uint32_t idx) const
void setBalance(uint32_t idx, bool balance)
std::array< T, d > pow(std::array< T, d > &x, double p)
#define BITPIT_UNUSED(variable)