NEMoSys  0.63.0
A modular, extensible resource with robust automated mesh generation, mesh quality analysis, adaptive mesh refinement, and data transfer between arbitrary meshes.
NucMeshShapeData.H
Go to the documentation of this file.
1 /*******************************************************************************
2 * Promesh *
3 * Copyright (C) 2022, IllinoisRocstar LLC. All rights reserved. *
4 * *
5 * Promesh is the property of IllinoisRocstar LLC. *
6 * *
7 * IllinoisRocstar LLC *
8 * Champaign, IL *
9 * www.illinoisrocstar.com *
10 * promesh@illinoisrocstar.com *
11 *******************************************************************************/
12 /*******************************************************************************
13 * This file is part of Promesh *
14 * *
15 * This version of Promesh is free software: you can redistribute it and/or *
16 * modify it under the terms of the GNU Lesser General Public License as *
17 * published by the Free Software Foundation, either version 3 of the License, *
18 * or (at your option) any later version. *
19 * *
20 * Promesh is distributed in the hope that it will be useful, but WITHOUT ANY *
21 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more *
23 * details. *
24 * *
25 * You should have received a copy of the GNU Lesser General Public License *
26 * along with this program. If not, see <https://www.gnu.org/licenses/>. *
27 * *
28 *******************************************************************************/
29 #ifndef NEMOSYS_NUCMESHSHAPEDATA_H_
30 #define NEMOSYS_NUCMESHSHAPEDATA_H_
31 
32 #include "nemosys_export.h"
33 #include "Geometry/ShapeData.H"
34 
35 #include <string>
36 
37 #include <SMDSAbs_ElementType.hxx>
38 
39 #include "Geometry/GeoManager.H"
40 
41 class SMESH_Gen;
42 class SMESH_Mesh;
43 class SMESH_Hypothesis;
44 
45 namespace NEM {
46 namespace NUCMESH {
47 
48 class NEMOSYS_EXPORT NucMeshShapeData : public NEM::GEO::ShapeData {
49  public:
50  /**
51  * Method that is called when a @c GeoManager instance tries to mesh @p shape
52  * @details Default implementation does nothing
53  * @param[in] shape Shape to mesh
54  * @param[in,out] generator Generator that will mesh @shape
55  * @param[in,out] mesh Mesh that will mesh @shape
56  * @param[out] generatedHyps Output list of created hypotheses/algorithms
57  * (for memory management; will be deleted when the @c GeoManager instance is
58  * deleted)
59  */
60  virtual void setupAlgos(
61  const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &mesh,
62  std::vector<std::unique_ptr<SMESH_Hypothesis>> &generatedHyps) const {};
63 };
64 
65 /**
66  * CRTP pattern to implement @c NEM::GEO::ShapeData::updateModified by copying
67  * @tparam T Shape type
68  * @tparam Base Immediate parent type
69  */
70 template <typename T, typename Base>
71 class NEMOSYS_EXPORT CopyOverrideShapeData : public Base {
72  using Base::Base;
73 
74  public:
75  void updateModified(const TopoDS_Shape &shape,
76  const TopTools_ListOfShape &modifiedShapes,
77  NEM::GEO::GeoManager &geoMetadata) const override {
78  for (auto &modifiedShape : modifiedShapes) {
79  geoMetadata.getMap()[modifiedShape] =
80  std::shared_ptr<NEM::GEO::ShapeData>{
81  new T{*static_cast<const T *>(this)}};
82  }
83  }
84 
85  protected:
87 };
88 
89 /**
90  * Class to hold the material/physical group of a geometry
91  */
92 class NEMOSYS_EXPORT GroupData : public NucMeshShapeData {
93  public:
94  GroupData(std::string groupName, SMDSAbs_ElementType type)
95  : groupName(std::move(groupName)), type(type) {}
96 
97  void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator,
98  SMESH_Mesh &mesh,
99  std::vector<std::unique_ptr<SMESH_Hypothesis>> &generatedHyps)
100  const override;
101 
102  std::string groupName;
103  SMDSAbs_ElementType type;
104 };
105 
106 /**
107  *
108  */
109 class NEMOSYS_EXPORT SideSetEdge
110  : public CopyOverrideShapeData<SideSetEdge, GroupData> {
111  public:
112  explicit SideSetEdge(std::string groupName)
113  : CRTPBase(std::move(groupName), SMDSAbs_Edge) {}
114 
115  void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator,
116  SMESH_Mesh &mesh,
117  std::vector<std::unique_ptr<SMESH_Hypothesis>> &generatedHyps)
118  const override {
119  this->GroupData::setupAlgos(shape, generator, mesh, generatedHyps);
120  }
121 };
122 
123 /**
124  * Class to describe meshing an edge by @c StdMeshers_NumberOfSegments
125  */
126 class NEMOSYS_EXPORT EdgeSegments
127  : public CopyOverrideShapeData<EdgeSegments, SideSetEdge> {
128  public:
129  explicit EdgeSegments(std::string groupName, int numSegments);
130 
131  void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator,
132  SMESH_Mesh &mesh,
133  std::vector<std::unique_ptr<SMESH_Hypothesis>> &generatedHyps)
134  const override;
135 
136  private:
138 };
139 
140 /**
141  * Apply a tri mesh to a face
142  */
143 class NEMOSYS_EXPORT TriMeshSurface
144  : public CopyOverrideShapeData<TriMeshSurface, GroupData> {
145  public:
146  explicit TriMeshSurface(std::string groupName)
147  : CRTPBase(std::move(groupName), SMDSAbs_Face) {}
148 
149  void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator,
150  SMESH_Mesh &mesh,
151  std::vector<std::unique_ptr<SMESH_Hypothesis>> &generatedHyps)
152  const override;
153 };
154 
155 /**
156  * Structured quad mesh (assuming edges meshed appropriately) or quad-dominant
157  * mesh
158  */
159 class NEMOSYS_EXPORT QuadMeshSurface
160  : public CopyOverrideShapeData<QuadMeshSurface, GroupData> {
161  public:
162  explicit QuadMeshSurface(std::string groupName)
163  : CRTPBase(std::move(groupName), SMDSAbs_Face) {}
164 
165  void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator,
166  SMESH_Mesh &mesh,
167  std::vector<std::unique_ptr<SMESH_Hypothesis>> &generatedHyps)
168  const override;
169 };
170 
171 } // namespace NUCMESH
172 } // namespace NEM
173 
174 #endif // NEMOSYS_NUCMESHSHAPEDATA_H_
GroupData(std::string groupName, SMDSAbs_ElementType type)
SideSetEdge(std::string groupName)
Class to manage TopoDS_Shapes along with metadata.
Definition: GeoManager.H:61
SMDSAbs_ElementType type
CRTP pattern to implement NEM::GEO::ShapeData::updateModified by copying.
Class to describe meshing an edge by StdMeshers_NumberOfSegments.
void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &mesh, std::vector< std::unique_ptr< SMESH_Hypothesis >> &generatedHyps) const override
Method that is called when a GeoManager instance tries to mesh shape.
STL namespace.
void updateModified(const TopoDS_Shape &shape, const TopTools_ListOfShape &modifiedShapes, NEM::GEO::GeoManager &geoMetadata) const override
TriMeshSurface(std::string groupName)
void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &mesh, std::vector< std::unique_ptr< SMESH_Hypothesis >> &generatedHyps) const override
Method that is called when a GeoManager instance tries to mesh shape.
QuadMeshSurface(std::string groupName)
Class to hold the material/physical group of a geometry.
std::shared_ptr< meshBase > mesh
Data stored in an instance of GeoManager.
Definition: ShapeData.H:50
Apply a tri mesh to a face.
Structured quad mesh (assuming edges meshed appropriately) or quad-dominant mesh. ...
MapType & getMap()
Definition: GeoManager.C:186
virtual void setupAlgos(const TopoDS_Shape &shape, SMESH_Gen &generator, SMESH_Mesh &mesh, std::vector< std::unique_ptr< SMESH_Hypothesis >> &generatedHyps) const
Method that is called when a GeoManager instance tries to mesh shape.