Skip to content

Commit

Permalink
Add coverage for ANY_BLOCK_ID in MooseMeshUtils::getSubdomainId
Browse files Browse the repository at this point in the history
  • Loading branch information
loganharbour committed Nov 18, 2021
1 parent 19c7564 commit a970a0a
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/include/userobjects/MooseMeshUtilsTest.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//* 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 "GeneralUserObject.h"

class MooseMeshUtilsTest : public GeneralUserObject
{
public:
static InputParameters validParams();

MooseMeshUtilsTest(const InputParameters & parameters);

virtual void execute() override{};
virtual void initialize() override{};
virtual void finalize() override{};
};
31 changes: 31 additions & 0 deletions test/src/userobjects/MooseMeshUtilsTest.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//* 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 "MooseMeshUtilsTest.h"
#include "MooseMeshUtils.h"

registerMooseObject("MooseTestApp", MooseMeshUtilsTest);

InputParameters
MooseMeshUtilsTest::validParams()
{
auto params = GeneralUserObject::validParams();

params.addParam<bool>(
"get_subdomain_id_any", false, "Tests the error for getSubdomainID with ANY_BLOCK_ID");

return params;
}

MooseMeshUtilsTest::MooseMeshUtilsTest(const InputParameters & parameters)
: GeneralUserObject(parameters)
{
if (getParam<bool>("get_subdomain_id_any"))
MooseMeshUtils::getSubdomainID("ANY_BLOCK_ID", _fe_problem.mesh().getMesh());
}
Empty file.
14 changes: 14 additions & 0 deletions test/tests/utils/moose_mesh_utils/moose_mesh_utils.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[Mesh]
[gmg]
type = GeneratedMeshGenerator
dim = 1
[]
[]

[UserObjects/test]
type = MooseMeshUtilsTest
[]

[Executioner]
type = Steady
[]
12 changes: 12 additions & 0 deletions test/tests/utils/moose_mesh_utils/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Tests]
design = 'MooseMesh.md'
issues = '#17710'

[get_subdomain_id_any]
type = RunException
input = 'moose_mesh_utils.i'
cli_args = 'UserObjects/test/get_subdomain_id_any=true'
requirement = 'The mesh system shall report a reasonable error when using a subdomain name that is reserved for internal use'
expect_err = 'getSubdomainID\(\) does not work with "ANY_BLOCK_ID"'
[]
[]

0 comments on commit a970a0a

Please sign in to comment.