forked from idaholab/moose
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a postprocessor that computes the inner product of two variable (i…
- Loading branch information
Sebastian Schunert
committed
Aug 15, 2016
1 parent
c5c257e
commit cd52f04
Showing
6 changed files
with
199 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,38 @@ | ||
/****************************************************************/ | ||
/* 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 VARIABLEINNERPRODUCT_H | ||
#define VARIABLEINNERPRODUCT_H | ||
|
||
#include "ElementIntegralVariablePostprocessor.h" | ||
|
||
//Forward Declarations | ||
class VariableInnerProduct; | ||
|
||
template<> | ||
InputParameters validParams<VariableInnerProduct>(); | ||
|
||
class VariableInnerProduct : public ElementIntegralVariablePostprocessor | ||
{ | ||
public: | ||
VariableInnerProduct(const InputParameters & parameters); | ||
|
||
protected: | ||
virtual Real computeQpIntegral() override; | ||
|
||
/// Holds the values of second_variable at current quadrature points | ||
const VariableValue & _v; | ||
}; | ||
|
||
#endif //VariableInnerProduct_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,35 @@ | ||
/****************************************************************/ | ||
/* 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 "VariableInnerProduct.h" | ||
|
||
template<> | ||
InputParameters validParams<VariableInnerProduct>() | ||
{ | ||
InputParameters params = validParams<ElementIntegralVariablePostprocessor>(); | ||
params.addRequiredCoupledVar("second_variable", "The name of the second variable in the inner product (variable, second_variable)"); | ||
return params; | ||
} | ||
|
||
VariableInnerProduct::VariableInnerProduct(const InputParameters & parameters) : | ||
ElementIntegralVariablePostprocessor(parameters), | ||
_v(coupledValue("second_variable")) | ||
{ | ||
} | ||
|
||
Real | ||
VariableInnerProduct::computeQpIntegral() | ||
{ | ||
return _u[_qp] * _v[_qp]; | ||
} |
4 changes: 4 additions & 0 deletions
4
test/tests/postprocessors/variable_inner_product/gold/variable_inner_product.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,4 @@ | ||
time,f_dot_f,f_dot_g,norm_f | ||
0,0,0,0 | ||
1,0.4,4.1633363423443e-17,0.63245553203368 | ||
|
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,8 @@ | ||
[Tests] | ||
[./variable_inner_product_test] | ||
type = 'CSVDiff' | ||
input = 'variable_inner_product.i' | ||
csvdiff = 'variable_inner_product.csv' | ||
group = 'requirements' | ||
[../] | ||
[] |
112 changes: 112 additions & 0 deletions
112
test/tests/postprocessors/variable_inner_product/variable_inner_product.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,112 @@ | ||
[Mesh] | ||
type = GeneratedMesh | ||
dim = 2 | ||
nx = 2 | ||
ny = 2 | ||
xmin = -1 | ||
xmax = 1 | ||
ymin = 0 | ||
ymax = 1 | ||
elem_type = QUAD9 | ||
[] | ||
|
||
[AuxVariables] | ||
[./f] | ||
order = SECOND | ||
family = LAGRANGE | ||
[./InitialCondition] | ||
type = FunctionIC | ||
function = leg2 | ||
[../] | ||
[../] | ||
[./g] | ||
order = FIRST | ||
family = LAGRANGE | ||
[./InitialCondition] | ||
type = FunctionIC | ||
function = leg1 | ||
[../] | ||
[../] | ||
[] | ||
|
||
[Variables] | ||
[./u] | ||
order = FIRST | ||
family = LAGRANGE | ||
[../] | ||
[] | ||
|
||
[Kernels] | ||
[./diff] | ||
type = Diffusion | ||
variable = u | ||
[../] | ||
[] | ||
|
||
[Functions] | ||
[./leg1] | ||
type = ParsedFunction | ||
value = 'x' | ||
[../] | ||
|
||
[./leg2] | ||
type = ParsedFunction | ||
value = '0.5*(3.0*x*x-1.0)' | ||
[../] | ||
[] | ||
|
||
[BCs] | ||
active = 'left right' | ||
|
||
[./left] | ||
type = DirichletBC | ||
variable = u | ||
boundary = 1 | ||
value = 0 | ||
[../] | ||
|
||
[./right] | ||
type = DirichletBC | ||
variable = u | ||
boundary = 2 | ||
value = 1 | ||
[../] | ||
[] | ||
|
||
[Executioner] | ||
type = Steady | ||
|
||
# Preconditioned JFNK (default) | ||
solve_type = 'PJFNK' | ||
|
||
[./Quadrature] | ||
order = fourth | ||
[] | ||
|
||
petsc_options_iname = '-pc_type -pc_hypre_type' | ||
petsc_options_value = 'hypre boomeramg' | ||
[] | ||
|
||
[Postprocessors] | ||
[./f_dot_g] | ||
type = VariableInnerProduct | ||
variable = f | ||
second_variable = g | ||
[../] | ||
|
||
[./f_dot_f] | ||
type = VariableInnerProduct | ||
variable = f | ||
second_variable = f | ||
[../] | ||
|
||
[./norm_f] | ||
type = ElementL2Norm | ||
variable = f | ||
[../] | ||
[] | ||
|
||
[Outputs] | ||
file_base = variable_inner_product | ||
csv = true | ||
[] |