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 DifferencePostprocessor (closes idaholab#3268)
- Loading branch information
1 parent
eaa07b6
commit d11771a
Showing
6 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
framework/include/postprocessors/DifferencePostprocessor.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,33 @@ | ||
#ifndef DIFFERENCEPOSTPROCESSOR_H | ||
#define DIFFERENCEPOSTPROCESSOR_H | ||
|
||
#include "GeneralPostprocessor.h" | ||
|
||
class DifferencePostprocessor; | ||
|
||
template<> | ||
InputParameters validParams<DifferencePostprocessor>(); | ||
|
||
/** | ||
* Computes the difference between two postprocessors | ||
* | ||
* result = value1 - value2 | ||
*/ | ||
class DifferencePostprocessor : public GeneralPostprocessor | ||
{ | ||
public: | ||
DifferencePostprocessor(const std::string & name, InputParameters parameters); | ||
virtual ~DifferencePostprocessor(); | ||
|
||
virtual void initialize(); | ||
virtual void execute(); | ||
virtual PostprocessorValue getValue(); | ||
virtual void threadJoin(const UserObject & uo); | ||
|
||
protected: | ||
const PostprocessorValue & _value1; | ||
const PostprocessorValue & _value2; | ||
}; | ||
|
||
|
||
#endif /* DIFFERENCEPOSTPROCESSOR_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
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,44 @@ | ||
#include "DifferencePostprocessor.h" | ||
|
||
template<> | ||
InputParameters validParams<DifferencePostprocessor>() | ||
{ | ||
InputParameters params = validParams<GeneralPostprocessor>(); | ||
params.addRequiredParam<PostprocessorName>("value1", "First value"); | ||
params.addRequiredParam<PostprocessorName>("value2", "Second value"); | ||
|
||
return params; | ||
} | ||
|
||
DifferencePostprocessor::DifferencePostprocessor(const std::string & name, InputParameters parameters) : | ||
GeneralPostprocessor(name, parameters), | ||
_value1(getPostprocessorValue("value1")), | ||
_value2(getPostprocessorValue("value2")) | ||
{ | ||
} | ||
|
||
DifferencePostprocessor::~DifferencePostprocessor() | ||
{ | ||
} | ||
|
||
void | ||
DifferencePostprocessor::initialize() | ||
{ | ||
} | ||
|
||
void | ||
DifferencePostprocessor::execute() | ||
{ | ||
} | ||
|
||
PostprocessorValue | ||
DifferencePostprocessor::getValue() | ||
{ | ||
return _value1 - _value2; | ||
} | ||
|
||
void | ||
DifferencePostprocessor::threadJoin(const UserObject & /*uo*/) | ||
{ | ||
// nothing to do here, general PPS do not run threaded | ||
} |
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,90 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
xmin = 0 | ||
xmax = 1 | ||
ymin = 0 | ||
ymax = 1 | ||
nx = 2 | ||
ny = 2 | ||
[] | ||
|
||
[AuxVariables] | ||
[./v] | ||
[../] | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
[../] | ||
[] | ||
|
||
[ICs] | ||
[./u_ic] | ||
type = ConstantIC | ||
variable = u | ||
value = 2 | ||
[../] | ||
[] | ||
|
||
[AuxKernels] | ||
[./one] | ||
type = ConstantAux | ||
variable = v | ||
value = 1 | ||
[../] | ||
[] | ||
|
||
[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] | ||
[./u_avg] | ||
type = ElementAverageValue | ||
variable = u | ||
[../] | ||
|
||
[./v_avg] | ||
type = ElementAverageValue | ||
variable = v | ||
[../] | ||
|
||
[./diff] | ||
type = DifferencePostprocessor | ||
value1 = v_avg | ||
value2 = u_avg | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
[] | ||
|
||
[Outputs] | ||
output_initial = true | ||
exodus = true | ||
[./console] | ||
type = Console | ||
perf_log = true | ||
linear_residuals = true | ||
[../] | ||
[] |
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 = 'difference_pps.i' | ||
exodiff = 'difference_pps_out.e' | ||
[../] | ||
[] |