https://mooseframework.inl.gov
GapLineMeshGenerator.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
3 //*
4 //* All rights reserved, see COPYRIGHT for full restrictions
5 //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6 //*
7 //* Licensed under LGPL 2.1, please see LICENSE for details
8 //* https://www.gnu.org/licenses/lgpl-2.1.html
9 
10 #include "GapLineMeshGenerator.h"
11 
12 #include "MooseMeshUtils.h"
13 #include "BoundaryLayerUtils.h"
14 #include "MooseUtils.h"
15 #include "CastUniquePointer.h"
16 
17 #include "libmesh/mesh_triangle_holes.h"
18 
20 
23 {
25 
26  params.addRequiredParam<MeshGeneratorName>("input", "The input mesh to create the gap based on.");
27 
28  params.addRequiredParam<Real>("thickness", "The thickness of the gap to be created.");
29 
30  MooseEnum gap_direction("OUTWARD INWARD", "OUTWARD");
31 
32  params.addParam<MooseEnum>("gap_direction",
33  gap_direction,
34  "In which direction the gap is created with respect to the side "
35  "normal of the elements along the boundary of the input mesh.");
36 
37  params.addParam<std::vector<boundary_id_type>>(
38  "boundary_ids",
39  std::vector<boundary_id_type>(),
40  "The boundary IDs around which the gap will be created.");
41 
42  params.addParam<Real>("max_elem_size", "The maximum element size for the generated gap mesh.");
43 
44  params.addClassDescription(
45  "Generates a polyline mesh that is based on an input 2D-XY mesh. The 2D-XY mesh needs to be "
46  "a "
47  "connected mesh with only one outer boundary manifold. The polyline mesh generated along "
48  "with the boundary of the input mesh form an unmeshed gap with a specified thickness.");
49 
50  return params;
51 }
52 
54  : PolygonMeshGeneratorBase(parameters),
55  _input(getMesh("input")),
56  _thickness(getParam<Real>("thickness")),
57  _gap_direction(getParam<MooseEnum>("gap_direction").template getEnum<GapDirection>()),
58  _boundary_ids(getParam<std::vector<boundary_id_type>>("boundary_ids"))
59 {
60 }
61 
62 std::unique_ptr<MeshBase>
64 {
65  // Put the boundary mesh in a local pointer
66  std::unique_ptr<UnstructuredMesh> mesh =
67  dynamic_pointer_cast<UnstructuredMesh>(std::move(_input));
68 
69  std::set<std::size_t> mesh_bdry_ids(_boundary_ids.begin(), _boundary_ids.end());
70  // MeshedHole is a good tool to extract and sort boundary points
71  TriangulatorInterface::MeshedHole bdry_mh(*mesh, mesh_bdry_ids);
72 
73  // Reduce the point list to only contain vertices (linear-only: no midpoints)
74  std::vector<Point> reduced_pts_list;
75  std::vector<Point> reduced_mid_pts_list;
77  bdry_mh, reduced_pts_list, reduced_mid_pts_list, /*skip_node_reduction=*/false);
78 
79  // Build the input polyline mesh to drive the normal computation in generateOffsetPolyline
80  auto ply_mesh = buildMeshBaseObject();
82  reduced_pts_list,
83  /*loop*/ true,
84  BoundaryName(),
85  BoundaryName(),
86  std::vector<unsigned int>({1}));
87 
88  std::unique_ptr<UnstructuredMesh> ply_mesh_u =
89  dynamic_pointer_cast<UnstructuredMesh>(std::move(ply_mesh));
90 
91  std::vector<Point> mod_reduced_pts_list =
93  ply_mesh_u,
94  reduced_pts_list,
95  reduced_mid_pts_list,
97  _thickness);
98 
99  auto ply_mesh_2 = buildMeshBaseObject();
100 
101  if (isParamValid("max_elem_size"))
103  mod_reduced_pts_list,
104  true,
105  BoundaryName(),
106  BoundaryName(),
107  getParam<Real>("max_elem_size"));
108  else
110  mod_reduced_pts_list,
111  true,
112  BoundaryName(),
113  BoundaryName(),
114  std::vector<unsigned int>({1}));
115 
116  return ply_mesh_2;
117 }
void buildPolyLineMesh(MeshBase &mesh, const std::vector< Point > &points, const bool loop, const BoundaryName &start_boundary, const BoundaryName &end_boundary, const std::vector< unsigned int > &nums_edges_between_points)
enum GapLineMeshGenerator::GapDirection _gap_direction
T & getMesh(MooseMesh &mesh)
function to cast mesh
Definition: SCM.h:35
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
GapDirection
The direction in which the gap is created with respect to the boundary of the input mesh...
static InputParameters validParams()
MeshBase & mesh
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
registerMooseObject("ReactorApp", GapLineMeshGenerator)
void addRequiredParam(const std::string &name, const std::string &doc_string)
const Real _thickness
The thickness of the gap to be created.
std::unique_ptr< MeshBase > generate() override
static InputParameters validParams()
int8_t boundary_id_type
Generate a polyline mesh that is based on an input 2D-XY mesh.
std::vector< Point > generateOffsetPolyline(MeshGenerator *mg, std::unique_ptr< libMesh::UnstructuredMesh > &ply_mesh_u, std::vector< Point > &points, std::vector< Point > &mid_points, const bool outward, const Real thickness)
GapLineMeshGenerator(const InputParameters &parameters)
std::unique_ptr< MeshBase > & _input
Input mesh defining the boundary.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
A base class that contains common members for Reactor module mesh generators.
void addClassDescription(const std::string &doc_string)
void collectExteriorVertexPointsFromMesh(libMesh::TriangulatorInterface::MeshedHole &bdry_mh, std::vector< Point > &points, std::vector< Point > &mid_points, const bool skip_node_reduction=false)
bool isParamValid(const std::string &name) const
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
const std::vector< boundary_id_type > _boundary_ids
The boundary IDs around which the gap will be created.