Skip to content

Commit

Permalink
Merge pull request #28291 from grunerjmeier/BlockRestrictionDebugOutput
Browse files Browse the repository at this point in the history
add BlockRestrictionDebugOutput
  • Loading branch information
GiudGiud authored Aug 6, 2024
2 parents 9bca361 + ae976e5 commit 004e08e
Show file tree
Hide file tree
Showing 9 changed files with 575 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# BlockRestrictionDebugOutput

!syntax description /Outputs/BlockRestrictionDebugOutput

## Overview

The BlockRestrictionDebugOutput object is, as the name suggests, designed to write out
information regarding block-restriction of Moose objects for debugging purposes. Please
refer to the [Debug/index.md] for more information.

!syntax parameters /Outputs/BlockRestrictionDebugOutput

!syntax inputs /Outputs/BlockRestrictionDebugOutput

!syntax children /Outputs/BlockRestrictionDebugOutput
1 change: 1 addition & 0 deletions framework/doc/content/syntax/Debug/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ for most objects, list the objects created by an action. The `Debug` system also
- [!param](/Debug/show_material_props) for material properties, created on elements, neighbors and sides
- [!param](/Debug/show_reporters) for reporters, created directly or from systems that derive from Reporters, such as [VectorPostprocessors](syntax/Postprocessors/index.md) and [Positions](syntax/Positions/index.md)
- [!param](/Debug/show_functors) for [Functors](syntax/Functors/index.md), an abstraction for objects which includes [Functions](syntax/Functions/index.md) and [Variables](syntax/Variables/index.md)
- [!param](/Debug/show_block_restriction) for information regarding block-restriction of objects


Additionally, [!param](/Debug/show_execution_order) will provide the list of objects executed as they are executed.
Expand Down
53 changes: 53 additions & 0 deletions framework/include/outputs/BlockRestrictionDebugOutput.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

// MOOSE includes
#include "Output.h"

// Forward declarations
class NonlinearSystemBase;
/**
* A class for producing various debug related outputs
*
* This class may be used from inside the [Outputs] block or via the [Debug] block (preferred)
*/
class BlockRestrictionDebugOutput : public Output
{
public:
static InputParameters validParams();

/**
* Get the supported scopes of output (e.g., variables, etc.)
*/
static MultiMooseEnum getScopes(std::string default_scopes = "");

BlockRestrictionDebugOutput(const InputParameters & parameters);

protected:
/// multi-enum of object types to show the block-restriction for
const MultiMooseEnum & _scope;

/// Reference to MOOSE's nonlinear system
const NonlinearSystemBase & _nl;

/// Reference to libMesh system
const System & _sys;

/**
* Perform the debugging output
*/
virtual void output() override;

/**
* Prints block-restriction information
*/
void printBlockRestrictionMap() const;
};
1 change: 1 addition & 0 deletions framework/include/systems/NonlinearSystemBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@ class NonlinearSystemBase : public SolverSystem, public PerfGraphInterface
* Access functions to Warehouses from outside NonlinearSystemBase
*/
MooseObjectTagWarehouse<KernelBase> & getKernelWarehouse() { return _kernels; }
const MooseObjectTagWarehouse<KernelBase> & getKernelWarehouse() const { return _kernels; }
MooseObjectTagWarehouse<DGKernelBase> & getDGKernelWarehouse() { return _dg_kernels; }
MooseObjectTagWarehouse<InterfaceKernelBase> & getInterfaceKernelWarehouse()
{
Expand Down
16 changes: 16 additions & 0 deletions framework/src/actions/SetupDebugAction.C
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "ActionFactory.h"
#include "AddAuxVariableAction.h"
#include "MooseUtils.h"
#include "BlockRestrictionDebugOutput.h"

registerMooseAction("MooseApp", SetupDebugAction, "add_output");

Expand Down Expand Up @@ -60,6 +61,10 @@ SetupDebugAction::validParams()
"Add a AuxVariable named \"pid\" that shows the partitioning for each process");
params.addParam<bool>(
"show_functors", false, "Whether to print information about the functors in the problem");
params.addParam<MultiMooseEnum>(
"show_block_restriction",
BlockRestrictionDebugOutput::getScopes("none"),
"Print out active objects like variables supplied for each block.");

params.addClassDescription("Adds various debugging type output to the simulation system.");

Expand Down Expand Up @@ -143,4 +148,15 @@ SetupDebugAction::act()
// Add functor output
if (getParam<bool>("show_functors"))
_problem->setFunctorOutput(getParam<bool>("show_functors"));

// Block-restriction
const MultiMooseEnum & block_restriction_scope =
_pars.get<MultiMooseEnum>("show_block_restriction");
if (block_restriction_scope.isValid() && !block_restriction_scope.contains("none"))
{
const std::string type = "BlockRestrictionDebugOutput";
auto params = _factory.getValidParams(type);
params.set<MultiMooseEnum>("scope") = block_restriction_scope;
_problem->addOutput(type, "_moose_block_restriction_debug_output", params);
}
}
Loading

0 comments on commit 004e08e

Please sign in to comment.