https://mooseframework.inl.gov
Loading...
Searching...
No Matches
MaterialPropertyDebugOutput.C
Go to the documentation of this file.
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
12#include "FEProblem.h"
13#include "MooseApp.h"
14#include "Material.h"
15#include "ConsoleUtils.h"
16#include "MooseMesh.h"
17#include "MooseObjectName.h"
18
19#include "libmesh/transient_system.h"
20
22
25{
27 params.addClassDescription("Debug output object for displaying material property information.");
28 params.set<ExecFlagEnum>("execute_on") = EXEC_INITIAL;
29 return params;
30}
31
37
38void
40{
41 // Write out objects that consume properties
42 std::stringstream consumed;
43 for (const auto & pair : _problem_ptr->getConsumedPropertyMap())
44 {
45 consumed << " Object: " << pair.first << "\n";
46 consumed << " Properties: " << MooseUtils::join(pair.second, ", ") << "\n\n";
47 }
48
49 _console << "\n\nConsumed Material Properties:\n";
50 _console << std::setw(ConsoleUtils::console_field_width) << consumed.str() << std::endl;
51}
52
53void
55{
56 // Build output streams for block materials and block face materials
57 std::stringstream active_block, active_face, active_neighbor, active_boundary;
58
59 // Reference to mesh for getting boundary/block names
61
62 // Reference to the Material warehouse
64
65 // Active materials on block
66 {
67 const auto & objects = warehouse.getBlockObjects();
68 for (const auto & it : objects)
69 {
70 active_block << " Subdomain: " << mesh.getSubdomainName(it.first) << " (" << it.first
71 << ")\n";
72 printMaterialProperties(active_block, it.second);
73 }
74 }
75
76 // Active face materials on blocks
77 {
78 const auto & objects = warehouse[Moose::FACE_MATERIAL_DATA].getBlockObjects();
79 for (const auto & it : objects)
80 {
81 active_face << " Subdomain: " << mesh.getSubdomainName(it.first) << " (" << it.first
82 << ")\n";
83 printMaterialProperties(active_face, it.second);
84 }
85 }
86
87 // Active neighbor materials on blocks
88 {
89 const auto & objects = warehouse[Moose::NEIGHBOR_MATERIAL_DATA].getBlockObjects();
90 for (const auto & it : objects)
91 {
92 active_neighbor << " Subdomain: " << mesh.getSubdomainName(it.first) << " (" << it.first
93 << ")\n";
94 printMaterialProperties(active_neighbor, it.second);
95 }
96 }
97
98 // Active boundary materials
99 {
100 const auto & objects = warehouse.getBoundaryObjects();
101 for (const auto & it : objects)
102 {
103 active_boundary << " Boundary: " << mesh.getBoundaryName(it.first) << " (" << it.first
104 << ")\n";
105 printMaterialProperties(active_boundary, it.second);
106 }
107 }
108
109 // Write the stored strings to the ConsoleUtils output objects
110 _console << "\n\nActive Materials:\n";
111 _console << std::setw(ConsoleUtils::console_field_width) << active_block.str() << '\n';
112
113 _console << std::setw(ConsoleUtils::console_field_width) << "Active Face Materials:\n";
114 _console << std::setw(ConsoleUtils::console_field_width) << active_face.str() << '\n';
115
116 _console << std::setw(ConsoleUtils::console_field_width) << "Active Neighboring Materials:\n";
117 _console << std::setw(ConsoleUtils::console_field_width) << active_neighbor.str() << '\n';
118
119 _console << std::setw(ConsoleUtils::console_field_width) << "Active Boundary Materials:\n";
120 _console << std::setw(ConsoleUtils::console_field_width) << active_boundary.str() << std::endl;
121}
122
123void
125 std::stringstream & output, const std::vector<std::shared_ptr<MaterialBase>> & materials) const
126{
127 // Loop through all material objects
128 for (const auto & mat : materials)
129 {
130 // Get a list of properties for the current material
131 const std::set<std::string> & props = mat->getSuppliedItems();
132
133 // Adds the material name to the output stream
134 output << std::left << std::setw(ConsoleUtils::console_field_width)
135 << " Material Name: " << mat->name() << '\n';
136
137 // Build stream for properties using the ConsoleUtils helper functions to wrap the names if
138 // there are too many for one line
139 std::streampos begin_string_pos = output.tellp();
140 std::streampos curr_string_pos = begin_string_pos;
141 output << std::left << std::setw(ConsoleUtils::console_field_width) << " Property Names: ";
142 for (const auto & prop : props)
143 {
144 output << "\"" << prop << "\" ";
145 curr_string_pos = output.tellp();
146 ConsoleUtils::insertNewline(output, begin_string_pos, curr_string_pos);
147 }
148 output << '\n';
149 }
150
151 output << std::flush;
152}
registerMooseObject("MooseApp", MaterialPropertyDebugOutput)
const ExecFlagType EXEC_INITIAL
Definition Moose.C:30
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
std::streampos tellp() const
A MultiMooseEnum object to hold "execute_on" flags.
const MaterialWarehouse & getMaterialWarehouse() const
virtual MooseMesh & mesh() override
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
void addClassDescription(const std::string &doc_string)
This method adds a description of the class that will be displayed in the input file syntax dump.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
A class for producing various debug related outputs.
void printMaterialMap() const
Prints material property information in a format similar to Moose system information.
MaterialPropertyDebugOutput(const InputParameters &parameters)
virtual void output() override
Perform the debugging output.
void printMaterialProperties(std::stringstream &output, const std::vector< std::shared_ptr< MaterialBase > > &materials) const
Builds a output streams for the properties in each material object.
MaterialBase objects are special in that they have additional objects created automatically (see FEPr...
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition MooseMesh.h:95
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getBlockObjects(THREAD_ID tid=0) const
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getBoundaryObjects(THREAD_ID tid=0) const
Based class for output objects.
Definition Output.h:52
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
Definition Output.h:185
static InputParameters validParams()
Definition Output.C:32
const std::map< MooseObjectName, std::set< std::string > > & getConsumedPropertyMap() const
Return the map that tracks the object with consumed material properties.
Definition SubProblem.C:743
MeshBase & mesh
static const unsigned int console_field_width
Width used for printing simulation information.
void insertNewline(std::stringstream &oss, std::streampos &begin, std::streampos &curr)
Helper function function for stringstream formatting.
@ NEIGHBOR_MATERIAL_DATA
Definition MooseTypes.h:750
@ FACE_MATERIAL_DATA
Definition MooseTypes.h:749