LCOV - code coverage report
Current view: top level - src/meshgenerators - SubdomainIDGenerator.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 419b9d Lines: 17 18 94.4 %
Date: 2025-08-08 20:01:16 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 "SubdomainIDGenerator.h"
      11             : #include "CastUniquePointer.h"
      12             : 
      13             : #include "libmesh/elem.h"
      14             : 
      15             : registerMooseObject("MooseApp", SubdomainIDGenerator);
      16             : 
      17             : InputParameters
      18       15325 : SubdomainIDGenerator::validParams()
      19             : {
      20       15325 :   InputParameters params = MeshGenerator::validParams();
      21             : 
      22       15325 :   params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
      23       15325 :   params.addRequiredParam<SubdomainID>("subdomain_id", "New subdomain IDs of all elements");
      24       15325 :   params.addClassDescription("Sets all the elements of the input mesh to a unique subdomain ID.");
      25             : 
      26       15325 :   return params;
      27           0 : }
      28             : 
      29         530 : SubdomainIDGenerator::SubdomainIDGenerator(const InputParameters & parameters)
      30             :   : MeshGenerator(parameters),
      31         530 :     _input(getMesh("input")),
      32        1060 :     _subdomain_id(getParam<SubdomainID>("subdomain_id"))
      33             : {
      34         530 : }
      35             : 
      36             : std::unique_ptr<MeshBase>
      37         512 : SubdomainIDGenerator::generate()
      38             : {
      39         512 :   std::unique_ptr<MeshBase> mesh = std::move(_input);
      40             : 
      41       51916 :   for (auto & elem : mesh->element_ptr_range())
      42       51916 :     elem->subdomain_id() = _subdomain_id;
      43             : 
      44         512 :   mesh->set_isnt_prepared();
      45        1024 :   return dynamic_pointer_cast<MeshBase>(mesh);
      46         512 : }

Generated by: LCOV version 1.14