def get_bt_masks(mesh, key, fiat_element): """Get masks for top and bottom dofs. :arg mesh: The mesh to use. :arg key: Canonicalised entity_dofs (see :func:`entity_dofs_key`). :arg fiat_element: The FIAT element. :returns: A dict mapping ``"topological"`` and ``"geometric"`` keys to bottom and top dofs (extruded) or ``None``. """ if not bool(mesh.layers): return None bt_masks = {} # Compute the top and bottom masks to identify boundary dofs # # Sorting the keys of the closure entity dofs, the whole cell # comes last [-1], before that the horizontal facet [-2], before # that vertical facets [-3]. We need the horizontal facets here. closure_dofs = fiat_element.entity_closure_dofs() b_mask = closure_dofs[sorted(closure_dofs.keys())[-2]][0] t_mask = closure_dofs[sorted(closure_dofs.keys())[-2]][1] bt_masks["topological"] = (b_mask, t_mask) # conversion to tuple # Geometric facet dofs facet_dofs = horiz_facet_support_dofs(fiat_element) bt_masks["geometric"] = (facet_dofs[0], facet_dofs[1]) return bt_masks
def get_bt_masks(mesh, key, fiat_element): """Get masks for top and bottom dofs. :arg mesh: The mesh to use. :arg key: Canonicalised entity_dofs (see :func:`entity_dofs_key`). :arg fiat_element: The FIAT element. :returns: A dict mapping ``"topological"`` and ``"geometric"`` keys to bottom and top dofs (extruded) or ``None``. """ if not bool(mesh.layers): return None bt_masks = {} # Compute the top and bottom masks to identify boundary dofs # # Sorting the keys of the closure entity dofs, the whole cell # comes last [-1], before that the horizontal facet [-2], before # that vertical facets [-3]. We need the horizontal facets here. closure_dofs = fiat_element.entity_closure_dofs() b_mask = closure_dofs[sorted(closure_dofs.keys())[-2]][0] t_mask = closure_dofs[sorted(closure_dofs.keys())[-2]][1] bt_masks["topological"] = (b_mask, t_mask) # conversion to tuple # Geometric facet dofs facet_dofs = horiz_facet_support_dofs(fiat_element) bt_masks["geometric"] = (facet_dofs[0], facet_dofs[1]) return bt_masks
def test_prism_hdiv(prism_mesh, space, degree, horiz_expected, vert_expected): W0_h = FiniteElement(space, "triangle", degree) W1_h = FiniteElement("DG", "triangle", degree - 1) W0_v = FiniteElement("DG", "interval", degree - 1) W0 = HDiv(TensorProductElement(W0_h, W0_v)) W1_v = FiniteElement("CG", "interval", degree) W1 = HDiv(TensorProductElement(W1_h, W1_v)) V = FunctionSpace(prism_mesh, W0+W1) assert horiz_expected == horiz_facet_support_dofs(V.fiat_element) assert vert_expected == vert_facet_support_dofs(V.fiat_element)
def test_prism(prism_mesh, args, kwargs, horiz_expected, vert_expected): V = FunctionSpace(prism_mesh, *args, **kwargs) assert horiz_expected == horiz_facet_support_dofs(V.fiat_element) assert vert_expected == vert_facet_support_dofs(V.fiat_element)