genericinput_example_00004.cpp
1 /*---------------------------------------------------------------------------*\
2  *
3  * mimmo
4  *
5  * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6  *
7  * -------------------------------------------------------------------------
8  * License
9  * This file is part of mimmo.
10  *
11  * mimmo is free software: you can redistribute it and/or modify it
12  * under the terms of the GNU Lesser General Public License v3 (LGPL)
13  * as published by the Free Software Foundation.
14  *
15  * mimmo is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18  * License for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * along with mimmo. If not, see <http://www.gnu.org/licenses/>.
22  *
23  \ *---------------------------------------------------------------------------*/
24 
25 #include "mimmo_iogeneric.hpp"
26 #include "MRBF.hpp"
27 
42 // =================================================================================== //
43 
44 
45 void test00004() {
46 
47  /*
48  Reading and Writing a STL geometry (namely a plane)
49  */
51  read->setReadDir("geodata");
52  read->setReadFilename("plane4");
53  read->setReadFileType(FileType::STL);
54  read->setWriteDir(".");
55  read->setWriteFilename("./genericinput_output_00004.0001");
56  read->setWriteFileType(FileType::SURFVTU);
57 
58  /*
59  Reading a point cloud and their associated displacements from file.
60  These will serve as input to create the RBF manipulator
61  */
62  mimmo::IOCloudPoints * iocp = new mimmo::IOCloudPoints(true);
63  iocp->setName("genericinput_example_00004_RBFSet");
64  iocp->setReadDir("input");
65  iocp->setReadFilename("generic_iocloud.txt");
66  iocp->setPlotInExecution(true);
67 
68  /*
69  Create the RBF manipulator. Shape and Support Radius of RBF function
70  need to be specified
71  */
72  mimmo::MRBF * rbf = new mimmo::MRBF();
73  rbf->setFunction(bitpit::RBFBasisFunction::C1C1);
74  rbf->setSupportRadiusReal(0.6);
75  rbf->setApply(true); //when chain executed, this will apply directly the deformation calculated to the target geometry
76 
77  /*
78  Create block connections.
79  */
80  mimmo::pin::addPin(read, rbf, M_GEOM, M_GEOM);
81  mimmo::pin::addPin(iocp, rbf, M_GEOM, M_GEOM2);
83 
84  /*
85  Define the execution chain.
86  */
87  mimmo::Chain ch0;
88  ch0.addObject(read);
89  ch0.addObject(iocp);
90  ch0.addObject(rbf);
91 
92 
93  /*
94  Execute the chain.
95  Use debug flag true to print out the execution steps.
96  */
97  ch0.exec(true);
98 
99  /*
100  print the deformed geometry
101  */
102  read->getGeometry()->getPatch()->write("./genericinput_output_00004.0002");
103 
104 
105  /* Clean up & exit;
106  */
107  delete read;
108  delete iocp;
109  delete rbf;
110 
111 }
112 
113 // =================================================================================== //
114 
115 int main( int argc, char *argv[] ) {
116 
117  BITPIT_UNUSED(argc);
118  BITPIT_UNUSED(argv);
119 
120 #if MIMMO_ENABLE_MPI
121  MPI_Init(&argc, &argv);
122 #endif
123 
124  try{
125  test00004();
126  }
127  catch(std::exception & e){
128  std::cout<<"genericinput_example_00004 exited with an error of type : "<<e.what()<<std::endl;
129  return 1;
130  }
131 #if MIMMO_ENABLE_MPI
132  MPI_Finalize();
133 #endif
134 
135  return 0;
136 }
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