Skip to content

Commit

Permalink
add filter_part_boundaries
Browse files Browse the repository at this point in the history
eases setting up boundaries when calling operators on only one volume (i.e., uncoupled)
  • Loading branch information
majosm committed May 25, 2023
1 parent bfad1f7 commit c112288
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion grudge/discretization.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
.. currentmodule:: grudge.discretization
.. autoclass:: PartID
.. autofunction:: filter_part_boundaries
"""

__copyright__ = """
Expand Down Expand Up @@ -35,7 +36,8 @@
THE SOFTWARE.
"""

from typing import Sequence, Mapping, Optional, Union, Tuple, TYPE_CHECKING, Any
from typing import (
Sequence, Mapping, Optional, Union, List, Tuple, TYPE_CHECKING, Any)

from pytools import memoize_method, single_valued

Expand Down Expand Up @@ -1015,4 +1017,44 @@ def make_discretization_collection(
# }}}


# {{{ filter_part_boundaries

def filter_part_boundaries(
dcoll: DiscretizationCollection,
*,
volume_dd: DOFDesc = DD_VOLUME_ALL,
neighbor_volume_dd: Optional[DOFDesc] = None,
neighbor_rank: Optional[int] = None) -> List[DOFDesc]:
"""
Retrieve tags of part boundaries that match *neighbor_volume_dd* and/or
*neighbor_rank*.
"""
vol_mesh = dcoll.discr_from_dd(volume_dd).mesh

from meshmode.mesh import InterPartAdjacencyGroup
filtered_part_bdry_dds = [
volume_dd.trace(fagrp.boundary_tag)
for fagrp_list in vol_mesh.facial_adjacency_groups
for fagrp in fagrp_list
if isinstance(fagrp, InterPartAdjacencyGroup)]

if neighbor_volume_dd is not None:
filtered_part_bdry_dds = [
bdry_dd
for bdry_dd in filtered_part_bdry_dds
if (
bdry_dd.domain_tag.tag.part_id.volume_tag
== neighbor_volume_dd.domain_tag.tag)]

if neighbor_rank is not None:
filtered_part_bdry_dds = [
bdry_dd
for bdry_dd in filtered_part_bdry_dds
if bdry_dd.domain_tag.tag.part_id.rank == neighbor_rank]

return filtered_part_bdry_dds

# }}}


# vim: foldmethod=marker

0 comments on commit c112288

Please sign in to comment.