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 
29 {
31  params.addClassDescription("Copies variable information from a file.");
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  {
55  if (_current_task == "check_copy_nodal_vars")
57  else
58  {
59  SystemBase * system;
60  // Is this a NonlinearSystem variable or an AuxiliarySystem variable?
61  if (_current_task == "copy_nodal_vars")
62  system = &_problem->getNonlinearSystemBase(/*nl_sys=*/0);
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 }
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:1150
static InputParameters validParams()
Base class for a system (of equations)
Definition: SystemBase.h:85
virtual const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:57
Base class for actions.
Definition: Action.h:38
CopyNodalVarsAction(const InputParameters &params)
bool isParamValid(const std::string &name) const
Test if the supplied parameter is valid.
static InputParameters validParams()
Definition: Action.C:24
void setExodusFileRestart(bool flag)
Set the flag to indicate whether or not we need to use a separate Exodus reader to read the mesh BEFO...
Definition: MooseApp.h:419
registerMooseAction("MooseApp", CopyNodalVarsAction, "check_copy_nodal_vars")
const std::string & _current_task
The current action (even though we have separate instances for each action)
Definition: Action.h:173
MooseApp & _app
The MOOSE application this is associated with.
Definition: MooseBase.h:84
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...
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:179
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...
virtual void act() override
Method to add objects to the simulation or perform other setup tasks.
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...