Skip to content

Commit c112288

Browse files
committed
add filter_part_boundaries
eases setting up boundaries when calling operators on only one volume (i.e., uncoupled)
1 parent bfad1f7 commit c112288

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

grudge/discretization.py

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
99
.. currentmodule:: grudge.discretization
1010
.. autoclass:: PartID
11+
.. autofunction:: filter_part_boundaries
1112
"""
1213

1314
__copyright__ = """
@@ -35,7 +36,8 @@
3536
THE SOFTWARE.
3637
"""
3738

38-
from typing import Sequence, Mapping, Optional, Union, Tuple, TYPE_CHECKING, Any
39+
from typing import (
40+
Sequence, Mapping, Optional, Union, List, Tuple, TYPE_CHECKING, Any)
3941

4042
from pytools import memoize_method, single_valued
4143

@@ -1015,4 +1017,44 @@ def make_discretization_collection(
10151017
# }}}
10161018

10171019

1020+
# {{{ filter_part_boundaries
1021+
1022+
def filter_part_boundaries(
1023+
dcoll: DiscretizationCollection,
1024+
*,
1025+
volume_dd: DOFDesc = DD_VOLUME_ALL,
1026+
neighbor_volume_dd: Optional[DOFDesc] = None,
1027+
neighbor_rank: Optional[int] = None) -> List[DOFDesc]:
1028+
"""
1029+
Retrieve tags of part boundaries that match *neighbor_volume_dd* and/or
1030+
*neighbor_rank*.
1031+
"""
1032+
vol_mesh = dcoll.discr_from_dd(volume_dd).mesh
1033+
1034+
from meshmode.mesh import InterPartAdjacencyGroup
1035+
filtered_part_bdry_dds = [
1036+
volume_dd.trace(fagrp.boundary_tag)
1037+
for fagrp_list in vol_mesh.facial_adjacency_groups
1038+
for fagrp in fagrp_list
1039+
if isinstance(fagrp, InterPartAdjacencyGroup)]
1040+
1041+
if neighbor_volume_dd is not None:
1042+
filtered_part_bdry_dds = [
1043+
bdry_dd
1044+
for bdry_dd in filtered_part_bdry_dds
1045+
if (
1046+
bdry_dd.domain_tag.tag.part_id.volume_tag
1047+
== neighbor_volume_dd.domain_tag.tag)]
1048+
1049+
if neighbor_rank is not None:
1050+
filtered_part_bdry_dds = [
1051+
bdry_dd
1052+
for bdry_dd in filtered_part_bdry_dds
1053+
if bdry_dd.domain_tag.tag.part_id.rank == neighbor_rank]
1054+
1055+
return filtered_part_bdry_dds
1056+
1057+
# }}}
1058+
1059+
10181060
# vim: foldmethod=marker

0 commit comments

Comments
 (0)