Loading [MathJax]/extensions/tex2jax.js
https://mooseframework.inl.gov
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
MessageFromInput.C
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://mooseframework.inl.gov
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 #include "MessageFromInput.h"
11 #include "ConsoleStream.h"
12 #include "ConsoleUtils.h"
13 
15 
18 {
19  // Get the input parameters from the parent class
21 
22  // Add parameters
23  params.addRequiredParam<std::string>("message", "The message to print out");
24 
25  // we run this object once at the initialization by default
26  params.set<ExecFlagEnum>("execute_on") = EXEC_INITIAL;
27 
28  params.addClassDescription("Print out a message from the input file");
29 
30  return params;
31 }
32 
34  : GeneralUserObject(parameters), _input_message(getParam<std::string>("message"))
35 {
36 }
37 
39 
40 void
42 {
43  auto total_width = std::setw(ConsoleUtils::console_field_width);
44  _console << total_width << "\n";
45  _console << "Message: " << std::endl
46  << ConsoleUtils::indent(2) << COLOR_YELLOW << _input_message << "\n";
47  _console << COLOR_DEFAULT << total_width << "\n" << std::endl;
48  _console << std ::flush;
49 }
std::string indent(unsigned int spaces)
Create empty string for indenting.
Definition: ConsoleUtils.C:41
const std::string _input_message
hold the message from the input file
User object that get a message from an input file and print it out during the simulation.
A MultiMooseEnum object to hold "execute_on" flags.
Definition: ExecFlagEnum.h:21
static InputParameters validParams()
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addRequiredParam(const std::string &name, const std::string &doc_string)
This method adds a parameter and documentation string to the InputParameters object that will be extr...
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:30
MessageFromInput(const InputParameters &parameters)
virtual void execute() override
Print out the message.
registerMooseObject("MooseApp", MessageFromInput)
static InputParameters validParams()
virtual ~MessageFromInput()
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...
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
const ExecFlagType EXEC_INITIAL
Definition: Moose.C:28