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...
 
std::string outputLegacyInformation (MooseApp &app)
 Output the legacy flag information. More...
 
void insertNewline (std::stringstream &oss, std::streampos &begin, std::streampos &curr)
 Helper function function for stringstream formatting. More...
 
std::string outputSystemInformationHelper (std::stringstream &oss, System &system)
 

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 346 of file ConsoleUtils.C.

347 {
348  if (curr - begin > console_line_length)
349  {
350  oss << "\n";
351  begin = oss.tellp();
352  oss << std::setw(console_field_width + 2) << ""; // "{ "
353  }
354 }

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

◆ outputAuxiliarySystemInformation()

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

Output the Auxiliary system information.

Definition at line 109 of file ConsoleUtils.C.

110 {
112 }

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

◆ outputExecutionInformation()

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

Output execution information.

Definition at line 261 of file ConsoleUtils.C.

262 {
263 
264  std::stringstream oss;
265  oss << std::left;
266 
267  Executioner * exec = app.getExecutioner();
268 
269  oss << "Execution Information:\n"
270  << std::setw(console_field_width) << " Executioner: " << demangle(typeid(*exec).name())
271  << '\n';
272 
273  std::string time_stepper = exec->getTimeStepperName();
274  if (time_stepper != "")
275  oss << std::setw(console_field_width) << " TimeStepper: " << time_stepper << '\n';
276 
277  oss << std::setw(console_field_width)
278  << " Solver Mode: " << Moose::stringify(problem.solverParams()._type) << '\n';
279 
280  const std::string & pc_desc = problem.getPetscOptions().pc_description;
281  if (!pc_desc.empty())
282  oss << std::setw(console_field_width) << " PETSc Preconditioner: " << pc_desc << '\n';
283 
285  if (mpc)
286  {
287  oss << std::setw(console_field_width)
288  << " MOOSE Preconditioner: " << mpc->getParamTempl<std::string>("_type");
289  if (mpc->name() == "_moose_auto")
290  oss << " (auto)";
291  oss << '\n';
292  }
293  oss << '\n';
294 
295  return oss.str();
296 }

Referenced by Console::outputSystemInformation().

◆ 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.

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 }

Referenced by Console::outputSystemInformation().

◆ outputLegacyInformation()

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

Output the legacy flag information.

Definition at line 328 of file ConsoleUtils.C.

329 {
330  std::stringstream oss;
331  oss << std::left;
332 
333  if (app.parameters().get<bool>("use_legacy_dirichlet_bc"))
334  {
335  oss << COLOR_RED << "LEGACY MODES ENABLED:" << COLOR_DEFAULT << '\n';
336  oss << " Default for parameter preset = false for all DirichletBC and ADDirichletBC objects.\n"
337  << " Set use_legacy_dirichlet_bc = false in the application to change to the preferred "
338  "behavior.\n"
339  << COLOR_DEFAULT << '\n';
340  }
341 
342  return oss.str();
343 }

Referenced by Console::outputSystemInformation().

◆ outputMeshInformation()

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

Output the mesh information.

Definition at line 55 of file ConsoleUtils.C.

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 }

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

◆ outputNonlinearSystemInformation()

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

Output the Nonlinear system information.

Definition at line 216 of file ConsoleUtils.C.

217 {
218  std::stringstream oss;
219  oss << std::left;
220 
221 #ifndef MOOSE_SPARSE_AD
222  if (problem.haveADObjects())
223  {
224  oss << std::setw(console_field_width)
225  << " AD size required: " << problem.getNonlinearSystemBase().requiredDerivativeSize()
226  << "\n";
227  }
228 #endif
230 }

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

◆ outputOutputInformation()

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

Output the output information.

Definition at line 299 of file ConsoleUtils.C.

300 {
301  std::stringstream oss;
302  oss << std::left;
303 
304  const std::vector<Output *> outputs = app.getOutputWarehouse().getOutputs<Output>();
305  oss << "Outputs:\n";
306  for (const auto & out : outputs)
307  {
308  // Display the "execute_on" settings
309  const MultiMooseEnum & execute_on = out->executeOn();
310  oss << " " << std::setw(console_field_width - 2) << out->name() << "\"" << execute_on
311  << "\"\n";
312 
313  // Display the advanced "execute_on" settings, only if they are different from "execute_on"
314  if (out->isAdvanced())
315  {
316  const OutputOnWarehouse & adv_on = out->advancedExecuteOn();
317  for (const auto & adv_it : adv_on)
318  if (execute_on != adv_it.second)
319  oss << " " << std::setw(console_field_width - 4) << adv_it.first + ":"
320  << "\"" << adv_it.second << "\"\n";
321  }
322  }
323 
324  return oss.str();
325 }

Referenced by Console::outputSystemInformation().

◆ outputRelationshipManagerInformation()

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

Output action RelationshipManager information.

Definition at line 241 of file ConsoleUtils.C.

242 {
243  std::stringstream oss;
244  oss << std::left;
245 
246  auto info_strings = app.getRelationshipManagerInfo();
247  if (info_strings.size())
248  {
249  for (const auto & info_pair : info_strings)
250  oss << std::setw(console_field_width)
251  << " " + MooseUtils::underscoreToCamelCase(MooseUtils::toLower(info_pair.first), true) +
252  ":"
253  << info_pair.second << '\n';
254  oss << '\n';
255  }
256 
257  return oss.str();
258 }

Referenced by Console::outputSystemInformation().

◆ outputSystemInformationHelper() [1/2]

std::string ConsoleUtils::outputSystemInformationHelper ( std::stringstream &  oss,
System &  system 
)

Definition at line 115 of file ConsoleUtils.C.

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

◆ outputSystemInformationHelper() [2/2]

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

Output system information.

Parameters
systemThe libMesh system to output
See also
outputAuxiliarySystemInformation outputNonlinearSystemInformation

Definition at line 233 of file ConsoleUtils.C.

234 {
235  std::stringstream oss;
236 
238 }

Referenced by outputAuxiliarySystemInformation(), and outputNonlinearSystemInformation().

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().

Executioner::getTimeStepperName
virtual std::string getTimeStepperName()
The name of the TimeStepper This is an empty string for non-Transient executioners.
Definition: Executioner.h:96
SystemInfo::getInfo
std::string getInfo() const
Definition: SystemInfo.C:26
FEProblemBase::haveADObjects
void haveADObjects(bool have_ad_objects) override
Method for setting whether we have any ad objects.
Definition: FEProblemBase.C:6470
OutputWarehouse::getOutputs
std::vector< T * > getOutputs(const std::vector< OutputName > &names)
Return a vector of objects by names.
Definition: OutputWarehouse.h:388
MooseApp::getOutputWarehouse
OutputWarehouse & getOutputWarehouse()
Get the OutputWarehouse objects.
Definition: MooseApp.C:1122
FEProblemBase::getPetscOptions
Moose::PetscSupport::PetscOptions & getPetscOptions()
Retrieve a writable reference the PETSc options (used by PetscSupport)
Definition: FEProblemBase.h:519
Moose::PetscSupport::PetscOptions::pc_description
std::string pc_description
Preconditioner description.
Definition: PetscSupport.h:54
MooseUtils::toLower
std::string toLower(const std::string &name)
Convert supplied string to lower case.
Definition: MooseUtils.C:677
ConsoleUtils::console_field_width
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:29
NonlinearSystemBase::requiredDerivativeSize
std::size_t requiredDerivativeSize() const
Return the required size of the derivative vector.
Definition: NonlinearSystemBase.h:675
MoosePreconditioner
Base class for MOOSE preconditioners.
Definition: MoosePreconditioner.h:34
Executioner
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:32
MooseUtils::underscoreToCamelCase
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:343
MooseMesh::partitionerName
const MooseEnum & partitionerName() const
Definition: MooseMesh.h:819
MooseApp::isUseSplit
bool isUseSplit() const
Whether or not we are running with pre-split (distributed mesh)
Definition: MooseApp.C:952
MooseApp::getSystemInfo
const SystemInfo * getSystemInfo() const
Get SystemInfo object.
Definition: MooseApp.h:449
Moose::stringify
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:61
MooseMesh::isParallelTypeForced
bool isParallelTypeForced() const
Tell the user if the distribution was overriden for any reason.
Definition: MooseMesh.h:814
MooseMesh::isDistributedMesh
bool isDistributedMesh() const
Returns the final Mesh distribution type.
Definition: MooseMesh.h:809
MooseMesh::getMesh
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2599
NonlinearSystemBase::getPreconditioner
const MoosePreconditioner * getPreconditioner() const
Definition: NonlinearSystemBase.C:3009
MooseObject::getMooseApp
MooseApp & getMooseApp() const
Get the MooseApp this object is associated with.
Definition: MooseObject.h:105
ConsoleUtils::console_line_length
static const unsigned int console_line_length
Line length for printing simulation information.
Definition: ConsoleUtils.h:32
MooseObject::getParamTempl
const T & getParamTempl(const std::string &name) const
Retrieve a parameter for the object.
Definition: MooseObject.h:208
MooseApp::getRelationshipManagerInfo
std::vector< std::pair< std::string, std::string > > getRelationshipManagerInfo() const
Returns the Relationship managers info suitable for printing.
Definition: MooseApp.C:1983
NonlinearSystemBase::system
virtual System & system() override
Get the reference to the libMesh system.
Definition: NonlinearSystemBase.h:618
MooseApp::getExecutioner
Executioner * getExecutioner() const
Retrieve the Executioner for this App.
Definition: MooseApp.h:282
ConsoleUtils::insertNewline
void insertNewline(std::stringstream &oss, std::streampos &begin, std::streampos &curr)
Helper function function for stringstream formatting.
Definition: ConsoleUtils.C:346
FEProblemBase::solverParams
SolverParams & solverParams()
Get the solver parameters.
Definition: FEProblemBase.C:6313
Output
Based class for output objects.
Definition: Output.h:41
MooseMesh::isPartitionerForced
bool isPartitionerForced() const
Tell the user if the partitioner was overriden for any reason.
Definition: MooseMesh.h:824
MultiMooseEnum
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
Definition: MultiMooseEnum.h:38
MooseMesh
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
system
nl system()
Definition: PetscDMMoose.C:1287
FEProblemBase::getNonlinearSystemBase
NonlinearSystemBase & getNonlinearSystemBase()
Definition: FEProblemBase.h:560
FEProblemBase::getAuxiliarySystem
AuxiliarySystem & getAuxiliarySystem()
Definition: FEProblemBase.h:648
OutputOnWarehouse
A helper warehouse class for storing the "execute_on" settings for the various output types.
Definition: AdvancedOutputUtils.h:124
MooseApp::parameters
InputParameters & parameters()
Get the parameters of the object.
Definition: MooseApp.h:90
AuxiliarySystem::system
virtual System & system() override
Get the reference to the libMesh system.
Definition: AuxiliarySystem.h:179
ConsoleUtils::outputSystemInformationHelper
std::string outputSystemInformationHelper(std::stringstream &oss, System &system)
Definition: ConsoleUtils.C:115
FEProblemBase::mesh
virtual MooseMesh & mesh() override
Definition: FEProblemBase.h:148
MooseObject::name
virtual const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:70
SolverParams::_type
Moose::SolveType _type
Definition: SolverParams.h:19