Skip to content

Add vacuum and reflective BCs using the MoabSkinner#1286

Open
meltawila wants to merge 5 commits intoneams-th-coe:develfrom
meltawila:add_bcs
Open

Add vacuum and reflective BCs using the MoabSkinner#1286
meltawila wants to merge 5 commits intoneams-th-coe:develfrom
meltawila:add_bcs

Conversation

@meltawila
Copy link
Copy Markdown
Member

closes #1285

@moosebuild
Copy link
Copy Markdown
Collaborator

moosebuild commented Feb 4, 2026

Job Documentation, step Sync to remote on 585a259 wanted to post the following:

View the site here

This comment will be updated on new commits.

@moosebuild
Copy link
Copy Markdown
Collaborator

moosebuild commented Feb 4, 2026

Job Coverage, step Generate coverage on 585a259 wanted to post the following:

Coverage

9d0111 #1286 585a25
Total Total +/- New
Rate 93.16% 93.21% +0.05% 100.00%
Hits 9779 9889 +110 114
Misses 718 720 +2 0

Diff coverage report

Full coverage report

This comment will be updated on new commits.

@moosebuild
Copy link
Copy Markdown
Collaborator

Job Precheck, step Clang format on 7b6eb7b wanted to post the following:

Your code requires style changes.

A patch was auto generated and copied here
You can directly apply the patch by running, in the top level of your repository:

curl -s https://mooseframework.inl.gov/cardinal/docs/PRs/1286/clang_format/style.patch | git apply -v

Alternatively, with your repository up to date and in the top level of your repository:

git clang-format 9d01119411a3ede62b36e8d0952b0358083f866d

@meltawila meltawila marked this pull request as ready for review March 24, 2026 15:54
@meltawila
Copy link
Copy Markdown
Member Author

@aprilnovak this should be ready for review now

params.addParam<std::vector<BoundaryName>>("vacuum_bcs_surfaces",
"Sideset names/ids to assign vacuum BCs to");
params.addParam<std::vector<BoundaryName>>("reflective_bcs_surfaces",
"Sideset names/ids to assign reflective BCs to");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: does the code work with either names or IDs?

{
auto namesToSidesetIDs =
[&](const std::vector<BoundaryName> & names, const std::string & param_name)
{
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this inline function seems more complicated than it needs to be? it does not use the param_name input. Since you just call this right below, I'd suggest to get rid of this inline thing to simplify the code.

{
const BoundaryID id = getMooseMesh().getBoundaryID(n);
if (!getMooseMesh().meshSidesetIds().count(id))
mooseError("Boundary '", n, "' is not a sideset.");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work properly if user provides IDs directly in the .i file?

for (auto id : vac_ids)
if (ref_ids.count(id))
mooseError(
"Same sideset ", id, " appears in both vacuum_bcs_surfaces and reflective_bcs_surfaces.");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this covered by a test?

for (const auto * elem : getMooseMesh().getMesh().active_element_ptr_range())
{
auto elem_to_moab_tets_it = _id_to_elem_handles.find(elem->id());
if (elem_to_moab_tets_it == _id_to_elem_handles.end())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this ever get called or is this dead code?

{
const moab::EntityHandle surf_set = surf_pair.first;
moab::Range tris;
check(_moab->get_entities_by_handle(surf_set, tris));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this check checking?

(!ref_tris.empty() && !moab::intersect(tris, ref_tris).empty());

if (has_vacuum_tris)
check(_moab->add_entities(vac_group, &surf_set, 1));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this check checking?

if (has_vacuum_tris)
check(_moab->add_entities(vac_group, &surf_set, 1));
if (has_reflective_tris)
check(_moab->add_entities(ref_group, &surf_set, 1));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this check checking?

input = openmc.i
csvdiff = 'all_vacuum.csv'
cli_args = 'UserObjects/moab/vacuum_bcs_surfaces="top bottom front back left right" Outputs/file/file_base="all_vacuum"'
requirement = "The system shall give identical Monte Carlo solution (file mesh tallies and k) when adding "
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the requirement needs to be unique for each test. This is identical to the all_reflective test.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and several other tests here, it looks like

[]

allow_renumbering = false
parallel_type = replicated
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you already have the restriction to replicated mesh in the tests file, you don't need to include it here

Copy link
Copy Markdown
Contributor

@gonuke gonuke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few questions/comments based on a first pass through this. I'll try to take a deeper look soon.

Also, while I'm not fully versed in the style conventions of this project, it seems like the function to add the boundary conditions would be more readable if broken into a number of smaller functions each with a clear semantic purpose.

Comment on lines +808 to +811
for (auto id : vac_ids)
if (ref_ids.count(id))
mooseError(
"Same sideset ", id, " appears in both vacuum_bcs_surfaces and reflective_bcs_surfaces.");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want to test this sooner, ie. in the constructor?

const auto ref_ids = namesToSidesetIDs(_reflective_bcs_surfaces, "reflective_bcs_surfaces");

for (auto id : vac_ids)
if (ref_ids.count(id))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a simple way to use set logic to get all the overlapping ids at once and issue a single error with them all?

for (const auto tet : elem_to_moab_tets_it->second)
{
moab::Range tri_faces;
check(_moab->get_adjacencies(&tet, 1, 2, true, tri_faces));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also replace those magic numbers (1,2) with a variable that clarifies their purpose.

}

void
MoabSkinner::addBoundaryConditionGroups()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this would be simpler if the method only handled one of the boundary conditions at a time, and was called once for each boundary conditions (assuming that the user has requested it)


const auto & boundary_info = getMooseMesh().getMesh().get_boundary_info();

for (const auto * elem : getMooseMesh().getMesh().active_element_ptr_range())
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Caveat: I'm not deeply familiar with this particular implementation of skinning, but am very familiar with the concept.) This whole loop appears to be almost like it's performing a skinning operation again. Could some of this information have been captured more easily during the process of skinning the mesh rather than going back after the fact to query the mesh again?

Comment on lines +880 to +883
const moab::EntityHandle moab_surface_meshset = surface_entry.first;
unsigned int surface_id = 0;
check(_moab->tag_get_data(id_tag, &moab_surface_meshset, 1, &surface_id));
max_surface_id = std::max(max_surface_id, surface_id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it's more efficient to load all the surface meshset handles into a vector and get all the IDs in a single call to tag_get_data?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Assign DAGMC boundary conditions using MoabSkinner

4 participants