forked from idaholab/moose
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding TimeExtremeValue Postprocessor
closes idaholab#6902
- Loading branch information
Showing
6 changed files
with
224 additions
and
0 deletions.
There are no files selected for viewing
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,57 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#ifndef TIMEEXTREMEVALUE_H | ||
#define TIMEEXTREMEVALUE_H | ||
|
||
#include "GeneralPostprocessor.h" | ||
|
||
//Forward Declarations | ||
class TimeExtremeValue; | ||
|
||
// Input parameters | ||
template<> | ||
InputParameters validParams<TimeExtremeValue>(); | ||
|
||
/// A postprocessor for reporting the max/min value of another postprocessor over time | ||
class TimeExtremeValue : public GeneralPostprocessor | ||
{ | ||
public: | ||
/// What type of extreme value we are going to compute | ||
enum ExtremeType | ||
{ | ||
MAX, | ||
MIN | ||
}; | ||
|
||
/** | ||
* Class constructor | ||
* @param parameters The input parameters | ||
*/ | ||
TimeExtremeValue(const InputParameters & parameters); | ||
virtual void initialize() {} | ||
virtual void execute(); | ||
virtual Real getValue(); | ||
|
||
protected: | ||
const PostprocessorValue & _postprocessor; | ||
|
||
/// The extreme value type ("min" or "max") | ||
ExtremeType _type; | ||
|
||
/// The extreme value | ||
Real _value; | ||
}; | ||
|
||
#endif |
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
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,62 @@ | ||
/****************************************************************/ | ||
/* DO NOT MODIFY THIS HEADER */ | ||
/* MOOSE - Multiphysics Object Oriented Simulation Environment */ | ||
/* */ | ||
/* (c) 2010 Battelle Energy Alliance, LLC */ | ||
/* ALL RIGHTS RESERVED */ | ||
/* */ | ||
/* Prepared by Battelle Energy Alliance, LLC */ | ||
/* Under Contract No. DE-AC07-05ID14517 */ | ||
/* With the U. S. Department of Energy */ | ||
/* */ | ||
/* See COPYRIGHT for full restrictions */ | ||
/****************************************************************/ | ||
|
||
#include "TimeExtremeValue.h" | ||
|
||
#include <algorithm> | ||
#include <limits> | ||
|
||
template<> | ||
InputParameters validParams<TimeExtremeValue>() | ||
{ | ||
// Define the min/max enumeration | ||
MooseEnum type_options("max=0 min=1", "max"); | ||
|
||
// Define the parameters | ||
InputParameters params = validParams<GeneralPostprocessor>(); | ||
params.addParam<MooseEnum>("value_type", type_options, "Type of extreme value to return. 'max' returns the maximum value. 'min' returns the minimum value."); | ||
params.addRequiredParam<PostprocessorName>("postprocessor", "The name of the postprocessor used for reporting time extreme values"); | ||
params.addClassDescription("A postprocessor for reporting the max/min value of another postprocessor over time."); | ||
|
||
return params; | ||
} | ||
|
||
TimeExtremeValue::TimeExtremeValue(const InputParameters & parameters) : | ||
GeneralPostprocessor(parameters), | ||
_postprocessor(getPostprocessorValue("postprocessor")), | ||
_type((ExtremeType)(int)parameters.get<MooseEnum>("value_type")), | ||
_value(_type == 0 ? -std::numeric_limits<Real>::max() : std::numeric_limits<Real>::max()) | ||
{ | ||
} | ||
|
||
void | ||
TimeExtremeValue::execute() | ||
{ | ||
switch (_type) | ||
{ | ||
case MAX: | ||
_value = std::max(_value, _postprocessor); | ||
break; | ||
|
||
case MIN: | ||
_value = std::min(_value, _postprocessor); | ||
break; | ||
} | ||
} | ||
|
||
Real | ||
TimeExtremeValue::getValue() | ||
{ | ||
return _value; | ||
} |
13 changes: 13 additions & 0 deletions
13
test/tests/postprocessors/time_extreme_value/gold/time_extreme_value_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,13 @@ | ||
time,max_nl_dofs,nl_dofs | ||
0,9,9 | ||
0.1,9,9 | ||
0.2,25,25 | ||
0.3,72,72 | ||
0.4,72,72 | ||
0.5,72,72 | ||
0.6,72,59 | ||
0.7,72,59 | ||
0.8,72,25 | ||
0.9,72,9 | ||
1,72,9 | ||
|
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,8 @@ | ||
[Tests] | ||
[./time_extreme_pps] | ||
type = 'CSVDiff' | ||
input = 'time_extreme_value.i' | ||
csvdiff = 'time_extreme_value_out.csv' | ||
max_parallel = 4 # Only four elements | ||
[../] | ||
[] |
82 changes: 82 additions & 0 deletions
82
test/tests/postprocessors/time_extreme_value/time_extreme_value.i
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,82 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
nx = 2 | ||
ny = 2 | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./diff] | ||
type = Diffusion | ||
variable = u | ||
[../] | ||
[./time] | ||
type = TimeDerivative | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[BCs] | ||
[./left] | ||
type = FunctionDirichletBC | ||
variable = u | ||
boundary = left | ||
function = 'if(t<1.0,t,1.0)' | ||
[../] | ||
[./right] | ||
type = FunctionDirichletBC | ||
variable = u | ||
boundary = right | ||
function = 'if(t<1.0,2.0-t,1.0)' | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
num_steps = 10 | ||
dt = 0.1 | ||
solve_type = PJFNK | ||
petsc_options_iname = '-pc_type -pc_hypre_type' | ||
petsc_options_value = 'hypre boomeramg' | ||
|
||
[] | ||
|
||
[Postprocessors] | ||
[./max_nl_dofs] | ||
type = TimeExtremeValue | ||
value_type = max | ||
postprocessor = nl_dofs | ||
execute_on = 'initial timestep_end' | ||
[../] | ||
|
||
[./nl_dofs] | ||
type = NumDOFs | ||
system = NL | ||
execute_on = 'initial timestep_end' | ||
[../] | ||
[] | ||
|
||
[Adaptivity] | ||
marker = marker | ||
max_h_level = 2 | ||
[./Markers] | ||
[./marker] | ||
type = ValueRangeMarker | ||
lower_bound = 0.7 | ||
upper_bound = 1.3 | ||
buffer_size = 0.2 | ||
variable = u | ||
invert = true | ||
third_state = DO_NOTHING | ||
[../] | ||
[../] | ||
[] | ||
|
||
[Outputs] | ||
csv = true | ||
[] |