Skip to content

Commit

Permalink
Add pid_aux option to [Debug]
Browse files Browse the repository at this point in the history
  • Loading branch information
loganharbour authored and jain651 committed Apr 19, 2021
1 parent d68ad8c commit a50f4c5
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 0 deletions.
21 changes: 21 additions & 0 deletions framework/src/actions/SetupDebugAction.C
Expand Up @@ -15,6 +15,7 @@
#include "MooseApp.h"
#include "MooseObjectAction.h"
#include "ActionFactory.h"
#include "AddAuxVariableAction.h"

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

Expand All @@ -38,6 +39,10 @@ SetupDebugAction::validParams()
false,
"Print out the material properties supplied for each block, face, neighbor, and/or sideset");
params.addParam<bool>("show_mesh_meta_data", false, "Print out the available mesh meta data");
params.addParam<bool>(
"pid_aux",
false,
"Add a AuxVariable named \"pid\" that shows the processors and partitioning");

params.addClassDescription(
"Adds various debugging type Output objects to the simulation system.");
Expand Down Expand Up @@ -88,4 +93,20 @@ SetupDebugAction::act()
for (auto & pair : it->second.first)
_console << " " << pair.first << std::endl;
}

// Add pid aux
if (getParam<bool>("pid_aux"))
{
if (_problem->hasVariable("pid"))
paramError("pid_aux", "Variable with the name \"pid\" already exists");

auto fe_type = FEType(CONSTANT, MONOMIAL);
auto type = AddAuxVariableAction::determineType(fe_type, 1);
auto var_params = _factory.getValidParams(type);
_problem->addAuxVariable(type, "pid", var_params);

InputParameters params = _factory.getValidParams("ProcessorIDAux");
params.set<AuxVariableName>("variable") = "pid";
_problem->addAuxKernel("ProcessorIDAux", "pid_aux", params);
}
}
28 changes: 28 additions & 0 deletions test/tests/misc/debug_pid_aux/debug_pid_aux.i
@@ -0,0 +1,28 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 8
ny = 8
[Partitioner]
type = GridPartitioner
nx = 2
ny = 2
nz = 1
[]
[]

[Debug]
pid_aux = true
[]

[Problem]
solve = false
[]

[Executioner]
type = Steady
[]

[Outputs]
exodus = true
[]
Binary file not shown.
15 changes: 15 additions & 0 deletions test/tests/misc/debug_pid_aux/tests
@@ -0,0 +1,15 @@
[Tests]
[test]
type = 'Exodiff'
input = 'debug_pid_aux.i'
exodiff = 'debug_pid_aux_out.e'

requirement = 'The system shall support the output a processor id field for the purposes of debugging'
issues = '#16154'
design = 'SetupDebugAction.md ProcessorIDAux.md'

min_parallel = 4
max_parallel = 4
mesh_mode = REPLICATED
[]
[]

0 comments on commit a50f4c5

Please sign in to comment.