www.mooseframework.org
Functions | Variables
ConsoleUtils Namespace Reference

Functions

std::string indent (unsigned int spaces)
 Create empty string for indenting. More...
 
std::string outputFrameworkInformation (const MooseApp &app)
 Outputs framework information. More...
 
std::string outputMeshInformation (FEProblemBase &problem, bool verbose=true)
 Output the mesh information. More...
 
std::string outputAuxiliarySystemInformation (FEProblemBase &problem)
 Output the Auxiliary system information. More...
 
std::string outputNonlinearSystemInformation (FEProblemBase &problem)
 Output the Nonlinear system information. More...
 
std::string outputRelationshipManagerInformation (const MooseApp &app)
 Output action RelationshipManager information. More...
 
std::string outputExecutionInformation (const MooseApp &app, FEProblemBase &problem)
 Output execution information. More...
 
std::string outputOutputInformation (MooseApp &app)
 Output the output information. More...
 
std::string outputSystemInformationHelper (System &system)
 Output system information. More...
 
void insertNewline (std::stringstream &oss, std::streampos &begin, std::streampos &curr)
 Helper function function for stringstream formatting. More...
 

Variables

static const unsigned int console_field_width = 27
 Width used for printing simulation information. More...
 
static const unsigned int console_line_length = 100
 Line length for printing simulation information. More...
 

Function Documentation

◆ indent()

std::string ConsoleUtils::indent ( unsigned int  spaces)

◆ insertNewline()

void ConsoleUtils::insertNewline ( std::stringstream &  oss,
std::streampos &  begin,
std::streampos &  curr 
)

Helper function function for stringstream formatting.

Definition at line 310 of file ConsoleUtils.C.

Referenced by outputSystemInformationHelper(), and MaterialPropertyDebugOutput::printMaterialProperties().

311 {
312  if (curr - begin > console_line_length)
313  {
314  oss << "\n";
315  begin = oss.tellp();
316  oss << std::setw(console_field_width + 2) << ""; // "{ "
317  }
318 }
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:29
static const unsigned int console_line_length
Line length for printing simulation information.
Definition: ConsoleUtils.h:32

◆ outputAuxiliarySystemInformation()

std::string ConsoleUtils::outputAuxiliarySystemInformation ( FEProblemBase problem)

Output the Auxiliary system information.

Definition at line 109 of file ConsoleUtils.C.

Referenced by Console::meshChanged(), and Console::outputSystemInformation().

110 {
112 }
std::string outputSystemInformationHelper(System &system)
Output system information.
Definition: ConsoleUtils.C:121
AuxiliarySystem & getAuxiliarySystem()
virtual System & system() override
Get the reference to the libMesh system.

◆ outputExecutionInformation()

std::string ConsoleUtils::outputExecutionInformation ( const MooseApp app,
FEProblemBase problem 
)

Output execution information.

Definition at line 243 of file ConsoleUtils.C.

Referenced by Console::outputSystemInformation().

244 {
245 
246  std::stringstream oss;
247  oss << std::left;
248 
249  Executioner * exec = app.getExecutioner();
250 
251  oss << "Execution Information:\n"
252  << std::setw(console_field_width) << " Executioner: " << demangle(typeid(*exec).name())
253  << '\n';
254 
255  std::string time_stepper = exec->getTimeStepperName();
256  if (time_stepper != "")
257  oss << std::setw(console_field_width) << " TimeStepper: " << time_stepper << '\n';
258 
259  oss << std::setw(console_field_width)
260  << " Solver Mode: " << Moose::stringify(problem.solverParams()._type) << '\n';
261 
262  const std::string & pc_desc = problem.getPetscOptions().pc_description;
263  if (!pc_desc.empty())
264  oss << std::setw(console_field_width) << " PETSc Preconditioner: " << pc_desc << '\n';
265 
267  if (mpc)
268  {
269  oss << std::setw(console_field_width)
270  << " MOOSE Preconditioner: " << mpc->getParam<std::string>("_type");
271  if (mpc->name() == "_moose_auto")
272  oss << " (auto)";
273  oss << '\n';
274  }
275  oss << '\n';
276 
277  return oss.str();
278 }
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition: MooseApp.h:255
Moose::PetscSupport::PetscOptions & getPetscOptions()
Retrieve a writable reference the PETSc options (used by PetscSupport)
MoosePreconditioner const * getPreconditioner() const
SolverParams & solverParams()
Get the solver parameters.
NonlinearSystemBase & getNonlinearSystemBase()
const T & getParam(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseObject.h:191
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:29
Base class for MOOSE preconditioners.
Moose::SolveType _type
Definition: SolverParams.h:19
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:32
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:60
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:59
virtual std::string getTimeStepperName()
The name of the TimeStepper This is an empty string for non-Transient executioners.
Definition: Executioner.h:94
std::string pc_description
Preconditioner description.
Definition: PetscSupport.h:54

◆ outputFrameworkInformation()

std::string ConsoleUtils::outputFrameworkInformation ( const MooseApp app)

Outputs framework information.

This includes the versions and timestamps

Definition at line 36 of file ConsoleUtils.C.

Referenced by Console::outputSystemInformation().

37 {
38  std::stringstream oss;
39  oss << std::left;
40 
41  if (app.getSystemInfo() != NULL)
42  oss << app.getSystemInfo()->getInfo();
43 
44  oss << std::left << "Parallelism:\n"
45  << std::setw(console_field_width)
46  << " Num Processors: " << static_cast<std::size_t>(app.n_processors()) << '\n'
47  << std::setw(console_field_width)
48  << " Num Threads: " << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
49  << '\n';
50 
51  return oss.str();
52 }
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:29
const SystemInfo * getSystemInfo() const
Get SystemInfo object.
Definition: MooseApp.h:423
std::string getInfo() const
Definition: SystemInfo.C:26

◆ outputMeshInformation()

std::string ConsoleUtils::outputMeshInformation ( FEProblemBase problem,
bool  verbose = true 
)

Output the mesh information.

Definition at line 55 of file ConsoleUtils.C.

Referenced by Console::meshChanged(), and Console::outputSystemInformation().

56 {
57  std::stringstream oss;
58  oss << std::left;
59 
60  MooseMesh & moose_mesh = problem.mesh();
61  MeshBase & mesh = moose_mesh.getMesh();
62 
63  if (verbose)
64  {
65  bool forced = moose_mesh.isParallelTypeForced();
66  bool pre_split = problem.getMooseApp().isUseSplit();
67 
68  // clang-format off
69  oss << "Mesh: " << '\n'
70  << std::setw(console_field_width)
71  << " Parallel Type: " << (moose_mesh.isDistributedMesh() ? "distributed" : "replicated")
72  << (forced || pre_split ? " (" : "")
73  << (forced ? "forced" : "")
74  << (forced && pre_split ? ", " : "")
75  << (pre_split ? "pre-split" : "")
76  << (forced || pre_split ? ")" : "")
77  << '\n'
78  << std::setw(console_field_width) << " Mesh Dimension: " << mesh.mesh_dimension() << '\n'
79  << std::setw(console_field_width) << " Spatial Dimension: " << mesh.spatial_dimension()
80  << '\n';
81  // clang-format on
82  }
83 
84  oss << std::setw(console_field_width) << " Nodes:" << '\n'
85  << std::setw(console_field_width) << " Total:" << mesh.n_nodes() << '\n'
86  << std::setw(console_field_width) << " Local:" << mesh.n_local_nodes() << '\n'
87  << std::setw(console_field_width) << " Elems:" << '\n'
88  << std::setw(console_field_width) << " Total:" << mesh.n_active_elem() << '\n'
89  << std::setw(console_field_width) << " Local:" << mesh.n_active_local_elem() << '\n';
90 
91  if (verbose)
92  {
93 
94  oss << std::setw(console_field_width)
95  << " Num Subdomains: " << static_cast<std::size_t>(mesh.n_subdomains()) << '\n'
96  << std::setw(console_field_width)
97  << " Num Partitions: " << static_cast<std::size_t>(mesh.n_partitions()) << '\n';
98  if (problem.n_processors() > 1)
99  oss << std::setw(console_field_width) << " Partitioner: " << moose_mesh.partitionerName()
100  << (moose_mesh.isPartitionerForced() ? " (forced) " : "") << '\n';
101  }
102 
103  oss << '\n';
104 
105  return oss.str();
106 }
bool isDistributedMesh() const
Returns the final Mesh distribution type.
Definition: MooseMesh.h:784
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:29
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2567
bool isPartitionerForced() const
Tell the user if the partitioner was overriden for any reason.
Definition: MooseMesh.h:799
bool isUseSplit() const
Whether or not we are running with pre-split (distributed mesh)
Definition: MooseApp.C:877
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
virtual MooseMesh & mesh() override
bool isParallelTypeForced() const
Tell the user if the distribution was overriden for any reason.
Definition: MooseMesh.h:789
MooseApp & getMooseApp() const
Get the MooseApp this object is associated with.
Definition: MooseObject.h:94
const MooseEnum & partitionerName() const
Definition: MooseMesh.h:794

◆ outputNonlinearSystemInformation()

std::string ConsoleUtils::outputNonlinearSystemInformation ( FEProblemBase problem)

Output the Nonlinear system information.

Definition at line 115 of file ConsoleUtils.C.

Referenced by Console::meshChanged(), and Console::outputSystemInformation().

116 {
118 }
NonlinearSystemBase & getNonlinearSystemBase()
std::string outputSystemInformationHelper(System &system)
Output system information.
Definition: ConsoleUtils.C:121
virtual System & system() override
Get the reference to the libMesh system.

◆ outputOutputInformation()

std::string ConsoleUtils::outputOutputInformation ( MooseApp app)

Output the output information.

Definition at line 281 of file ConsoleUtils.C.

Referenced by Console::outputSystemInformation().

282 {
283  std::stringstream oss;
284  oss << std::left;
285 
286  const std::vector<Output *> outputs = app.getOutputWarehouse().getOutputs<Output>();
287  oss << "Outputs:\n";
288  for (const auto & out : outputs)
289  {
290  // Display the "execute_on" settings
291  const MultiMooseEnum & execute_on = out->executeOn();
292  oss << " " << std::setw(console_field_width - 2) << out->name() << "\"" << execute_on
293  << "\"\n";
294 
295  // Display the advanced "execute_on" settings, only if they are different from "execute_on"
296  if (out->isAdvanced())
297  {
298  const OutputOnWarehouse & adv_on = out->advancedExecuteOn();
299  for (const auto & adv_it : adv_on)
300  if (execute_on != adv_it.second)
301  oss << " " << std::setw(console_field_width - 4) << adv_it.first + ":"
302  << "\"" << adv_it.second << "\"\n";
303  }
304  }
305 
306  return oss.str();
307 }
std::vector< T * > getOutputs(const std::vector< OutputName > &names)
Return a vector of objects by names.
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:29
Based class for output objects.
Definition: Output.h:41
A helper warehouse class for storing the "execute_on" settings for the various output types...
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:59
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:1055

◆ outputRelationshipManagerInformation()

std::string ConsoleUtils::outputRelationshipManagerInformation ( const MooseApp app)

Output action RelationshipManager information.

Definition at line 223 of file ConsoleUtils.C.

Referenced by Console::outputSystemInformation().

224 {
225  std::stringstream oss;
226  oss << std::left;
227 
228  auto info_strings = app.getRelationshipManagerInfo();
229  if (info_strings.size())
230  {
231  for (const auto & info_pair : info_strings)
232  oss << std::setw(console_field_width)
233  << " " + MooseUtils::underscoreToCamelCase(MooseUtils::toLower(info_pair.first), true) +
234  ":"
235  << info_pair.second << '\n';
236  oss << '\n';
237  }
238 
239  return oss.str();
240 }
std::string toLower(const std::string &name)
Convert supplied string to lower case.
Definition: MooseUtils.C:659
std::vector< std::pair< std::string, std::string > > getRelationshipManagerInfo() const
Returns the Relationship managers info suitable for printing.
Definition: MooseApp.C:1793
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:29
std::string underscoreToCamelCase(const std::string &underscore_name, bool leading_upper_case)
Function for converting an underscore name to a camel case name.
Definition: MooseUtils.C:331

◆ outputSystemInformationHelper()

std::string ConsoleUtils::outputSystemInformationHelper ( System &  system)

Output system information.

Parameters
systemThe libMesh system to output
See also
outputAuxiliarySystemInformation outputNonlinearSystemInformation

Definition at line 121 of file ConsoleUtils.C.

Referenced by outputAuxiliarySystemInformation(), and outputNonlinearSystemInformation().

122 {
123  std::stringstream oss;
124  oss << std::left;
125 
126  if (system.n_dofs())
127  {
128  oss << std::setw(console_field_width) << " Num DOFs: " << system.n_dofs() << '\n'
129  << std::setw(console_field_width) << " Num Local DOFs: " << system.n_local_dofs() << '\n';
130 
131  std::streampos begin_string_pos = oss.tellp();
132  std::streampos curr_string_pos = begin_string_pos;
133  oss << std::setw(console_field_width) << " Variables: ";
134  for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
135  {
136  const VariableGroup & vg_description(system.variable_group(vg));
137 
138  if (vg_description.n_variables() > 1)
139  oss << "{ ";
140  for (unsigned int vn = 0; vn < vg_description.n_variables(); vn++)
141  {
142  oss << "\"" << vg_description.name(vn) << "\" ";
143  curr_string_pos = oss.tellp();
144  insertNewline(oss, begin_string_pos, curr_string_pos);
145  }
146 
147  if (vg_description.n_variables() > 1)
148  oss << "} ";
149  }
150  oss << '\n';
151 
152  begin_string_pos = oss.tellp();
153  curr_string_pos = begin_string_pos;
154  oss << std::setw(console_field_width) << " Finite Element Types: ";
155 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
156  for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
157  {
158  oss << "\""
159  << libMesh::Utility::enum_to_string<FEFamily>(
160  system.get_dof_map().variable_group(vg).type().family)
161  << "\" ";
162  curr_string_pos = oss.tellp();
163  insertNewline(oss, begin_string_pos, curr_string_pos);
164  }
165  oss << '\n';
166 #else
167  for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
168  {
169  oss << "\""
170  << libMesh::Utility::enum_to_string<FEFamily>(
171  system.get_dof_map().variable_group(vg).type().family)
172  << "\", \""
173  << libMesh::Utility::enum_to_string<FEFamily>(
174  system.get_dof_map().variable_group(vg).type().radial_family)
175  << "\" ";
176  curr_string_pos = oss.tellp();
177  insertNewline(oss, begin_string_pos, curr_string_pos);
178  }
179  oss << '\n';
180 
181  begin_string_pos = oss.tellp();
182  curr_string_pos = begin_string_pos;
183  oss << std::setw(console_field_width) << " Infinite Element Mapping: ";
184  for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
185  {
186  oss << "\""
187  << libMesh::Utility::enum_to_string<InfMapType>(
188  system.get_dof_map().variable_group(vg).type().inf_map)
189  << "\" ";
190  curr_string_pos = oss.tellp();
191  insertNewline(oss, begin_string_pos, curr_string_pos);
192  }
193  oss << '\n';
194 #endif
195 
196  begin_string_pos = oss.tellp();
197  curr_string_pos = begin_string_pos;
198  oss << std::setw(console_field_width) << " Approximation Orders: ";
199  for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
200  {
201 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
202  oss << "\""
203  << Utility::enum_to_string<Order>(system.get_dof_map().variable_group(vg).type().order)
204  << "\" ";
205 #else
206  oss << "\""
207  << Utility::enum_to_string<Order>(system.get_dof_map().variable_group(vg).type().order)
208  << "\", \""
209  << Utility::enum_to_string<Order>(
210  system.get_dof_map().variable_group(vg).type().radial_order)
211  << "\" ";
212 #endif
213  curr_string_pos = oss.tellp();
214  insertNewline(oss, begin_string_pos, curr_string_pos);
215  }
216  oss << "\n\n";
217  }
218 
219  return oss.str();
220 }
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:29
nl system()
void insertNewline(std::stringstream &oss, std::streampos &begin, std::streampos &curr)
Helper function function for stringstream formatting.
Definition: ConsoleUtils.C:310

Variable Documentation

◆ console_field_width

const unsigned int ConsoleUtils::console_field_width = 27
static

◆ console_line_length

const unsigned int ConsoleUtils::console_line_length = 100
static

Line length for printing simulation information.

Definition at line 32 of file ConsoleUtils.h.

Referenced by insertNewline().