-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created NodalExtremeValue postprocessor for getting the min or max va…
…lue (closes-#2026) r19794
- Loading branch information
1 parent
2c1866e
commit c33b91c
Showing
7 changed files
with
255 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,50 @@ | ||
/****************************************************************/ | ||
/* 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 NODALEXTREMEVALUE_H | ||
#define NODALEXTREMEVALUE_H | ||
|
||
#include "NodalVariablePostprocessor.h" | ||
|
||
//Forward Declarations | ||
class NodalExtremeValue; | ||
|
||
// Input parameters | ||
template<> | ||
InputParameters validParams<NodalExtremeValue>(); | ||
|
||
/// A postprocessor for collecting the nodal min or max value | ||
class NodalExtremeValue : public NodalVariablePostprocessor | ||
{ | ||
public: | ||
/** | ||
* Class constructor | ||
* @param name The name of the postprocessor | ||
* @param parameters The input parameters | ||
*/ | ||
NodalExtremeValue(const std::string & name, InputParameters parameters); | ||
virtual void initialize(); | ||
virtual void execute(); | ||
virtual Real getValue(); | ||
virtual void threadJoin(const UserObject & y); | ||
|
||
protected: | ||
/// The extreme value type ("min" or "max") | ||
int _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
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 @@ | ||
/****************************************************************/ | ||
/* 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 "NodalExtremeValue.h" | ||
|
||
#include <algorithm> | ||
#include <limits> | ||
|
||
template<> | ||
InputParameters validParams<NodalExtremeValue>() | ||
{ | ||
// Define the min/max enumeration | ||
MooseEnum type_options("max=0, min=1", "max"); | ||
|
||
// Define the parameters | ||
InputParameters params = validParams<NodalVariablePostprocessor>(); | ||
params.addParam<MooseEnum>("value_type", type_options, "Type of extreme value to return. 'max' returns the maximum value. 'min' returns the minimu value."); | ||
return params; | ||
} | ||
|
||
NodalExtremeValue::NodalExtremeValue(const std::string & name, InputParameters parameters) : | ||
NodalVariablePostprocessor(name, parameters), | ||
_type(parameters.get<MooseEnum>("value_type")), | ||
_value(_type == 0 ? -std::numeric_limits<Real>::max() : std::numeric_limits<Real>::max()) | ||
{} | ||
|
||
void | ||
NodalExtremeValue::initialize() | ||
{ | ||
switch (_type) | ||
{ | ||
case 0: | ||
_value = -std::numeric_limits<Real>::max(); // start w/ the min | ||
break; | ||
|
||
case 1: | ||
_value = std::numeric_limits<Real>::max(); // start w/ the max | ||
break; | ||
} | ||
} | ||
|
||
void | ||
NodalExtremeValue::execute() | ||
{ | ||
switch (_type) | ||
{ | ||
case 0: | ||
_value = std::max(_value, _u[_qp]); | ||
break; | ||
|
||
case 1: | ||
_value = std::min(_value, _u[_qp]); | ||
break; | ||
} | ||
} | ||
|
||
Real | ||
NodalExtremeValue::getValue() | ||
{ | ||
switch (_type) | ||
{ | ||
case 0: | ||
gatherMax(_value); | ||
break; | ||
case 1: | ||
gatherMin(_value); | ||
break; | ||
} | ||
|
||
return _value; | ||
} | ||
|
||
void | ||
NodalExtremeValue::threadJoin(const UserObject & y) | ||
{ | ||
const NodalExtremeValue & pps = static_cast<const NodalExtremeValue &>(y); | ||
|
||
switch (_type) | ||
{ | ||
case 0: | ||
_value = std::max(_value, pps._value); | ||
break; | ||
case 1: | ||
_value = std::min(_value, pps._value); | ||
break; | ||
} | ||
} |
Binary file added
BIN
+68.4 KB
test/tests/postprocessors/nodal_pps/gold/nodal_extreme_pps_test_out.e
Binary file not shown.
91 changes: 91 additions & 0 deletions
91
test/tests/postprocessors/nodal_pps/nodal_extreme_pps_test.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,91 @@ | ||
[Mesh] | ||
type = FileMesh | ||
file = trapezoid.e | ||
uniform_refine = 1 | ||
[] | ||
|
||
[Functions] | ||
[./tr_x] | ||
type = ParsedFunction | ||
value = -x*cos(pi/3) | ||
[../] | ||
[./tr_y] | ||
type = ParsedFunction | ||
value = x*sin(pi/3) | ||
[../] | ||
[./itr_x] | ||
type = ParsedFunction | ||
value = -x/cos(pi/3) | ||
[../] | ||
[./itr_y] | ||
type = ParsedFunction | ||
value = 0 | ||
[../] | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
order = FIRST | ||
family = LAGRANGE | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./diff] | ||
type = Diffusion | ||
variable = u | ||
[../] | ||
[./forcing] | ||
type = GaussContForcing | ||
variable = u | ||
x_center = 2 | ||
y_center = -1 | ||
x_spread = 0.25 | ||
y_spread = 0.5 | ||
[../] | ||
[./dot] | ||
type = TimeDerivative | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[BCs] | ||
# active = ' ' | ||
[./Periodic] | ||
[./x] | ||
primary = 1 | ||
secondary = 4 | ||
transform_func = 'tr_x tr_y' | ||
inv_transform_func = 'itr_x itr_y' | ||
[../] | ||
[../] | ||
[] | ||
|
||
[Postprocessors] | ||
[./max_nodal_pps] | ||
type = NodalExtremeValue | ||
variable = u | ||
[../] | ||
[./max_node_id] | ||
type = NodalProxyMaxValue | ||
variable = u | ||
[../] | ||
[./min_nodal_pps] | ||
type = NodalExtremeValue | ||
variable = u | ||
value_type = min | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Transient | ||
dt = 0.5 | ||
num_steps = 6 | ||
[] | ||
|
||
[Output] | ||
interval = 1 | ||
exodus = true | ||
perf_log = true | ||
[] | ||
|
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