RefineGeometry.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 __REFINEGEOMETRY_HPP__
25 #define __REFINEGEOMETRY_HPP__
26 
27 #include "BaseManipulation.hpp"
28 
29 namespace mimmo{
30 
35 enum class RefineType{
36  TERNARY = 0,
39  REDGREEN = 1
41 };
42 
93 
94 protected:
97  int m_steps;
99  std::vector<long> m_activecells;
101 public:
102  RefineGeometry();
103  RefineGeometry(const bitpit::Config::Section & rootXML);
104  virtual ~RefineGeometry();
105 
106  RefineGeometry(const RefineGeometry & other);
108 
109  void buildPorts();
110 
112 
113  void setRefineType(RefineType type);
114  void setRefineType(int type);
115  void setRefineSteps(int steps);
116  void setSmoothingSteps(int steps);
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 
123  void plotOptionalResults();
124 protected:
125  void swap(RefineGeometry & x) noexcept;
126 
127  void ternaryRefine(std::unordered_map<long,long> * mapping = nullptr, mimmo::MimmoSharedPointer<MimmoObject> coarsepatch = nullptr, mimmo::MimmoSharedPointer<MimmoObject> refinepatch = nullptr);
128  std::vector<long> ternaryRefineCell(const long & cellId, const std::vector<bitpit::Vertex> & vertices, const std::array<double,3> & center);
129  void redgreenRefine(std::unordered_map<long,long> * mapping = nullptr, mimmo::MimmoSharedPointer<MimmoObject> coarsepatch = nullptr, mimmo::MimmoSharedPointer<MimmoObject> refinepatch = nullptr);
130  std::vector<long> redRefineCell(const long & cellId, const std::vector<long> & newVertexIds);
131  std::vector<long> greenRefineCell(const long & cellId, const long newVertexId, int iface);
132  void smoothing(std::set<long> * constrainedVertices = nullptr);
133  bool checkTriangulation();
134 };
135 
136 REGISTER_PORT(M_GEOM, MC_SCALAR, MD_MIMMO_, __REFINEGEOMETRY_HPP__)
137 REGISTER_PORT(M_GEOM2, MC_SCALAR, MD_MIMMO_, __REFINEGEOMETRY_HPP__)
138 
139 REGISTER(BaseManipulation, RefineGeometry, "mimmo.RefineGeometry")
140 
141 };
142 
143 #endif /* __REFINEGEOMETRY_HPP__ */
#define M_GEOM
std::vector< long > ternaryRefineCell(const long &cellId, const std::vector< bitpit::Vertex > &vertices, const std::array< double, 3 > &center)
void setSmoothingSteps(int steps)
RefineType
Methods available for refining globally a (surface) geometry.
virtual void flushSectionXML(bitpit::Config::Section &slotXML, std::string name="")
#define M_GEOM2
std::vector< long > m_activecells
void swap(RefineGeometry &x) noexcept
virtual void absorbSectionXML(const bitpit::Config::Section &slotXML, std::string name="")
BaseManipulation is the base class of any manipulation object of the library.
#define MC_SCALAR
#define REGISTER_PORT(Name, Container, Datatype, ManipBlock)
void setRefineType(RefineType type)
void setRefineSteps(int steps)
std::vector< long > redRefineCell(const long &cellId, const std::vector< long > &newVertexIds)
std::vector< long > greenRefineCell(const long &cellId, const long newVertexId, int iface)
RefineGeometry is an executable block class capable of refine a surface geometry.
void redgreenRefine(std::unordered_map< long, long > *mapping=nullptr, mimmo::MimmoSharedPointer< MimmoObject > coarsepatch=nullptr, mimmo::MimmoSharedPointer< MimmoObject > refinepatch=nullptr)
#define MD_MIMMO_
RefineGeometry & operator=(RefineGeometry other)
MimmoSharedPointer is a custom implementation of shared pointer.
void smoothing(std::set< long > *constrainedVertices=nullptr)
#define REGISTER(Base, Derived, name)
Definition: factory.hpp:206
void ternaryRefine(std::unordered_map< long, long > *mapping=nullptr, mimmo::MimmoSharedPointer< MimmoObject > coarsepatch=nullptr, mimmo::MimmoSharedPointer< MimmoObject > refinepatch=nullptr)