Skip to content

Commit

Permalink
Merge pull request #28351 from lindsayad/not-too-many-rms-28330
Browse files Browse the repository at this point in the history
Don't add redundant GhostBoundary objects
  • Loading branch information
lindsayad authored Aug 12, 2024
2 parents 766e270 + 086a313 commit 63a4daa
Show file tree
Hide file tree
Showing 8 changed files with 125 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "libmesh/mesh_base.h"
#include "libmesh/boundary_info.h"

registerMooseObject("HeatTransferApp", GhostBoundary);
registerMooseObject("MooseApp", GhostBoundary);

using namespace libMesh;

Expand Down Expand Up @@ -98,9 +98,19 @@ GhostBoundary::operator()(const MeshBase::const_element_iterator & /*range_begin
bool
GhostBoundary::operator>=(const RelationshipManager & other) const
{
if (auto asoi = dynamic_cast<const GhostBoundary *>(&other))
if (_boundary_name == asoi->_boundary_name && baseGreaterEqual(*asoi))
if (auto asoi = dynamic_cast<const GhostBoundary *>(&other); asoi && baseGreaterEqual(*asoi))
{
std::set<BoundaryName> our_set(_boundary_name.begin(), _boundary_name.end());
std::set<BoundaryName> their_set(asoi->_boundary_name.begin(), asoi->_boundary_name.end());
std::set<BoundaryName> difference;
std::set_difference(their_set.begin(),
their_set.end(),
our_set.begin(),
our_set.end(),
std::inserter(difference, difference.end()));
if (difference.empty())
return true;
}
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion framework/src/relationshipmanagers/GhostEverything.C
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ GhostEverything::operator()(const MeshBase::const_element_iterator & range_begin
bool
GhostEverything::operator>=(const RelationshipManager & other) const
{
return dynamic_cast<const GhostEverything *>(&other);
return baseGreaterEqual(other);
}

std::unique_ptr<GhostingFunctor>
Expand Down
24 changes: 24 additions & 0 deletions test/include/userobjects/TestGhostBoundarySideUserObject.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 "SideUserObject.h"

class TestGhostBoundarySideUserObject : public SideUserObject
{
public:
static InputParameters validParams();

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

registerMooseObject("MooseTestApp", TestGhostBoundarySideUserObject);

InputParameters
TestGhostBoundarySideUserObject::validParams()
{
InputParameters params = SideUserObject::validParams();
params.addRelationshipManager("GhostBoundary",
Moose::RelationshipManagerType::GEOMETRIC,
[](const InputParameters & obj_params, InputParameters & rm_params)
{
rm_params.set<std::vector<BoundaryName>>("boundary") =
obj_params.get<std::vector<BoundaryName>>("boundary");
});
return params;
}

TestGhostBoundarySideUserObject::TestGhostBoundarySideUserObject(const InputParameters & parameters)
: SideUserObject(parameters)
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
time,num_rms
0,0
1,2
42 changes: 42 additions & 0 deletions test/tests/relationship_managers/ghost_boundary/test.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[Mesh]
[gen]
type = GeneratedMeshGenerator
dim = 2
nx = 5
ny = 5
[]
[]

[UserObjects]
[all]
type = TestGhostBoundarySideUserObject
boundary = 'left right top bottom'
[]
[some]
type = TestGhostBoundarySideUserObject
boundary = 'left right'
[]
[]

[Postprocessors]
[num_rms]
type = NumRelationshipManagers
rm_type = 'geometric'
[]
[]

[Problem]
solve = false
[]

[Executioner]
type = Steady
[]

[Outputs]
[info]
type = Console
system_info = 'relationship'
[]
csv = true
[]
10 changes: 10 additions & 0 deletions test/tests/relationship_managers/ghost_boundary/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Tests]
design = 'RelationshipManager.md'
issues = '#28330'
[test]
type = CSVDiff
input = test.i
csvdiff = test_out.csv
requirement = 'The system shall not add a relationship manager ghosting boundaries that are a subset of the boundaries ghosted by another relationship manager.'
[]
[]

0 comments on commit 63a4daa

Please sign in to comment.