Skip to content

Commit

Permalink
Add a test (#13953)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schunert authored and milljm committed Sep 10, 2019
1 parent 73813de commit aeeb288
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 0 deletions.
34 changes: 34 additions & 0 deletions test/include/postprocessors/AverageBID.h
@@ -0,0 +1,34 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#pragma once

#include "SidePostprocessor.h"

// Forward Declarations
class AverageBID;

template <>
InputParameters validParams<AverageBID>();

class AverageBID : public SidePostprocessor
{
public:
AverageBID(const InputParameters & parameters);

virtual PostprocessorValue getValue() override;
virtual void execute() override;
virtual void initialize() override;
virtual void finalize() override;
virtual void threadJoin(const UserObject & uo) override;

protected:
Real _sum_bid;
unsigned int _n_summands;
};
59 changes: 59 additions & 0 deletions test/src/postprocessors/AverageBID.C
@@ -0,0 +1,59 @@
//* This file is part of the MOOSE framework
//* https://www.mooseframework.org
//*
//* All rights reserved, see COPYRIGHT for full restrictions
//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
//*
//* Licensed under LGPL 2.1, please see LICENSE for details
//* https://www.gnu.org/licenses/lgpl-2.1.html

#include "AverageBID.h"

#include "Assembly.h"

registerMooseObject("MooseTestApp", AverageBID);

template <>
InputParameters
validParams<AverageBID>()
{
InputParameters params = validParams<SidePostprocessor>();
return params;
}

AverageBID::AverageBID(const InputParameters & parameters) : SidePostprocessor(parameters) {}

void
AverageBID::initialize()
{
_sum_bid = 0;
_n_summands = 0;
}

void
AverageBID::execute()
{
_sum_bid += _current_boundary_id;
++_n_summands;
}

void
AverageBID::finalize()
{
gatherSum(_sum_bid);
gatherSum(_n_summands);
}

Real
AverageBID::getValue()
{
return _sum_bid / _n_summands;
}

void
AverageBID::threadJoin(const UserObject & y)
{
const AverageBID & pps = static_cast<const AverageBID &>(y);
_sum_bid += pps._sum_bid;
_n_summands += pps._n_summands;
}
@@ -0,0 +1,57 @@
#
# This is used to create the mesh but it does not work with --distributed-mesh flag
# and the parallel test bombs.
#
#[Mesh]
# type = MeshGeneratorMesh
#
# [./cartesian]
# type = CartesianMeshGenerator
# dim = 2
# dx = '1 1'
# dy = '1'
# subdomain_id = '1 2'
# [../]
#
# [./interior_bc]
# type = SideSetsBetweenSubdomainsGenerator
# master_block = 1
# paired_block = 2
# new_boundary = 12
# input = cartesian
# [../]
#[]

[Mesh]
type = FileMesh
file = current_boundary_id_in.e
[]

[Problem]
kernel_coverage_check = false
[]

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

[Postprocessors]
[./interior_boundary]
type = AverageBID
boundary = 12
[../]

[./top_boundary]
type = AverageBID
boundary = top
[../]
[]

[Executioner]
type = Steady
[]

[Outputs]
csv = true
[]
Binary file not shown.
@@ -0,0 +1,3 @@
time,interior_boundary,top_boundary
0,0,0
1,12,2
10 changes: 10 additions & 0 deletions test/tests/postprocessors/current_boundary_id/tests
@@ -0,0 +1,10 @@
[Tests]
issues = '#13953'
design = 'Assembly.md'
[current_boundary_id]
type = CSVDiff
input = current_boundary_id.i
csvdiff = 'current_boundary_id_out.csv'
requirement = "The current boundary id shall be available in objects evaluated on boundaries."
[]
[]

0 comments on commit aeeb288

Please sign in to comment.