www.mooseframework.org
AssignSubdomainID.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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 "AssignSubdomainID.h"
11 #include "MooseMesh.h"
12 
13 #include "libmesh/elem.h"
14 
16 
17 template <>
20 {
22  params.addRequiredParam<SubdomainID>("subdomain_id", "New subdomain IDs of all elements");
23  return params;
24 }
25 
27  : MeshModifier(parameters), _subdomain_id(getParam<SubdomainID>("subdomain_id"))
28 {
29 }
30 
31 void
33 {
34  for (auto & elem : _mesh_ptr->getMesh().element_ptr_range())
35  elem->subdomain_id() = _subdomain_id;
36 }
AssignSubdomainID(const InputParameters &parameters)
MeshModifiers are objects that can modify or add to an existing mesh.
Definition: MeshModifier.h:25
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
MeshModifier for assigning a subdomain ID to all elements.
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...
MooseMesh * _mesh_ptr
Pointer to the mesh.
Definition: MeshModifier.h:68
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2567
virtual void modify() override
Pure virtual modify function MUST be overridden by children classes.
registerMooseObject("MooseApp", AssignSubdomainID)
subdomain_id_type SubdomainID
SubdomainID _subdomain_id
The subdomain ID to assign to every elemennt.
InputParameters validParams< AssignSubdomainID >()
InputParameters validParams< MeshModifier >()
Definition: MeshModifier.C:15