genericinput_example_00003.cpp

Example of reading displacements related to a 3x2x2 FFDLattice manipulator, and applying deformation onto a target mesh.Using: GenericDispls, FFDLattice, 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 "FFDLattice.hpp"
// =================================================================================== //
void test00003() {
/*
Read and Write a STL geometry of a plane
*/
read->setReadDir("geodata");
read->setReadFilename("plane4");
read->setReadFileType(FileType::STL);
read->setWriteDir(".");
read->setWriteFilename("./genericinput_output_00003.0001");
read->setWriteFileType(FileType::SURFVTU);
/*
Creating a FFDLattice manipulator of dimension 3x2x2 around a box centered in 0,0,-0.5
with span 2,2,1
*/
latt->setName("genericinput_example_00003_Lattice");
latt->setOrigin({{0.0,0.0,-0.5}});
latt->setSpan({{2.0,2.0,1.0}});
latt->setDimension(iarray3E({{3,2,2}}));
latt->setDegrees(iarray3E{2,1,1});
latt->build();
latt->setPlotInExecution(true);
latt->setApply(true); // when chain executed, this will apply directly deformation onto the target mesh
/*
Create a reader for the displacement file associated to the lattice and
available from file
*/
iodispls->setReadDir("input");
iodispls->setReadFilename("generic_displ_00002.txt");
/*
Define pin connections between blocks.
*/
/*
Define execution chain.
*/
ch0.addObject(read);
ch0.addObject(latt);
ch0.addObject(iodispls);
/*
Execute the chain.
Use debug flag true to print out the execution steps.
*/
ch0.exec(true);
/*
print out the file the deformed geometry
*/
read->getGeometry()->getPatch()->write("./genericinput_output_00003.0002");
/* Clean up & exit;
*/
delete read;
delete iodispls;
delete latt;
}
// =================================================================================== //
int main( int argc, char *argv[] ) {
BITPIT_UNUSED(argc);
BITPIT_UNUSED(argv);
#if MIMMO_ENABLE_MPI
MPI_Init(&argc, &argv);
#endif
try{
test00003();
}
catch(std::exception & e){
std::cout<<"genericinput_example_00003 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
std::array< int, 3 > iarray3E
void setDimension(ivector1D dim)
Chain is the class used to manage the chain execution of multiple executable blocks (manipulation obj...
Definition: Chain.hpp:48
#define M_DISPLS
#define M_GEOM
void setWriteFileType(FileType type)
void setName(std::string name)
void setOrigin(darray3E origin)
void setWriteDir(std::string dir)
void setDegrees(iarray3E curveDegrees)
Definition: FFDLattice.cpp:273
void setShape(ShapeType type=ShapeType::CUBE)
void setWriteFilename(std::string filename)
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 setReadFilename(std::string filename)
GenericDispls is the class to read from file an initial set of displacements as a generic vector fiel...
void setSpan(double, double, double)
void setReadFileType(FileType type)
MimmoSharedPointer< MimmoObject > getGeometry()
void setApply(bool flag=true)
void setReadDir(std::string dir)
Free Form Deformation of a 3D surface and point clouds, with structured lattice.
Definition: FFDLattice.hpp:133
void setReadDir(std::string dir)
int addObject(BaseManipulation *obj, int id_=-1)
Definition: Chain.cpp:170
virtual bool build()