www.mooseframework.org
Functions | Variables
ConsoleUtils Namespace Reference

Functions

std::string indent (unsigned int spaces)
 Create empty string for indenting. More...
 
std::string outputFrameworkInformation (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 outputExecutionInformation (MooseApp &app, FEProblemBase &problem)
 Output execution information. More...
 
std::string outputOutputInformation (MooseApp &app)
 Output the output information. More...
 
std::string outputSystemInformationHelper (const 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

std::string ConsoleUtils::indent ( unsigned int  spaces)
void ConsoleUtils::insertNewline ( std::stringstream &  oss,
std::streampos &  begin,
std::streampos &  curr 
)

Helper function function for stringstream formatting.

Definition at line 269 of file ConsoleUtils.C.

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

270 {
271  if (curr - begin > console_line_length)
272  {
273  oss << "\n";
274  begin = oss.tellp();
275  oss << std::setw(console_field_width + 2) << ""; // "{ "
276  }
277 }
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:35
static const unsigned int console_line_length
Line length for printing simulation information.
Definition: ConsoleUtils.h:38
std::string ConsoleUtils::outputAuxiliarySystemInformation ( FEProblemBase problem)

Output the Auxiliary system information.

Definition at line 103 of file ConsoleUtils.C.

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

104 {
106 }
std::string outputSystemInformationHelper(const System &system)
Output system information.
Definition: ConsoleUtils.C:115
AuxiliarySystem & getAuxiliarySystem()
virtual System & system() override
Get the reference to the libMesh system.
std::string ConsoleUtils::outputExecutionInformation ( MooseApp app,
FEProblemBase problem 
)

Output execution information.

Definition at line 212 of file ConsoleUtils.C.

Referenced by Console::outputSystemInformation().

213 {
214 
215  std::stringstream oss;
216  oss << std::left;
217 
218  Executioner * exec = app.getExecutioner();
219 
220  oss << "Execution Information:\n"
221  << std::setw(console_field_width) << " Executioner: " << demangle(typeid(*exec).name())
222  << '\n';
223 
224  std::string time_stepper = exec->getTimeStepperName();
225  if (time_stepper != "")
226  oss << std::setw(console_field_width) << " TimeStepper: " << time_stepper << '\n';
227 
228  oss << std::setw(console_field_width)
229  << " Solver Mode: " << Moose::stringify(problem.solverParams()._type) << '\n';
230 
231  const std::string & pc_desc = problem.getPetscOptions().pc_description;
232  if (!pc_desc.empty())
233  oss << std::setw(console_field_width) << " Preconditioner: " << pc_desc << '\n';
234  oss << '\n';
235 
236  return oss.str();
237 }
Moose::PetscSupport::PetscOptions & getPetscOptions()
Retrieve a writable reference the PETSc options (used by PetscSupport)
virtual std::string getTimeStepperName()
The name of the TimeStepper This is an empty string for non-Transient executioners.
Definition: Executioner.C:168
SolverParams & solverParams()
Get the solver parameters.
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:35
Moose::SolveType _type
Definition: SolverParams.h:25
Executioners are objects that do the actual work of solving your problem.
Definition: Executioner.h:41
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:66
Executioner * getExecutioner()
Retrieve the Executioner for this App.
Definition: MooseApp.h:233
std::string pc_description
Preconditioner description.
Definition: PetscSupport.h:56
std::string ConsoleUtils::outputFrameworkInformation ( MooseApp app)

Outputs framework information.

This includes the versions and timestamps

Definition at line 40 of file ConsoleUtils.C.

Referenced by Console::outputSystemInformation().

41 {
42  std::stringstream oss;
43  oss << std::left;
44 
45  if (app.getSystemInfo() != NULL)
46  oss << app.getSystemInfo()->getInfo();
47 
48  oss << std::left << "Parallelism:\n"
49  << std::setw(console_field_width)
50  << " Num Processors: " << static_cast<std::size_t>(app.n_processors()) << '\n'
51  << std::setw(console_field_width)
52  << " Num Threads: " << static_cast<std::size_t>(libMesh::n_threads()) << '\n'
53  << '\n';
54 
55  return oss.str();
56 }
const SystemInfo * getSystemInfo() const
Get SystemInfo object.
Definition: MooseApp.h:377
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:35
std::string getInfo() const
Definition: SystemInfo.C:32
std::string ConsoleUtils::outputMeshInformation ( FEProblemBase problem,
bool  verbose = true 
)

Output the mesh information.

Definition at line 59 of file ConsoleUtils.C.

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

60 {
61  std::stringstream oss;
62  oss << std::left;
63 
64  MooseMesh & moose_mesh = problem.mesh();
65  MeshBase & mesh = moose_mesh.getMesh();
66 
67  if (verbose)
68  {
69  oss << "Mesh: " << '\n'
70  << std::setw(console_field_width)
71  << " Parallel Type: " << (moose_mesh.isDistributedMesh() ? "distributed" : "replicated")
72  << (moose_mesh.isParallelTypeForced() ? " (forced) " : "") << '\n'
73  << std::setw(console_field_width) << " Mesh Dimension: " << mesh.mesh_dimension() << '\n'
74  << std::setw(console_field_width) << " Spatial Dimension: " << mesh.spatial_dimension()
75  << '\n';
76  }
77 
78  oss << std::setw(console_field_width) << " Nodes:" << '\n'
79  << std::setw(console_field_width) << " Total:" << mesh.n_nodes() << '\n'
80  << std::setw(console_field_width) << " Local:" << mesh.n_local_nodes() << '\n'
81  << std::setw(console_field_width) << " Elems:" << '\n'
82  << std::setw(console_field_width) << " Total:" << mesh.n_active_elem() << '\n'
83  << std::setw(console_field_width) << " Local:" << mesh.n_active_local_elem() << '\n';
84 
85  if (verbose)
86  {
87 
88  oss << std::setw(console_field_width)
89  << " Num Subdomains: " << static_cast<std::size_t>(mesh.n_subdomains()) << '\n'
90  << std::setw(console_field_width)
91  << " Num Partitions: " << static_cast<std::size_t>(mesh.n_partitions()) << '\n';
92  if (problem.n_processors() > 1)
93  oss << std::setw(console_field_width) << " Partitioner: " << moose_mesh.partitionerName()
94  << (moose_mesh.isPartitionerForced() ? " (forced) " : "") << '\n';
95  }
96 
97  oss << '\n';
98 
99  return oss.str();
100 }
bool isParallelTypeForced() const
Tell the user if the distribution was overriden for any reason.
Definition: MooseMesh.h:742
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:35
MeshBase & getMesh()
Accessor for the underlying libMesh Mesh object.
Definition: MooseMesh.C:2355
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
const MooseEnum & partitionerName() const
Definition: MooseMesh.h:747
bool isPartitionerForced() const
Tell the user if the partitioner was overriden for any reason.
Definition: MooseMesh.h:752
virtual MooseMesh & mesh() override
bool isDistributedMesh() const
Returns the final Mesh distribution type.
Definition: MooseMesh.h:737
std::string ConsoleUtils::outputNonlinearSystemInformation ( FEProblemBase problem)

Output the Nonlinear system information.

Definition at line 109 of file ConsoleUtils.C.

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

110 {
112 }
NonlinearSystemBase & getNonlinearSystemBase()
std::string outputSystemInformationHelper(const System &system)
Output system information.
Definition: ConsoleUtils.C:115
virtual System & system() override
Get the reference to the libMesh system.
std::string ConsoleUtils::outputOutputInformation ( MooseApp app)

Output the output information.

Definition at line 240 of file ConsoleUtils.C.

Referenced by Console::outputSystemInformation().

241 {
242  std::stringstream oss;
243  oss << std::left;
244 
245  const std::vector<Output *> outputs = app.getOutputWarehouse().getOutputs<Output>();
246  oss << "Outputs:\n";
247  for (const auto & out : outputs)
248  {
249  // Display the "execute_on" settings
250  const MultiMooseEnum & execute_on = out->executeOn();
251  oss << " " << std::setw(console_field_width - 2) << out->name() << "\"" << execute_on
252  << "\"\n";
253 
254  // Display the advanced "execute_on" settings, only if they are different from "execute_on"
255  if (out->isAdvanced())
256  {
257  const OutputOnWarehouse & adv_on = out->advancedExecuteOn();
258  for (const auto & adv_it : adv_on)
259  if (execute_on != adv_it.second)
260  oss << " " << std::setw(console_field_width - 4) << adv_it.first + ":"
261  << "\"" << adv_it.second << "\"\n";
262  }
263  }
264 
265  return oss.str();
266 }
const std::string & name() const
Get the name of the object.
Definition: MooseObject.h:47
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:35
Based class for output objects.
Definition: Output.h:45
A helper warehouse class for storing the "execute_on" settings for the various output types...
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:841
std::string ConsoleUtils::outputSystemInformationHelper ( const System &  system)

Output system information.

Parameters
systemThe libMesh system to output
See also
outputAuxiliarySystemInformation outputNonlinearSystemInformation

Definition at line 115 of file ConsoleUtils.C.

Referenced by outputAuxiliarySystemInformation(), and outputNonlinearSystemInformation().

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

Variable Documentation

const unsigned int ConsoleUtils::console_field_width = 27
static
const unsigned int ConsoleUtils::console_line_length = 100
static

Line length for printing simulation information.

Definition at line 38 of file ConsoleUtils.h.

Referenced by insertNewline().