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 15275 : SubdomainIDGenerator::validParams() 19 : { 20 15275 : InputParameters params = MeshGenerator::validParams(); 21 : 22 15275 : params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify"); 23 15275 : params.addRequiredParam<SubdomainID>("subdomain_id", "New subdomain IDs of all elements"); 24 15275 : params.addClassDescription("Sets all the elements of the input mesh to a unique subdomain ID."); 25 : 26 15275 : return params; 27 0 : } 28 : 29 505 : SubdomainIDGenerator::SubdomainIDGenerator(const InputParameters & parameters) 30 : : MeshGenerator(parameters), 31 505 : _input(getMesh("input")), 32 1010 : _subdomain_id(getParam<SubdomainID>("subdomain_id")) 33 : { 34 505 : } 35 : 36 : std::unique_ptr<MeshBase> 37 487 : SubdomainIDGenerator::generate() 38 : { 39 487 : std::unique_ptr<MeshBase> mesh = std::move(_input); 40 : 41 47559 : for (auto & elem : mesh->element_ptr_range()) 42 47559 : elem->subdomain_id() = _subdomain_id; 43 : 44 487 : mesh->set_isnt_prepared(); 45 974 : return dynamic_pointer_cast<MeshBase>(mesh); 46 487 : }