24 #include "libmesh/transient_system.h" 37 "The types of object to output block coverage for, if nothing is " 38 "provided everything will be output.");
40 params.
addParam<NonlinearSystemName>(
41 "nl_sys",
"nl0",
"The nonlinear system that we should output information for.");
44 "Debug output object for displaying information regarding block-restriction of objects.");
52 return MultiMooseEnum(
"none all variables kernels auxvariables auxkernels materials userobjects",
59 _nl(_problem_ptr->getNonlinearSystemBase(
60 _problem_ptr->nlSysNum(getParam<NonlinearSystemName>(
"nl_sys")))),
79 std::stringstream
out;
81 auto printCategoryAndNames = [&
out](std::string category, std::set<std::string> & names)
83 const auto n = names.size();
87 out <<
" " << category <<
" (" << n <<
" " << ((n == 1) ?
"item" :
"items") <<
"): ";
91 std::streampos begin_string_pos =
out.
tellp();
92 std::streampos curr_string_pos = begin_string_pos;
94 for (
const auto &
name : names)
113 const std::set<SubdomainID> & mesh_subdomains =
mesh.meshSubdomains();
117 const auto & kernels = kernel_warehouse.
getObjects( 0);
126 std::vector<UserObject *> userObjects;
130 .condition<AttribThread>(0)
131 .queryIntoUnsorted(userObjects);
137 for (
const auto & subdomain_id : mesh_subdomains)
140 const auto & subdomain_name =
mesh.getSubdomainName(subdomain_id);
143 out <<
" Subdomain '" << subdomain_name <<
"' (id " << subdomain_id <<
"):\n";
145 bool objectsFound =
false;
150 std::set<std::string> names;
151 for (
unsigned int var_num = 0; var_num <
_sys.
n_vars(); var_num++)
165 objectsFound = printCategoryAndNames(
"Variables", names) || objectsFound;
171 std::set<std::string> names;
172 for (
const auto & kernel : kernels)
174 if (kernel->hasBlocks(subdomain_id))
175 names.insert(kernel->name());
177 objectsFound = printCategoryAndNames(
"Kernels", names) || objectsFound;
183 std::set<std::string> names;
184 const auto & sys = auxSystem.system();
185 for (
unsigned int vg = 0; vg < sys.n_variable_groups(); vg++)
187 const VariableGroup & vg_description(sys.variable_group(vg));
188 for (
unsigned int vn = 0; vn < vg_description.n_variables(); vn++)
190 if (vg_description.active_on_subdomain(subdomain_id))
191 names.insert(vg_description.name(vn));
194 objectsFound = printCategoryAndNames(
"AuxVariables", names) || objectsFound;
202 const auto & wh = auxSystem.nodalAuxWarehouse();
203 std::set<std::string> names;
204 if (wh.hasActiveBlockObjects(subdomain_id))
206 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
207 for (
auto & auxkernel : auxkernels)
208 names.insert(auxkernel->name());
210 objectsFound = printCategoryAndNames(
"AuxKernels[nodal]", names) || objectsFound;
214 const auto & wh = auxSystem.nodalVectorAuxWarehouse();
215 std::set<std::string> names;
216 if (wh.hasActiveBlockObjects(subdomain_id))
218 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
219 for (
auto & auxkernel : auxkernels)
220 names.insert(auxkernel->name());
222 objectsFound = printCategoryAndNames(
"AuxKernels[nodalVector]", names) || objectsFound;
226 const auto & wh = auxSystem.nodalArrayAuxWarehouse();
227 std::set<std::string> names;
228 if (wh.hasActiveBlockObjects(subdomain_id))
230 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
231 for (
auto & auxkernel : auxkernels)
232 names.insert(auxkernel->name());
234 objectsFound = printCategoryAndNames(
"AuxKernels[nodalArray]", names) || objectsFound;
238 const auto & wh = auxSystem.elemAuxWarehouse();
239 std::set<std::string> names;
240 if (wh.hasActiveBlockObjects(subdomain_id))
242 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
243 for (
auto & auxkernel : auxkernels)
244 names.insert(auxkernel->name());
246 objectsFound = printCategoryAndNames(
"AuxKernels[elemAux]", names) || objectsFound;
250 const auto & wh = auxSystem.elemVectorAuxWarehouse();
251 std::set<std::string> names;
252 if (wh.hasActiveBlockObjects(subdomain_id))
254 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
255 for (
auto & auxkernel : auxkernels)
256 names.insert(auxkernel->name());
258 objectsFound = printCategoryAndNames(
"AuxKernels[elemVector]", names) || objectsFound;
262 const auto & wh = auxSystem.elemArrayAuxWarehouse();
263 std::set<std::string> names;
264 if (wh.hasActiveBlockObjects(subdomain_id))
266 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
267 for (
auto & auxkernel : auxkernels)
268 names.insert(auxkernel->name());
270 objectsFound = printCategoryAndNames(
"AuxKernels[elemArray]", names) || objectsFound;
277 std::set<std::string> names;
278 if (material_warehouse.hasActiveBlockObjects(subdomain_id))
280 auto const objs = material_warehouse.getBlockObjects(subdomain_id);
281 for (
const auto & mat : objs)
282 names.insert(mat->name());
284 objectsFound = printCategoryAndNames(
"Materials", names) || objectsFound;
290 std::set<std::string> names;
291 for (
const auto & obj : userObjects)
292 if (
BlockRestrictable * blockrestrictable_obj = dynamic_cast<BlockRestrictable *>(obj))
293 if (blockrestrictable_obj->hasBlocks(subdomain_id))
294 names.insert(obj->name());
295 objectsFound = printCategoryAndNames(
"UserObjects", names) || objectsFound;
299 out <<
" (no objects found)\n";
305 _console <<
"\n[DBG] Block-Restrictions (" << mesh_subdomains.size()
306 <<
" subdomains): showing active objects\n";
virtual bool hasVariable(const std::string &var_name) const override
Whether or not this problem has the variable.
BlockRestrictionDebugOutput(const InputParameters ¶meters)
A MultiMooseEnum object to hold "execute_on" flags.
void printBlockRestrictionMap() const
Prints block-restriction information.
virtual bool isValid() const override
IsValid.
virtual void output() override
Perform the debugging output.
MooseObjectTagWarehouse< KernelBase > & getKernelWarehouse()
Access functions to Warehouses from outside NonlinearSystemBase.
A class for producing various debug related outputs.
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...
const MaterialWarehouse & getMaterialWarehouse() const
const NonlinearSystemBase & _nl
Reference to MOOSE's nonlinear system.
virtual const std::string & name() const
Get the name of the class.
virtual const MooseVariableFieldBase & getVariable(const THREAD_ID tid, const std::string &var_name, Moose::VarKindType expected_var_type=Moose::VarKindType::VAR_ANY, Moose::VarFieldType expected_var_field_type=Moose::VarFieldType::VAR_FIELD_ANY) const override
Returns the variable reference for requested variable which must be of the expected_var_type (Nonline...
static const unsigned int console_field_width
Width used for printing simulation information.
Based class for output objects.
bool contains(const std::string &value) const
Methods for seeing if a value is set in the MultiMooseEnum.
const std::vector< std::shared_ptr< T > > & getObjects(THREAD_ID tid=0) const
Retrieve complete vector to the all/block/boundary restricted objects for a given thread...
TheWarehouse & theWarehouse() const
const MultiMooseEnum & _scope
multi-enum of object types to show the block-restriction for
void insertNewline(std::stringstream &oss, std::streampos &begin, std::streampos &curr)
Helper function function for stringstream formatting.
FEProblemBase * _problem_ptr
Pointer the the FEProblemBase object for output object (use this)
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
const std::string & variable_name(const unsigned int i) const
static InputParameters validParams()
std::string stringify(const T &t)
conversion to string
AuxiliarySystem & getAuxiliarySystem()
registerMooseObject("MooseApp", BlockRestrictionDebugOutput)
virtual void insert(libMesh::NumericVector< libMesh::Number > &vector)=0
Insert the currently cached degree of freedom values into the provided vector.
Query query()
query creates and returns an initialized a query object for querying objects from the warehouse...
static MultiMooseEnum getScopes(std::string default_scopes="")
Get the supported scopes of output (e.g., variables, etc.)
An interface that restricts an object to subdomains via the 'blocks' input parameter.
virtual MooseMesh & mesh() override
QueryCache & condition(Args &&... args)
Adds a new condition to the query.
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...
bool hasBlocks(const SubdomainName &name) const
Test if the supplied block name is valid for this object.
unsigned int n_vars() const
static InputParameters validParams()
const libMesh::System & _sys
Reference to libMesh system.
const ExecFlagType EXEC_INITIAL