Skip to content

Commit

Permalink
Adding TimeExtremeValue Postprocessor
Browse files Browse the repository at this point in the history
  • Loading branch information
permcody committed May 4, 2016
1 parent 8c7bb53 commit d611f12
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 0 deletions.
57 changes: 57 additions & 0 deletions framework/include/postprocessors/TimeExtremeValue.h
@@ -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 collecting the nodal min or max value
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
2 changes: 2 additions & 0 deletions framework/src/base/Moose.C
Expand Up @@ -208,6 +208,7 @@
#include "ExecutionerAttributeReporter.h"
#include "PercentChangePostprocessor.h"
#include "ElementL2Difference.h"
#include "TimeExtremeValue.h"

// vector PPS
#include "ConstantVectorPostprocessor.h"
Expand Down Expand Up @@ -618,6 +619,7 @@ registerObjects(Factory & factory)
registerPostprocessor(ExecutionerAttributeReporter);
registerPostprocessor(PercentChangePostprocessor);
registerPostprocessor(ElementL2Difference);
registerPostprocessor(TimeExtremeValue);

// vector PPS
registerVectorPostprocessor(ConstantVectorPostprocessor);
Expand Down
60 changes: 60 additions & 0 deletions framework/src/postprocessors/TimeExtremeValue.C
@@ -0,0 +1,60 @@
/****************************************************************/
/* 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");
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;
}
@@ -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

8 changes: 8 additions & 0 deletions test/tests/postprocessors/time_extreme_value/tests
@@ -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 test/tests/postprocessors/time_extreme_value/time_extreme_value.i
@@ -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]
[./nl_dofs]
type = NumDOFs
system = NL
execute_on = 'initial timestep_end'
[../]

[./max_nl_dofs]
type = TimeExtremeValue
value_type = max
postprocessor = nl_dofs
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
[]

0 comments on commit d611f12

Please sign in to comment.