Skip to content

Commit

Permalink
add a test for coupled elemental sln idaholab#9690
Browse files Browse the repository at this point in the history
  • Loading branch information
YaqiWang committed Sep 6, 2017
1 parent 5fbadcf commit 70c63a3
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 0 deletions.
37 changes: 37 additions & 0 deletions test/include/postprocessors/ElementMomentSum.h
@@ -0,0 +1,37 @@
/****************************************************************/
/* 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 ELEMENTMOMENTSUM_H
#define ELEMENTMOMENTSUM_H

#include "ElementIntegralVariablePostprocessor.h"

// Forward Declarations
class ElementMomentSum;

template <>
InputParameters validParams<ElementMomentSum>();

class ElementMomentSum : public ElementIntegralVariablePostprocessor
{
public:
ElementMomentSum(const InputParameters & parameters);

protected:
virtual void execute() override;

const DenseVector<Number> & _elemental_sln;
};

#endif // ELEMENTMOMENTSUM_H
2 changes: 2 additions & 0 deletions test/src/base/MooseTestApp.C
Expand Up @@ -221,6 +221,7 @@
#include "NumAdaptivityCycles.h"
#include "TestDiscontinuousValuePP.h"
#include "RandomPostprocessor.h"
#include "ElementMomentSum.h"
#include "ChannelGradientVectorPostprocessor.h"

// Functions
Expand Down Expand Up @@ -561,6 +562,7 @@ MooseTestApp::registerObjects(Factory & factory)
registerPostprocessor(NumAdaptivityCycles);
registerPostprocessor(TestDiscontinuousValuePP);
registerPostprocessor(RandomPostprocessor);
registerPostprocessor(ElementMomentSum);

registerVectorPostprocessor(LateDeclarationVectorPostprocessor);
registerVectorPostprocessor(ChannelGradientVectorPostprocessor);
Expand Down
46 changes: 46 additions & 0 deletions test/src/postprocessors/ElementMomentSum.C
@@ -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 */
/****************************************************************/

#include "ElementMomentSum.h"

#include "MooseVariable.h"

template <>
InputParameters
validParams<ElementMomentSum>()
{
InputParameters params = validParams<ElementIntegralVariablePostprocessor>();
params.addParam<bool>("use_old", false, "True to coupled old variable");
return params;
}

ElementMomentSum::ElementMomentSum(const InputParameters & parameters)
: ElementIntegralVariablePostprocessor(parameters),
_elemental_sln(getParam<bool>("use_old") ? coupledSolutionDoFsOld("variable")
: coupledSolutionDoFs("variable"))
{
}

void
ElementMomentSum::execute()
{
unsigned int ndofs = _elemental_sln.size();
Real v = 0;
for (unsigned int i = 0; i < ndofs; ++i)
v += _elemental_sln(i);
v /= ndofs;
v *= _current_elem_volume;

_integral_value += v;
}
@@ -0,0 +1,73 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 3
ny = 3
[]

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

[Kernels]
[./diff]
type = Diffusion
variable = u
[../]
[./time]
type = TimeDerivative
variable = u
[../]
[]

[BCs]
[./left]
type = DirichletBC
variable = u
boundary = left
value = 0
[../]
[./right]
type = DirichletBC
variable = u
boundary = right
value = 1
[../]
[]

[Postprocessors]
[./L2_norm]
type = ElementL2Norm
variable = u
[../]
[./integral]
type = ElementIntegralVariablePostprocessor
variable = u
[../]
[./direct_sum]
type = ElementMomentSum
variable = u
[../]
[./direct_sum_old]
type = ElementMomentSum
variable = u
implicit = false
[../]
[./direct_sum_older]
type = ElementMomentSum
variable = u
use_old = true
implicit = false
[../]
[]

[Executioner]
type = Transient
num_steps = 3
nl_abs_tol = 1e-12
[]

[Outputs]
csv = true
[]
@@ -0,0 +1,6 @@
time,L2_norm,direct_sum,direct_sum_old,direct_sum_older,integral
0,0,0,0,0,0
1,0.54729958835168,0.46610169491525,0,0,0.46610169491525
2,0.57484469915105,0.49712726228095,0.46610169491525,0,0.49712726228095
3,0.5771390732329,0.49975654765402,0.49712726228095,0.46610169491525,0.49975654765402

Binary file not shown.
9 changes: 9 additions & 0 deletions test/tests/postprocessors/coupled_solution_dofs/tests
@@ -0,0 +1,9 @@
[Tests]
[./test]
type = 'CSVDiff'
input = 'coupled_solution_dofs.i'
csvdiff = 'coupled_solution_dofs_out.csv'
max_parallel = 3
max_threads = 3
[../]
[]

0 comments on commit 70c63a3

Please sign in to comment.