-
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.
Merge pull request #29128 from anshchaube/num_time_steps
Adds postprocessor to track time step number for transient problems
- Loading branch information
Showing
6 changed files
with
125 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
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,13 @@ | ||
# NumTimeSteps | ||
|
||
!syntax description /Postprocessors/NumTimeSteps | ||
|
||
## Example Input Syntax | ||
|
||
!listing /test/tests/postprocessors/num_time_steps/numtimesteps.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,34 @@ | ||
//* 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" | ||
|
||
/** | ||
* Reports on the number of time steps already taken in the transient | ||
*/ | ||
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/numtimesteps_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 | ||
0.001,1 | ||
0.002,2 | ||
0.003,3 | ||
0.004,4 | ||
0.005,5 | ||
0.006,6 | ||
0.007,7 | ||
0.008,8 | ||
0.009,9 | ||
0.01,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,23 @@ | ||
[Mesh/gmg] | ||
type = GeneratedMeshGenerator | ||
dim = 1 | ||
[] | ||
|
||
[Postprocessors/timestep_ctr] | ||
type = NumTimeSteps | ||
[] | ||
|
||
[Problem] | ||
solve = False | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
dt = 0.001 | ||
num_steps = 10 | ||
[] | ||
|
||
[Outputs] | ||
csv = true | ||
exodus = false | ||
[] |
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,11 @@ | ||
[Tests] | ||
issues = '#29127' | ||
design = 'NumTimeSteps.md' | ||
[num_time_steps] | ||
type = 'CSVDiff' | ||
input = 'numtimesteps.i' | ||
csvdiff = 'numtimesteps_out.csv' | ||
requirement = 'The postprocessor shall be able to count the number of time-steps that have been taken ' | ||
'over the course of the simulation of a transient.' | ||
[] | ||
[] |