https://mooseframework.inl.gov
Loading...
Searching...
No Matches
SubdomainIDGenerator.C
Go to the documentation of this file.
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
11#include "CastUniquePointer.h"
12
13#include "libmesh/elem.h"
14
16
19{
21
22 params.addRequiredParam<MeshGeneratorName>("input", "The mesh we want to modify");
23 params.addRequiredParam<SubdomainID>("subdomain_id", "New subdomain IDs of all elements");
24 params.addClassDescription("Sets all the elements of the input mesh to a unique subdomain ID.");
25
26 return params;
27}
28
30 : MeshGenerator(parameters),
31 _input(getMesh("input")),
32 _subdomain_id(getParam<SubdomainID>("subdomain_id"))
33{
34}
35
36std::unique_ptr<MeshBase>
38{
39 std::unique_ptr<MeshBase> mesh = std::move(_input);
40
41 for (auto & elem : mesh->element_ptr_range())
42 elem->subdomain_id() = _subdomain_id;
43
44 mesh->unset_is_prepared();
45 return dynamic_pointer_cast<MeshBase>(mesh);
46}
registerMooseObject("MooseApp", SubdomainIDGenerator)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
MeshGenerators are objects that can modify or add to an existing mesh.
static InputParameters validParams()
MeshGenerator for assigning a subdomain ID to all elements.
SubdomainIDGenerator(const InputParameters &parameters)
SubdomainID _subdomain_id
The subdomain ID to assign to every elemennt.
std::unique_ptr< MeshBase > generate() override
Generate / modify the mesh.
static InputParameters validParams()
std::unique_ptr< MeshBase > & _input
the input mesh, which may be output by another mesh generator
MeshBase & mesh