www.mooseframework.org
MaterialPropertyDebugOutput.C
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 // MOOSE includes
17 #include "FEProblem.h"
18 #include "MooseApp.h"
19 #include "Material.h"
20 #include "ConsoleUtils.h"
21 #include "MooseMesh.h"
22 
23 #include "libmesh/transient_system.h"
24 
25 template <>
28 {
30 
31  // This object only outputs data once, in the constructor, so disable fine control
32  params.suppressParameter<MultiMooseEnum>("execute_on");
33 
34  return params;
35 }
36 
38  : Output(parameters)
39 {
41 }
42 
43 void
45 {
46 }
47 
48 void
50 {
51  // Build output streams for block materials and block face materials
52  std::stringstream active_block, active_face, active_neighbor, active_boundary;
53 
54  // Reference to mesh for getting boundary/block names
55  MooseMesh & mesh = _problem_ptr->mesh();
56 
57  // Reference to the Material warehouse
59 
60  // Active materials on block
61  {
62  const auto & objects = warehouse.getBlockObjects();
63  for (const auto & it : objects)
64  {
65  active_block << " Subdomain: " << mesh.getSubdomainName(it.first) << " (" << it.first
66  << ")\n";
67  printMaterialProperties(active_block, it.second);
68  }
69  }
70 
71  // Active face materials on blocks
72  {
73  const auto & objects = warehouse[Moose::FACE_MATERIAL_DATA].getBlockObjects();
74  for (const auto & it : objects)
75  {
76  active_block << " Subdomain: " << mesh.getSubdomainName(it.first) << " (" << it.first
77  << ")\n";
78  printMaterialProperties(active_face, it.second);
79  }
80  }
81 
82  // Active neighbor materials on blocks
83  {
84  const auto & objects = warehouse[Moose::NEIGHBOR_MATERIAL_DATA].getBlockObjects();
85  for (const auto & it : objects)
86  {
87  active_block << " Subdomain: " << mesh.getSubdomainName(it.first) << " (" << it.first
88  << ")\n";
89  printMaterialProperties(active_neighbor, it.second);
90  }
91  }
92 
93  // Active boundary materials
94  {
95  const auto & objects = warehouse.getBoundaryObjects();
96  for (const auto & it : objects)
97  {
98  active_boundary << " Boundary: " << mesh.getBoundaryName(it.first) << " (" << it.first
99  << ")\n";
100  printMaterialProperties(active_boundary, it.second);
101  }
102  }
103 
104  // Write the stored strings to the ConsoleUtils output objects
105  _console << "\n\nActive Materials:\n";
106  _console << std::setw(ConsoleUtils::console_field_width) << active_block.str() << '\n';
107 
108  _console << std::setw(ConsoleUtils::console_field_width) << "Active Face Materials:\n";
109  _console << std::setw(ConsoleUtils::console_field_width) << active_face.str() << '\n';
110 
111  _console << std::setw(ConsoleUtils::console_field_width) << "Active Neighboring Materials:\n";
112  _console << std::setw(ConsoleUtils::console_field_width) << active_neighbor.str() << '\n';
113 
114  _console << std::setw(ConsoleUtils::console_field_width) << "Active Boundary Materials:\n";
115  _console << std::setw(ConsoleUtils::console_field_width) << active_boundary.str() << '\n';
116 }
117 
118 void
120  std::stringstream & output, const std::vector<std::shared_ptr<Material>> & materials) const
121 {
122  // Loop through all material objects
123  for (const auto & mat : materials)
124  {
125  // Get a list of properties for the current material
126  const std::set<std::string> & props = mat->getSuppliedItems();
127 
128  // Adds the material name to the output stream
129  output << std::left << std::setw(ConsoleUtils::console_field_width)
130  << " Material Name: " << mat->name() << '\n';
131 
132  // Build stream for properties using the ConsoleUtils helper functions to wrap the names if
133  // there are too many for one line
134  std::streampos begin_string_pos = output.tellp();
135  std::streampos curr_string_pos = begin_string_pos;
136  output << std::left << std::setw(ConsoleUtils::console_field_width) << " Property Names: ";
137  for (const auto & prop : props)
138  {
139  output << "\"" << prop << "\" ";
140  curr_string_pos = output.tellp();
141  ConsoleUtils::insertNewline(output, begin_string_pos, curr_string_pos);
142  }
143  output << '\n';
144  }
145 }
const std::string & getBoundaryName(BoundaryID boundary_id)
Return the name of the boundary given the id.
Definition: MooseMesh.C:1068
void printMaterialProperties(std::stringstream &output, const std::vector< std::shared_ptr< Material >> &materials) const
Builds a output streams for the properties in each material object.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
Material objects are special in that they have additional objects created automatically (see FEProble...
const std::map< BoundaryID, std::vector< std::shared_ptr< T > > > & getBoundaryObjects(THREAD_ID tid=0) const
static const unsigned int console_field_width
Width used for printing simulation information.
Definition: ConsoleUtils.h:35
void suppressParameter(const std::string &name)
This method suppresses an inherited parameter so that it isn&#39;t required or valid in the derived class...
Based class for output objects.
Definition: Output.h:45
MaterialPropertyDebugOutput(const InputParameters &parameters)
Class constructor.
void insertNewline(std::stringstream &oss, std::streampos &begin, std::streampos &curr)
Helper function function for stringstream formatting.
Definition: ConsoleUtils.C:269
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
Definition: Output.h:171
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Definition: MooseMesh.h:74
InputParameters validParams< Output >()
Definition: Output.C:34
virtual void output(const ExecFlagType &type) override
Perform the debugging output For this object this is empty; the output is preformed in the constructo...
void printMaterialMap() const
Prints material property information in a format similar to Moose system information.
const MaterialWarehouse & getMaterialWarehouse()
const std::map< SubdomainID, std::vector< std::shared_ptr< T > > > & getBlockObjects(THREAD_ID tid=0) const
virtual MooseMesh & mesh() override
ExecFlagType
Execution flags - when is the object executed/evaluated.
Definition: MooseTypes.h:90
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
This is a "smart" enum class intended to replace many of the shortcomings in the C++ enum type It sho...
InputParameters validParams< MaterialPropertyDebugOutput >()
const std::string & getSubdomainName(SubdomainID subdomain_id)
Return the name of a block given an id.
Definition: MooseMesh.C:1046