geohandlers_example_00001.cpp
Example of usage of selection and refinement of a target geometry sub-patch.Using: MimmoGeometry, SelectionByBox, SelectionBySphere, RefineGeometry, Chain, Partition (only MPI ).
To run : ./geohandlers_example_00001
To run (MPI Version): mpirun -np X geohandlers_example_00001
visit: mimmo website
/*---------------------------------------------------------------------------*\
*
* mimmo
*
* Copyright (C) 2015-2021 OPTIMAD engineering Srl
*
* -------------------------------------------------------------------------
* License
* This file is part of mimmo.
*
* mimmo is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License v3 (LGPL)
* as published by the Free Software Foundation.
*
* mimmo is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with mimmo. If not, see <http://www.gnu.org/licenses/>.
*
\ *---------------------------------------------------------------------------*/
#include "mimmo_geohandlers.hpp"
#if MIMMO_ENABLE_MPI
#include "mimmo_parallel.hpp"
#endif
#include <bitpit_common.hpp>
// =================================================================================== //
// =================================================================================== //
void test00001() {
/*
Read a target geometry from file. CONVERT option will let the block to write
the just read file in another file, immediately after the reading.
*/
mimmo0->setReadFileType(FileType::STL);
mimmo0->setWriteFileType(FileType::STL);
/*
Write a geometry to file
*/
mimmo1->setWriteDir(".");
mimmo1->setWriteFileType(FileType::SURFVTU);
mimmo1->setWriteFilename("geohandlers_output_00001.0001");
/*
Write a geometry to file
*/
mimmo2->setWriteDir(".");
mimmo2->setWriteFileType(FileType::SURFVTU);
mimmo2->setWriteFilename("geohandlers_output_00001.0002");
#if MIMMO_ENABLE_MPI
/*
Distribute a target mesh geometry among processors
*/
mimmo::Partition* partition = new mimmo::Partition();
partition->setPartitionMethod(mimmo::PartitionMethod::PARTGEOM);
partition->setPlotInExecution(true);
#endif
/*
Select a portion of geometry incapsulated inside a Box/Cube.
Span and origin of the box are needed.
*/
boxSel->setOrigin({{-0.5,-0.5,0.2}});
boxSel->setSpan(0.6,0.6,0.6);
/*
Select a portion of geometry incapsulated inside a Sphere.
Radius, angular spans and origin of the sphere are needed.
*/
sphSel->setOrigin({{-0.5, 0.5,0.2}});
sphSel->setSpan(0.34, 2*BITPIT_PI, BITPIT_PI);
/*
Block to refine triangles of a target mesh
Refine Engine type and number of refinement steps are needed.
Smoothing steps >0 activate a n-steps procedure to attempt smoothing/regularizing
the final refined mesh.
*/
refine->setRefineSteps(2);
refine->setSmoothingSteps(1);
/*
Define block pin connections.
*/
#if MIMMO_ENABLE_MPI
#else
#endif
/*
Setup execution chain.
*/
mimmo::Chain ch0;
ch0.addObject(mimmo0);
#if MIMMO_ENABLE_MPI
ch0.addObject(partition);
#endif
ch0.addObject(boxSel);
ch0.addObject(refine);
ch0.addObject(sphSel);
ch0.addObject(mimmo1);
ch0.addObject(mimmo2);
/*
Execute the chain.
Use debug flag true to to print out the execution steps.
*/
/*
Clean up & exit;
*/
delete boxSel;
delete sphSel;
delete mimmo0;
#if MIMMO_ENABLE_MPI
delete partition;
#endif
delete refine;
delete mimmo1;
delete mimmo2;
return;
}
// =================================================================================== //
int main( int argc, char *argv[] ) {
BITPIT_UNUSED(argc);
BITPIT_UNUSED(argv);
#if MIMMO_ENABLE_MPI
MPI_Init(&argc, &argv);
#endif
try{
test00001();
}
catch(std::exception & e){
std::cout<<"geohandlers_example_00001 exited with an error of type : "<<e.what()<<std::endl;
return 1;
}
#if MIMMO_ENABLE_MPI
MPI_Finalize();
#endif
return 0;
}
Chain is the class used to manage the chain execution of multiple executable blocks (manipulation obj...
Definition: Chain.hpp:48
@ REDGREEN
void setSmoothingSteps(int steps)
Definition: RefineGeometry.cpp:160
void setWriteFileType(FileType type)
Definition: MimmoGeometry.cpp:230
void setWriteFilename(std::string filename)
Definition: MimmoGeometry.cpp:268
void setRefineType(RefineType type)
Definition: RefineGeometry.cpp:126
void setReadFilename(std::string filename)
Definition: MimmoGeometry.cpp:221
void setRefineSteps(int steps)
Definition: RefineGeometry.cpp:150
bool addPin(BaseManipulation *objSend, BaseManipulation *objRec, PortID portS, PortID portR, bool forced)
Definition: MimmoNamespace.cpp:68
MimmoGeometry is an executable block class wrapping(linking or internally instantiating) a Mimmo Obje...
Definition: MimmoGeometry.hpp:151
RefineGeometry is an executable block class capable of refine a surface geometry.
Definition: RefineGeometry.hpp:92
void setReadFileType(FileType type)
Definition: MimmoGeometry.cpp:192