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.
CirclesAndPolys.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_CIRCLESANDPOLYS_H_
30 #define NEMOSYS_CIRCLESANDPOLYS_H_
31 
32 #include "nemosys_export.h"
33 #include "NucMesh/ShapeBase.H"
34 
35 #include <array>
36 #include <utility>
37 #include <vector>
38 
39 namespace NEM {
40 namespace NUCMESH {
41 
42 struct PolyRing;
43 struct Ring;
44 
45 /**
46  * @brief A set of concentric circles and polygons and the faces they enclose
47  */
48 class NEMOSYS_EXPORT CirclesAndPolys : public ShapeBase {
49  public:
50  /**
51  * Container to describe a set of concentric circles/polygons
52  * @param numSides Number of sides for polygons (note circles are treated as
53  * @p numSides arcs)
54  * @param rings Radius and meshing description of each ring
55  * @param center Center of shapes
56  */
57  CirclesAndPolys(int numSides, std::vector<PolyRing> rings,
58  const std::array<double, 3> &center = {0, 0, 0});
59 
60  int getNumSides() const;
61  void setNumSides(int numSides);
62  const std::vector<PolyRing> &getRings() const;
63  void setRings(std::vector<PolyRing> rings);
64  void addRing(const PolyRing &ring);
65 
66  protected:
67  NEM::GEO::GeoManager createGeo() const override;
68 
69  private:
70  int numSides_;
71  std::vector<PolyRing> rings_;
72 };
73 
74 /**
75  * @brief A set of concentric circles and the faces they enclose
76  */
77 class NEMOSYS_EXPORT Circles : public ShapeBase {
78  public:
79  /**
80  * Container to describe a set of concentric circles (note circles treated as
81  * two 180 degree arcs)
82  * @param rings Radius and meshing description of each ring
83  * @param center Center of shapes
84  */
85  explicit Circles(std::vector<Ring> rings,
86  const std::array<double, 3> &center = {0, 0, 0});
87 
88  const std::vector<Ring> &getRings() const;
89  void setRings(std::vector<Ring> rings);
90  void addRing(const Ring &ring);
91 
92  protected:
93  NEM::GEO::GeoManager createGeo() const override;
94 
95  private:
96  std::vector<Ring> rings_;
97 };
98 
99 struct NEMOSYS_EXPORT RingMeshOption {
100  public:
101  enum class MeshingType {
102  TRI,
103  QUAD,
104  STRUCT,
105  };
106 
108  return RingMeshOption{MeshingType::TRI};
109  };
112  };
114  const std::array<int, 2> &numElems) {
115  return RingMeshOption{numElems};
116  }
117 
118  MeshingType meshingType; // Mesh type struct
119  // Structured mesh number of segments (radial,circum)
120  std::array<int, 2> numSegments;
121 
122  private:
123  explicit RingMeshOption(MeshingType type);
124  explicit RingMeshOption(const std::array<int, 2> &numElems);
125 };
126 
127 struct NEMOSYS_EXPORT Ring {
128  /**
129  * Describe a set of faces in a @p Circles
130  * @param radius Outer radius
131  * @param meshType Options for meshing
132  * @param material Name of material
133  */
134  Ring(double radius, const RingMeshOption &meshType, std::string material = {},
135  std::string sideset = {})
136  : radius(radius),
137  meshType(meshType),
138  material(std::move(material)),
139  sideset(std::move(sideset)) {}
140  double radius;
142  std::string material;
143  std::string sideset;
144 };
145 
146 struct NEMOSYS_EXPORT PolyRing : public Ring {
147  enum class ShapeType { CIRCLE, POLYGON };
148  /**
149  * Describe a set of faces in a @p CirclesAndPolys
150  * @param shapeType Circular or Polygon ring
151  * @param radius Outer radius
152  * @param meshType Options for meshing
153  * @param rotation Rotation of outer edges
154  * @param id Material ID
155  */
156  PolyRing(ShapeType shapeType, double radius, const RingMeshOption &meshType,
157  double rotation = 0, std::string material = {},
158  std::string sideset = {})
159  : Ring(radius, meshType, std::move(material), std::move(sideset)),
160  shapeType(shapeType),
161  rotation(rotation) {}
163  double rotation;
164 };
165 
166 } // namespace NUCMESH
167 } // namespace NEM
168 
169 #endif // NEMOSYS_CIRCLESANDPOLYS_H_
Class to manage TopoDS_Shapes along with metadata.
Definition: GeoManager.H:61
Ring(double radius, const RingMeshOption &meshType, std::string material={}, std::string sideset={})
Describe a set of faces in a Circles.
std::vector< Ring > rings_
static RingMeshOption ApplyTriMesh()
QUAD
Definition: exoMesh.H:55
static constexpr auto shapeType
Definition: NucMeshJson.H:81
static RingMeshOption ApplyQuadMesh()
static RingMeshOption ApplyStructuredMesh(const std::array< int, 2 > &numElems)
std::array< int, 2 > numSegments
PolyRing(ShapeType shapeType, double radius, const RingMeshOption &meshType, double rotation=0, std::string material={}, std::string sideset={})
Describe a set of faces in a CirclesAndPolys.
std::vector< PolyRing > rings_
Abstract base class for types that create NEM::GEO::GeoManager.
Definition: ShapeBase.H:52
RingMeshOption meshType
A set of concentric circles and polygons and the faces they enclose.
A set of concentric circles and the faces they enclose.