utils_example_00001.cpp
Example of seeding a point cloud over an unstructured non-homogeneous mesh.Using: MimmoGeometry, CreateSeedsOnSurface
To run: ./utils_example_00001
To run: mpirun -np X utils_example_00001
Please note MPI version of the example partition a very coarse support mesh. Do not exceed with number of processors (X=2 is fine).
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 test00001() {
/*
Read a target polygonal mesh from file. CONVERT option will let the block to write
the just read file in another file, immediately after the reading.
*/
bitpit::Logger & log = mimmo0->getLog();
log.setPriority(bitpit::log::Priority::NORMAL);
mimmo0->setReadFileType(FileType::SURFVTU);
mimmo0->setWriteFileType(FileType::SURFVTU);
mimmo0->exec();
log<<"Reading and converting the initial mesh"<<std::endl;
#if MIMMO_ENABLE_MPI
/*
Distribute the mesh among the processes
*/
mimmo::Partition * part = new mimmo::Partition();
part->setPartitionMethod(mimmo::PartitionMethod::PARTGEOM);
part->setGeometry(mimmo0->getGeometry());
part->setPlotInExecution(true);
part->exec();
log<<"Partitioning the initial mesh"<<std::endl;
target = part->getGeometry();
#else
target = mimmo0->getGeometry();
#endif
/*
Create a custom sensitivity field on target points
use a linear decay in spherical coordinates from center 0.5,0.5,0.
*/
mimmo::MimmoPiercedVector<double> sensitivity;
darray3E center({{0.5,0.5,0}});
{
darray3E pMin,pMax;
target->getBoundingBox(pMin, pMax, true);
double maxD = norm2(pMax-pMin)/3.;
double localvalue;
for(bitpit::Vertex & v : target->getVertices()){
localvalue = norm2(v.getCoords() - center);
if(localvalue < maxD){
sensitivity[v.getId()] += -1.0*localvalue/maxD;
}else{
sensitivity[v.getId()] = 0.0;
}
}
}
log<<"Creating artificial sensitivity"<<std::endl;
/*
Creation of the seeder. Use Level set engine to place 9 points on
surface, starting from a seed point in the absolute origin.
*/
cseed->setSeed(center);
cseed->setNPoints(20);
cseed->setSensitivityMap(&sensitivity);
cseed->setEngine(0);
cseed->setRandomSignature(1599826209);
cseed->setGeometry(target);
cseed->exec();
log<<"Seeding points on surface mesh"<<std::endl;
/*
plot on screen the id to reproduce random distribution if a Random engine
is selected into cseed block.
*/
}
/*
Clean up & exit;
*/
delete mimmo0;
delete cseed;
#if MIMMO_ENABLE_MPI
delete part;
#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{
test00001() ;
}
catch(std::exception & e){
std::cout<<"utils_example_00001 exited with an error of type : "<<e.what()<<std::endl;
return 1;
}
#if MIMMO_ENABLE_MPI==1
}
MPI_Finalize();
#endif
return 0;
}
@ RANDOM
void setWriteFileType(FileType type)
Definition: MimmoGeometry.cpp:230
void setRandomSignature(uint32_t signature)
Definition: CreateSeedsOnSurface.cpp:328
void setRandomFixed(bool fix)
Definition: CreateSeedsOnSurface.cpp:316
long getRandomSignature()
Definition: CreateSeedsOnSurface.cpp:237
void setWriteFilename(std::string filename)
Definition: MimmoGeometry.cpp:268
void setSensitivityMap(dmpvector1D *field)
Definition: CreateSeedsOnSurface.cpp:339
void setReadFilename(std::string filename)
Definition: MimmoGeometry.cpp:221
Distribute a raw list of points on a target 3D surface.
Definition: CreateSeedsOnSurface.hpp:111
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
CSeedSurf getEngineENUM()
Definition: CreateSeedsOnSurface.cpp:174
@ POINT
void setPlotInExecution(bool)
Definition: BaseManipulation.cpp:443
void setReadFileType(FileType type)
Definition: MimmoGeometry.cpp:192
void setGeometry(MimmoSharedPointer< MimmoObject >)
Definition: CreateSeedsOnSurface.cpp:297
MimmoSharedPointer< MimmoObject > getGeometry()
Definition: BaseManipulation.cpp:235