3D adaptive mesh refinement (AMR) using PABLOThis example creates a 3D Octree mesh on the cube domain [0,1]x[0,1]x[0,1].
The domain is refined globally one time and periodic conditions are imposed on the boundaries of the domain. Then, the face, vertex and edge neighbors of the cells are found and print.
#if BITPIT_ENABLE_MPI==1
#include <mpi.h>
#endif
#include "bitpit_PABLO.hpp"
using namespace bitpit;
void run()
{
pablo11.
write(
"pablo000011.0");
pablo11.
write(
"pablo000011.1");
log::cout() << "Number of Octants : " << nOct << std::endl;
log::cout() << "Extracting the four face neighbours of each Octant " << std::endl;
for (uint32_t iOct = 0; iOct < nOct; ++iOct) {
std::vector<uint32_t> neigh;
std::vector<bool> isGhost;
log::cout() << ". Octant index : " << iOct << std::endl;
for (uint8_t iFace=0; iFace<pablo11.
getNfaces(); ++iFace) {
log::cout() << " - For face " << (int)iFace << "; " << neigh.size() << " neighbours: [ ";
for (auto iNeigh : neigh) {
log::cout() << iNeigh << " ";
}
log::cout() << "]" << std::endl;
}
}
log::cout() << "Extracting the four vertex neighbours of each Octant " << std::endl;
for (uint32_t iOct = 0; iOct < nOct; ++iOct) {
std::vector<uint32_t> neigh;
std::vector<bool> isGhost;
log::cout() << ". Octant index : " << iOct << std::endl;
for (uint8_t iVertex=0; iVertex<pablo11.
getNnodes(); ++iVertex) {
log::cout() << " - For vertex " << (int)iVertex << "; " << neigh.size() << " neighbours: [ ";
for (auto iNeigh: neigh) {
log::cout() << iNeigh << " ";
}
log::cout() << "]" << std::endl;
}
}
log::cout() << "Extracting the four edge neighbours of each Octant " << std::endl;
for (uint32_t iOct=0; iOct < nOct; ++iOct) {
std::vector<uint32_t> neigh;
std::vector<bool> isGhost;
log::cout() << ". Octant index : " << iOct << std::endl;
for (uint8_t iEdge = 0; iEdge<pablo11.
getNedges(); ++iEdge) {
log::cout() << " - For edge " << (int)iEdge << "; " << neigh.size() << " neighbours: [ ";
for (auto iNeigh: neigh) {
log::cout() << iNeigh << " ";
}
log::cout() << "]" << std::endl;
}
}
}
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
}
uint32_t getNumOctants() const
void computeConnectivity()
uint8_t getNnodes() const
bool adaptGlobalRefine(bool mapper_flag=false)
void findNeighbours(uint32_t idx, uint8_t face, uint8_t codim, u32vector &neighbours, bvector &isghost) const
uint8_t getNedges() const
void updateConnectivity()
uint8_t getNfaces() const
void setPeriodic(uint8_t i)
#define BITPIT_UNUSED(variable)