Cardinal
NekMeshGenerator.h
Go to the documentation of this file.
1 /********************************************************************/
2 /* SOFTWARE COPYRIGHT NOTIFICATION */
3 /* Cardinal */
4 /* */
5 /* (c) 2021 UChicago Argonne, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by UChicago Argonne, LLC */
9 /* Under Contract No. DE-AC02-06CH11357 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* Prepared by Battelle Energy Alliance, LLC */
13 /* Under Contract No. DE-AC07-05ID14517 */
14 /* With the U. S. Department of Energy */
15 /* */
16 /* See LICENSE for full restrictions */
17 /********************************************************************/
18 
19 #pragma once
20 
21 #include "MeshGenerator.h"
22 
29 class NekMeshGenerator : public MeshGenerator
30 {
31 public:
32  static InputParameters validParams();
33 
34  NekMeshGenerator(const InputParameters & parameters);
35 
36  std::unique_ptr<MeshBase> generate() override;
37 
38 
39  void initializeElemData(std::unique_ptr<MeshBase> & mesh);
40 
45  void checkElementType(std::unique_ptr<MeshBase> & mesh);
46 
52  virtual std::pair<unsigned int, unsigned int> pairedNodesAboutMidPoint(const unsigned int & node_id) const;
53 
59  unsigned int getFaceNode(const unsigned int & primary_face) const;
60 
66  virtual bool isCornerNode(const unsigned int & node) const;
67 
71  void moveNodes(std::unique_ptr<MeshBase> & mesh, std::vector<Real> & polygon_layer_smoothing);
72 
79  const Elem * getNextLayerElem(const Elem & elem, const unsigned int & touching_face,
80  unsigned int & next_touching_face) const;
81 
88  unsigned int midPointNodeIndex(const unsigned int & face_id, const unsigned int & face_node) const;
89 
96  unsigned int pairedFaceNode(const unsigned int & node_id, const unsigned int & face_id) const;
97 
106  std::vector<Elem *> getBoundaryLayerElems(Elem * elem, const unsigned int & n_layers,
107  const unsigned int & primary_face) const;
108 
117  void moveElem(Elem * elem, const unsigned int & boundary_index, const unsigned int & primary_face,
118  const std::vector<Real> & polygon_layer_smoothing);
119 
126  bool isNearCorner(const Point & pt) const;
127 
134  unsigned int getNodeIndex(const Elem * elem, const Point & pt) const;
135 
142  Point getClosestOrigin(const unsigned int & index, const Point & pt) const;
143 
149  void checkPointLength(const std::vector<std::vector<Real>> & points, std::string name) const;
150 
157  void adjustMidPointNode(const unsigned int & node_id, Elem * elem) const;
158 
165  BoundaryID getBoundaryID(const BoundaryName & name, const MeshBase & mesh) const;
166 
173  Point projectPoint(const Point & origin, const Point & pt) const;
174 
183  Point adjustPointToCircle(const unsigned int & node_id, Elem * elem, const Real & radius, const Point & origin) const;
184 
185 protected:
187  std::unique_ptr<MeshBase> & _input;
188 
190  const MooseEnum & _geometry_type;
191 
193  const MooseEnum & _axis;
194 
196  const bool & _curve_corners;
197 
213  const Real & _rotation_angle;
214 
217 
220 
222  unsigned int _n_start_nodes;
223 
225  unsigned int _n_end_nodes;
226 
229 
231  unsigned int _n_sides;
232 
234  unsigned int _n_corner_nodes;
235 
237  std::vector<BoundaryID> _moving_boundary;
238 
240  std::vector<Real> _radius;
241 
243  std::vector<std::vector<Real>> _origin;
244 
246  std::vector<unsigned int> _layers;
247 
250 
252  std::vector<Point> _polygon_corners;
253 
256 
259 
261  std::set<BoundaryID> _boundaries_to_rebuild;
262 
264  std::map<BoundaryID, BoundaryName> _boundary_id_to_name;
265 
267  std::vector<std::vector<unsigned int>> _side_ids;
268 
270  std::vector<std::vector<unsigned int>> _corner_nodes;
271 
273  std::vector<std::vector<std::pair<unsigned int, unsigned int>>> _across_pair;
274 
276  std::vector<unsigned int> _across_face;
277 
279  ElemType _etype;
280 
282  std::vector<std::vector<unsigned int>> _side_nodes_map;
283 
285  std::vector<std::vector<unsigned int>> _face_nodes_map;
286 };
unsigned int _n_noncorner_boundaries
Number of boundaries to be moved that do not include the corners.
Definition: NekMeshGenerator.h:258
Point projectPoint(const Point &origin, const Point &pt) const
Definition: NekMeshGenerator.C:191
void moveNodes(std::unique_ptr< MeshBase > &mesh, std::vector< Real > &polygon_layer_smoothing)
Definition: NekMeshGenerator.C:481
Point getClosestOrigin(const unsigned int &index, const Point &pt) const
Definition: NekMeshGenerator.C:304
const Elem * getNextLayerElem(const Elem &elem, const unsigned int &touching_face, unsigned int &next_touching_face) const
Definition: NekMeshGenerator.C:439
void adjustMidPointNode(const unsigned int &node_id, Elem *elem) const
Definition: NekMeshGenerator.C:268
std::vector< std::vector< unsigned int > > _face_nodes_map
Face nodes map.
Definition: NekMeshGenerator.h:285
Real _corner_radius
If curving corners, the radius of curvature of the corner.
Definition: NekMeshGenerator.h:249
void moveElem(Elem *elem, const unsigned int &boundary_index, const unsigned int &primary_face, const std::vector< Real > &polygon_layer_smoothing)
Definition: NekMeshGenerator.C:333
std::vector< std::vector< Real > > _origin
Origins of the circular surface(s)
Definition: NekMeshGenerator.h:243
std::vector< unsigned int > _across_face
For each face, the paired face "across" to the other side of the original elem type.
Definition: NekMeshGenerator.h:276
const MooseEnum & _geometry_type
Geometry type to curve boundaries to.
Definition: NekMeshGenerator.h:190
unsigned int getFaceNode(const unsigned int &primary_face) const
Definition: NekMeshGenerator.C:534
unsigned int pairedFaceNode(const unsigned int &node_id, const unsigned int &face_id) const
Definition: NekMeshGenerator.C:413
unsigned int getNodeIndex(const Elem *elem, const Point &pt) const
Definition: NekMeshGenerator.C:294
Real _max_corner_distance
Maximum distance a point can be from a corner and still require movement to the curved corners.
Definition: NekMeshGenerator.h:255
const bool & _retain_original_elem_type
Whether to skip the optional output conversion to Quad8 or Hex20 elements.
Definition: NekMeshGenerator.h:216
Definition: CardinalEnums.h:135
void checkPointLength(const std::vector< std::vector< Real >> &points, std::string name) const
Definition: NekMeshGenerator.C:249
Point adjustPointToCircle(const unsigned int &node_id, Elem *elem, const Real &radius, const Point &origin) const
Definition: NekMeshGenerator.C:202
NekMeshGenerator(const InputParameters &parameters)
Definition: NekMeshGenerator.C:132
unsigned int midPointNodeIndex(const unsigned int &face_id, const unsigned int &face_node) const
Definition: NekMeshGenerator.C:430
BoundaryID getBoundaryID(const BoundaryName &name, const MeshBase &mesh) const
Definition: NekMeshGenerator.C:236
void checkElementType(std::unique_ptr< MeshBase > &mesh)
Definition: NekMeshGenerator.C:540
std::vector< Point > _polygon_corners
If curving corners, the corner coordinates of the polygon.
Definition: NekMeshGenerator.h:252
std::vector< unsigned int > _layers
Number of layers to sweep on each boundary.
Definition: NekMeshGenerator.h:246
std::vector< BoundaryID > _moving_boundary
Sideset IDs to move to fit the circular surface.
Definition: NekMeshGenerator.h:237
std::map< BoundaryID, BoundaryName > _boundary_id_to_name
Original boundary names and IDs.
Definition: NekMeshGenerator.h:264
std::vector< std::vector< unsigned int > > _side_nodes_map
Side nodes map.
Definition: NekMeshGenerator.h:282
std::unique_ptr< MeshBase > & _input
Mesh to modify.
Definition: NekMeshGenerator.h:187
std::vector< Real > _radius
Radii of the circular surface(s)
Definition: NekMeshGenerator.h:240
unsigned int _n_end_nodes
Number of nodes per element in resulting mesh.
Definition: NekMeshGenerator.h:225
virtual std::pair< unsigned int, unsigned int > pairedNodesAboutMidPoint(const unsigned int &node_id) const
Definition: NekMeshGenerator.C:685
const bool & _curve_corners
Whether to move corner nodes to fit curved radii of a regular polygon.
Definition: NekMeshGenerator.h:196
const MooseEnum & _axis
Axis of the mesh about which to build the circular surface.
Definition: NekMeshGenerator.h:193
std::vector< std::vector< unsigned int > > _side_ids
For each face, the mid-side nodes to be adjusted.
Definition: NekMeshGenerator.h:267
std::set< BoundaryID > _boundaries_to_rebuild
Boundaries to rebuild in the new mesh.
Definition: NekMeshGenerator.h:261
static InputParameters validParams()
Definition: NekMeshGenerator.C:38
std::unique_ptr< MeshBase > generate() override
Definition: NekMeshGenerator.C:694
unsigned int _n_sides
Number of sides per element (faces in 3-D, edges in 2-D)
Definition: NekMeshGenerator.h:231
unsigned int _n_start_nodes
Number of nodes per element in original mesh.
Definition: NekMeshGenerator.h:222
std::vector< std::vector< unsigned int > > _corner_nodes
For each face, the corner node indices.
Definition: NekMeshGenerator.h:270
virtual bool isCornerNode(const unsigned int &node) const
Definition: NekMeshGenerator.C:679
Definition: NekMeshGenerator.h:29
const Real & _rotation_angle
Definition: NekMeshGenerator.h:213
void initializeElemData(std::unique_ptr< MeshBase > &mesh)
Definition: NekMeshGenerator.C:565
unsigned int _n_start_nodes_per_side
Number of nodes per side of the starting element.
Definition: NekMeshGenerator.h:228
ElemType _etype
Element type in the original mesh.
Definition: NekMeshGenerator.h:279
unsigned int _n_corner_nodes
Number of corner nodes.
Definition: NekMeshGenerator.h:234
std::vector< std::vector< std::pair< unsigned int, unsigned int > > > _across_pair
For each face, the node pairing "across" that face to the other side of the original elem type.
Definition: NekMeshGenerator.h:273
const bool _has_moving_boundary
Whether sidesets will be moved to match circular surfaces.
Definition: NekMeshGenerator.h:219
std::vector< Elem * > getBoundaryLayerElems(Elem *elem, const unsigned int &n_layers, const unsigned int &primary_face) const
Definition: NekMeshGenerator.C:390
bool isNearCorner(const Point &pt) const
Definition: NekMeshGenerator.C:284