Skip to content

Commit

Permalink
Add test for a VPP that declares a vector fairly late refs idaholab#7809
Browse files Browse the repository at this point in the history
  • Loading branch information
friedmud committed Nov 12, 2016
1 parent f26cf04 commit 28f2371
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 0 deletions.
@@ -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 LATEDECLARATIONVECTORPOSTPROCESSOR_H
#define LATEDECLARATIONVECTORPOSTPROCESSOR_H

#include "GeneralVectorPostprocessor.h"

//Forward Declarations
class LateDeclarationVectorPostprocessor;

template<>
InputParameters validParams<LateDeclarationVectorPostprocessor>();

class LateDeclarationVectorPostprocessor : public GeneralVectorPostprocessor
{
public:
LateDeclarationVectorPostprocessor(const InputParameters & parameters);

virtual void initialize() override;
virtual void execute() override;

protected:
VectorPostprocessorValue * _value;
};

#endif
3 changes: 3 additions & 0 deletions test/src/base/MooseTestApp.C
Expand Up @@ -96,6 +96,7 @@
#include "ExampleShapeElementKernel.h"
#include "ExampleShapeElementKernel2.h"
#include "SimpleTestShapeElementKernel.h"
#include "LateDeclarationVectorPostprocessor.h"

#include "RobinBC.h"
#include "InflowBC.h"
Expand Down Expand Up @@ -510,6 +511,8 @@ MooseTestApp::registerObjects(Factory & factory)
registerPostprocessor(ScalarCoupledPostprocessor);
registerPostprocessor(NumAdaptivityCycles);

registerVectorPostprocessor(LateDeclarationVectorPostprocessor);

registerMarker(RandomHitMarker);
registerMarker(QPointMarker);
registerMarker(CircleMarker);
Expand Down
44 changes: 44 additions & 0 deletions test/src/vectorpostprocessors/LateDeclarationVectorPostprocessor.C
@@ -0,0 +1,44 @@
/****************************************************************/
/* 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 "LateDeclarationVectorPostprocessor.h"

template<>
InputParameters validParams<LateDeclarationVectorPostprocessor>()
{
InputParameters params = validParams<GeneralVectorPostprocessor>();

params.addRequiredParam<VectorPostprocessorValue>("value", "The vector value this object will have.");
return params;
}

LateDeclarationVectorPostprocessor::LateDeclarationVectorPostprocessor(const InputParameters & parameters) :
GeneralVectorPostprocessor(parameters),
_value(nullptr)
{
}

void
LateDeclarationVectorPostprocessor::initialize()
{
if (_t_step == 1)
_value = &declareVector("value");
}

void
LateDeclarationVectorPostprocessor::execute()
{
if (_t_step == 1)
*_value = getParam<VectorPostprocessorValue>("value");
}
@@ -0,0 +1,4 @@
value
1.5
2.7

@@ -0,0 +1,53 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[Variables]
[./u]
[../]
[]

[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 = LateDeclarationVectorPostprocessor
value = '1.5 2.7'
[../]
[]

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

[Outputs]
execute_on = 'initial timestep_end'
csv = true
[]
@@ -0,0 +1,7 @@
[Tests]
[./test]
type = 'CSVDiff'
input = 'late_declaration_vector_postprocessor.i'
csvdiff = 'late_declaration_vector_postprocessor_out_constant_0001.csv'
[../]
[]

0 comments on commit 28f2371

Please sign in to comment.