2D adaptive mesh refinement (AMR) using PABLO
2D adaptive mesh refinement (AMR) using PABLOThis example creates a 2D Octree mesh on the square domain [0,1]x[0,1].
In this example the domain is iteratively refined using a slight modification of the first refinement criterion of PABLO_example_00001.
Here, each octant is marked for further refinement if at least one of its vertices lies within a circle of specified radius. Again the iterative refinement is performed for a specified number of iterations.
Using the present criterion the geometry is captured better than in example PABLO_example_00001.
Then a global coarsening iteration is performed, followed by an iterative coarsening of each quadrant within a smaller circle inside the original geometry. The coarsening procedure is repeated 5 times and the 2:1 balancing option is de-activated.
To run: ./PABLO_example_00002
To see the result visit: PABLO website
#if BITPIT_ENABLE_MPI==1
#include <mpi.h>
#endif
#include "bitpit_PABLO.hpp"
using namespace std;
using namespace bitpit;
void run()
{
int iter = 0;
uint32_t idx=0;
pablo2.
write(
"pablo00002_iter"+to_string(
static_cast<unsigned long long>(iter)));
for (iter=1; iter<3; iter++){
pablo2.
write(
"pablo00002_iter"+to_string(
static_cast<unsigned long long>(iter)));
}
double xc, yc;
xc = yc = 0.5;
double radius = 0.4;
for (iter=3; iter<9; iter++){
for (unsigned int i=0; i<nocts; i++){
vector<array<double,3> > nodes = pablo2.
getNodes(i);
for (int j=0; j<4; 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))){
}
}
}
pablo2.
write(
"pablo00002_iter"+to_string(
static_cast<unsigned long long>(iter)));
}
pablo2.
write(
"pablo00002_iter"+to_string(
static_cast<unsigned long long>(iter)));
xc = yc = 0.35;
radius = 0.15;
for (iter=10; iter<15; iter++){
for (unsigned int i=0; i<nocts; i++){
vector<array<double,3> > nodes = pablo2.
getNodes(i);
for (int j=0; j<4; 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))){
}
}
}
pablo2.
write(
"pablo00002_iter"+to_string(
static_cast<unsigned long long>(iter)));
}
}
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 adaptGlobalCoarse(bool mapper_flag=false)
bool adapt(bool mapper_flag=false)
void computeConnectivity()
bool adaptGlobalRefine(bool mapper_flag=false)
void updateConnectivity()
void setBalance(uint32_t idx, bool balance)
std::array< T, d > pow(std::array< T, d > &x, double p)
#define BITPIT_UNUSED(variable)
---
layout: doxygen_footer
---