Skip to content

Commit

Permalink
Merge pull request #4808 from WilkAndy/int_f_4799
Browse files Browse the repository at this point in the history
FunctionSideIntegral added.  Fixes #4799
  • Loading branch information
permcody committed Mar 11, 2015
2 parents 5dddc92 + 61eb6d4 commit 85a5f3e
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 0 deletions.
45 changes: 45 additions & 0 deletions framework/include/postprocessors/FunctionSideIntegral.h
@@ -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
2 changes: 2 additions & 0 deletions framework/src/base/Moose.C
Expand Up @@ -187,6 +187,7 @@
#include "ElementExtremeValue.h"
#include "DifferencePostprocessor.h"
#include "NumPicardIterations.h"
#include "FunctionSideIntegral.h"

// vector PPS
#include "ConstantVectorPostprocessor.h"
Expand Down Expand Up @@ -554,6 +555,7 @@ registerObjects(Factory & factory)
registerPostprocessor(ElementExtremeValue);
registerPostprocessor(DifferencePostprocessor);
registerPostprocessor(NumPicardIterations);
registerPostprocessor(FunctionSideIntegral);

// vector PPS
registerVectorPostprocessor(ConstantVectorPostprocessor);
Expand Down
41 changes: 41 additions & 0 deletions framework/src/postprocessors/FunctionSideIntegral.C
@@ -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]);
}
@@ -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
[../]
[]
@@ -0,0 +1,3 @@
time,xmin_and_xmax,ymax,ymin,zmax,zmin
1,432,24,0,-48,8

9 changes: 9 additions & 0 deletions test/tests/postprocessors/function_sideintegral/tests
@@ -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
[../]
[]

0 comments on commit 85a5f3e

Please sign in to comment.