diff --git a/meshmode/mesh/__init__.py b/meshmode/mesh/__init__.py index b6e4d6894c09a850d0d1d721f5a1e0ac2c59b6ed..4e72cb90fac569bc943f09a11218770d3c1196e4 100644 --- a/meshmode/mesh/__init__.py +++ b/meshmode/mesh/__init__.py @@ -45,6 +45,7 @@ __doc__ = """ .. autofunction:: as_python .. autofunction:: check_bc_coverage +.. autofunction:: is_boundary_tag_empty Predefined Boundary tags ------------------------ @@ -983,4 +984,32 @@ def check_bc_coverage(mesh, boundary_tags, incomplete_ok=False): # }}} + +# {{{ is_boundary_tag_empty + +def is_boundary_tag_empty(mesh, btag): + """Return *True* if the corresponding boundary tag does not occur as part of + *mesh*. + """ + + btag_index = mesh.btag_to_index.get(btag, None) + if btag_index is None: + return True + + btag_bit = 1 << btag_index + + for igrp in range(len(mesh.groups)): + bdry_fagrp = mesh.facial_adjacency_groups[igrp].get(None, None) + if bdry_fagrp is None: + continue + + neg = bdry_fagrp.neighbors < 0 + if (-bdry_fagrp.neighbors[neg] & btag_bit).any(): + return False + + return True + +# }}} + + # vim: foldmethod=marker