LCOV - code coverage report
Current view: top level - src/meshgenerators - BlockToMeshConverterGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31405 (292dce) with base fef103 Lines: 16 20 80.0 %
Date: 2025-09-04 07:52:05 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 "BlockToMeshConverterGenerator.h"
      11             : #include "CastUniquePointer.h"
      12             : #include "libmesh/elem.h"
      13             : #include "MooseMeshUtils.h"
      14             : 
      15             : registerMooseObject("MooseApp", BlockToMeshConverterGenerator);
      16             : 
      17             : InputParameters
      18       14417 : BlockToMeshConverterGenerator::validParams()
      19             : {
      20       14417 :   InputParameters params = MeshGenerator::validParams();
      21             : 
      22       28834 :   params.addClassDescription(
      23             :       "Converts one or more blocks (subdomains) from a mesh into a stand-alone mesh with a "
      24             :       "single block in it.");
      25             : 
      26       57668 :   params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
      27       43251 :   params.addRequiredParam<std::vector<SubdomainName>>(
      28             :       "target_blocks",
      29             :       "The (list of) blocks (or 'subdomains') we wish to have moved to a new mesh (by name, not "
      30             :       "ID)");
      31             : 
      32       14417 :   return params;
      33           0 : }
      34             : 
      35          76 : BlockToMeshConverterGenerator::BlockToMeshConverterGenerator(const InputParameters & parameters)
      36             :   : MeshGenerator(parameters),
      37          76 :     _input(getMesh("input")),
      38         228 :     _target_blocks(getParam<std::vector<SubdomainName>>("target_blocks"))
      39             : {
      40          76 : }
      41             : 
      42             : std::unique_ptr<MeshBase>
      43          76 : BlockToMeshConverterGenerator::generate()
      44             : {
      45          76 :   std::unique_ptr<MeshBase> mesh = std::move(_input);
      46             : 
      47          76 :   auto new_mesh = buildMeshBaseObject();
      48             : 
      49             :   try
      50             :   {
      51          76 :     MooseMeshUtils::convertBlockToMesh(mesh, new_mesh, _target_blocks);
      52             :   }
      53           0 :   catch (MooseException & e)
      54             :   {
      55           0 :     paramError("target_blocks", e.what());
      56           0 :   }
      57             : 
      58         144 :   return dynamic_pointer_cast<MeshBase>(new_mesh);
      59          72 : }

Generated by: LCOV version 1.14