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
91 std::unique_ptr<PabloUniform> treePointer2 = std::unique_ptr<PabloUniform>(
new PabloUniform(x_0, y_0, z_0, l, 2));
108#if BITPIT_ENABLE_MPI==1
109 patch_2D->
setVTKWriteTarget(PatchKernel::WriteTarget::WRITE_TARGET_CELLS_INTERNAL);
118 for (
int k = 0; k < 4; ++k) {
121 log::cout() <<
">> Marking the cells to adapt... " << std::endl;
123 for (
int i = 0; i < 100; ++i) {
124 long cellId = rand() % nCells * 2;
125 if (!patch_2D->
getCells().exists(cellId)) {
130 for (
auto neighId : patch_2D->findCellNeighs(cellId)) {
135 for (
int i = 0; i < 50; ++i) {
136 long cellId = rand() % nCells * 2;
137 if (!patch_2D->
getCells().exists(cellId)) {
142 for (
auto neighId : patch_2D->findCellNeighs(cellId)) {
148 log::cout() <<
">> Initial number of cells... " << nCells << std::endl;
153 log::cout() <<
">> Final number of cells... " << nCells << std::endl;
161#if BITPIT_ENABLE_MPI==1
162 patch_2D->
setVTKWriteTarget(PatchKernel::WriteTarget::WRITE_TARGET_CELLS_INTERNAL);
167#if BITPIT_ENABLE_MPI==1
174 mapobject.initialize(
true);
177#if BITPIT_ENABLE_MPI==1
178 patch_2D_original->
setVTKWriteTarget(PatchKernel::WriteTarget::WRITE_TARGET_CELLS_INTERNAL);
180 patch_2D_original->
write();
182 std::vector<uint64_t> refineList;
183 refineList.push_back( 7);
184 refineList.push_back( 13);
185 refineList.push_back( 15);
186 refineList.push_back( 26);
187 refineList.push_back( 27);
188 refineList.push_back( 31);
189 refineList.push_back( 37);
190 refineList.push_back( 39);
191 refineList.push_back( 49);
192 refineList.push_back( 50);
193 refineList.push_back( 51);
194 refineList.push_back( 53);
195 refineList.push_back( 55);
196 refineList.push_back( 63);
197 refineList.push_back( 78);
198 refineList.push_back(100);
199 refineList.push_back(102);
200 refineList.push_back(105);
201 refineList.push_back(108);
202 refineList.push_back(109);
203 refineList.push_back(110);
204 refineList.push_back(135);
205 refineList.push_back(141);
206 refineList.push_back(143);
207 refineList.push_back(146);
208 refineList.push_back(147);
209 refineList.push_back(151);
210 refineList.push_back(153);
211 refineList.push_back(154);
212 refineList.push_back(155);
213 refineList.push_back(157);
214 refineList.push_back(159);
215 refineList.push_back(165);
216 refineList.push_back(167);
217 refineList.push_back(183);
218 refineList.push_back(198);
219 refineList.push_back(204);
220 refineList.push_back(206);
221 refineList.push_back(225);
222 refineList.push_back(228);
223 refineList.push_back(229);
224 refineList.push_back(230);
226 for (uint64_t ind : refineList) {
227#if BITPIT_ENABLE_MPI==1
229 if (patch_2D_original->
getRank() == owner){
237#if BITPIT_ENABLE_MPI==1
242 std::vector<adaption::Info> infoAdapt = patch_2D_original->
adaptionPrepare(
true);
244 mapobject.adaptionPrepare(infoAdapt,
true);
248 mapobject.adaptionAlter(infoAdapt,
true,
true);
252 mapobject.adaptionCleanup();
262 for (
Cell & cell : patch_2D_original->getCells()){
263 if (cell.isInterior()){
264 long id = cell.getId();
266 vdata[count] = data[id];
272 patch_2D_original->
getVTK().
addData(
"data", VTKFieldType::SCALAR, VTKLocation::CELL, vdata);
273#if BITPIT_ENABLE_MPI==1
274 patch_2D_original->
setVTKWriteTarget(PatchKernel::WriteTarget::WRITE_TARGET_CELLS_INTERNAL);
276 patch_2D_original->
write();
285 for (
Cell & cell : patch_2D->getCells()){
286 if (cell.isInterior()){
287 long id = cell.getId();
288 if (mapper[
id].type == mapping::Type::TYPE_RENUMBERING){
289 data2[id] = data[mapper[id].ids[0]];
290 vdata2[count] = data2[id];
292 else if (mapper[
id].type == mapping::Type::TYPE_COARSENING){
294 int n = mapper[id].ids.size();
295 for (
long idd : mapper[id].ids){
296 data2[id] += data[idd] / n;
298 vdata2[count] = data2[id];
300 else if (mapper[
id].type == mapping::Type::TYPE_REFINEMENT){
301 data2[id] = data[mapper[id].ids[0]];
302 vdata2[count] = data2[id];
309 patch_2D->
getVTK().
addData(
"data", VTKFieldType::SCALAR, VTKLocation::CELL, vdata2);
322 for (
Cell & cell : patch_2D_original->getCells()){
323 if (cell.isInterior()){
324 long id = cell.getId();
325 if (invmapper[
id].type == mapping::Type::TYPE_RENUMBERING){
326 data3[id] = data2[invmapper[id].ids[0]];
327 vdata3[count] = data3[id];
329 else if (invmapper[
id].type == mapping::Type::TYPE_COARSENING){
331 int n = invmapper[id].ids.size();
332 for (
long idd : invmapper[id].ids){
333 data3[id] += data2[idd] / n;
335 vdata3[count] = data3[id];
337 else if (invmapper[
id].type == mapping::Type::TYPE_REFINEMENT){
338 data3[id] = data2[invmapper[id].ids[0]];
339 vdata3[count] = data3[id];
346 patch_2D_original->
getVTK().
addData(
"data", VTKFieldType::SCALAR, VTKLocation::CELL, vdata3);
347 patch_2D_original->
write();
357int main(
int argc,
char *argv[])
360 MPI_Init(&argc,&argv);
366 }
catch (
const std::exception &exception) {
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
std::vector< adaption::Info > adaptionPrepare(bool trackAdaption=true)
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
std::vector< adaption::Info > adaptionAlter(bool trackAdaption=true, bool squeezeStorage=false)
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)