https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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
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
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
62std::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,
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}
registerMooseObject("ReactorApp", GapLineMeshGenerator)
Generate a polyline mesh that is based on an input 2D-XY mesh.
static InputParameters validParams()
std::unique_ptr< MeshBase > & _input
Input mesh defining the boundary.
std::unique_ptr< MeshBase > generate() override
GapLineMeshGenerator(const InputParameters &parameters)
const std::vector< boundary_id_type > _boundary_ids
The boundary IDs around which the gap will be created.
enum GapLineMeshGenerator::GapDirection _gap_direction
const Real _thickness
The thickness of the gap to be created.
GapDirection
The direction in which the gap is created with respect to the boundary of the input mesh.
void addRequiredParam(const std::string &name, const std::string &doc_string)
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
std::unique_ptr< MeshBase > buildMeshBaseObject(unsigned int dim=libMesh::invalid_uint)
bool isParamValid(const std::string &name) const
A base class that contains common members for Reactor module mesh generators.
static InputParameters validParams()
MeshBase & mesh
void collectExteriorVertexPointsFromMesh(libMesh::TriangulatorInterface::MeshedHole &bdry_mh, std::vector< Point > &points, std::vector< Point > &mid_points, const bool skip_node_reduction=false)
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)
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)