manipulators_example_00001.cpp
Example of usage of global deformation blocks in cascade to manipulate an input geometry.Using: MimmoGeometry, TranslationGeometry, ScaleGeometry, TwistGeometry, BendGeometry, RotationGeometry, Chain, Partition(MPI version).
To run: ./manipulators_example_00001
To run (MPI version): mpirun -np X manipulators_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_manipulators.hpp"
#include "mimmo_iogeneric.hpp"
#include <bitpit_common.hpp>
#if MIMMO_ENABLE_MPI
#include "mimmo_parallel.hpp"
#endif
// =================================================================================== //
void test00001() {
/*
Read a prism from STL file. Convert mode is to save the just read geometry in
another file with name manipulators_output_00001.stl
*/
mimmo0->setReadFileType(FileType::STL);
mimmo0->setWriteFileType(FileType::STL);
/*
It will write to file the first partial deformation due to translation manipulation
*/
mimmo1->setWriteDir(".");
mimmo1->setWriteFileType(FileType::STL);
mimmo1->setWriteFilename("manipulators_output_00001.0001");
/*
It will write to file the second partial deformation due to both translation and scaling
*/
mimmo2->setWriteDir(".");
mimmo2->setWriteFileType(FileType::STL);
mimmo2->setWriteFilename("manipulators_output_00001.0002");
/*
It will write to file the third partial deformation due to translation/scaling and twisting
*/
mimmo3->setWriteDir(".");
mimmo3->setWriteFileType(FileType::STL);
mimmo3->setWriteFilename("manipulators_output_00001.0003");
/*
It will write to file the fourth deformation due to translation/scaling/twisting and bending
*/
mimmo4->setWriteDir(".");
mimmo4->setWriteFileType(FileType::STL);
mimmo4->setWriteFilename("manipulators_output_00001.0004");
/*
It will write to file the final deformation due to translation/scaling/twisting/bending and rotation
*/
mimmo5->setWriteDir(".");
mimmo5->setWriteFileType(FileType::STL);
mimmo5->setWriteFilename("manipulators_output_00001.0005");
#if MIMMO_ENABLE_MPI
/*
Distribute the target mesh among the processes.
*/
mimmo::Partition* partition= new mimmo::Partition();
partition->setPartitionMethod(mimmo::PartitionMethod::PARTGEOM);
#endif
/*
Creation of translation block.
Translation performed in z direction by -1.0 unit length.
*/
translation->setTranslation(1.0);
/*
Apply the translation deformation to the mesh.
*/
/*
Creation of scaling block.
Scaling performed in y & z direction by 0.5 factor.
*/
/*
Apply the scaling deformation to the mesh.
*/
/*
Creation of twisting block.
Twisting performed in x direction by a maximum angle at a distance 1.0
from the origin equal to pi/3 radiants.
*/
twist->setTwist((BITPIT_PI/3));
twist->setMaxDistance(1.0);
/*
Apply the twisting deformation to the mesh.
*/
/*
Creation of bending block.
Bending performed in x direction by a maximum angle at a distance 1.0
from the origin equal to pi/3 radiants.
*/
umatrix33E degree = {0,0,0, 0,0,0, 2,0,0};
bend->setDegree(degree);
dmat33Evec coeffs;
coeffs[2][0].resize(3);
coeffs[2][0][0] = 0;
coeffs[2][0][1] = 0;
coeffs[2][0][2] = 0.5;
bend->setCoeffs(&coeffs);
/*
* Bend directly applied during execution, no external applier for it!
*/
bend->setApply();
/*
Creation of rotation block.
Rotation performed around an axis through the origin and
with direction (0.25,0.25,0.75) by pi/4 radiants.
*/
rotation->setRotation((BITPIT_PI/4));
/*
Apply the rotation deformation to the mesh.
*/
/* Setup pin connections.
*/
#if MIMMO_ENABLE_MPI
#else
#endif
/*
Setup execution chain.
*/
mimmo::Chain ch0;
#if MIMMO_ENABLE_MPI
ch0.addObject(partition);
#endif
ch0.addObject(mimmo0);
ch0.addObject(translation);
ch0.addObject(applierTranslation);
ch0.addObject(mimmo1);
ch0.addObject(scaling);
ch0.addObject(applierScaling);
ch0.addObject(mimmo2);
ch0.addObject(twist);
ch0.addObject(applierTwist);
ch0.addObject(mimmo3);
ch0.addObject(bend);
ch0.addObject(mimmo4);
ch0.addObject(rotation);
ch0.addObject(applierRotation);
ch0.addObject(mimmo5);
/*
Execute the chain.
Use debug flag false to avoid to print out the execution steps on console.
*/
/*
Clean up & exit;
*/
#if MIMMO_ENABLE_MPI
delete partition;
#endif
delete mimmo0;
delete translation;
delete applierTranslation;
delete mimmo1;
delete scaling;
delete applierScaling;
delete mimmo2;
delete twist;
delete applierTwist;
delete mimmo3;
delete bend;
delete mimmo4;
delete rotation;
delete applierRotation;
delete mimmo5;
return;
}
int main(int argc, char *argv[]) {
BITPIT_UNUSED(argc);
BITPIT_UNUSED(argv);
#if MIMMO_ENABLE_MPI==1
MPI_Init(&argc, &argv);
{
#endif
try{
test00001() ;
}
catch(std::exception & e){
std::cout<<"manipulators_example_00001 exited with an error of type : "<<e.what()<<std::endl;
return 1;
}
#if MIMMO_ENABLE_MPI==1
}
MPI_Finalize();
#endif
return 0;
}
void setMaxDistance(double distance)
Definition: TwistGeometry.cpp:166
ScaleGeometry is the class that applies a scaling to a given geometry patch in respect to the mean po...
Definition: ScaleGeometry.hpp:78
void setDirection(darray3E direction)
Definition: TranslationGeometry.cpp:108
Chain is the class used to manage the chain execution of multiple executable blocks (manipulation obj...
Definition: Chain.hpp:48
RotationGeometry is the class that applies a rotation to a given geometry patch.
Definition: RotationGeometry.hpp:79
Apply is the class that applies the deformation resulting from a manipulation object to the geometry.
Definition: Apply.hpp:89
void setDirection(darray3E direction)
Definition: TwistGeometry.cpp:139
void setWriteFileType(FileType type)
Definition: MimmoGeometry.cpp:230
BendGeometry applies custom bending deformations along axis-directions of a target geometry.
Definition: BendGeometry.hpp:120
void setWriteFilename(std::string filename)
Definition: MimmoGeometry.cpp:268
void setTranslation(double alpha)
Definition: TranslationGeometry.cpp:119
void setReadFilename(std::string filename)
Definition: MimmoGeometry.cpp:221
void setRotation(double alpha)
Definition: RotationGeometry.cpp:146
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
TranslationGeometry is the class that applies a translation to a given geometry patch.
Definition: TranslationGeometry.hpp:75
void setReadFileType(FileType type)
Definition: MimmoGeometry.cpp:192
TwistGeometry is the class that applies a twist to a given geometry patch.
Definition: TwistGeometry.hpp:85
void setDirection(darray3E direction)
Definition: RotationGeometry.cpp:135