genericinput_example_00004.cpp

Example of reading point positions and displacements related to a RBF manipulator, and applying deformation to a target meshUsing: IOCloudPoints, MRBF, MimmoGeometry, Chain

To run : ./genericinput_example_00003
To run (MPI version): mpirun -np X genericinput_example_00003
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_iogeneric.hpp"
#include "MRBF.hpp"
// =================================================================================== //
void test00004() {
/*
Reading and Writing a STL geometry (namely a plane)
*/
read->setReadDir("geodata");
read->setReadFilename("plane4");
read->setReadFileType(FileType::STL);
read->setWriteDir(".");
read->setWriteFilename("./genericinput_output_00004.0001");
read->setWriteFileType(FileType::SURFVTU);
/*
Reading a point cloud and their associated displacements from file.
These will serve as input to create the RBF manipulator
*/
iocp->setName("genericinput_example_00004_RBFSet");
iocp->setReadDir("input");
iocp->setReadFilename("generic_iocloud.txt");
iocp->setPlotInExecution(true);
/*
Create the RBF manipulator. Shape and Support Radius of RBF function
need to be specified
*/
mimmo::MRBF * rbf = new mimmo::MRBF();
rbf->setFunction(bitpit::RBFBasisFunction::C1C1);
rbf->setApply(true); //when chain executed, this will apply directly the deformation calculated to the target geometry
/*
Create block connections.
*/
/*
Define the execution chain.
*/
ch0.addObject(read);
ch0.addObject(iocp);
ch0.addObject(rbf);
/*
Execute the chain.
Use debug flag true to print out the execution steps.
*/
ch0.exec(true);
/*
print the deformed geometry
*/
read->getGeometry()->getPatch()->write("./genericinput_output_00004.0002");
/* Clean up & exit;
*/
delete read;
delete iocp;
delete rbf;
}
// =================================================================================== //
int main( int argc, char *argv[] ) {
BITPIT_UNUSED(argc);
BITPIT_UNUSED(argv);
#if MIMMO_ENABLE_MPI
MPI_Init(&argc, &argv);
#endif
try{
test00004();
}
catch(std::exception & e){
std::cout<<"genericinput_example_00004 exited with an error of type : "<<e.what()<<std::endl;
return 1;
}
#if MIMMO_ENABLE_MPI
MPI_Finalize();
#endif
return 0;
}
void exec(bool debug=false)
Definition: Chain.cpp:284
void setReadFilename(std::string filename)
void setReadDir(std::string 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 setSupportRadiusReal(double suppR_)
Definition: MRBF.cpp:436
void setWriteFileType(FileType type)
void setName(std::string name)
void setWriteDir(std::string dir)
#define M_GEOM2
void setWriteFilename(std::string filename)
#define M_VECTORFIELD
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...
Radial Basis Function evaluation from clouds of control points.
Definition: MRBF.hpp:146
void setReadFileType(FileType type)
IOCloudPoints is the class to read from file a set of cloud 3D points w/ attached a scalar field of f...
MimmoSharedPointer< MimmoObject > getGeometry()
void setApply(bool flag=true)
void setReadDir(std::string dir)
int addObject(BaseManipulation *obj, int id_=-1)
Definition: Chain.cpp:170
void setFunction(const MRBFBasisFunction &funct, bool isCompact=false)
Definition: MRBF.cpp:594