LCOV - code coverage report
Current view: top level - src/meshgenerators - GapLineMeshGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose reactor: #33187 (5aa0b2) with base d7c4bd Lines: 43 43 100.0 %
Date: 2026-06-30 12:23:22 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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             : 
      19             : registerMooseObject("ReactorApp", GapLineMeshGenerator);
      20             : 
      21             : InputParameters
      22          60 : GapLineMeshGenerator::validParams()
      23             : {
      24          60 :   InputParameters params = PolygonMeshGeneratorBase::validParams();
      25             : 
      26         120 :   params.addRequiredParam<MeshGeneratorName>("input", "The input mesh to create the gap based on.");
      27             : 
      28         120 :   params.addRequiredParam<Real>("thickness", "The thickness of the gap to be created.");
      29             : 
      30         120 :   MooseEnum gap_direction("OUTWARD INWARD", "OUTWARD");
      31             : 
      32         120 :   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          60 :   params.addParam<std::vector<boundary_id_type>>(
      38             :       "boundary_ids",
      39          60 :       std::vector<boundary_id_type>(),
      40             :       "The boundary IDs around which the gap will be created.");
      41             : 
      42         120 :   params.addParam<Real>("max_elem_size", "The maximum element size for the generated gap mesh.");
      43             : 
      44          60 :   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          60 :   return params;
      51          60 : }
      52             : 
      53          30 : GapLineMeshGenerator::GapLineMeshGenerator(const InputParameters & parameters)
      54             :   : PolygonMeshGeneratorBase(parameters),
      55          30 :     _input(getMesh("input")),
      56          60 :     _thickness(getParam<Real>("thickness")),
      57          60 :     _gap_direction(getParam<MooseEnum>("gap_direction").template getEnum<GapDirection>()),
      58          90 :     _boundary_ids(getParam<std::vector<boundary_id_type>>("boundary_ids"))
      59             : {
      60          30 : }
      61             : 
      62             : std::unique_ptr<MeshBase>
      63          30 : GapLineMeshGenerator::generate()
      64             : {
      65             :   // Put the boundary mesh in a local pointer
      66             :   std::unique_ptr<UnstructuredMesh> mesh =
      67          30 :       dynamic_pointer_cast<UnstructuredMesh>(std::move(_input));
      68             : 
      69          30 :   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          60 :   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;
      76          30 :   BoundaryLayerUtils::collectExteriorVertexPointsFromMesh(
      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          30 :   auto ply_mesh = buildMeshBaseObject();
      81          30 :   MooseMeshUtils::buildPolyLineMesh(*ply_mesh,
      82             :                                     reduced_pts_list,
      83             :                                     /*loop*/ true,
      84          30 :                                     BoundaryName(),
      85          30 :                                     BoundaryName(),
      86          60 :                                     std::vector<unsigned int>({1}));
      87             : 
      88             :   std::unique_ptr<UnstructuredMesh> ply_mesh_u =
      89          30 :       dynamic_pointer_cast<UnstructuredMesh>(std::move(ply_mesh));
      90             : 
      91             :   std::vector<Point> mod_reduced_pts_list =
      92             :       BoundaryLayerUtils::generateOffsetPolyline(this,
      93             :                                                  ply_mesh_u,
      94             :                                                  reduced_pts_list,
      95             :                                                  reduced_mid_pts_list,
      96          30 :                                                  _gap_direction == GapDirection::OUTWARD,
      97          30 :                                                  _thickness);
      98             : 
      99          28 :   auto ply_mesh_2 = buildMeshBaseObject();
     100             : 
     101          56 :   if (isParamValid("max_elem_size"))
     102           7 :     MooseMeshUtils::buildPolyLineMesh(*ply_mesh_2,
     103             :                                       mod_reduced_pts_list,
     104             :                                       true,
     105           7 :                                       BoundaryName(),
     106           7 :                                       BoundaryName(),
     107          14 :                                       getParam<Real>("max_elem_size"));
     108             :   else
     109          21 :     MooseMeshUtils::buildPolyLineMesh(*ply_mesh_2,
     110             :                                       mod_reduced_pts_list,
     111             :                                       true,
     112          21 :                                       BoundaryName(),
     113          21 :                                       BoundaryName(),
     114          42 :                                       std::vector<unsigned int>({1}));
     115             : 
     116          28 :   return ply_mesh_2;
     117          56 : }

Generated by: LCOV version 1.14