Parallel 3D adaptive mesh refinement (AMR) with data using PABLO.
Parallel 3D adaptive mesh refinement (AMR) with data using PABLOThe load-balance example with data and "compact families" in example 00008 is here rerun for a three-dimensional octree mesh.
#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;
xc = yc = 0.5;
double radius = 0.25;
vector<double> oct_data(nocts, 0.0), ghost_data(nghosts, 0.0);
for (unsigned int i=0; i<nocts; i++){
vector<array<double,3> > nodes = pablo9.
getNodes(i);
array<double,3> center = pablo9.
getCenter(i);
for (int j=0; j<8; j++){
double x = nodes[j][0];
double y = nodes[j][1];
if ((
pow((x-xc),2.0)+
pow((y-yc),2.0) <=
pow(radius,2.0))){
oct_data[i] = (
pow((center[0]-xc),2.0)+
pow((center[1]-yc),2.0));
}
}
}
iter = 0;
pablo9.
writeTest(
"pablo00009_iter"+to_string(
static_cast<unsigned long long>(iter)), oct_data);
int start = 1;
for (iter=start; iter<start+2; iter++){
for (unsigned int i=0; i<nocts; i++){
vector<array<double,3> > nodes = pablo9.
getNodes(i);
array<double,3> center = pablo9.
getCenter(i);
for (int j=0; j<8; j++){
double x = nodes[j][0];
double y = nodes[j][1];
if ((
pow((x-xc),2.0)+
pow((y-yc),2.0) <=
pow(radius,2.0))){
if (center[0]<=xc){
}
else{
}
}
}
}
vector<double> oct_data_new;
vector<uint32_t> mapper;
vector<bool> isghost;
oct_data_new.resize(nocts, 0.0);
for (uint32_t i=0; i<nocts; i++){
for (int j=0; j<8; j++){
if (isghost[j]){
oct_data_new[i] += ghost_data[mapper[j]]/8;
}
else{
oct_data_new[i] += oct_data[mapper[j]]/8;
}
}
}
oct_data_new[i] += oct_data[mapper[0]];
}
else{
oct_data_new[i] += oct_data[mapper[0]];
}
}
oct_data = oct_data_new;
vector<double>().swap(oct_data_new);
pablo9.
writeTest(
"pablo00009_iter"+to_string(
static_cast<unsigned long long>(iter)), oct_data);
}
#if BITPIT_ENABLE_MPI==1
uint8_t levels = 4;
UserDataLB<vector<double> > data_lb(oct_data,ghost_data);
#endif
pablo9.
writeTest(
"pablo00009_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 getMapping(uint32_t idx, u32vector &mapper, bvector &isghost) const
void loadBalance(const dvector *weight=NULL)
bool adaptGlobalRefine(bool mapper_flag=false)
uint32_t getNumGhosts() const
void updateConnectivity()
bool getIsNewC(uint32_t idx) const
void setBalance(uint32_t idx, bool balance)
bool getIsNewR(uint32_t idx) const
std::array< T, d > pow(std::array< T, d > &x, double p)
#define BITPIT_UNUSED(variable)