Line data Source code
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 : // MOOSE includes
11 : #include "ConsoleUtils.h"
12 :
13 : #include "AuxiliarySystem.h"
14 : #include "Conversion.h"
15 : #include "Executioner.h"
16 : #include "MoosePreconditioner.h"
17 : #include "FEProblem.h"
18 : #include "MooseApp.h"
19 : #include "MooseMesh.h"
20 : #include "MooseObject.h"
21 : #include "NonlinearSystem.h"
22 : #include "OutputWarehouse.h"
23 : #include "SystemInfo.h"
24 : #include "Checkpoint.h"
25 : #include "InputParameterWarehouse.h"
26 : #include "Registry.h"
27 : #include "CommandLine.h"
28 : #include "Split.h"
29 :
30 : #include <filesystem>
31 :
32 : #include "libmesh/string_to_enum.h"
33 : #include "libmesh/simple_range.h"
34 :
35 : using namespace libMesh;
36 :
37 : namespace ConsoleUtils
38 : {
39 :
40 : std::string
41 28043 : indent(unsigned int spaces)
42 : {
43 56086 : return std::string(spaces, ' ');
44 : }
45 :
46 : std::string
47 90302 : outputFrameworkInformation(const MooseApp & app)
48 : {
49 90302 : std::stringstream oss;
50 90302 : oss << std::left;
51 :
52 90302 : oss << app.getSystemInfo().getInfo();
53 :
54 90302 : oss << "Input File(s):\n";
55 180880 : for (const auto & entry : app.getInputFileNames())
56 90578 : oss << " " << std::filesystem::absolute(entry).c_str() << "\n";
57 90302 : oss << "\n";
58 :
59 90302 : const auto & cl = std::as_const(*app.commandLine());
60 : // We skip the 0th argument of the main app, i.e., the name used to invoke the program
61 : const auto cl_range =
62 180604 : as_range(std::next(cl.getEntries().begin(), app.multiAppLevel() == 0), cl.getEntries().end());
63 :
64 90302 : std::stringstream args_oss;
65 789224 : for (const auto & entry : cl_range)
66 698922 : if (!entry.hit_param && !entry.subapp_name && entry.name != "-i")
67 469407 : args_oss << " " << cl.formatEntry(entry) << "\n";
68 90302 : if (args_oss.str().size())
69 86788 : oss << "Command Line Argument(s):\n" << args_oss.str() << "\n";
70 :
71 90302 : std::stringstream input_args_oss;
72 789224 : for (const auto & entry : cl_range)
73 698922 : if (entry.hit_param && !entry.subapp_name)
74 153427 : input_args_oss << " " << cl.formatEntry(entry) << "\n";
75 90302 : if (input_args_oss.str().size())
76 79292 : oss << "Command Line Input Argument(s):\n" << input_args_oss.str() << "\n";
77 :
78 90302 : const auto checkpoints = app.getOutputWarehouse().getOutputs<Checkpoint>();
79 90302 : if (checkpoints.size())
80 : {
81 75602 : oss << std::left << "Checkpoint:\n";
82 75602 : oss << checkpoints[0]->checkpointInfo().str();
83 75602 : oss << std::endl;
84 : }
85 :
86 90302 : oss << std::left << "Parallelism:\n"
87 : << std::setw(console_field_width)
88 90302 : << " Num Processors: " << static_cast<std::size_t>(app.n_processors()) << '\n'
89 : << std::setw(console_field_width)
90 90302 : << " Num Threads: " << static_cast<std::size_t>(libMesh::n_threads()) << std::endl;
91 :
92 180604 : return oss.str();
93 90302 : }
94 :
95 : std::string
96 55850 : outputMeshInformation(FEProblemBase & problem, bool verbose)
97 : {
98 55850 : std::stringstream oss;
99 55850 : oss << std::left;
100 :
101 55850 : const MooseMesh & mesh = problem.mesh();
102 :
103 55850 : const auto fe_backend = problem.feBackend();
104 :
105 55850 : if (verbose)
106 : {
107 55487 : oss << "\nMesh: " << '\n' << std::setw(console_field_width);
108 :
109 55487 : oss << " Parallel Type: " << (mesh.isDistributedMesh() ? "distributed" : "replicated");
110 55487 : if (fe_backend == Moose::FEBackend::LibMesh)
111 : {
112 55138 : bool forced = mesh.isParallelTypeForced();
113 55138 : bool pre_split = mesh.isSplit();
114 54512 : oss << (forced || pre_split ? " (" : "") << (forced ? "forced" : "")
115 626 : << (forced && pre_split ? ", " : "") << (pre_split ? "pre-split" : "")
116 110276 : << (forced || pre_split ? ")" : "");
117 : }
118 55487 : oss << '\n';
119 55487 : oss << std::setw(console_field_width) << " Mesh Dimension: " << mesh.dimension() << '\n'
120 55487 : << std::setw(console_field_width) << " Spatial Dimension: " << mesh.spatialDimension()
121 55487 : << '\n';
122 : }
123 :
124 : // Nodes, only associated with the mesh in libMesh
125 55850 : if (fe_backend == Moose::FEBackend::LibMesh)
126 : {
127 55501 : if (mesh.n_processors() > 1)
128 : {
129 25444 : dof_id_type nnodes = mesh.nNodes();
130 25444 : dof_id_type nnodes_local = mesh.nLocalNodes();
131 : oss << std::setw(console_field_width) << " Nodes:" << '\n'
132 25444 : << std::setw(console_field_width) << " Total:" << nnodes << '\n';
133 25444 : oss << std::setw(console_field_width) << " Local:" << nnodes_local << '\n';
134 25444 : dof_id_type min_nnodes = nnodes_local, max_nnodes = nnodes_local;
135 25444 : mesh.comm().min(min_nnodes);
136 25444 : mesh.comm().max(max_nnodes);
137 25444 : if (mesh.processor_id() == 0)
138 11892 : oss << std::setw(console_field_width) << " Min/Max/Avg:" << min_nnodes << '/'
139 11892 : << max_nnodes << '/' << nnodes / mesh.n_processors() << '\n';
140 : }
141 : else
142 30057 : oss << std::setw(console_field_width) << " Nodes:" << mesh.nNodes() << '\n';
143 : }
144 :
145 : // Elements
146 55850 : if (mesh.n_processors() > 1)
147 : {
148 25512 : dof_id_type nelems = mesh.nActiveElem();
149 25512 : dof_id_type nelems_local = mesh.nActiveLocalElem();
150 : oss << std::setw(console_field_width) << " Elems:" << '\n'
151 25512 : << std::setw(console_field_width) << " Total:" << nelems << '\n';
152 25512 : oss << std::setw(console_field_width) << " Local:" << nelems_local << '\n';
153 25512 : dof_id_type min_nelems = nelems_local, max_nelems = nelems_local;
154 25512 : mesh.comm().min(min_nelems);
155 25512 : mesh.comm().max(max_nelems);
156 25512 : if (mesh.processor_id() == 0)
157 11926 : oss << std::setw(console_field_width) << " Min/Max/Avg:" << min_nelems << '/' << max_nelems
158 11926 : << '/' << nelems / mesh.n_processors() << '\n';
159 : }
160 : else
161 30338 : oss << std::setw(console_field_width) << " Elems:" << mesh.nActiveElem() << '\n';
162 :
163 : // P-refinement
164 55850 : if (fe_backend == Moose::FEBackend::LibMesh)
165 : {
166 55501 : if (mesh.maxPLevel() > 0)
167 : oss << std::setw(console_field_width)
168 42 : << " Max p-Refinement Level: " << static_cast<std::size_t>(mesh.maxPLevel()) << '\n';
169 55501 : if (mesh.maxHLevel() > 0)
170 : oss << std::setw(console_field_width)
171 6393 : << " Max h-Refinement Level: " << static_cast<std::size_t>(mesh.maxHLevel()) << '\n';
172 : }
173 :
174 55850 : if (verbose)
175 : {
176 : oss << std::setw(console_field_width)
177 55487 : << " Num Subdomains: " << static_cast<std::size_t>(mesh.nSubdomains()) << '\n';
178 55487 : if (mesh.n_processors() > 1 && fe_backend == Moose::FEBackend::LibMesh)
179 : {
180 : oss << std::setw(console_field_width)
181 25270 : << " Num Partitions: " << static_cast<std::size_t>(mesh.nPartitions()) << '\n'
182 25270 : << std::setw(console_field_width) << " Partitioner: " << mesh.partitionerName()
183 25270 : << (mesh.isPartitionerForced() ? " (forced) " : "") << '\n';
184 25270 : if (mesh.skipPartitioning())
185 700 : oss << std::setw(console_field_width) << " Skipping all partitioning!" << '\n';
186 24570 : else if (mesh.skipNoncriticalPartitioning())
187 0 : oss << std::setw(console_field_width) << " Skipping noncritical partitioning!" << '\n';
188 : }
189 : }
190 :
191 55850 : oss << std::endl;
192 :
193 111700 : return oss.str();
194 55850 : }
195 :
196 : std::string
197 55850 : outputAuxiliarySystemInformation(FEProblemBase & problem)
198 : {
199 55850 : return outputSystemInformationHelper(problem.getAuxiliarySystem().system());
200 : }
201 :
202 : std::string
203 111975 : outputSystemInformationHelper(std::stringstream & oss, System & system)
204 : {
205 111975 : oss << std::left;
206 :
207 111975 : if (system.n_dofs())
208 : {
209 69619 : oss << std::setw(console_field_width) << " Num DOFs: " << system.n_dofs() << '\n'
210 69619 : << std::setw(console_field_width) << " Num Local DOFs: " << system.n_local_dofs() << '\n';
211 :
212 69619 : if (system.n_constrained_dofs())
213 : {
214 : oss << std::setw(console_field_width)
215 1246 : << " Num Constrained DOFs: " << system.n_constrained_dofs() << '\n'
216 : << std::setw(console_field_width)
217 1246 : << " Local Constrained DOFs: " << system.n_local_constrained_dofs() << '\n';
218 : }
219 :
220 69619 : std::streampos begin_string_pos = oss.tellp();
221 69619 : std::streampos curr_string_pos = begin_string_pos;
222 69619 : oss << std::setw(console_field_width) << " Variables: ";
223 159205 : for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
224 : {
225 89586 : const VariableGroup & vg_description(system.variable_group(vg));
226 :
227 89586 : if (vg_description.n_variables() > 1)
228 15442 : oss << "{ ";
229 89586 : if (vg_description.n_variables() > 10)
230 : {
231 : // when the number of variables in this group is larger than 10, we only output the first
232 : // and the last 5 variable names
233 3252 : for (unsigned int vn = 0; vn < 5; vn++)
234 : {
235 2710 : oss << "\"" << vg_description.name(vn) << "\" ";
236 2710 : curr_string_pos = oss.tellp();
237 2710 : insertNewline(oss, begin_string_pos, curr_string_pos);
238 : }
239 542 : oss << "... ";
240 542 : curr_string_pos = oss.tellp();
241 542 : insertNewline(oss, begin_string_pos, curr_string_pos);
242 3252 : for (unsigned int vn = vg_description.n_variables() - 5; vn < vg_description.n_variables();
243 : vn++)
244 : {
245 2710 : oss << "\"" << vg_description.name(vn) << "\" ";
246 2710 : curr_string_pos = oss.tellp();
247 2710 : insertNewline(oss, begin_string_pos, curr_string_pos);
248 : }
249 : }
250 : else
251 204658 : for (unsigned int vn = 0; vn < vg_description.n_variables(); vn++)
252 : {
253 115614 : oss << "\"" << vg_description.name(vn) << "\" ";
254 115614 : curr_string_pos = oss.tellp();
255 115614 : insertNewline(oss, begin_string_pos, curr_string_pos);
256 : }
257 :
258 89586 : if (vg_description.n_variables() > 1)
259 15442 : oss << "} ";
260 : }
261 69619 : oss << '\n';
262 :
263 69619 : begin_string_pos = oss.tellp();
264 69619 : curr_string_pos = begin_string_pos;
265 69619 : oss << std::setw(console_field_width) << " Finite Element Types: ";
266 : #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
267 159205 : for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
268 : {
269 : oss << "\""
270 89586 : << libMesh::Utility::enum_to_string<FEFamily>(
271 89586 : system.get_dof_map().variable_group(vg).type().family)
272 179172 : << "\" ";
273 89586 : curr_string_pos = oss.tellp();
274 89586 : insertNewline(oss, begin_string_pos, curr_string_pos);
275 : }
276 69619 : oss << '\n';
277 : #else
278 : for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
279 : {
280 : oss << "\""
281 : << libMesh::Utility::enum_to_string<FEFamily>(
282 : system.get_dof_map().variable_group(vg).type().family)
283 : << "\", \""
284 : << libMesh::Utility::enum_to_string<FEFamily>(
285 : system.get_dof_map().variable_group(vg).type().radial_family)
286 : << "\" ";
287 : curr_string_pos = oss.tellp();
288 : insertNewline(oss, begin_string_pos, curr_string_pos);
289 : }
290 : oss << '\n';
291 :
292 : begin_string_pos = oss.tellp();
293 : curr_string_pos = begin_string_pos;
294 : oss << std::setw(console_field_width) << " Infinite Element Mapping: ";
295 : for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
296 : {
297 : oss << "\""
298 : << libMesh::Utility::enum_to_string<InfMapType>(
299 : system.get_dof_map().variable_group(vg).type().inf_map)
300 : << "\" ";
301 : curr_string_pos = oss.tellp();
302 : insertNewline(oss, begin_string_pos, curr_string_pos);
303 : }
304 : oss << '\n';
305 : #endif
306 :
307 69619 : begin_string_pos = oss.tellp();
308 69619 : curr_string_pos = begin_string_pos;
309 69619 : oss << std::setw(console_field_width) << " Approximation Orders: ";
310 159205 : for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
311 : {
312 : #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
313 : oss << "\""
314 179172 : << Utility::enum_to_string<Order>(system.get_dof_map().variable_group(vg).type().order)
315 179172 : << "\" ";
316 : #else
317 : oss << "\""
318 : << Utility::enum_to_string<Order>(system.get_dof_map().variable_group(vg).type().order)
319 : << "\", \""
320 : << Utility::enum_to_string<Order>(
321 : system.get_dof_map().variable_group(vg).type().radial_order)
322 : << "\" ";
323 : #endif
324 89586 : curr_string_pos = oss.tellp();
325 89586 : insertNewline(oss, begin_string_pos, curr_string_pos);
326 : }
327 69619 : oss << "\n" << std::endl;
328 : }
329 :
330 111975 : return oss.str();
331 : }
332 :
333 : std::string
334 56125 : outputSolverSystemInformation(FEProblemBase & problem, const unsigned int sys_num)
335 : {
336 56125 : std::stringstream oss;
337 56125 : oss << std::left;
338 :
339 112250 : return outputSystemInformationHelper(oss, problem.getSolverSystem(sys_num).system());
340 56125 : }
341 :
342 : std::string
343 55850 : outputSystemInformationHelper(System & system)
344 : {
345 55850 : std::stringstream oss;
346 :
347 111700 : return outputSystemInformationHelper(oss, system);
348 55850 : }
349 :
350 : std::string
351 102 : outputRelationshipManagerInformation(const MooseApp & app)
352 : {
353 102 : std::stringstream oss;
354 102 : oss << std::left;
355 :
356 102 : auto info_strings = app.getRelationshipManagerInfo();
357 102 : if (info_strings.size())
358 : {
359 636 : for (const auto & info_pair : info_strings)
360 : oss << std::setw(console_field_width)
361 1068 : << " " + MooseUtils::underscoreToCamelCase(MooseUtils::toLower(info_pair.first), true) +
362 : ":"
363 1068 : << info_pair.second << '\n';
364 102 : oss << std::endl;
365 : }
366 :
367 204 : return oss.str();
368 102 : }
369 :
370 : std::string
371 55487 : outputExecutionInformation(const MooseApp & app, FEProblemBase & problem)
372 : {
373 :
374 55487 : std::stringstream oss;
375 55487 : oss << std::left;
376 :
377 55487 : Executioner * exec = app.getExecutioner();
378 :
379 : oss << "Execution Information:\n"
380 55487 : << std::setw(console_field_width) << " Executioner: " << exec->type() << '\n';
381 :
382 55487 : std::string time_stepper = exec->getTimeStepperName();
383 55487 : if (time_stepper != "")
384 25814 : oss << std::setw(console_field_width) << " TimeStepper: " << time_stepper << '\n';
385 55487 : const auto time_integrator_names = exec->getTimeIntegratorNames();
386 55487 : if (!time_integrator_names.empty())
387 : oss << std::setw(console_field_width)
388 77103 : << " TimeIntegrator(s): " << MooseUtils::join(time_integrator_names, " ") << '\n';
389 :
390 : oss << std::setw(console_field_width)
391 166461 : << std::string(" Solver") +
392 110974 : (problem.feBackend() == Moose::FEBackend::LibMesh ? " Mode" : "") + ": ";
393 111249 : for (const std::size_t i : make_range(problem.numSolverSystems()))
394 221948 : oss << (problem.numSolverSystems() > 1 ? "[" + problem.getSolverSystemNames()[i] + "]: " : "")
395 55762 : << problem.solverTypeString(i) << " ";
396 55487 : oss << '\n';
397 :
398 : // Check for a selection of common PETSc pc options on the command line for
399 : // all solver systems and all field splits within each nonlinear system
400 55487 : std::string pc_desc;
401 111249 : for (const std::size_t i : make_range(problem.numSolverSystems()))
402 : {
403 111524 : std::vector<std::string> splits = {""};
404 55762 : if (problem.isSolverSystemNonlinear(i))
405 54907 : for (const auto & split : problem.getNonlinearSystemBase(i).getSplits().getObjects())
406 485 : splits.push_back("fieldsplit_" + split->name() + "_");
407 :
408 112009 : for (const std::string & split : splits)
409 : {
410 56247 : std::string pc_desc_split;
411 56247 : const std::string prefix = problem.solverParams(i)._prefix + split;
412 553929 : for (const auto & entry : std::as_const(*app.commandLine()).getEntries())
413 1493046 : if (entry.name == prefix + "pc_type" || entry.name == prefix + "sub_pc_type" ||
414 1493046 : entry.name == prefix + "pc_hypre_type" || entry.name == prefix + "pc_fieldsplit_type")
415 0 : pc_desc_split += entry.value ? *entry.value + " " : "unspecified ";
416 :
417 56247 : if (!pc_desc_split.empty() && prefix.size() > 1)
418 0 : pc_desc += "[" + prefix.substr(1, prefix.size() - 2) + "]: ";
419 56247 : pc_desc += pc_desc_split;
420 56247 : }
421 55762 : }
422 :
423 : // Alert the user any unoverridden options will still be picked up from the input file
424 55487 : if (!pc_desc.empty())
425 0 : pc_desc += "(see input file for unoverridden options)";
426 :
427 : // If there are no PETSc pc options on the command line, print the input file options
428 55487 : if (pc_desc.empty())
429 55487 : pc_desc = problem.getPetscOptions().pc_description;
430 :
431 55487 : if (!pc_desc.empty())
432 23795 : oss << std::setw(console_field_width) << " PETSc Preconditioner: " << pc_desc << '\n';
433 :
434 55487 : std::string mpc_desc;
435 109909 : for (const std::size_t i : make_range(problem.numNonlinearSystems()))
436 : {
437 54422 : MoosePreconditioner const * mpc = problem.getNonlinearSystemBase(i).getPreconditioner();
438 54422 : if (mpc)
439 : {
440 13478 : if (problem.numNonlinearSystems() > 1)
441 268 : mpc_desc += "[" + problem.getNonlinearSystemNames()[i] + "]: ";
442 13478 : mpc_desc += mpc->type() + " ";
443 13478 : if (mpc->name().find("_moose_auto") != std::string::npos)
444 9497 : mpc_desc += "(auto) ";
445 : }
446 : }
447 :
448 55487 : if (!mpc_desc.empty())
449 13344 : oss << std::setw(console_field_width) << " MOOSE Preconditioner: " << mpc_desc << '\n';
450 :
451 110974 : return oss.str();
452 55487 : }
453 :
454 : std::string
455 10 : outputOutputInformation(MooseApp & app)
456 : {
457 10 : std::stringstream oss;
458 10 : oss << std::left;
459 :
460 10 : const std::vector<Output *> outputs = app.getOutputWarehouse().getOutputs<Output>();
461 10 : oss << "Outputs:\n";
462 60 : for (const auto & out : outputs)
463 : {
464 : // Display the "execute_on" settings
465 50 : const MultiMooseEnum & execute_on = out->executeOn();
466 50 : oss << " " << std::setw(console_field_width - 2) << out->name() << "\"" << execute_on
467 50 : << "\"\n";
468 :
469 : // Display the advanced "execute_on" settings, only if they are different from "execute_on"
470 50 : if (out->isAdvanced())
471 : {
472 20 : const OutputOnWarehouse & adv_on = out->advancedExecuteOn();
473 140 : for (const auto & adv_it : adv_on)
474 120 : if (execute_on != adv_it.second)
475 140 : oss << " " << std::setw(console_field_width - 4) << adv_it.first + ":" << "\""
476 70 : << adv_it.second << "\"" << std::endl;
477 : }
478 : }
479 :
480 20 : return oss.str();
481 10 : }
482 :
483 : std::string
484 26 : outputPreSMOResidualInformation()
485 : {
486 26 : std::stringstream oss;
487 26 : oss << std::left;
488 :
489 26 : oss << COLOR_BLUE;
490 : oss << "Executioner/use_pre_smo_residual is set to true. The pre-SMO residual will be evaluated "
491 : "at the beginning of each time step before executing objects that could modify the "
492 : "solution, such as preset BCs, predictors, correctors, constraints, and certain user "
493 : "objects. The pre-SMO residuals will be prefixed with * and will be used in the relative "
494 26 : "convergence check.\n";
495 26 : oss << COLOR_DEFAULT;
496 :
497 52 : return oss.str();
498 26 : }
499 :
500 : std::string
501 55500 : outputLegacyInformation(MooseApp & app)
502 : {
503 55500 : std::stringstream oss;
504 55500 : oss << std::left;
505 :
506 55500 : if (app.parameters().get<bool>("use_legacy_material_output"))
507 : {
508 0 : oss << COLOR_RED << "LEGACY MODES ENABLED:" << COLOR_DEFAULT << '\n';
509 : oss << " This application uses the legacy material output option: material properties are "
510 : "output only on TIMESTEP_END, not INITIAL. To remove this message, set "
511 : "'use_legacy_material_output' to false in this application. If there are gold output "
512 : "files that contain material property output for which output occurs on INITIAL, then "
513 : "these will generate diffs due to zero values being stored, and these tests should be "
514 : "re-golded.\n"
515 0 : << COLOR_DEFAULT << std::endl;
516 : }
517 :
518 55500 : if (app.parameters().get<bool>("use_legacy_initial_residual_evaluation_behavior"))
519 : {
520 0 : oss << COLOR_RED << "LEGACY MODES ENABLED:" << COLOR_DEFAULT << '\n';
521 : oss << " This application uses the legacy initial residual evaluation behavior. The legacy "
522 : "behavior performs an often times redundant residual evaluation before the solution "
523 : "modifying objects are executed prior to the initial (0th nonlinear iteration) residual "
524 : "evaluation. The new behavior skips that redundant residual evaluation unless the "
525 : "parameter Executioner/use_pre_smo_residual is set to true. To remove this message and "
526 : "enable the new behavior, set the parameter "
527 : "'use_legacy_initial_residual_evaluation_behavior' to false in *App.C. Some tests that "
528 : "rely on the side effects of the legacy behavior may fail/diff and should be "
529 : "re-golded.\n"
530 0 : << COLOR_DEFAULT << std::endl;
531 : }
532 :
533 111000 : return oss.str();
534 55500 : }
535 :
536 : std::string
537 10 : outputDataFilePaths()
538 : {
539 10 : std::stringstream oss;
540 10 : oss << "Data File Paths:\n";
541 20 : for (const auto & [name, path] : Registry::getDataFilePaths())
542 10 : oss << " " << name << ": " << path << "\n";
543 20 : return oss.str() + "\n";
544 10 : }
545 :
546 : std::string
547 10 : outputDataFileParams(MooseApp & app)
548 : {
549 10 : std::map<std::string, std::string> values; // for A-Z sort
550 526 : for (const auto & object_name_params_pair : app.getInputParameterWarehouse().getInputParameters())
551 : {
552 516 : const auto & params = object_name_params_pair.second;
553 13000 : for (const auto & name_value_pair : *params)
554 : {
555 12484 : const auto & name = name_value_pair.first;
556 12484 : if (const auto path = params->queryDataFileNamePath(name))
557 40 : if (params->getHitNode(name))
558 12484 : values.emplace(params->paramFullpath(name), path->path);
559 : }
560 : }
561 :
562 10 : std::stringstream oss;
563 10 : oss << "Data File Parameters:\n";
564 20 : for (const auto & [param, value] : values)
565 10 : oss << " " << param << " = " << value << "\n";
566 20 : return oss.str() + '\n';
567 10 : }
568 :
569 : void
570 369167 : insertNewline(std::stringstream & oss, std::streampos & begin, std::streampos & curr)
571 : {
572 369167 : if (curr - begin > console_line_length)
573 : {
574 6045 : oss << "\n";
575 6045 : begin = oss.tellp();
576 6045 : oss << std::setw(console_field_width + 2) << ""; // "{ "
577 : }
578 369167 : }
579 :
580 : std::string
581 63368 : formatString(std::string message, const std::string & prefix)
582 : {
583 63368 : MooseUtils::indentMessage(prefix, message, COLOR_DEFAULT, true, " ");
584 63368 : std::stringstream stream;
585 63368 : std::streampos start = stream.tellp();
586 63368 : stream << message;
587 63368 : std::streampos end = stream.tellp();
588 63368 : insertNewline(stream, start, end);
589 63368 : auto formatted_string = stream.str();
590 : // no need to end with a line break
591 63368 : if (formatted_string.back() == '\n')
592 0 : formatted_string.pop_back();
593 126736 : return formatted_string;
594 63368 : }
595 :
596 : std::string
597 13181 : mooseObjectVectorToString(const std::vector<MooseObject *> & objs, const std::string & sep /*=""*/)
598 : {
599 13181 : std::string object_names = "";
600 13181 : if (objs.size())
601 : {
602 : // Gather all the object names
603 13181 : std::vector<std::string> names;
604 13181 : names.reserve(objs.size());
605 37916 : for (const auto & obj : objs)
606 : {
607 : mooseAssert(obj, "Trying to print a null object");
608 24735 : names.push_back(obj->name());
609 : }
610 :
611 13181 : object_names = MooseUtils::join(names, sep);
612 13181 : }
613 13181 : return object_names;
614 0 : }
615 :
616 : } // ConsoleUtils namespace
|