www.mooseframework.org
CopyNodalVarsAction.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
16 #include "CopyNodalVarsAction.h"
17 
18 #include "ActionWarehouse.h"
19 #include "AuxiliarySystem.h"
20 #include "FEProblem.h"
21 #include "MooseApp.h"
22 #include "NonlinearSystemBase.h"
23 
24 #include <map>
25 
26 template <>
29 {
31  params.addParam<std::string>(
32  "initial_from_file_timestep",
33  "LATEST",
34  "Gives the timestep (or \"LATEST\") for which to read a solution from a file "
35  "for a given variable. (Default: LATEST)");
36  params.addParam<std::string>(
37  "initial_from_file_var",
38  "Gives the name of a variable for which to read an initial condition from a mesh file");
39 
40  params.addParamNamesToGroup("initial_from_file_timestep initial_from_file_var",
41  "Initial From File");
42 
43  return params;
44 }
45 
47 
48 void
50 {
51 
52  if (isParamValid("initial_from_file_var"))
53  {
55 
56  if (_current_task == "check_copy_nodal_vars")
57  _app.setFileRestart() = true;
58  else
59  {
60  // Is this a NonlinearSystem variable or an AuxiliarySystem variable?
61  if (_current_task == "copy_nodal_vars")
62  system = &_problem->getNonlinearSystemBase();
63  else
64  system = &_problem->getAuxiliarySystem();
65 
66  system->addVariableToCopy(name(),
67  getParam<std::string>("initial_from_file_var"),
68  getParam<std::string>("initial_from_file_timestep"));
69  }
70  }
71 }
bool & setFileRestart()
This method is here so we can determine whether or not we need to use a separate reader to read the m...
Definition: MooseApp.h:271
CopyNodalVarsAction(InputParameters params)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
virtual void addVariableToCopy(const std::string &dest_name, const std::string &source_name, const std::string &timestep)
Add info about variable that will be copied.
Definition: SystemBase.C:616
Base class for a system (of equations)
Definition: SystemBase.h:91
Base class for actions.
Definition: Action.h:39
nl system()
const std::string & _current_task
The current action (even though we have seperate instances for each action)
Definition: Action.h:125
bool isParamValid(const std::string &name) const
Definition: Action.h:80
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...
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:98
InputParameters validParams< CopyNodalVarsAction >()
virtual void act() override
InputParameters validParams< Action >()
Definition: Action.C:23
void addParamNamesToGroup(const std::string &space_delim_names, const std::string group_name)
This method takes a space delimited list of parameter names and adds them to the specified group name...