Skip to content

Commit

Permalink
Add VectorPostprocessorInterface to ScalarKernel closes idaholab#7425
Browse files Browse the repository at this point in the history
  • Loading branch information
friedmud committed Jul 31, 2016
1 parent 898b639 commit 7456dcd
Show file tree
Hide file tree
Showing 8 changed files with 173 additions and 1 deletion.
4 changes: 3 additions & 1 deletion framework/include/kernels/ScalarKernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "TransientInterface.h"
#include "ZeroInterface.h"
#include "MeshChangedInterface.h"
#include "VectorPostprocessorInterface.h"

// Forward declarations
class ScalarKernel;
Expand All @@ -46,7 +47,8 @@ class ScalarKernel :
public PostprocessorInterface,
public TransientInterface,
public ZeroInterface,
public MeshChangedInterface
public MeshChangedInterface,
protected VectorPostprocessorInterface
{
public:
ScalarKernel(const InputParameters & parameters);
Expand Down
1 change: 1 addition & 0 deletions framework/src/kernels/ScalarKernel.C
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ ScalarKernel::ScalarKernel(const InputParameters & parameters) :
TransientInterface(this),
ZeroInterface(parameters),
MeshChangedInterface(parameters),
VectorPostprocessorInterface(this),
_subproblem(*parameters.get<SubProblem *>("_subproblem")),
_sys(*parameters.get<SystemBase *>("_sys")),

Expand Down
46 changes: 46 additions & 0 deletions test/include/scalarkernels/VectorPostprocessorScalarKernel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/****************************************************************/
/* 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 VECTORPOSTPROCESSORSCALARKERNEL_H
#define VECTORPOSTPROCESSORSCALARKERNEL_H


#include "ODEKernel.h"

//Forward Declarations
class VectorPostprocessorScalarKernel;

template<>
InputParameters validParams<VectorPostprocessorScalarKernel>();

/**
*
*/
class VectorPostprocessorScalarKernel : public ODEKernel
{
public:
VectorPostprocessorScalarKernel(const InputParameters & parameters);
virtual ~VectorPostprocessorScalarKernel();

protected:
virtual Real computeQpResidual();
virtual Real computeQpJacobian();

const VectorPostprocessorValue & _vpp;

unsigned int _index;
};


#endif /* VECTORPOSTPROCESSORSCALARKERNEL_H */
2 changes: 2 additions & 0 deletions test/src/base/MooseTestApp.C
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@
#include "ImplicitODEy.h"
#include "AlphaCED.h"
#include "PostprocessorCED.h"
#include "VectorPostprocessorScalarKernel.h"

#include "EqualValueNodalConstraint.h"

Expand Down Expand Up @@ -424,6 +425,7 @@ MooseTestApp::registerObjects(Factory & factory)
registerScalarKernel(ImplicitODEy);
registerScalarKernel(AlphaCED);
registerScalarKernel(PostprocessorCED);
registerScalarKernel(VectorPostprocessorScalarKernel);

// Functions
registerFunction(TimestepSetupFunction);
Expand Down
48 changes: 48 additions & 0 deletions test/src/scalarkernels/VectorPostprocessorScalarKernel.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/****************************************************************/
/* 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 "VectorPostprocessorScalarKernel.h"

template<>
InputParameters validParams<VectorPostprocessorScalarKernel>()
{
InputParameters params = validParams<ODEKernel>();

params.addRequiredParam<VectorPostprocessorName>("vpp", "VectorPostprocessor to pull the values out of");
params.addRequiredParam<std::string>("vector", "The vector to use from the VectorPostprocessor. This vector MUST be the same size as the scalar variable's ORDER.");

return params;
}

VectorPostprocessorScalarKernel::VectorPostprocessorScalarKernel(const InputParameters & parameters) :
ODEKernel(parameters),
_vpp(getVectorPostprocessorValue("vpp", getParam<std::string>("vector")))
{
}

VectorPostprocessorScalarKernel::~VectorPostprocessorScalarKernel()
{
}

Real
VectorPostprocessorScalarKernel::computeQpResidual()
{
return _u[_i] - _vpp[_i];
}

Real
VectorPostprocessorScalarKernel::computeQpJacobian()
{
return 1.;
}
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[Variables]
[./u]
[../]
[./scalar]
order = THIRD
family = SCALAR
[../]
[]

[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
[../]
[]

[VectorPostprocessors]
[./constant]
type = ConstantVectorPostprocessor
value = '1.7 2.3 4.7'
[../]
[]

[Executioner]
# Preconditioned JFNK (default)
type = Steady
solve_type = PJFNK
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
[]

[Outputs]
exodus = true
[]

[ScalarKernels]
[./vppsk]
variable = scalar
vector = value
type = VectorPostprocessorScalarKernel
vpp = constant
[../]
[]

7 changes: 7 additions & 0 deletions test/tests/kernels/scalarkernel_vectorpostprocessor/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Tests]
[./test]
type = 'Exodiff'
input = 'scalarkernel_vectorpostprocessor.i'
exodiff = 'scalarkernel_vectorpostprocessor_out.e'
[../]
[]

0 comments on commit 7456dcd

Please sign in to comment.