-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds postprocessor to track time step number for transient problems
Minor quality-of-life improvement for users who want to track time step counts during their MOOSE simulations. closes #29127
- Loading branch information
1 parent
8a5faa9
commit c915948
Showing
6 changed files
with
199 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
framework/doc/content/source/postprocessors/NumTimeSteps.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# TimestepSize | ||
|
||
!syntax description /Postprocessors/NumTimeSteps | ||
|
||
## Description | ||
|
||
`NumTimeSteps` reports the timestep size. | ||
|
||
## Example Input Syntax | ||
|
||
!listing /Users/achaube/tools/moose/test/tests/postprocessors/num_time_steps/moose.i block=Postprocessors | ||
|
||
!syntax parameters /Postprocessors/NumTimeSteps | ||
|
||
!syntax inputs /Postprocessors/NumTimeSteps | ||
|
||
!syntax children /Postprocessors/NumTimeSteps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//* 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 | ||
|
||
#include "GeneralPostprocessor.h" | ||
|
||
class NumTimeSteps : public GeneralPostprocessor | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
NumTimeSteps(const InputParameters & parameters); | ||
|
||
virtual void initialize() override {} | ||
virtual void execute() override {} | ||
|
||
/** | ||
* This will return the current time step number. | ||
*/ | ||
virtual Real getValue() const override; | ||
|
||
protected: | ||
FEProblemBase & _feproblem; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//* 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 | ||
|
||
#include "NumTimeSteps.h" | ||
#include "FEProblem.h" | ||
|
||
registerMooseObject("MooseApp", NumTimeSteps); | ||
|
||
InputParameters | ||
NumTimeSteps::validParams() | ||
{ | ||
InputParameters params = GeneralPostprocessor::validParams(); | ||
params.addClassDescription("Reports the timestep number"); | ||
return params; | ||
} | ||
|
||
NumTimeSteps::NumTimeSteps(const InputParameters & parameters) | ||
: GeneralPostprocessor(parameters), _feproblem(dynamic_cast<FEProblemBase &>(_subproblem)) | ||
{ | ||
} | ||
|
||
Real | ||
NumTimeSteps::getValue() const | ||
{ | ||
return _feproblem.timeStep(); | ||
} |
12 changes: 12 additions & 0 deletions
12
test/tests/postprocessors/num_time_steps/gold/moose_out.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
time,timestep_ctr | ||
0,0 | ||
1,1 | ||
2,2 | ||
3,3 | ||
4,4 | ||
5,5 | ||
6,6 | ||
7,7 | ||
8,8 | ||
9,9 | ||
10,10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 3 | ||
nx = 30 | ||
ny = 30 | ||
nz = 30 | ||
[] | ||
|
||
[Variables] | ||
[temperature] | ||
initial_condition = 500.0 | ||
[] | ||
[] | ||
|
||
[AuxVariables] | ||
[source] | ||
[] | ||
[] | ||
|
||
[Kernels] | ||
[conduction] | ||
type = HeatConduction | ||
variable = temperature | ||
[] | ||
[source] | ||
type = CoupledForce | ||
variable = temperature | ||
v = source | ||
[] | ||
[] | ||
|
||
[AuxKernels] | ||
[source] | ||
type = ParsedAux | ||
variable = source | ||
function = 'temperature*7*t' | ||
coupled_variables = 'temperature' | ||
execute_on = 'linear' | ||
use_xyzt = true | ||
[] | ||
[] | ||
|
||
[BCs] | ||
[left] | ||
type = DirichletBC | ||
variable = temperature | ||
boundary = 'left' | ||
value = 500.0 | ||
[] | ||
[right] | ||
type = DirichletBC | ||
variable = temperature | ||
boundary = 'right' | ||
value = 600.0 | ||
[] | ||
[top] | ||
type = DirichletBC | ||
variable = temperature | ||
boundary = 'top' | ||
value = 650.0 | ||
[] | ||
[front] | ||
type = DirichletBC | ||
variable = temperature | ||
boundary = 'front' | ||
value = 650.0 | ||
[] | ||
[] | ||
|
||
[Materials] | ||
[k] | ||
type = GenericConstantMaterial | ||
prop_names = 'thermal_conductivity' | ||
prop_values = '1.5' | ||
[] | ||
[] | ||
|
||
[Postprocessors] | ||
[timestep_ctr] | ||
type = NumTimeSteps | ||
[] | ||
[] | ||
|
||
|
||
[Executioner] | ||
type = Transient | ||
nl_abs_tol = 1e-10 | ||
nl_rel_tol = 1e-4 | ||
dt = 1 | ||
num_steps = 10 | ||
[] | ||
|
||
[Outputs] | ||
exodus = false | ||
csv = true | ||
hide = 'source temperature' | ||
[] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Tests] | ||
[num_time_steps] | ||
type = 'CSVDiff' | ||
input = 'numtimesteps.i' | ||
csvdiff = 'numtimesteps_out.csv' | ||
requirement = 'The postprocessor `NumTimeSteps` shall count the number of time-steps accurately' | ||
'over the course of a transient solve' | ||
[] | ||
[] |