geohandlers_example_00000.cpp

Example of usage of selection block to select a sub-patch of an input geometry.Using: SelectionByCylinder, MimmoGeometry, Chain.

To run : ./geohandlers_example_00000
To run (MPI version): mpirun -np X geohandlers_example_00000
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"
#include <bitpit_common.hpp>
// =================================================================================== //
// =================================================================================== //
void test00001() {
/*
Read a STL geometry (namely a plane). Convert mode will also write the just read geometry
in the new stl file (specified with setWriteFilename)
*/
mimmo0->setName("mimmo0");
mimmo0->setReadDir("./geodata");
mimmo0->setReadFileType(FileType::STL);
mimmo0->setReadFilename("plane3");
mimmo0->setWriteDir("./");
mimmo0->setWriteFileType(FileType::STL);
mimmo0->setWriteFilename("geohandlers_output_00000.0000");
/*
Write a STL geometry.
*/
mimmo1->setWriteDir(".");
mimmo1->setWriteFileType(FileType::STL);
mimmo1->setWriteFilename("geohandlers_output_00000.0001");
/*
Select a subportion of geometry using a cylinder shape
*/
sel3->setOrigin({{0.5, 0.0, 0.0}});
sel3->setSpan({{0.75, 2.0*BITPIT_PI, 0.4}});
sel3->setInfLimits({{0.25, 0.0, 0.0}});
sel3->setRefSystem({{0,1,0}}, {{0,0,1}}, {{1,0,0}});
sel3->setPlotInExecution(true);
/*
Define block pin connections.
*/
mimmo::pin::addPin(mimmo0, sel3, M_GEOM, M_GEOM);
mimmo::pin::addPin(sel3, mimmo1, M_GEOM, M_GEOM);
/*
Setup execution chain.
*/
ch0.addObject(mimmo0);
ch0.addObject(sel3);
ch0.addObject(mimmo1);
/*
Execute the chain.
Use debug flag true to to print out the execution steps.
*/
ch0.exec(true);
/* Clean up & exit;
*/
delete sel3;
delete mimmo0;
delete mimmo1;
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_00000 exited with an error of type : "<<e.what()<<std::endl;
return 1;
}
#if MIMMO_ENABLE_MPI
MPI_Finalize();
#endif
return 0;
}
void setOrigin(darray3E)
void exec(bool debug=false)
Definition: Chain.cpp:284
void setInfLimits(double val, int dir)
Chain is the class used to manage the chain execution of multiple executable blocks (manipulation obj...
Definition: Chain.hpp:48
#define M_GEOM
void setWriteFileType(FileType type)
void setName(std::string name)
void setWriteDir(std::string dir)
void setWriteFilename(std::string filename)
Selection through cylinder primitive.
void setRefSystem(darray3E, darray3E, darray3E)
void setReadFilename(std::string filename)
bool addPin(BaseManipulation *objSend, BaseManipulation *objRec, PortID portS, PortID portR, bool forced)
MimmoGeometry is an executable block class wrapping(linking or internally instantiating) a Mimmo Obje...
void setReadFileType(FileType type)
void setSpan(double, double, double)
void setReadDir(std::string dir)
int addObject(BaseManipulation *obj, int id_=-1)
Definition: Chain.cpp:170