Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4808 from WilkAndy/int_f_4799
FunctionSideIntegral added. Fixes #4799
- Loading branch information
Showing
6 changed files
with
189 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,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 */ | ||
/****************************************************************/ | ||
|
||
#ifndef FUNCTIONSIDEINTEGRAL_H | ||
#define FUNCTIONSIDEINTEGRAL_H | ||
|
||
#include "Function.h" | ||
#include "SideIntegralPostprocessor.h" | ||
|
||
//Forward Declarations | ||
class FunctionSideIntegral; | ||
|
||
template<> | ||
InputParameters validParams<FunctionSideIntegral>(); | ||
|
||
/** | ||
* This postprocessor computes the integral of a function over a specified boundary | ||
*/ | ||
class FunctionSideIntegral : public SideIntegralPostprocessor | ||
{ | ||
public: | ||
FunctionSideIntegral(const std::string & name, InputParameters parameters); | ||
virtual void threadJoin(const UserObject & y); | ||
|
||
protected: | ||
virtual Real computeQpIntegral(); | ||
|
||
/// The function | ||
Function & _func; | ||
|
||
|
||
}; | ||
|
||
#endif //FUNCTIONSIDEINTEGRAL_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,41 @@ | ||
/****************************************************************/ | ||
/* 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 "FunctionSideIntegral.h" | ||
|
||
template<> | ||
InputParameters validParams<FunctionSideIntegral>() | ||
{ | ||
InputParameters params = validParams<SideIntegralPostprocessor>(); | ||
params.addParam<FunctionName>("function", 1.0, "This postprocessor will return the integral of this function over the boundary"); | ||
return params; | ||
} | ||
|
||
FunctionSideIntegral::FunctionSideIntegral(const std::string & name, InputParameters parameters) : | ||
SideIntegralPostprocessor(name, parameters), | ||
_func(getFunction("function")) | ||
{} | ||
|
||
void | ||
FunctionSideIntegral::threadJoin(const UserObject &y) | ||
{ | ||
const FunctionSideIntegral & pps = static_cast<const FunctionSideIntegral &>(y); | ||
_integral_value += pps._integral_value; | ||
} | ||
|
||
Real | ||
FunctionSideIntegral::computeQpIntegral() | ||
{ | ||
return _func.value(_t, _q_point[_qp]); | ||
} |
89 changes: 89 additions & 0 deletions
89
test/tests/postprocessors/function_sideintegral/function_sideintegral.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,89 @@ | ||
# calculates the integral of various functions over | ||
# boundaries of the mesh. See [Postprocessors] for | ||
# a description of the functions | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 3 | ||
nx = 5 | ||
ny = 5 | ||
nz = 5 | ||
xmin = -1 | ||
xmax = 1 | ||
ymin = -2 | ||
ymax = 2 | ||
zmin = 0 | ||
zmax = 6 | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./diff] | ||
type = Diffusion | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[ICs] | ||
[./u] | ||
type = ConstantIC | ||
variable = u | ||
value = 0 | ||
[../] | ||
[] | ||
|
||
[Postprocessors] | ||
[./zmin] | ||
# no function is provided, so it should default to 1 | ||
# yielding postprocessor = 8 | ||
type = FunctionSideIntegral | ||
boundary = back | ||
[../] | ||
[./zmax] | ||
# result should be -6*area_of_zmax_sideset = -48 | ||
type = FunctionSideIntegral | ||
boundary = front | ||
function = '-z' | ||
[../] | ||
[./ymin] | ||
# since the integrand is odd in x, the result should be zero | ||
type = FunctionSideIntegral | ||
boundary = bottom | ||
function = 'x*pow(z,4)' | ||
[../] | ||
[./ymax] | ||
# result should be 24 | ||
type = FunctionSideIntegral | ||
boundary = top | ||
function = 'y*(1+x)*(z-2)' | ||
[../] | ||
[./xmin_and_xmax] | ||
# here the integral is over two sidesets | ||
# result should be 432 | ||
type = FunctionSideIntegral | ||
boundary = 'left right' | ||
function = '(3+x)*z' | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
|
||
# Preconditioned JFNK (default) | ||
solve_type = 'PJFNK' | ||
|
||
petsc_options_iname = '-pc_type -pc_hypre_type' | ||
petsc_options_value = 'hypre boomeramg' | ||
[] | ||
|
||
[Outputs] | ||
file_base = function_sideintegral | ||
print_perf_log = true | ||
[./csv] | ||
type = CSV | ||
interval = 1 | ||
[../] | ||
[] |
3 changes: 3 additions & 0 deletions
3
test/tests/postprocessors/function_sideintegral/gold/function_sideintegral.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,3 @@ | ||
time,xmin_and_xmax,ymax,ymin,zmax,zmin | ||
1,432,24,0,-48,8 | ||
|
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,9 @@ | ||
[Tests] | ||
[./function_sideintegral] | ||
type = 'CSVDiff' | ||
input = 'function_sideintegral.i' | ||
csvdiff = 'function_sideintegral.csv' | ||
rel_err = 1.0E-5 | ||
abs_zero = 1.0E-5 | ||
[../] | ||
[] |