forked from idaholab/falcon
-
Notifications
You must be signed in to change notification settings - Fork 0
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 idaholab#100 from somu15/timePP
Time integrated reporter value PP
- Loading branch information
Showing
6 changed files
with
183 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
doc/content/source/postprocessors/TimeIntegratedReporterValue.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 @@ | ||
# TimeIntegratedReporterValue | ||
|
||
!syntax description /Postprocessors/TimeIntegratedReporterValue | ||
|
||
## Description | ||
|
||
`TimeIntegratedReporterValue` computes the time integrated value of a reporter object. | ||
|
||
## Example Input Syntax | ||
|
||
!listing test/tests/time_integrated_reporter/main.i block=Postprocessors | ||
|
||
!syntax parameters /Postprocessors/TimeIntegratedReporterValue | ||
|
||
!syntax inputs /Postprocessors/TimeIntegratedReporterValue | ||
|
||
!syntax children /Postprocessors/TimeIntegratedReporterValue |
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,43 @@ | ||
//* 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" | ||
|
||
/** | ||
* Integrate a reporter value over time using trapezoidal rule | ||
*/ | ||
class TimeIntegratedReporterValue : public GeneralPostprocessor | ||
{ | ||
public: | ||
static InputParameters validParams(); | ||
|
||
TimeIntegratedReporterValue(const InputParameters & parameters); | ||
|
||
virtual void initialize() override; | ||
virtual void execute() override; | ||
virtual Real getValue() override; | ||
|
||
protected: | ||
/// The total value of the variable | ||
Real _value; | ||
|
||
/// My old value | ||
Real _value_old; | ||
|
||
/// The current post-processor value | ||
std::vector<Real> _pps_value; | ||
|
||
/// The old post-processor value | ||
Real _pps_value_old; | ||
|
||
/// Return negative value of the output | ||
const bool & _use_negative_value; | ||
}; |
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,52 @@ | ||
//* 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 "TimeIntegratedReporterValue.h" | ||
|
||
registerMooseObject("FalconApp", TimeIntegratedReporterValue); | ||
|
||
InputParameters | ||
TimeIntegratedReporterValue::validParams() | ||
{ | ||
InputParameters params = GeneralPostprocessor::validParams(); | ||
params.addClassDescription("Integrate a Postprocessor value over time using trapezoidal rule."); | ||
params.addRequiredParam<ReporterName>("reporter", "Reporter with the value."); | ||
params.addParam<bool>("use_negative_value", false, "Return negative value of the output."); | ||
return params; | ||
} | ||
|
||
TimeIntegratedReporterValue::TimeIntegratedReporterValue(const InputParameters & parameters) | ||
: GeneralPostprocessor(parameters), | ||
_value(0), | ||
_value_old(0), | ||
_pps_value(getReporterValue<std::vector<Real>>("reporter")), | ||
_pps_value_old(0), | ||
_use_negative_value(getParam<bool>("use_negative_value")) | ||
{ | ||
} | ||
|
||
void | ||
TimeIntegratedReporterValue::initialize() | ||
{ | ||
} | ||
|
||
void | ||
TimeIntegratedReporterValue::execute() | ||
{ | ||
_pps_value = getReporterValue<std::vector<Real>>("reporter"); | ||
_value = _value_old + 0.5 * (_pps_value[0] + _pps_value_old) * _dt; | ||
_pps_value_old = _pps_value[0]; | ||
_value_old = _value; | ||
} | ||
|
||
Real | ||
TimeIntegratedReporterValue::getValue() | ||
{ | ||
return _use_negative_value ? (-_value) : _value; | ||
} |
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,7 @@ | ||
time,int_value,pp | ||
0,0,1 | ||
1,-0.5,1 | ||
2,-1.5,1 | ||
3,-2.5,1 | ||
4,-3.5,1 | ||
5,-4.5,1 |
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,54 @@ | ||
[Mesh/mesh] | ||
type = GeneratedMeshGenerator | ||
dim = 1 | ||
[] | ||
|
||
[Problem] | ||
kernel_coverage_check = false | ||
solve = false | ||
[] | ||
|
||
[Functions/fun] | ||
type = ParsedFunction | ||
value = '1' | ||
[] | ||
|
||
[Postprocessors/pp] | ||
type = FunctionValuePostprocessor | ||
function = fun | ||
point = '1 0 0' | ||
execute_on = 'initial timestep_end' | ||
[] | ||
|
||
[Reporters] | ||
[accumulate] | ||
type = AccumulateReporter | ||
reporters = 'pp/value' | ||
[] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
num_steps = 5 | ||
|
||
fixed_point_max_its = 1 | ||
custom_pp = pp | ||
direct_pp_value = true | ||
disable_fixed_point_residual_norm_check = true | ||
accept_on_max_fixed_point_iteration = true | ||
[] | ||
|
||
[Postprocessors] | ||
[int_value] | ||
type = TimeIntegratedReporterValue | ||
reporter = 'accumulate/pp:value' | ||
use_negative_value = true | ||
[] | ||
[] | ||
|
||
[Outputs] | ||
[out] | ||
type = CSV | ||
execute_system_information_on = none | ||
[] | ||
[] |
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,10 @@ | ||
[Tests] | ||
[timeintegratedreporter] | ||
type = 'CSVDiff' | ||
input = 'main.i' | ||
csvdiff = 'main_out.csv' | ||
abs_zero = 1.0e-07 | ||
rel_err = 1.0e-04 | ||
[] | ||
[] | ||
|