www.mooseframework.org
AddOutputAction.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 "AddOutputAction.h"
17 #include "FEProblem.h"
18 #include "Factory.h"
19 #include "OutputWarehouse.h"
20 #include "Output.h"
21 #include "MooseApp.h"
22 #include "FileMesh.h"
23 #include "MooseApp.h"
24 
25 #include "libmesh/mesh_function.h"
26 #include "libmesh/mesh_refinement.h"
27 #include "libmesh/explicit_system.h"
28 
29 template <>
32 {
34  return params;
35 }
36 
38 
39 void
41 {
42  // Do nothing if FEProblemBase is NULL, this should only be the case for CoupledProblem
43  if (_problem.get() == NULL)
44  return;
45 
46  // Get a reference to the OutputWarehouse
47  OutputWarehouse & output_warehouse = _app.getOutputWarehouse();
48 
49  // Reject the reserved names for objects not built by MOOSE
50  if (!_moose_object_pars.get<bool>("_built_by_moose") && output_warehouse.isReservedName(_name))
51  mooseError("The name '", _name, "' is a reserved name for output objects");
52 
53  // Check that an object by the same name does not already exist; this must be done before the
54  // object
55  // is created to avoid getting misleading errors from the Parser
56  if (output_warehouse.hasOutput(_name))
57  mooseError("An output object named '", _name, "' already exists");
58 
59  // Add a pointer to the FEProblemBase class
60  _moose_object_pars.addPrivateParam<FEProblemBase *>("_fe_problem_base", _problem.get());
61 
62  // Create common parameter exclude list
63  std::vector<std::string> exclude;
64  if (_type == "Console")
65  {
66  exclude.push_back("execute_on");
67 
68  // --show-input should enable the display of the input file on the screen
69  if (_app.getParam<bool>("show_input") && _moose_object_pars.get<bool>("output_screen"))
70  _moose_object_pars.set<MultiMooseEnum>("execute_input_on") = "initial";
71  }
72 
73  // Apply the common parameters
74  InputParameters * common = output_warehouse.getCommonParameters();
75  if (common != NULL)
76  _moose_object_pars.applyParameters(*common, exclude);
77 
78  // Set the correct value for the binary flag for XDA/XDR output
79  if (_type == "XDR")
80  _moose_object_pars.set<bool>("_binary") = true;
81  else if (_type == "XDA")
82  _moose_object_pars.set<bool>("_binary") = false;
83 
84  // Adjust the checkpoint suffix if auto recovery was enabled
85  if (_name == "auto_recovery_checkpoint")
86  _moose_object_pars.set<std::string>("suffix") = "auto_recovery";
87 
88  // Create the object and add it to the warehouse
89  std::shared_ptr<Output> output = _factory.create<Output>(_type, _name, _moose_object_pars);
90  output_warehouse.addOutput(output);
91 }
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:46
void addPrivateParam(const std::string &name, const T &value)
These method add a parameter to the InputParameters object which can be retrieved like any other para...
void addOutput(std::shared_ptr< Output > &output)
Adds an existing output object to the warehouse.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
bool isReservedName(const std::string &name)
Test if the given name is reserved.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Factory & _factory
The Factory associated with the MooseApp.
Definition: Action.h:101
AddOutputAction(InputParameters params)
Class constructor.
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
std::string _name
The name of the action.
Definition: Action.h:92
Based class for output objects.
Definition: Output.h:45
Class for storing and utilizing output objects.
InputParameters validParams< MooseObjectAction >()
void applyParameters(const InputParameters &common, std::vector< std::string > exclude=std::vector< std::string >())
Method for applying common parameters.
virtual void act() override
const T & getParam(const std::string &name)
Retrieve a parameter for the object.
Definition: MooseApp.h:738
InputParameters * getCommonParameters()
Get a reference to the common output parameters.
std::string _type
The Object type that is being created.
InputParameters _moose_object_pars
The parameters for the object to be created.
bool hasOutput(const std::string &name) const
Returns true if the output object exists.
std::shared_ptr< FEProblemBase > & _problem
Convenience reference to a problem this action works on.
Definition: Action.h:131
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
MooseApp & _app
The MOOSE application this is associated with.
Definition: Action.h:98
InputParameters validParams< AddOutputAction >()
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:840