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.
Add ElementExtremeValue PP... also add a missing intermediate base-cl…
…ass so there is symmetry with nodal PPs closes idaholab#2776
- Loading branch information
Showing
9 changed files
with
331 additions
and
1 deletion.
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,52 @@ | ||
/****************************************************************/ | ||
/* 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 ELEMENTEXTREMEVALUE_H | ||
#define ELEMENTEXTREMEVALUE_H | ||
|
||
#include "ElementVariablePostprocessor.h" | ||
|
||
//Forward Declarations | ||
class ElementExtremeValue; | ||
|
||
// Input parameters | ||
template<> | ||
InputParameters validParams<ElementExtremeValue>(); | ||
|
||
/// A postprocessor for collecting the nodal min or max value | ||
class ElementExtremeValue : public ElementVariablePostprocessor | ||
{ | ||
public: | ||
/** | ||
* Class constructor | ||
* @param name The name of the postprocessor | ||
* @param parameters The input parameters | ||
*/ | ||
ElementExtremeValue(const std::string & name, InputParameters parameters); | ||
virtual void initialize(); | ||
virtual Real getValue(); | ||
virtual void threadJoin(const UserObject & y); | ||
|
||
protected: | ||
/// Get the extreme value at each quadrature point | ||
virtual void computeQpValue(); | ||
|
||
/// The extreme value type ("min" or "max") | ||
int _type; | ||
This comment has been minimized.
Sorry, something went wrong. |
||
|
||
/// The extreme value | ||
Real _value; | ||
}; | ||
|
||
#endif |
60 changes: 60 additions & 0 deletions
60
framework/include/postprocessors/ElementVariablePostprocessor.h
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,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 */ | ||
/****************************************************************/ | ||
|
||
#ifndef ELEMENTVARIABLEPOSTPROCESSOR_H | ||
#define ELEMENTVARIABLEPOSTPROCESSOR_H | ||
|
||
#include "ElementPostprocessor.h" | ||
#include "MooseVariableInterface.h" | ||
|
||
class MooseVariable; | ||
|
||
//Forward Declarations | ||
class ElementVariablePostprocessor; | ||
|
||
template<> | ||
InputParameters validParams<ElementVariablePostprocessor>(); | ||
|
||
class ElementVariablePostprocessor : | ||
public ElementPostprocessor, | ||
public MooseVariableInterface | ||
{ | ||
public: | ||
ElementVariablePostprocessor(const std::string & name, InputParameters parameters); | ||
|
||
/// Just does a loop over "qp" calling computeQpValue() | ||
virtual void execute(); | ||
|
||
protected: | ||
|
||
/// This is what derived classes should override to do something on every quadrature point on every element | ||
virtual void computeQpValue() = 0; | ||
|
||
/// The MooseVariable the object is acting on | ||
MooseVariable & _var; | ||
|
||
/// Holds the solution at current quadrature points | ||
VariableValue & _u; | ||
|
||
/// Holds the solution gradient at the current quadrature points | ||
VariableGradient & _grad_u; | ||
|
||
/// Holds the solution derivative at the current quadrature points | ||
VariableValue & _u_dot; | ||
|
||
/// The current quadrature point | ||
unsigned int _qp; | ||
}; | ||
|
||
#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,100 @@ | ||
/****************************************************************/ | ||
/* 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 "ElementExtremeValue.h" | ||
|
||
#include <algorithm> | ||
#include <limits> | ||
|
||
template<> | ||
InputParameters validParams<ElementExtremeValue>() | ||
{ | ||
// Define the min/max enumeration | ||
MooseEnum type_options("max=0, min=1", "max"); | ||
|
||
// Define the parameters | ||
InputParameters params = validParams<ElementVariablePostprocessor>(); | ||
|
||
params.addParam<MooseEnum>("value_type", type_options, "Type of extreme value to return. 'max' returns the maximum value. 'min' returns the minimum value."); | ||
This comment has been minimized.
Sorry, something went wrong.
permcody
|
||
|
||
return params; | ||
} | ||
|
||
ElementExtremeValue::ElementExtremeValue(const std::string & name, InputParameters parameters) : | ||
ElementVariablePostprocessor(name, parameters), | ||
_type(parameters.get<MooseEnum>("value_type")), | ||
_value(_type == 0 ? -std::numeric_limits<Real>::max() : std::numeric_limits<Real>::max()) | ||
{} | ||
|
||
void | ||
ElementExtremeValue::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 | ||
ElementExtremeValue::computeQpValue() | ||
{ | ||
switch (_type) | ||
{ | ||
case 0: | ||
_value = std::max(_value, _u[_qp]); | ||
break; | ||
|
||
case 1: | ||
_value = std::min(_value, _u[_qp]); | ||
break; | ||
} | ||
} | ||
|
||
Real | ||
ElementExtremeValue::getValue() | ||
{ | ||
switch (_type) | ||
{ | ||
case 0: | ||
gatherMax(_value); | ||
break; | ||
case 1: | ||
gatherMin(_value); | ||
break; | ||
} | ||
|
||
return _value; | ||
} | ||
|
||
void | ||
ElementExtremeValue::threadJoin(const UserObject & y) | ||
{ | ||
const ElementExtremeValue & pps = static_cast<const ElementExtremeValue &>(y); | ||
|
||
switch (_type) | ||
{ | ||
case 0: | ||
_value = std::max(_value, pps._value); | ||
break; | ||
case 1: | ||
_value = std::min(_value, pps._value); | ||
break; | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
framework/src/postprocessors/ElementVariablePostprocessor.C
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,45 @@ | ||
/****************************************************************/ | ||
/* 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 "ElementVariablePostprocessor.h" | ||
#include "MooseVariable.h" | ||
#include "SubProblem.h" | ||
#include "MooseTypes.h" | ||
|
||
template<> | ||
InputParameters validParams<ElementVariablePostprocessor>() | ||
{ | ||
InputParameters params = validParams<ElementPostprocessor>(); | ||
params.addRequiredParam<VariableName>("variable", "The name of the variable that this postprocessor operates on"); | ||
return params; | ||
} | ||
|
||
ElementVariablePostprocessor::ElementVariablePostprocessor(const std::string & name, InputParameters parameters) : | ||
ElementPostprocessor(name, parameters), | ||
MooseVariableInterface(parameters, false), | ||
_var(_subproblem.getVariable(_tid, parameters.get<VariableName>("variable"))), | ||
_u(_var.sln()), | ||
_grad_u(_var.gradSln()), | ||
_u_dot(_var.uDot()), | ||
_qp(0) | ||
{ | ||
addMooseVariableDependency(mooseVariable()); | ||
} | ||
|
||
void | ||
ElementVariablePostprocessor::execute() | ||
{ | ||
for (_qp=0; _qp<_qrule->n_points(); _qp++) | ||
computeQpValue(); | ||
} |
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
64 changes: 64 additions & 0 deletions
64
test/tests/postprocessors/element_extreme_value/element_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,64 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
nx = 10 | ||
ny = 10 | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./diff] | ||
type = Diffusion | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[BCs] | ||
[./left] | ||
type = DirichletBC | ||
variable = u | ||
boundary = left | ||
value = 0 | ||
[../] | ||
[./right] | ||
type = DirichletBC | ||
variable = u | ||
boundary = right | ||
value = 1 | ||
[../] | ||
[] | ||
|
||
[Postprocessors] | ||
[./max] | ||
type = ElementExtremeValue | ||
variable = u | ||
[../] | ||
[./min] | ||
type = ElementExtremeValue | ||
variable = u | ||
value_type = min | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
# Preconditioned JFNK (default) | ||
type = Steady | ||
solve_type = PJFNK | ||
petsc_options_iname = '-pc_type -pc_hypre_type' | ||
petsc_options_value = 'hypre boomeramg' | ||
[] | ||
|
||
[Outputs] | ||
output_initial = true | ||
exodus = true | ||
[./console] | ||
type = Console | ||
perf_log = true | ||
linear_residuals = true | ||
[../] | ||
[] | ||
|
Binary file added
BIN
+9.52 KB
test/tests/postprocessors/element_extreme_value/gold/element_extreme_value_out.e
Binary file not shown.
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 @@ | ||
[Tests] | ||
[./test] | ||
type = 'Exodiff' | ||
input = 'element_extreme_value.i' | ||
exodiff = 'element_extreme_value_out.e' | ||
[../] | ||
[] |
You should document which 'int' is which, or at the very least (since this is a base class) why not use a class enum or const to disambiguate min and max?
static const int MAX = 0; static const int MIN = 1;