33#if BITPIT_ENABLE_MPI==1
37#include "bitpit_POD.hpp"
38#include "bitpit_patchkernel.hpp"
39#include "bitpit_voloctree.hpp"
41using namespace bitpit;
50 log::cout() <<
" >> 2D octree patch" <<
"\n";
60 std::unique_ptr<PabloUniform> treePointer = std::unique_ptr<PabloUniform>(
new PabloUniform(x_0, y_0, z_0, l, 2));
63 std::cout <<
" Origin : ( " << octree.
getX0() <<
", " << octree.
getY0() <<
", " << octree.
getZ0() <<
" )" << std::endl;
64 std::cout <<
" Length : " << octree.
getL() << std::endl;
81 patch_2D_original->
update();
83#if BITPIT_ENABLE_MPI==1
88 std::vector<uint64_t> refineList;
89 refineList.push_back( 7);
90 refineList.push_back( 13);
91 refineList.push_back( 15);
92 refineList.push_back( 26);
93 refineList.push_back( 27);
94 refineList.push_back( 31);
95 refineList.push_back( 37);
96 refineList.push_back( 39);
97 refineList.push_back( 49);
98 refineList.push_back( 50);
99 refineList.push_back( 51);
100 refineList.push_back( 53);
101 refineList.push_back( 55);
102 refineList.push_back( 63);
103 refineList.push_back( 78);
104 refineList.push_back(100);
105 refineList.push_back(102);
106 refineList.push_back(105);
107 refineList.push_back(108);
108 refineList.push_back(109);
109 refineList.push_back(110);
110 refineList.push_back(135);
111 refineList.push_back(141);
112 refineList.push_back(143);
113 refineList.push_back(146);
114 refineList.push_back(147);
115 refineList.push_back(151);
116 refineList.push_back(153);
117 refineList.push_back(154);
118 refineList.push_back(155);
119 refineList.push_back(157);
120 refineList.push_back(159);
121 refineList.push_back(165);
122 refineList.push_back(167);
123 refineList.push_back(183);
124 refineList.push_back(198);
125 refineList.push_back(204);
126 refineList.push_back(206);
127 refineList.push_back(225);
128 refineList.push_back(228);
129 refineList.push_back(229);
130 refineList.push_back(230);
132 for (uint64_t ind : refineList) {
133#if BITPIT_ENABLE_MPI==1
135 if (patch_2D_original->
getRank() == owner){
143#if BITPIT_ENABLE_MPI==1
148 patch_2D_original->
update();
158 for (
Cell & cell : patch_2D_original->getCells()){
159 if (cell.isInterior()){
160 long id = cell.getId();
162 vdata[count] = data[id];
168 patch_2D_original->
getVTK().
addData(
"data", VTKFieldType::SCALAR, VTKLocation::CELL, vdata);
169#if BITPIT_ENABLE_MPI==1
170 patch_2D_original->
setVTKWriteTarget(PatchKernel::WriteTarget::WRITE_TARGET_CELLS_INTERNAL);
172 patch_2D_original->
write();
177 std::unique_ptr<PabloUniform> treePointer2 = std::unique_ptr<PabloUniform>(
new PabloUniform(x_0, y_0, z_0, l, 2));
192#if BITPIT_ENABLE_MPI==1
193 patch_2D->
setVTKWriteTarget(PatchKernel::WriteTarget::WRITE_TARGET_CELLS_INTERNAL);
200 for (
int k = 0; k < 4; ++k) {
203 log::cout() <<
">> Marking the cells to adapt... " << std::endl;
205 for (
int i = 0; i < 100; ++i) {
206 long cellId = rand() % nCells * 2;
207 if (!patch_2D->
getCells().exists(cellId)) {
211 for (
auto neighId : patch_2D->findCellNeighs(cellId)) {
216 for (
int i = 0; i < 50; ++i) {
217 long cellId = rand() % nCells * 2;
218 if (!patch_2D->
getCells().exists(cellId)) {
223 for (
auto neighId : patch_2D->findCellNeighs(cellId)) {
229 log::cout() <<
">> Initial number of cells... " << nCells << std::endl;
234 log::cout() <<
">> Final number of cells... " << nCells << std::endl;
242#if BITPIT_ENABLE_MPI==1
249 mapobject.initialize(
true);
257 for (
Cell & cell : patch_2D->getCells()){
258 if (cell.isInterior()){
259 long id = cell.getId();
260 if (mapper[
id].type == mapping::Type::TYPE_RENUMBERING){
261 data2[id] = data[mapper[id].ids[0]];
262 vdata2[count] = data2[id];
264 else if (mapper[
id].type == mapping::Type::TYPE_COARSENING){
266 int n = mapper[id].ids.size();
267 for (
long idd : mapper[id].ids){
268 data2[id] += data[idd] / n;
270 vdata2[count] = data2[id];
272 else if (mapper[
id].type == mapping::Type::TYPE_REFINEMENT){
273 data2[id] = data[mapper[id].ids[0]];
274 vdata2[count] = data2[id];
281 patch_2D->
getVTK().
addData(
"data", VTKFieldType::SCALAR, VTKLocation::CELL, vdata2);
294 for (
Cell & cell : patch_2D_original->getCells()){
295 if (cell.isInterior()){
296 long id = cell.getId();
297 if (invmapper[
id].type == mapping::Type::TYPE_RENUMBERING){
298 data3[id] = data2[invmapper[id].ids[0]];
299 vdata3[count] = data3[id];
301 else if (invmapper[
id].type == mapping::Type::TYPE_COARSENING){
303 int n = invmapper[id].ids.size();
304 for (
long idd : invmapper[id].ids){
305 data3[id] += data2[idd] / n;
307 vdata3[count] = data3[id];
309 else if (invmapper[
id].type == mapping::Type::TYPE_REFINEMENT){
310 data3[id] = data2[invmapper[id].ids[0]];
311 vdata3[count] = data3[id];
318 patch_2D_original->
getVTK().
addData(
"data", VTKFieldType::SCALAR, VTKLocation::CELL, vdata3);
319 patch_2D_original->
write();
329int main(
int argc,
char *argv[])
331#if BITPIT_ENABLE_MPI==1
332 MPI_Init(&argc,&argv);
338 }
catch (
const std::exception &exception) {
343#if BITPIT_ENABLE_MPI==1
The Cell class defines the cells.
uint32_t getLocalIdx(uint64_t gidx) const
bool adaptGlobalRefine(bool mapper_flag=false)
int getOwnerRank(uint64_t globalIdx) const
void initializeAdjacencies(AdjacenciesBuildStrategy strategy=ADJACENCIES_AUTOMATIC)
void markCellForRefinement(long id)
std::vector< adaption::Info > update(bool trackAdaption=true, bool squeezeStorage=false)
PiercedVector< Cell > & getCells()
virtual long getVertexCount() const
VTKUnstructuredGrid & getVTK()
std::vector< adaption::Info > partition(MPI_Comm communicator, const std::unordered_map< long, int > &cellRanks, bool trackPartitioning, bool squeezeStorage=false, std::size_t haloSize=1)
void markCellForCoarsening(long id)
const MPI_Comm & getCommunicator() const
void initializeInterfaces(InterfacesBuildStrategy strategy=INTERFACES_AUTOMATIC)
void setVTKWriteTarget(WriteTarget targetCells)
virtual long getCellCount() const
void write(VTKWriteMode mode=VTKWriteMode::DEFAULT)
long getInternalCellCount() const
Metafunction for generating a pierced storage.
VTKField & addData(VTKField &&field)
void setName(const std::string &)
The VolOctreeMapper is the class to map two meshes of class VolOctree.
The VolOctree defines a Octree patch.
int getCellLevel(long id) const
PabloUniform & getTree()
Gets a reference to the octree associated with the patch.
long getOctantId(const OctantInfo &octantInfo) const
Logger & cout(log::Level defaultSeverity, log::Visibility defaultVisibility)