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 25487 : indent(unsigned int spaces)
42 : {
43 50974 : return std::string(spaces, ' ');
44 : }
45 :
46 : std::string
47 88785 : outputFrameworkInformation(const MooseApp & app)
48 : {
49 88785 : std::stringstream oss;
50 88785 : oss << std::left;
51 :
52 88785 : oss << app.getSystemInfo().getInfo();
53 :
54 88785 : oss << "Input File(s):\n";
55 177819 : for (const auto & entry : app.getInputFileNames())
56 89034 : oss << " " << std::filesystem::absolute(entry).c_str() << "\n";
57 88785 : oss << "\n";
58 :
59 88785 : 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 177570 : as_range(std::next(cl.getEntries().begin(), app.multiAppLevel() == 0), cl.getEntries().end());
63 :
64 88785 : std::stringstream args_oss;
65 791818 : for (const auto & entry : cl_range)
66 703033 : if (!entry.hit_param && !entry.subapp_name && entry.name != "-i")
67 474164 : args_oss << " " << cl.formatEntry(entry) << "\n";
68 88785 : if (args_oss.str().size())
69 86973 : oss << "Command Line Argument(s):\n" << args_oss.str() << "\n";
70 :
71 88785 : std::stringstream input_args_oss;
72 791818 : for (const auto & entry : cl_range)
73 703033 : if (entry.hit_param && !entry.subapp_name)
74 153694 : input_args_oss << " " << cl.formatEntry(entry) << "\n";
75 88785 : if (input_args_oss.str().size())
76 78019 : oss << "Command Line Input Argument(s):\n" << input_args_oss.str() << "\n";
77 :
78 88785 : const auto checkpoints = app.getOutputWarehouse().getOutputs<Checkpoint>();
79 88785 : if (checkpoints.size())
80 : {
81 73829 : oss << std::left << "Checkpoint:\n";
82 73829 : oss << checkpoints[0]->checkpointInfo().str();
83 73829 : oss << std::endl;
84 : }
85 :
86 88785 : oss << std::left << "Parallelism:\n"
87 : << std::setw(console_field_width)
88 88785 : << " Num Processors: " << static_cast<std::size_t>(app.n_processors()) << '\n'
89 : << std::setw(console_field_width)
90 88785 : << " Num Threads: " << static_cast<std::size_t>(libMesh::n_threads()) << std::endl;
91 :
92 177570 : return oss.str();
93 88785 : }
94 :
95 : std::string
96 55478 : outputMeshInformation(FEProblemBase & problem, bool verbose)
97 : {
98 55478 : std::stringstream oss;
99 55478 : oss << std::left;
100 :
101 55478 : const MooseMesh & mesh = problem.mesh();
102 :
103 55478 : const auto fe_backend = problem.feBackend();
104 :
105 55478 : if (verbose)
106 : {
107 55153 : oss << "\nMesh: " << '\n' << std::setw(console_field_width);
108 :
109 55153 : oss << " Parallel Type: " << (mesh.isDistributedMesh() ? "distributed" : "replicated");
110 55153 : if (fe_backend == Moose::FEBackend::LibMesh)
111 : {
112 53692 : bool forced = mesh.isParallelTypeForced();
113 53692 : bool pre_split = mesh.isSplit();
114 53043 : oss << (forced || pre_split ? " (" : "") << (forced ? "forced" : "")
115 649 : << (forced && pre_split ? ", " : "") << (pre_split ? "pre-split" : "")
116 107384 : << (forced || pre_split ? ")" : "");
117 : }
118 55153 : oss << '\n';
119 55153 : oss << std::setw(console_field_width) << " Mesh Dimension: " << mesh.dimension() << '\n'
120 55153 : << std::setw(console_field_width) << " Spatial Dimension: " << mesh.spatialDimension()
121 55153 : << '\n';
122 : }
123 :
124 : // Nodes, only associated with the mesh in libMesh
125 55478 : if (fe_backend == Moose::FEBackend::LibMesh)
126 : {
127 54017 : if (mesh.n_processors() > 1)
128 : {
129 27449 : dof_id_type nnodes = mesh.nNodes();
130 27449 : dof_id_type nnodes_local = mesh.nLocalNodes();
131 : oss << std::setw(console_field_width) << " Nodes:" << '\n'
132 27449 : << std::setw(console_field_width) << " Total:" << nnodes << '\n';
133 27449 : oss << std::setw(console_field_width) << " Local:" << nnodes_local << '\n';
134 27449 : dof_id_type min_nnodes = nnodes_local, max_nnodes = nnodes_local;
135 27449 : mesh.comm().min(min_nnodes);
136 27449 : mesh.comm().max(max_nnodes);
137 27449 : if (mesh.processor_id() == 0)
138 12995 : oss << std::setw(console_field_width) << " Min/Max/Avg:" << min_nnodes << '/'
139 12995 : << max_nnodes << '/' << nnodes / mesh.n_processors() << '\n';
140 : }
141 : else
142 26568 : oss << std::setw(console_field_width) << " Nodes:" << mesh.nNodes() << '\n';
143 : }
144 :
145 : // Elements
146 55478 : if (mesh.n_processors() > 1)
147 : {
148 28177 : dof_id_type nelems = mesh.nActiveElem();
149 28177 : dof_id_type nelems_local = mesh.nActiveLocalElem();
150 : oss << std::setw(console_field_width) << " Elems:" << '\n'
151 28177 : << std::setw(console_field_width) << " Total:" << nelems << '\n';
152 28177 : oss << std::setw(console_field_width) << " Local:" << nelems_local << '\n';
153 28177 : dof_id_type min_nelems = nelems_local, max_nelems = nelems_local;
154 28177 : mesh.comm().min(min_nelems);
155 28177 : mesh.comm().max(max_nelems);
156 28177 : if (mesh.processor_id() == 0)
157 13359 : oss << std::setw(console_field_width) << " Min/Max/Avg:" << min_nelems << '/' << max_nelems
158 13359 : << '/' << nelems / mesh.n_processors() << '\n';
159 : }
160 : else
161 27301 : oss << std::setw(console_field_width) << " Elems:" << mesh.nActiveElem() << '\n';
162 :
163 : // P-refinement
164 55478 : if (fe_backend == Moose::FEBackend::LibMesh)
165 : {
166 54017 : 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 54017 : if (mesh.maxHLevel() > 0)
170 : oss << std::setw(console_field_width)
171 4858 : << " Max h-Refinement Level: " << static_cast<std::size_t>(mesh.maxHLevel()) << '\n';
172 : }
173 :
174 55478 : if (verbose)
175 : {
176 : oss << std::setw(console_field_width)
177 55153 : << " Num Subdomains: " << static_cast<std::size_t>(mesh.nSubdomains()) << '\n';
178 55153 : if (mesh.n_processors() > 1 && fe_backend == Moose::FEBackend::LibMesh)
179 : {
180 : oss << std::setw(console_field_width)
181 27275 : << " Num Partitions: " << static_cast<std::size_t>(mesh.nPartitions()) << '\n'
182 27275 : << std::setw(console_field_width) << " Partitioner: " << mesh.partitionerName()
183 27275 : << (mesh.isPartitionerForced() ? " (forced) " : "") << '\n';
184 27275 : if (mesh.skipPartitioning())
185 630 : oss << std::setw(console_field_width) << " Skipping all partitioning!" << '\n';
186 26645 : else if (mesh.skipNoncriticalPartitioning())
187 0 : oss << std::setw(console_field_width) << " Skipping noncritical partitioning!" << '\n';
188 : }
189 : }
190 :
191 55478 : oss << std::endl;
192 :
193 110956 : return oss.str();
194 55478 : }
195 :
196 : std::string
197 55478 : outputAuxiliarySystemInformation(FEProblemBase & problem)
198 : {
199 55478 : return outputSystemInformationHelper(problem.getAuxiliarySystem().system());
200 : }
201 :
202 : std::string
203 111203 : outputSystemInformationHelper(std::stringstream & oss, System & system)
204 : {
205 111203 : oss << std::left;
206 :
207 111203 : if (system.n_dofs())
208 : {
209 67534 : oss << std::setw(console_field_width) << " Num DOFs: " << system.n_dofs() << '\n'
210 67534 : << std::setw(console_field_width) << " Num Local DOFs: " << system.n_local_dofs() << '\n';
211 :
212 67534 : if (system.n_constrained_dofs())
213 : {
214 : oss << std::setw(console_field_width)
215 1019 : << " Num Constrained DOFs: " << system.n_constrained_dofs() << '\n'
216 : << std::setw(console_field_width)
217 1019 : << " Local Constrained DOFs: " << system.n_local_constrained_dofs() << '\n';
218 : }
219 :
220 67534 : std::streampos begin_string_pos = oss.tellp();
221 67534 : std::streampos curr_string_pos = begin_string_pos;
222 67534 : oss << std::setw(console_field_width) << " Variables: ";
223 154225 : for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
224 : {
225 86691 : const VariableGroup & vg_description(system.variable_group(vg));
226 :
227 86691 : if (vg_description.n_variables() > 1)
228 15596 : oss << "{ ";
229 86691 : 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 3120 : for (unsigned int vn = 0; vn < 5; vn++)
234 : {
235 2600 : oss << "\"" << vg_description.name(vn) << "\" ";
236 2600 : curr_string_pos = oss.tellp();
237 2600 : insertNewline(oss, begin_string_pos, curr_string_pos);
238 : }
239 520 : oss << "... ";
240 520 : curr_string_pos = oss.tellp();
241 520 : insertNewline(oss, begin_string_pos, curr_string_pos);
242 3120 : for (unsigned int vn = vg_description.n_variables() - 5; vn < vg_description.n_variables();
243 : vn++)
244 : {
245 2600 : oss << "\"" << vg_description.name(vn) << "\" ";
246 2600 : curr_string_pos = oss.tellp();
247 2600 : insertNewline(oss, begin_string_pos, curr_string_pos);
248 : }
249 : }
250 : else
251 198502 : for (unsigned int vn = 0; vn < vg_description.n_variables(); vn++)
252 : {
253 112331 : oss << "\"" << vg_description.name(vn) << "\" ";
254 112331 : curr_string_pos = oss.tellp();
255 112331 : insertNewline(oss, begin_string_pos, curr_string_pos);
256 : }
257 :
258 86691 : if (vg_description.n_variables() > 1)
259 15596 : oss << "} ";
260 : }
261 67534 : oss << '\n';
262 :
263 67534 : begin_string_pos = oss.tellp();
264 67534 : curr_string_pos = begin_string_pos;
265 67534 : oss << std::setw(console_field_width) << " Finite Element Types: ";
266 : #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
267 154225 : for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
268 : {
269 : oss << "\""
270 86691 : << libMesh::Utility::enum_to_string<FEFamily>(
271 86691 : system.get_dof_map().variable_group(vg).type().family)
272 173382 : << "\" ";
273 86691 : curr_string_pos = oss.tellp();
274 86691 : insertNewline(oss, begin_string_pos, curr_string_pos);
275 : }
276 67534 : 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 67534 : begin_string_pos = oss.tellp();
308 67534 : curr_string_pos = begin_string_pos;
309 67534 : oss << std::setw(console_field_width) << " Approximation Orders: ";
310 154225 : for (unsigned int vg = 0; vg < system.n_variable_groups(); vg++)
311 : {
312 : #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
313 : oss << "\""
314 173382 : << Utility::enum_to_string<Order>(system.get_dof_map().variable_group(vg).type().order)
315 173382 : << "\" ";
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 86691 : curr_string_pos = oss.tellp();
325 86691 : insertNewline(oss, begin_string_pos, curr_string_pos);
326 : }
327 67534 : oss << "\n" << std::endl;
328 : }
329 :
330 111203 : return oss.str();
331 : }
332 :
333 : std::string
334 55725 : outputSolverSystemInformation(FEProblemBase & problem, const unsigned int sys_num)
335 : {
336 55725 : std::stringstream oss;
337 55725 : oss << std::left;
338 :
339 111450 : return outputSystemInformationHelper(oss, problem.getSolverSystem(sys_num).system());
340 55725 : }
341 :
342 : std::string
343 55478 : outputSystemInformationHelper(System & system)
344 : {
345 55478 : std::stringstream oss;
346 :
347 110956 : return outputSystemInformationHelper(oss, system);
348 55478 : }
349 :
350 : std::string
351 91 : outputRelationshipManagerInformation(const MooseApp & app)
352 : {
353 91 : std::stringstream oss;
354 91 : oss << std::left;
355 :
356 91 : auto info_strings = app.getRelationshipManagerInfo();
357 91 : if (info_strings.size())
358 : {
359 569 : for (const auto & info_pair : info_strings)
360 : oss << std::setw(console_field_width)
361 956 : << " " + MooseUtils::underscoreToCamelCase(MooseUtils::toLower(info_pair.first), true) +
362 : ":"
363 956 : << info_pair.second << '\n';
364 91 : oss << std::endl;
365 : }
366 :
367 182 : return oss.str();
368 91 : }
369 :
370 : std::string
371 55153 : outputExecutionInformation(const MooseApp & app, FEProblemBase & problem)
372 : {
373 :
374 55153 : std::stringstream oss;
375 55153 : oss << std::left;
376 :
377 55153 : Executioner * exec = app.getExecutioner();
378 :
379 : oss << "Execution Information:\n"
380 55153 : << std::setw(console_field_width) << " Executioner: " << exec->type() << '\n';
381 :
382 55153 : std::string time_stepper = exec->getTimeStepperName();
383 55153 : if (time_stepper != "")
384 25689 : oss << std::setw(console_field_width) << " TimeStepper: " << time_stepper << '\n';
385 55153 : const auto time_integrator_names = exec->getTimeIntegratorNames();
386 55153 : if (!time_integrator_names.empty())
387 : oss << std::setw(console_field_width)
388 76158 : << " TimeIntegrator(s): " << MooseUtils::join(time_integrator_names, " ") << '\n';
389 :
390 : oss << std::setw(console_field_width)
391 165459 : << std::string(" Solver") +
392 110306 : (problem.feBackend() == Moose::FEBackend::LibMesh ? " Mode" : "") + ": ";
393 110553 : for (const std::size_t i : make_range(problem.numSolverSystems()))
394 220612 : oss << (problem.numSolverSystems() > 1 ? "[" + problem.getSolverSystemNames()[i] + "]: " : "")
395 55400 : << problem.solverTypeString(i) << " ";
396 55153 : 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 55153 : std::string pc_desc;
401 110553 : for (const std::size_t i : make_range(problem.numSolverSystems()))
402 : {
403 110800 : std::vector<std::string> splits = {""};
404 55400 : if (problem.isSolverSystemNonlinear(i))
405 54797 : for (const auto & split : problem.getNonlinearSystemBase(i).getSplits().getObjects())
406 429 : splits.push_back("fieldsplit_" + split->name() + "_");
407 :
408 111229 : for (const std::string & split : splits)
409 : {
410 55829 : std::string pc_desc_split;
411 55829 : const std::string prefix = problem.solverParams(i)._prefix + split;
412 560655 : for (const auto & entry : std::as_const(*app.commandLine()).getEntries())
413 1514478 : if (entry.name == prefix + "pc_type" || entry.name == prefix + "sub_pc_type" ||
414 1514478 : entry.name == prefix + "pc_hypre_type" || entry.name == prefix + "pc_fieldsplit_type")
415 0 : pc_desc_split += entry.value ? *entry.value + " " : "unspecified ";
416 :
417 55829 : if (!pc_desc_split.empty() && prefix.size() > 1)
418 0 : pc_desc += "[" + prefix.substr(1, prefix.size() - 2) + "]: ";
419 55829 : pc_desc += pc_desc_split;
420 55829 : }
421 55400 : }
422 :
423 : // Alert the user any unoverridden options will still be picked up from the input file
424 55153 : 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 55153 : if (pc_desc.empty())
429 55153 : pc_desc = problem.getPetscOptions().pc_description;
430 :
431 55153 : if (!pc_desc.empty())
432 22094 : oss << std::setw(console_field_width) << " PETSc Preconditioner: " << pc_desc << '\n';
433 :
434 55153 : std::string mpc_desc;
435 109521 : for (const std::size_t i : make_range(problem.numNonlinearSystems()))
436 : {
437 54368 : MoosePreconditioner const * mpc = problem.getNonlinearSystemBase(i).getPreconditioner();
438 54368 : if (mpc)
439 : {
440 12560 : if (problem.numNonlinearSystems() > 1)
441 246 : mpc_desc += "[" + problem.getNonlinearSystemNames()[i] + "]: ";
442 12560 : mpc_desc += mpc->type() + " ";
443 12560 : if (mpc->name().find("_moose_auto") != std::string::npos)
444 8693 : mpc_desc += "(auto) ";
445 : }
446 : }
447 :
448 55153 : if (!mpc_desc.empty())
449 12437 : oss << std::setw(console_field_width) << " MOOSE Preconditioner: " << mpc_desc << '\n';
450 :
451 55153 : oss << "\n";
452 :
453 110306 : return oss.str();
454 55153 : }
455 :
456 : std::string
457 9 : outputOutputInformation(MooseApp & app)
458 : {
459 9 : std::stringstream oss;
460 9 : oss << std::left;
461 :
462 9 : const std::vector<Output *> outputs = app.getOutputWarehouse().getOutputs<Output>();
463 9 : oss << "Outputs:\n";
464 54 : for (const auto & out : outputs)
465 : {
466 : // Display the "execute_on" settings
467 45 : const MultiMooseEnum & execute_on = out->executeOn();
468 45 : oss << " " << std::setw(console_field_width - 2) << out->name() << "\"" << execute_on
469 45 : << "\"\n";
470 :
471 : // Display the advanced "execute_on" settings, only if they are different from "execute_on"
472 45 : if (out->isAdvanced())
473 : {
474 18 : const OutputOnWarehouse & adv_on = out->advancedExecuteOn();
475 126 : for (const auto & adv_it : adv_on)
476 108 : if (execute_on != adv_it.second)
477 126 : oss << " " << std::setw(console_field_width - 4) << adv_it.first + ":" << "\""
478 63 : << adv_it.second << "\"" << std::endl;
479 : }
480 : }
481 :
482 18 : return oss.str();
483 9 : }
484 :
485 : std::string
486 24 : outputPreSMOResidualInformation()
487 : {
488 24 : std::stringstream oss;
489 24 : oss << std::left;
490 :
491 24 : oss << COLOR_BLUE;
492 : oss << "Executioner/use_pre_smo_residual is set to true. The pre-SMO residual will be evaluated "
493 : "at the beginning of each time step before executing objects that could modify the "
494 : "solution, such as preset BCs, predictors, correctors, constraints, and certain user "
495 : "objects. The pre-SMO residuals will be prefixed with * and will be used in the relative "
496 24 : "convergence check.\n";
497 24 : oss << COLOR_DEFAULT;
498 :
499 48 : return oss.str();
500 24 : }
501 :
502 : std::string
503 55165 : outputLegacyInformation(MooseApp & app)
504 : {
505 55165 : std::stringstream oss;
506 55165 : oss << std::left;
507 :
508 55165 : if (app.parameters().get<bool>("use_legacy_material_output"))
509 : {
510 4 : oss << COLOR_RED << "LEGACY MODES ENABLED:" << COLOR_DEFAULT << '\n';
511 : oss << " This application uses the legacy material output option: material properties are "
512 : "output only on TIMESTEP_END, not INITIAL. To remove this message, set "
513 : "'use_legacy_material_output' to false in this application. If there are gold output "
514 : "files that contain material property output for which output occurs on INITIAL, then "
515 : "these will generate diffs due to zero values being stored, and these tests should be "
516 : "re-golded.\n"
517 4 : << COLOR_DEFAULT << std::endl;
518 : }
519 :
520 55165 : if (app.parameters().get<bool>("use_legacy_initial_residual_evaluation_behavior"))
521 : {
522 4 : oss << COLOR_RED << "LEGACY MODES ENABLED:" << COLOR_DEFAULT << '\n';
523 : oss << " This application uses the legacy initial residual evaluation behavior. The legacy "
524 : "behavior performs an often times redundant residual evaluation before the solution "
525 : "modifying objects are executed prior to the initial (0th nonlinear iteration) residual "
526 : "evaluation. The new behavior skips that redundant residual evaluation unless the "
527 : "parameter Executioner/use_pre_smo_residual is set to true. To remove this message and "
528 : "enable the new behavior, set the parameter "
529 : "'use_legacy_initial_residual_evaluation_behavior' to false in *App.C. Some tests that "
530 : "rely on the side effects of the legacy behavior may fail/diff and should be "
531 : "re-golded.\n"
532 4 : << COLOR_DEFAULT << std::endl;
533 : }
534 :
535 110330 : return oss.str();
536 55165 : }
537 :
538 : std::string
539 9 : outputDataFilePaths()
540 : {
541 9 : std::stringstream oss;
542 9 : oss << "Data File Paths:\n";
543 27 : for (const auto & [name, path] : Registry::getDataFilePaths())
544 18 : oss << " " << name << ": " << path << "\n";
545 18 : return oss.str() + "\n";
546 9 : }
547 :
548 : std::string
549 9 : outputDataFileParams(MooseApp & app)
550 : {
551 9 : std::map<std::string, std::string> values; // for A-Z sort
552 483 : for (const auto & object_name_params_pair : app.getInputParameterWarehouse().getInputParameters())
553 : {
554 474 : const auto & params = object_name_params_pair.second;
555 11817 : for (const auto & name_value_pair : *params)
556 : {
557 11343 : const auto & name = name_value_pair.first;
558 11343 : if (const auto path = params->queryDataFileNamePath(name))
559 36 : if (params->getHitNode(name))
560 11343 : values.emplace(params->paramFullpath(name), path->path);
561 : }
562 : }
563 :
564 9 : std::stringstream oss;
565 9 : oss << "Data File Parameters:\n";
566 18 : for (const auto & [param, value] : values)
567 9 : oss << " " << param << " = " << value << "\n";
568 18 : return oss.str() + '\n';
569 9 : }
570 :
571 : void
572 355174 : insertNewline(std::stringstream & oss, std::streampos & begin, std::streampos & curr)
573 : {
574 355174 : if (curr - begin > console_line_length)
575 : {
576 5711 : oss << "\n";
577 5711 : begin = oss.tellp();
578 5711 : oss << std::setw(console_field_width + 2) << ""; // "{ "
579 : }
580 355174 : }
581 :
582 : std::string
583 58794 : formatString(std::string message, const std::string & prefix)
584 : {
585 58794 : MooseUtils::indentMessage(prefix, message, COLOR_DEFAULT, true, " ");
586 58794 : std::stringstream stream;
587 58794 : std::streampos start = stream.tellp();
588 58794 : stream << message;
589 58794 : std::streampos end = stream.tellp();
590 58794 : insertNewline(stream, start, end);
591 58794 : auto formatted_string = stream.str();
592 : // no need to end with a line break
593 58794 : if (formatted_string.back() == '\n')
594 0 : formatted_string.pop_back();
595 117588 : return formatted_string;
596 58794 : }
597 :
598 : std::string
599 10831 : mooseObjectVectorToString(const std::vector<MooseObject *> & objs, const std::string & sep /*=""*/)
600 : {
601 10831 : std::string object_names = "";
602 10831 : if (objs.size())
603 : {
604 : // Gather all the object names
605 10831 : std::vector<std::string> names;
606 10831 : names.reserve(objs.size());
607 30650 : for (const auto & obj : objs)
608 : {
609 : mooseAssert(obj, "Trying to print a null object");
610 19819 : names.push_back(obj->name());
611 : }
612 :
613 10831 : object_names = MooseUtils::join(names, sep);
614 10831 : }
615 10831 : return object_names;
616 0 : }
617 :
618 : } // ConsoleUtils namespace
|