LCOV - code coverage report
Current view: top level - src/meshgenerators - StitchMeshGeneratorBase.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 24 40 60.0 %
Date: 2025-08-08 20:01:16 Functions: 3 4 75.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 "StitchMeshGeneratorBase.h"
      11             : 
      12             : #include "MooseUtils.h"
      13             : #include "MooseMeshUtils.h"
      14             : 
      15             : #include "libmesh/unstructured_mesh.h"
      16             : 
      17             : InputParameters
      18       57632 : StitchMeshGeneratorBase::validParams()
      19             : {
      20       57632 :   InputParameters params = MeshGenerator::validParams();
      21             : 
      22       57632 :   MooseEnum algorithm("BINARY EXHAUSTIVE", "BINARY");
      23             : 
      24       57632 :   params.addParam<Real>(
      25             :       "stitching_hmin_tolerance_factor",
      26             :       TOLERANCE,
      27             :       "Factor multiplied by the elements hmin to form a tolerance to use when stitching nodes");
      28      172896 :   params.addParam<bool>(
      29      115264 :       "clear_stitched_boundary_ids", true, "Whether or not to clear the stitched boundary IDs");
      30       57632 :   params.addRequiredParam<std::vector<std::vector<std::string>>>(
      31             :       "stitch_boundaries_pairs",
      32             :       "Pairs of boundaries to be stitched together between the 1st mesh in inputs and each "
      33             :       "consecutive mesh");
      34       57632 :   params.addParam<MooseEnum>(
      35             :       "algorithm",
      36             :       algorithm,
      37             :       "Control the use of binary search for the nodes of the stitched surfaces.");
      38      172896 :   params.addParam<bool>(
      39      115264 :       "verbose_stitching", false, "Whether mesh stitching should have verbose output.");
      40             : 
      41      115264 :   return params;
      42       57632 : }
      43             : 
      44         275 : StitchMeshGeneratorBase::StitchMeshGeneratorBase(const InputParameters & parameters)
      45             :   : MeshGenerator(parameters),
      46         275 :     _clear_stitched_boundary_ids(getParam<bool>("clear_stitched_boundary_ids")),
      47         275 :     _stitch_boundaries_pairs(
      48             :         getParam<std::vector<std::vector<std::string>>>("stitch_boundaries_pairs")),
      49         550 :     _algorithm(parameters.get<MooseEnum>("algorithm"))
      50             : {
      51         275 : }
      52             : 
      53             : boundary_id_type
      54         664 : StitchMeshGeneratorBase::getBoundaryIdToStitch(const MeshBase & mesh,
      55             :                                                const std::string & input_mg_name,
      56             :                                                const BoundaryName & bname) const
      57             : {
      58             :   boundary_id_type bid;
      59             :   try
      60             :   {
      61         664 :     bid = MooseUtils::convert<boundary_id_type>(bname, true);
      62             :   }
      63         449 :   catch (...)
      64             :   {
      65         449 :     bid = mesh.get_boundary_info().get_id_by_name(bname);
      66             : 
      67         449 :     if (bid == BoundaryInfo::invalid_id)
      68           0 :       errorMissingBoundary(mesh, input_mg_name, bname);
      69         449 :   }
      70         664 :   return bid;
      71             : }
      72             : 
      73             : void
      74           0 : StitchMeshGeneratorBase::errorMissingBoundary(const MeshBase & mesh,
      75             :                                               const std::string & input_mg_name,
      76             :                                               const BoundaryName & bname) const
      77             : {
      78           0 :   std::stringstream error;
      79             : 
      80           0 :   error << "Boundary " << bname << " doesn't exist on mesh '" << input_mg_name << "'\n";
      81           0 :   error << "Boundary (sideset) names that do exist: \n";
      82           0 :   error << " ID : Name\n";
      83             : 
      84           0 :   auto & sideset_id_name_map = mesh.get_boundary_info().get_sideset_name_map();
      85             : 
      86           0 :   for (auto & ss_name_map_pair : sideset_id_name_map)
      87           0 :     error << " " << ss_name_map_pair.first << " : " << ss_name_map_pair.second << "\n";
      88             : 
      89           0 :   error << "\nBoundary (nodeset) names that do exist: \n";
      90           0 :   error << " ID : Name\n";
      91             : 
      92           0 :   auto & nodeset_id_name_map = mesh.get_boundary_info().get_nodeset_name_map();
      93             : 
      94           0 :   for (auto & ns_name_map_pair : nodeset_id_name_map)
      95           0 :     error << " " << ns_name_map_pair.first << " : " << ns_name_map_pair.second << "\n";
      96             : 
      97           0 :   paramError("stitch_boundaries_pairs", error.str());
      98           0 : }

Generated by: LCOV version 1.14