25 #include "libmesh/transient_system.h" 38 "The types of object to output block coverage for, if nothing is " 39 "provided everything will be output.");
41 params.
addParam<NonlinearSystemName>(
42 "nl_sys",
"nl0",
"The nonlinear system that we should output information for.");
45 "Debug output object for displaying information regarding block-restriction of objects.");
53 return MultiMooseEnum(
"none all variables kernels auxvariables auxkernels materials userobjects",
60 _nl(_problem_ptr->getNonlinearSystemBase(
61 _problem_ptr->nlSysNum(getParam<NonlinearSystemName>(
"nl_sys")))),
80 std::stringstream
out;
82 auto printCategoryAndNames = [&
out](std::string category, std::set<std::string> & names)
84 const auto n = names.size();
88 out <<
" " << category <<
" (" << n <<
" " << ((n == 1) ?
"item" :
"items") <<
"): ";
92 std::streampos begin_string_pos =
out.
tellp();
93 std::streampos curr_string_pos = begin_string_pos;
95 for (
const auto &
name : names)
114 const std::set<SubdomainID> & mesh_subdomains =
mesh.meshSubdomains();
118 const auto & kernels = kernel_warehouse.
getObjects( 0);
127 std::vector<UserObject *> userObjects;
131 .condition<AttribThread>(0)
132 .queryIntoUnsorted(userObjects);
138 for (
const auto & subdomain_id : mesh_subdomains)
141 const auto & subdomain_name =
mesh.getSubdomainName(subdomain_id);
144 out <<
" Subdomain '" << subdomain_name <<
"' (id " << subdomain_id <<
"):\n";
146 bool objectsFound =
false;
151 std::set<std::string> names;
152 for (
unsigned int var_num = 0; var_num <
_sys.
n_vars(); var_num++)
166 objectsFound = printCategoryAndNames(
"Variables", names) || objectsFound;
172 std::set<std::string> names;
173 for (
const auto & kernel : kernels)
175 if (kernel->hasBlocks(subdomain_id))
176 names.insert(kernel->name());
178 objectsFound = printCategoryAndNames(
"Kernels", names) || objectsFound;
184 std::set<std::string> names;
185 const auto & sys = auxSystem.system();
186 for (
unsigned int vg = 0; vg < sys.n_variable_groups(); vg++)
188 const VariableGroup & vg_description(sys.variable_group(vg));
189 for (
unsigned int vn = 0; vn < vg_description.n_variables(); vn++)
191 if (vg_description.active_on_subdomain(subdomain_id))
192 names.insert(vg_description.name(vn));
195 objectsFound = printCategoryAndNames(
"AuxVariables", names) || objectsFound;
203 const auto & wh = auxSystem.nodalAuxWarehouse();
204 std::set<std::string> names;
205 if (wh.hasActiveBlockObjects(subdomain_id))
207 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
208 for (
auto & auxkernel : auxkernels)
209 names.insert(auxkernel->name());
211 objectsFound = printCategoryAndNames(
"AuxKernels[nodal]", names) || objectsFound;
215 const auto & wh = auxSystem.nodalVectorAuxWarehouse();
216 std::set<std::string> names;
217 if (wh.hasActiveBlockObjects(subdomain_id))
219 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
220 for (
auto & auxkernel : auxkernels)
221 names.insert(auxkernel->name());
223 objectsFound = printCategoryAndNames(
"AuxKernels[nodalVector]", names) || objectsFound;
227 const auto & wh = auxSystem.nodalArrayAuxWarehouse();
228 std::set<std::string> names;
229 if (wh.hasActiveBlockObjects(subdomain_id))
231 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
232 for (
auto & auxkernel : auxkernels)
233 names.insert(auxkernel->name());
235 objectsFound = printCategoryAndNames(
"AuxKernels[nodalArray]", names) || objectsFound;
239 const auto & wh = auxSystem.elemAuxWarehouse();
240 std::set<std::string> names;
241 if (wh.hasActiveBlockObjects(subdomain_id))
243 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
244 for (
auto & auxkernel : auxkernels)
245 names.insert(auxkernel->name());
247 objectsFound = printCategoryAndNames(
"AuxKernels[elemAux]", names) || objectsFound;
251 const auto & wh = auxSystem.elemVectorAuxWarehouse();
252 std::set<std::string> names;
253 if (wh.hasActiveBlockObjects(subdomain_id))
255 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
256 for (
auto & auxkernel : auxkernels)
257 names.insert(auxkernel->name());
259 objectsFound = printCategoryAndNames(
"AuxKernels[elemVector]", names) || objectsFound;
263 const auto & wh = auxSystem.elemArrayAuxWarehouse();
264 std::set<std::string> names;
265 if (wh.hasActiveBlockObjects(subdomain_id))
267 const auto & auxkernels = wh.getActiveBlockObjects(subdomain_id);
268 for (
auto & auxkernel : auxkernels)
269 names.insert(auxkernel->name());
271 objectsFound = printCategoryAndNames(
"AuxKernels[elemArray]", names) || objectsFound;
278 std::set<std::string> names;
279 if (material_warehouse.hasActiveBlockObjects(subdomain_id))
281 auto const objs = material_warehouse.getBlockObjects(subdomain_id);
282 for (
const auto & mat : objs)
283 names.insert(mat->name());
285 objectsFound = printCategoryAndNames(
"Materials", names) || objectsFound;
291 std::set<std::string> names;
292 for (
const auto & obj : userObjects)
293 if (
BlockRestrictable * blockrestrictable_obj = dynamic_cast<BlockRestrictable *>(obj))
294 if (blockrestrictable_obj->hasBlocks(subdomain_id))
295 names.insert(obj->name());
296 objectsFound = printCategoryAndNames(
"UserObjects", names) || objectsFound;
300 out <<
" (no objects found)\n";
306 _console <<
"\n[DBG] Block-Restrictions (" << mesh_subdomains.size()
307 <<
" 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 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::string & name() const
Get the name of the class.
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