utils_example_00002.cpp
Example of calculating collision penetrations with ControlDeformExtSurface. The Stanford Bunny will fit the open box?Using: MimmoGeometry, ControlDeformExtSurface
To run : ./utils_example_00002
To run(MPI version): mpirun -np X utils_example_00002
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_utils.hpp"
#if MIMMO_ENABLE_MPI
#include "Partition.hpp"
#endif
// =================================================================================== //
void test00002() {
/*
reading target stanford Bunny
*/
bitpit::Logger & log = bunny->getLog();
bunny->setReadFileType(FileType::STL);
bunny->exec();
//customize the logger output
log.setPriority(bitpit::log::Priority::NORMAL);
log<<"Target Bunny read"<<std::endl;
log.setPriority(bitpit::log::Priority::DEBUG);
/*
reading constraint inclinedPlane geometry
*/
incplane->setName("ReaderInclinedPlaneConstraint");
incplane->setReadDir("geodata");
incplane->setReadFileType(FileType::STL);
incplane->setReadFilename("inclinedPlane");
incplane->exec();
log.setPriority(bitpit::log::Priority::NORMAL);
log<<"Inclined plane constraint read"<<std::endl;
log.setPriority(bitpit::log::Priority::DEBUG);
#if MIMMO_ENABLE_MPI
/*
Partitioner of the bunny -> distribute it among processes.
*/
mimmo::Partition* partbunny = new mimmo::Partition();
partbunny->setName("PartitionerBunny");
partbunny->setGeometry(bunny->getGeometry());
partbunny->setPlotInExecution(true);
partbunny->setPartitionMethod(mimmo::PartitionMethod::PARTGEOM);
partbunny->exec();
log.setPriority(bitpit::log::Priority::NORMAL);
log<<"Target Bunny partitioned"<<std::endl;
log.setPriority(bitpit::log::Priority::DEBUG);
/*
Partitioner of the inclined plane -> distribute it among processes.
*/
mimmo::Partition* partincplane = new mimmo::Partition();
partincplane->setName("PartitionerInclinedPlane");
partincplane->setGeometry(incplane->getGeometry());
partincplane->setPlotInExecution(true);
partincplane->setPartitionMethod(mimmo::PartitionMethod::PARTGEOM);
partincplane->exec();
log.setPriority(bitpit::log::Priority::NORMAL);
log<<"Inclined plane constraint partitioned"<<std::endl;
log.setPriority(bitpit::log::Priority::DEBUG);
#endif
/*
Create a dummy deformation field for the target bunny mesh
*/
#if MIMMO_ENABLE_MPI
mimmo::MimmoSharedPointer<mimmo::MimmoObject> target = partbunny->getGeometry();
mimmo::MimmoSharedPointer<mimmo::MimmoObject> constraint = partincplane->getGeometry();
#else
mimmo::MimmoSharedPointer<mimmo::MimmoObject> target = bunny->getGeometry();
mimmo::MimmoSharedPointer<mimmo::MimmoObject> constraint = incplane->getGeometry();
#endif
mimmo::dmpvecarr3E def;
/*
Creation of violation/penetration field calculator
Please note constraint meshes can be passed as MimmoObjects or
can be directly passed as file: in that case the class will parse them.
In case of MPI version the parsed result will be retained only on the master rank,.
*/
cdes->setGeometry(target);
cdes->addConstraint(constraint);
cdes->setDefField(&def);
cdes->setTolerance(0.0);
cdes->exec();
log.setPriority(bitpit::log::Priority::NORMAL);
log<<"Violation field calculated"<<std::endl;
log.setPriority(bitpit::log::Priority::DEBUG);
/* Clean up & exit;
*/
delete bunny;
delete incplane;
delete cdes;
#if MIMMO_ENABLE_MPI
delete partbunny;
delete partincplane;
#endif
return;
}
int main(int argc, char *argv[]) {
BITPIT_UNUSED(argc);
BITPIT_UNUSED(argv);
#if MIMMO_ENABLE_MPI==1
MPI_Init(&argc, &argv);
{
#endif
try{
test00002() ;
}
catch(std::exception & e){
std::cout<<"utils_example_00002 exited with an error of type : "<<e.what()<<std::endl;
return 1;
}
#if MIMMO_ENABLE_MPI==1
}
MPI_Finalize();
#endif
return 0;
}
ControlDeformExtSurface is a class that check a deformation field, associated to a MimmoObject geomet...
Definition: ControlDeformExtSurface.hpp:105
void setReadFilename(std::string filename)
Definition: MimmoGeometry.cpp:221
MimmoGeometry is an executable block class wrapping(linking or internally instantiating) a Mimmo Obje...
Definition: MimmoGeometry.hpp:151
void initialize(MimmoSharedPointer< MimmoObject >, MPVLocation, const mpv_t &)
Definition: MimmoPiercedVector.tpp:593
@ POINT
void addConstraintFile(std::string file, int format)
Definition: ControlDeformExtSurface.cpp:254
void setDefField(dmpvecarr3E *field)
Definition: ControlDeformExtSurface.cpp:180
void setPlotInExecution(bool)
Definition: BaseManipulation.cpp:443
void addConstraint(MimmoSharedPointer< MimmoObject > constraint)
Definition: ControlDeformExtSurface.cpp:220
void setReadFileType(FileType type)
Definition: MimmoGeometry.cpp:192
MimmoSharedPointer< MimmoObject > getGeometry()
Definition: BaseManipulation.cpp:235
void setTolerance(double tol)
Definition: ControlDeformExtSurface.cpp:209
void setGeometry(MimmoSharedPointer< MimmoObject > target)
Definition: ControlDeformExtSurface.cpp:191