From 6167a995140a0db6c8371047cfa608f074e34ce6 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner Date: Sat, 17 Oct 2015 13:39:01 -0500 Subject: [PATCH] Add mesh.is_boundary_tag_empty --- meshmode/mesh/__init__.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/meshmode/mesh/__init__.py b/meshmode/mesh/__init__.py index b6e4d689..4e72cb90 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 -- GitLab