LCOV - code coverage report
Current view: top level - src/meshgenerators - LowerDBlockFromSidesetGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 909fe5 Lines: 26 30 86.7 %
Date: 2025-08-29 20:01:24 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 "LowerDBlockFromSidesetGenerator.h"
      11             : #include "InputParameters.h"
      12             : #include "MooseTypes.h"
      13             : #include "CastUniquePointer.h"
      14             : #include "MooseMeshUtils.h"
      15             : 
      16             : #include "libmesh/distributed_mesh.h"
      17             : #include "libmesh/elem.h"
      18             : #include "libmesh/parallel_elem.h"
      19             : #include "libmesh/parallel_node.h"
      20             : #include "libmesh/compare_elems_by_level.h"
      21             : #include "libmesh/mesh_communication.h"
      22             : 
      23             : #include "timpi/parallel_sync.h"
      24             : 
      25             : #include <set>
      26             : #include <typeinfo>
      27             : 
      28             : registerMooseObject("MooseApp", LowerDBlockFromSidesetGenerator);
      29             : 
      30             : InputParameters
      31       18891 : LowerDBlockFromSidesetGenerator::validParams()
      32             : {
      33       18891 :   InputParameters params = MeshGenerator::validParams();
      34             : 
      35       75564 :   params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
      36       75564 :   params.addParam<SubdomainID>("new_block_id", "The lower dimensional block id to create");
      37       75564 :   params.addParam<SubdomainName>("new_block_name",
      38             :                                  "The lower dimensional block name to create (optional)");
      39       75564 :   params.addRequiredParam<std::vector<BoundaryName>>(
      40             :       "sidesets", "The sidesets from which to create the new block");
      41             : 
      42       18891 :   params.addClassDescription("Adds lower dimensional elements on the specified sidesets.");
      43             : 
      44       18891 :   return params;
      45           0 : }
      46             : 
      47        2313 : LowerDBlockFromSidesetGenerator::LowerDBlockFromSidesetGenerator(const InputParameters & parameters)
      48             :   : MeshGenerator(parameters),
      49        2313 :     _input(getMesh("input")),
      50        6939 :     _sideset_names(getParam<std::vector<BoundaryName>>("sidesets"))
      51             : {
      52        2313 : }
      53             : 
      54             : std::unique_ptr<MeshBase>
      55        2176 : LowerDBlockFromSidesetGenerator::generate()
      56             : {
      57        2176 :   std::unique_ptr<MeshBase> mesh = std::move(_input);
      58             : 
      59             :   // Generate a new block id if one isn't supplied.
      60        4352 :   SubdomainID new_block_id = isParamValid("new_block_id")
      61        8328 :                                  ? getParam<SubdomainID>("new_block_id")
      62        2176 :                                  : MooseMeshUtils::getNextFreeSubdomainID(*mesh);
      63             :   try
      64             :   {
      65        4364 :     MooseMeshUtils::createSubdomainFromSidesets(mesh,
      66        2176 :                                                 _sideset_names,
      67             :                                                 new_block_id,
      68        4360 :                                                 isParamValid("new_block_name")
      69        9488 :                                                     ? getParam<SubdomainName>("new_block_name")
      70             :                                                     : SubdomainName(),
      71        2176 :                                                 type());
      72             :   }
      73           4 :   catch (MooseException & e)
      74             :   {
      75           8 :     if (((std::string)e.what()).compare(0, 12, "The sideset ") == 0)
      76           8 :       paramError("sidesets", e.what());
      77             :     else
      78           0 :       mooseError(e.what());
      79           0 :   }
      80             : 
      81        2168 :   return mesh;
      82           0 : }

Generated by: LCOV version 1.14