LCOV - code coverage report
Current view: top level - src/meshgenerators - PolyLineMeshGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 32 36 88.9 %
Date: 2026-05-29 20:35:17 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 "PolyLineMeshGenerator.h"
      11             : 
      12             : #include "CastUniquePointer.h"
      13             : #include "MooseMeshUtils.h"
      14             : #include "MooseUtils.h"
      15             : 
      16             : #include "libmesh/elem.h"
      17             : #include "libmesh/int_range.h"
      18             : #include "libmesh/unstructured_mesh.h"
      19             : 
      20             : registerMooseObject("MooseApp", PolyLineMeshGenerator);
      21             : 
      22             : InputParameters
      23        3879 : PolyLineMeshGenerator::validParams()
      24             : {
      25        3879 :   InputParameters params = MeshGenerator::validParams();
      26             : 
      27       15516 :   params.addParam<std::vector<Point>>("points", "The points defining the polyline, in order");
      28             : 
      29       15516 :   params.addParam<bool>("loop", false, "Whether edges should form a closed loop");
      30             : 
      31       15516 :   params.addParam<BoundaryName>(
      32             :       "start_boundary", "start", "Boundary to assign to (non-looped) polyline start");
      33             : 
      34       15516 :   params.addParam<BoundaryName>(
      35             :       "end_boundary", "end", "Boundary to assign to (non-looped) polyline end");
      36             : 
      37       15516 :   params.addParam<std::vector<unsigned int>>(
      38             :       "nums_edges_between_points",
      39             :       {1},
      40             :       "How many Edge elements to build between each point pair. If a single value is given, it is "
      41             :       "applied to all segments. Otherwise, the number of entries must match the number of "
      42             :       "segments.");
      43       19395 :   params.addDeprecatedParam<unsigned int>("num_edges_between_points",
      44        7758 :                                           1,
      45             :                                           "How many Edge elements to build between each point pair",
      46             :                                           "Use nums_edges_between_points instead");
      47             : 
      48        3879 :   params.addClassDescription("Generates meshes from edges connecting a list of points.");
      49             : 
      50        3879 :   return params;
      51           0 : }
      52             : 
      53         412 : PolyLineMeshGenerator::PolyLineMeshGenerator(const InputParameters & parameters)
      54             :   : MeshGenerator(parameters),
      55         412 :     _points(getParam<std::vector<Point>>("points")),
      56         824 :     _loop(getParam<bool>("loop")),
      57         464 :     _start_boundary(_loop ? BoundaryName() : getParam<BoundaryName>("start_boundary")),
      58         516 :     _end_boundary(_loop ? BoundaryName() : getParam<BoundaryName>("end_boundary")),
      59        1216 :     _nums_edges_between_points(
      60         412 :         parameters.isParamSetByUser("num_edges_between_points")
      61         844 :             ? std::vector<unsigned int>{getParam<unsigned int>("num_edges_between_points")}
      62         412 :             : getParam<std::vector<unsigned int>>("nums_edges_between_points"))
      63             : {
      64         412 :   if (_points.size() < 2)
      65           0 :     paramError("points", "At least 2 points are needed to define a polyline");
      66             : 
      67         412 :   if (_loop && _points.size() < 3)
      68           0 :     paramError("points", "At least 3 points are needed to define a polygon");
      69             : 
      70         438 :   if (_nums_edges_between_points.size() != 1 &&
      71          26 :       _nums_edges_between_points.size() != _points.size() - 1 + (_loop ? 1 : 0))
      72          12 :     paramError(
      73             :         "nums_edges_between_points",
      74             :         "This size of this vector input parameter must be 1 or match the number of segments");
      75         406 : }
      76             : 
      77             : std::unique_ptr<MeshBase>
      78         396 : PolyLineMeshGenerator::generate()
      79             : {
      80         396 :   auto uptr_mesh = buildMeshBaseObject();
      81         396 :   MeshBase & mesh = *uptr_mesh;
      82             : 
      83         396 :   MooseMeshUtils::buildPolyLineMesh(
      84         396 :       mesh, _points, _loop, _start_boundary, _end_boundary, _nums_edges_between_points);
      85             : 
      86         396 :   return uptr_mesh;
      87           0 : }

Generated by: LCOV version 1.14