ControlDeformExtSurface.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 #ifndef __CONTROLDEFORMEXTSURFACE_HPP__
25 #define __CONTROLDEFORMEXTSURFACE_HPP__
26 
27 #include "BaseManipulation.hpp"
28 #include "MimmoGeometry.hpp"
29 
30 namespace mimmo{
31 
106 public:
111  typedef std::unordered_map<std::string, int> fileListWithType;
112  /*
113  \}
114  */
115 
116 private:
117  fileListWithType m_geoFileList;
118  std::unordered_set<MimmoSharedPointer<MimmoObject>> m_geoList;
119  dmpvector1D m_violationField;
120  dmpvecarr3E m_defField;
121  std::unordered_set<int> m_allowed;
122  double m_tolerance;
124 public:
126  ControlDeformExtSurface(const bitpit::Config::Section & rootXML);
127  virtual ~ControlDeformExtSurface();
128 
131 
132  void buildPorts();
133 
134  double getViolation();
136  double getTolerance();
137  const fileListWithType & getConstraintFiles() const;
138 
139  void setDefField(dmpvecarr3E *field);
141  void setTolerance(double tol);
142 
144 
146  void addConstraintFile(std::string file, int format);
147  void addConstraintFile(std::string file, FileType format);
148  void removeConstraintFile(std::string);
149  void removeConstraintFiles();
150 
151  void clear();
152  void execute();
153 
154  virtual void absorbSectionXML(const bitpit::Config::Section & slotXML, std::string name = "");
155  virtual void flushSectionXML(bitpit::Config::Section & slotXML, std::string name= "");
156 
157 protected:
158  void plotOptionalResults();
159  void swap(ControlDeformExtSurface & x) noexcept;
160 
161 private:
162  void readFileConstraints(std::vector<MimmoSharedPointer<MimmoObject> > & extFileGeos);
163  svector1D extractInfo(std::string file);
164  void evaluateSignedDistance(const std::vector<darray3E> &points, MimmoSharedPointer<MimmoObject> &geo, double initRadius, dvector1D & distances);
165  void writeLog();
166  void getGlobalBoundingBox(MimmoSharedPointer<MimmoObject> & geo, darray3E & bMin, darray3E & bMax);
167 
168 };
169 
170 REGISTER_PORT(M_GDISPLS, MC_SCALAR, MD_MPVECARR3FLOAT_,__CONTROLDEFORMEXTSURFACE_HPP__)
171 REGISTER_PORT(M_GEOM, MC_SCALAR, MD_MIMMO_,__CONTROLDEFORMEXTSURFACE_HPP__)
172 REGISTER_PORT(M_GEOM2, MC_SCALAR, MD_MIMMO_,__CONTROLDEFORMEXTSURFACE_HPP__)
173 REGISTER_PORT(M_VALUED, MC_SCALAR, MD_FLOAT,__CONTROLDEFORMEXTSURFACE_HPP__)
174 REGISTER_PORT(M_SCALARFIELD, MC_SCALAR, MD_MPVECFLOAT_,__CONTROLDEFORMEXTSURFACE_HPP__)
175 
176 
177 REGISTER(BaseManipulation, ControlDeformExtSurface,"mimmo.ControlDeformExtSurface")
178 
179 }
180 
181 #endif /* __CONTROLDEFORMEXTSURFACE_HPP__ */
#define M_GDISPLS
virtual void flushSectionXML(bitpit::Config::Section &slotXML, std::string name="")
#define M_GEOM
const fileListWithType & getConstraintFiles() const
std::vector< std::string > svector1D
#define MD_FLOAT
#define M_GEOM2
ControlDeformExtSurface is a class that check a deformation field, associated to a MimmoObject geomet...
BaseManipulation is the base class of any manipulation object of the library.
std::unordered_map< std::string, int > fileListWithType
#define MC_SCALAR
#define MD_MPVECARR3FLOAT_
#define REGISTER_PORT(Name, Container, Datatype, ManipBlock)
std::vector< double > dvector1D
#define M_VALUED
void addConstraintFile(std::string file, int format)
#define MD_MIMMO_
#define MD_MPVECFLOAT_
#define M_SCALARFIELD
std::array< double, 3 > darray3E
void addConstraint(MimmoSharedPointer< MimmoObject > constraint)
void setConstraintFiles(fileListWithType list)
MimmoSharedPointer is a custom implementation of shared pointer.
ControlDeformExtSurface & operator=(ControlDeformExtSurface other)
void setGeometry(MimmoSharedPointer< MimmoObject > target)
virtual void absorbSectionXML(const bitpit::Config::Section &slotXML, std::string name="")
void swap(ControlDeformExtSurface &x) noexcept
#define REGISTER(Base, Derived, name)
Definition: factory.hpp:206