ExtractFields.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 __EXTRACTFIELDS_HPP__
25 #define __EXTRACTFIELDS_HPP__
26 
27 #include "BaseManipulation.hpp"
28 
29 namespace mimmo{
34 enum class ExtractMode{
35  ID = 1,
36  PID = 2,
37  MAPPING = 3
38 };
39 
96 protected:
98  double m_tol;
100 public:
101  ExtractField();
102  virtual ~ExtractField();
103 
104  ExtractField(const ExtractField & other);
105  ExtractField& operator=(const ExtractField & other);
106 
107  void buildPorts();
108 
109  void setMode(ExtractMode mode);
110  void setMode(int mode);
111  void setTolerance(double tol);
113 
115  double getTolerance();
116 
117  void clear();
118  void execute();
119 
120  virtual void absorbSectionXML(const bitpit::Config::Section & slotXML, std::string name="");
121  virtual void flushSectionXML(bitpit::Config::Section & slotXML, std::string name="");
122 
126  virtual bool extract() = 0;
127 
128 protected:
129  void swap(ExtractField & x) noexcept;
130 
131 };
132 
133 
181 private:
182  dmpvector1D m_field;
183  dmpvector1D m_result;
185 public:
187  ExtractScalarField(const bitpit::Config::Section & rootXMl);
188  virtual ~ExtractScalarField();
189 
190  ExtractScalarField(const ExtractScalarField & other);
192 
193  void buildPorts();
195  void setField(dmpvector1D *field);
196 
198 
199  void clear();
200 
201  void plotOptionalResults();
202  bool extract();
203 
204 protected:
205  void swap(ExtractScalarField & x) noexcept;
206 
207 private:
208 
209  void extractID(mimmo::MPVLocation loc);
210  void extractPID(mimmo::MPVLocation loc);
211  void extractMapping(mimmo::MPVLocation loc);
212 
213 };
214 
215 
264 private:
265  dmpvecarr3E m_field;
266  dmpvecarr3E m_result;
268 public:
269 
271  ExtractVectorField(const bitpit::Config::Section & rootXMl);
272  virtual ~ExtractVectorField();
273  ExtractVectorField(const ExtractVectorField & other);
275 
276  void buildPorts();
278  void setField(dmpvecarr3E*field);
279 
281  void clear();
282 
283  void plotOptionalResults();
284  bool extract();
285 
286 protected:
287  void swap(ExtractVectorField & x) noexcept;
288 
289 private:
290  void extractID(mimmo::MPVLocation loc);
291  void extractPID(mimmo::MPVLocation loc);
292  void extractMapping(mimmo::MPVLocation loc);
293 
294 };
295 
296 
344 private:
345  MimmoPiercedVector<long> m_field;
346  MimmoPiercedVector<long> m_result;
348 public:
350  ExtractLongField(const bitpit::Config::Section & rootXMl);
351  virtual ~ExtractLongField();
352 
353  ExtractLongField(const ExtractLongField & other);
355 
356  void buildPorts();
358  void setField(MimmoPiercedVector<long> *field);
359 
361 
362  void clear();
363 
364  void plotOptionalResults();
365  bool extract();
366 
367 protected:
368  void swap(ExtractLongField & x) noexcept;
369 
370 private:
371 
372  void extractID(mimmo::MPVLocation loc);
373  void extractPID(mimmo::MPVLocation loc);
374  void extractMapping(mimmo::MPVLocation loc);
375 
376 };
377 
378 
379 
427 private:
431 public:
433  ExtractStringField(const bitpit::Config::Section & rootXMl);
434  virtual ~ExtractStringField();
435 
436  ExtractStringField(const ExtractStringField & other);
438 
439  void buildPorts();
442 
444 
445  void clear();
446 
447  void plotOptionalResults();
448  bool extract();
449 
450 protected:
451  void swap(ExtractStringField & x) noexcept;
452 
453 private:
454 
455  void extractID(mimmo::MPVLocation loc);
456  void extractPID(mimmo::MPVLocation loc);
457  void extractMapping(mimmo::MPVLocation loc);
458 
459 };
460 
461 
462 REGISTER_PORT(M_GEOM, MC_SCALAR, MD_MIMMO_, __EXTRACTFIELDS_HPP__)
463 REGISTER_PORT(M_SCALARFIELD, MC_SCALAR, MD_MPVECFLOAT_,__EXTRACTFIELDS_HPP__)
465 REGISTER_PORT(M_LONGFIELD, MC_SCALAR, MD_MPVECLONG_,__EXTRACTFIELDS_HPP__)
466 REGISTER_PORT(M_STRINGFIELD, MC_SCALAR, MD_MPVECSTRING_,__EXTRACTFIELDS_HPP__)
467 
468 REGISTER(BaseManipulation, ExtractScalarField, "mimmo.ExtractScalarField")
472 };
473 
474 #endif /* __EXTRACTFIELDS_HPP__ */
void setField(dmpvecarr3E *field)
ExtractMode
Modes available to extract fields.See class ExtractField documentation.
#define M_LONGFIELD
void swap(ExtractLongField &x) noexcept
ExtractScalarField is specialized derived class of ExtractField to extract a scalar field of doubles.
MimmoPiercedVector< std::string > getOriginalField()
void swap(ExtractField &x) noexcept
#define M_GEOM
virtual void flushSectionXML(bitpit::Config::Section &slotXML, std::string name="")
ExtractLongField & operator=(const ExtractLongField &other)
void setField(MimmoPiercedVector< long > *field)
ExtractScalarField & operator=(const ExtractScalarField &other)
MPVLocation
Define data location for the MimmoPiercedVector field.
ExtractField is an abstract executable block class for extracting/restricting an input field defined ...
void swap(ExtractScalarField &x) noexcept
ExtractVectorField & operator=(const ExtractVectorField &other)
void setField(MimmoPiercedVector< std::string > *field)
BaseManipulation is the base class of any manipulation object of the library.
ExtractMode getMode()
#define M_VECTORFIELD
void setTolerance(double tol)
#define M_STRINGFIELD
#define MC_SCALAR
ExtractField & operator=(const ExtractField &other)
#define MD_MPVECARR3FLOAT_
#define REGISTER_PORT(Name, Container, Datatype, ManipBlock)
MimmoPiercedVector< long > getOriginalField()
ExtractStringField & operator=(const ExtractStringField &other)
void setField(dmpvector1D *field)
void swap(ExtractVectorField &x) noexcept
#define MD_MIMMO_
virtual void absorbSectionXML(const bitpit::Config::Section &slotXML, std::string name="")
#define MD_MPVECFLOAT_
#define M_SCALARFIELD
MimmoPiercedVector< std::string > * getExtractedField()
void setGeometry(MimmoSharedPointer< MimmoObject > geometry)
MimmoPiercedVector< long > * getExtractedField()
void swap(ExtractStringField &x) noexcept
#define MD_MPVECLONG_
#define MD_MPVECSTRING_
void setMode(ExtractMode mode)
virtual bool extract()=0
ExtractStringField is specialized derived class of ExtractField to extract a scalar field of string.
#define REGISTER(Base, Derived, name)
Definition: factory.hpp:206
ExtractVectorField is specialized derived class of ExtractField to extract a vector field of array<do...
ExtractLongField is specialized derived class of ExtractField to extract a scalar field of long.