www.mooseframework.org
CopyNodalVarsAction.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 // MOOSE includes
11 #include "CopyNodalVarsAction.h"
12 
13 #include "ActionWarehouse.h"
14 #include "AuxiliarySystem.h"
15 #include "FEProblem.h"
16 #include "MooseApp.h"
17 #include "NonlinearSystemBase.h"
18 
19 #include <map>
20 
21 registerMooseAction("MooseApp", CopyNodalVarsAction, "check_copy_nodal_vars");
22 
23 registerMooseAction("MooseApp", CopyNodalVarsAction, "copy_nodal_vars");
24 
25 registerMooseAction("MooseApp", CopyNodalVarsAction, "copy_nodal_aux_vars");
26 
27 template <>
30 {
32  params.addParam<std::string>(
33  "initial_from_file_timestep",
34  "LATEST",
35  "Gives the timestep (or \"LATEST\") for which to read a solution from a file "
36  "for a given variable. (Default: LATEST)");
37  params.addParam<std::string>(
38  "initial_from_file_var",
39  "Gives the name of a variable for which to read an initial condition from a mesh file");
40 
41  params.addParamNamesToGroup("initial_from_file_timestep initial_from_file_var",
42  "Initial From File");
43 
44  return params;
45 }
46 
48 
49 void
51 {
52 
53  if (isParamValid("initial_from_file_var"))
54  {
56 
57  if (_current_task == "check_copy_nodal_vars")
58  _app.setFileRestart() = true;
59  else
60  {
61  // Is this a NonlinearSystem variable or an AuxiliarySystem variable?
62  if (_current_task == "copy_nodal_vars")
63  system = &_problem->getNonlinearSystemBase();
64  else
65  system = &_problem->getAuxiliarySystem();
66 
67  system->addVariableToCopy(name(),
68  getParam<std::string>("initial_from_file_var"),
69  getParam<std::string>("initial_from_file_timestep"));
70  }
71  }
72 }
bool isParamValid(const std::string &name) const
Definition: Action.h:115
const std::string & name() const
The name of the action.
Definition: Action.h:76
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:306
CopyNodalVarsAction(InputParameters params)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Base class for a system (of equations)
Definition: SystemBase.h:92
Base class for actions.
Definition: Action.h:35
nl system()
registerMooseAction("MooseApp", CopyNodalVarsAction, "check_copy_nodal_vars")
const std::string & _current_task
The current action (even though we have seperate instances for each action)
Definition: Action.h:210
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:216
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:183
InputParameters validParams< CopyNodalVarsAction >()
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
InputParameters validParams< Action >()
Definition: Action.C:22
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...