www.mooseframework.org
AddElementalFieldAction.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
17 #include "FEProblem.h"
18 #include "MooseMesh.h"
19 
20 #include "libmesh/fe.h"
21 
22 template <>
25 {
27  params.addParam<std::vector<SubdomainName>>("block", "The block id where this object lives.");
28 
29  return params;
30 }
31 
33 
34 void
36 {
37  std::set<SubdomainID> blocks;
38  std::vector<SubdomainName> block_param = getParam<std::vector<SubdomainName>>("block");
39  for (const auto & subdomain_name : block_param)
40  {
41  SubdomainID blk_id = _problem->mesh().getSubdomainID(subdomain_name);
42  blocks.insert(blk_id);
43  }
44 
45  FEType fe_type(CONSTANT, MONOMIAL);
46 
47  std::string variable = name();
48 
49  if (blocks.empty())
50  _problem->addAuxVariable(variable, fe_type);
51  else
52  _problem->addAuxVariable(variable, fe_type, &blocks);
53 }
subdomain_id_type SubdomainID
Definition: MooseTypes.h:77
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Base class for actions.
Definition: Action.h:39
InputParameters validParams< AddElementalFieldAction >()
virtual void act() override
AddElementalFieldAction(InputParameters params)
const std::string & name() const
The name of the action.
Definition: Action.h:51
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:131
void addParam(const std::string &name, const S &value, const std::string &doc_string)
These methods add an option parameter and a documentation string to the InputParameters object...
InputParameters validParams< Action >()
Definition: Action.C:23