CreateSeedsOnSurface.hpp
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 #ifndef __CREATESEEDSONSURFACE_HPP__
26 #define __CREATESEEDSONSURFACE_HPP__
27 
28 #include "BaseManipulation.hpp"
29 #include "OBBox.hpp"
30 
31 
32 
33 namespace mimmo{
34 
39 enum class CSeedSurf{
40  RANDOM = 0 ,
41  LEVELSET = 1 ,
42  CARTESIANGRID=2
44 };
45 
112 
113 private:
114 
115  dvecarr3E m_points;
116  int m_nPoints;
117  double m_minDist;
118  darray3E m_seed;
119  CSeedSurf m_engine;
120  bool m_seedbaricenter;
121  bool m_randomFixed;
122  uint32_t m_randomSignature;
123  dmpvector1D m_sensitivity;
125  //utility members
126  std::unique_ptr<mimmo::OBBox> m_bbox;
127  livector1D m_deads;
128  dmpvector1D m_sensitivity_triangulated;
129  dvector1D m_final_sensitivity;
131 public:
133  CreateSeedsOnSurface(const bitpit::Config::Section & rootXML);
134  virtual ~CreateSeedsOnSurface();
137 
138  void buildPorts();
139 
140  //get methods
141  int getNPoints();
144  int getEngine();
145  darray3E getSeed();
146  bool isSeedMassCenter();
147  double getMinDistance();
148  bool isRandomFixed();
149  long getRandomSignature();
150 
151  //set methods
152  void setNPoints( int);
153  void setEngineENUM( CSeedSurf);
154  void setEngine(int);
155  void setSeed(darray3E);
156  void setMassCenterAsSeed(bool );
158  void setRandomFixed(bool fix);
159  void setRandomSignature(uint32_t signature);
160  void setSensitivityMap(dmpvector1D *field);
161 
162  void clear();
163 
164  void solve(bool debug = false);
165  void plotCloud(std::string dir, std::string file, int counter, bool binary);
166 
167  void execute();
168 
169  virtual void absorbSectionXML(const bitpit::Config::Section & slotXML, std::string name="");
170  virtual void flushSectionXML(bitpit::Config::Section & slotXML, std::string name="");
171 
172 protected:
173  virtual void plotOptionalResults();
174  void swap(CreateSeedsOnSurface & x) noexcept;
175  void checkField();
176  void normalizeField();
177  bool checkTriangulation();
179 
180 private:
181  void solveLSet( bool debug = false);
182  void solveGrid(bool debug = false);
183  void solveRandom(bool debug = false);
184 
185  void decimatePoints(dvecarr3E & rawpoint, dvector1D & rawsensi);
186 
187  void solveEikonal(double g, double s, bitpit::PatchKernel &tri,std::unordered_map<long,long> & invConn, dmpvector1D & field);
188  double updateEikonal(double g, double s, long tVert,long tCell,bitpit::PatchKernel &tri, std::unordered_map<long int, short int> &flag, dmpvector1D & field);
189 
190  std::unordered_map<long,long> getInverseConn(bitpit::PatchKernel &);
191  bool isDeadFront(const long int label);
192  std::set<long> findVertexVertexOneRing(bitpit::PatchKernel &, const long &, const long & );
193 };
194 
195 REGISTER_PORT(M_POINT, MC_ARRAY3, MD_FLOAT,__CREATESEEDSONSURFACE_HPP__)
196 REGISTER_PORT(M_VALUELI, MC_SCALAR, MD_LONG,__CREATESEEDSONSURFACE_HPP__)
197 REGISTER_PORT(M_GEOM, MC_SCALAR, MD_MIMMO_,__CREATESEEDSONSURFACE_HPP__)
198 REGISTER_PORT(M_FILTER, MC_SCALAR, MD_MPVECFLOAT_,__CREATESEEDSONSURFACE_HPP__)
199 REGISTER_PORT(M_COORDS, MC_VECARR3, MD_FLOAT,__CREATESEEDSONSURFACE_HPP__)
200 
201 
202 REGISTER(BaseManipulation, CreateSeedsOnSurface, "mimmo.CreateSeedsOnSurface")
203 };
204 
205 #endif /* __CREATESEEDSONSURFACE_HPP__ */
MimmoSharedPointer< MimmoObject > createTriangulation()
CSeedSurf
Enum class for engine choice to set up initial points on a 3D surface.
#define M_GEOM
#define MC_ARRAY3
#define MD_FLOAT
std::vector< darray3E > dvecarr3E
std::vector< long > livector1D
virtual void flushSectionXML(bitpit::Config::Section &slotXML, std::string name="")
#define M_POINT
void setRandomSignature(uint32_t signature)
BaseManipulation is the base class of any manipulation object of the library.
virtual void absorbSectionXML(const bitpit::Config::Section &slotXML, std::string name="")
void setSensitivityMap(dmpvector1D *field)
void swap(CreateSeedsOnSurface &x) noexcept
#define MC_SCALAR
#define REGISTER_PORT(Name, Container, Datatype, ManipBlock)
std::vector< double > dvector1D
#define MD_LONG
Distribute a raw list of points on a target 3D surface.
#define M_VALUELI
#define MD_MIMMO_
void plotCloud(std::string dir, std::string file, int counter, bool binary)
CreateSeedsOnSurface & operator=(CreateSeedsOnSurface other)
#define MD_MPVECFLOAT_
std::array< double, 3 > darray3E
void setGeometry(MimmoSharedPointer< MimmoObject >)
MimmoSharedPointer is a custom implementation of shared pointer.
#define M_COORDS
#define MC_VECARR3
#define M_FILTER
#define REGISTER(Base, Derived, name)
Definition: factory.hpp:206