Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
322 changes: 185 additions & 137 deletions firedrake/cython/dmcommon.pyx

Large diffs are not rendered by default.

6 changes: 0 additions & 6 deletions firedrake/functionspaceimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,12 +984,6 @@ def _iterset_to_node_map_dat(
self,
iter_type: Literal["cell", "exterior_facet", "interior_facet"],
) -> op3.Dat:
# these are actually OK, but they shouldn't be used as offsets
# if len(self) > 1:
# raise TypeError("Cannot tabulate cell node maps for mixed spaces")
# if self.boundary_set:
# raise TypeError("Cannot tabulate cell node maps for restricted spaces")

# To convert between the fully unrolled DoF map and a node-wise one
# we just need to stride and divide by the block size.
dof_map_dat = self._iterset_to_dof_map_dat(iter_type)
Expand Down
955 changes: 665 additions & 290 deletions firedrake/mesh.py

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions firedrake/pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,6 @@ def _orient_axis_tree(axes, space: WithGeometry, cell_index: op3.Index, *, depth
dim_label = dim_axis_component.label

dof_axis_label = f"dof{dim_label}"
# dof_axis = utils.single_valued(axis for axis in space.plex_axes.axes if axis.label == dof_axis_label)
dof_axis = utils.single_valued(axis for axis in axes.axes if axis.label == f"dof{dim_label}")
if dof_axis.size == 0:
continue
Expand Down Expand Up @@ -421,7 +420,6 @@ def _orient_axis_tree(axes, space: WithGeometry, cell_index: op3.Index, *, depth
before = utils.just_one(new_targets[path][0]) # hack to get the right one...
assert before.axis == "dof"
new_targets[path] = [[before.record_new(
# expr=op3.replace_terminals(before.expr, {dof_axis.label: perm_expr}, assert_modified=True)
expr=op3.replace_terminals(before.expr, {dof_axis.label: perm_expr})
)]]

Expand Down
3 changes: 1 addition & 2 deletions firedrake/preconditioners/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ def add_coeff(coeff):
elif self.kinfo.integral_type == "exterior_facet":
add_dat(self._mesh.exterior_facet_local_facet_indices, 1)

# breakpoint()
return args, names, state_index

@cached_property
Expand Down Expand Up @@ -935,7 +934,7 @@ def initialize(self, obj):
)

patch.setDM(self.plex)
patch.setPatchCellNumbering(mesh_unique._plex_to_entity_numbering_sec("cell"))
patch.setPatchCellNumbering(mesh_unique._dm_to_entity_numbering_sec("cell"))

dms = [V_.dm for V_ in V]
cell_dof_maps = [V_.cell_dof_map_dat.data_ro for V_ in V]
Expand Down
2 changes: 1 addition & 1 deletion firedrake/pyplot/mpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ def marker_faces(marker):
else:
subset_dm_idxs = mesh.iter(facet_type, int(marker)).dm_indices
subset_idxs = dmcommon.section_offsets(
mesh._plex_to_entity_numbering_sec(facet_type), subset_dm_idxs
mesh._dm_to_entity_numbering_sec(facet_type), subset_dm_idxs
)

return exterior_facet_nodes_per_exterior_facet[subset_idxs]
Expand Down
8 changes: 4 additions & 4 deletions tests/firedrake/multigrid/test_grid_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"quadrilateral",
"tetrahedron",
"prism",
"hexahedron",
"extrudedquad",
],
scope="module",
)
Expand All @@ -22,7 +22,7 @@ def cell(request):

@pytest.fixture(params=["CG", "DG"])
def space(request, cell):
if cell in {"quadrilateral", "prism", "hexahedron"} and request.param == "DG":
if cell in {"quadrilateral", "prism", "extrudedquad"} and request.param == "DG":
return "DQ"
else:
return request.param
Expand All @@ -40,7 +40,7 @@ def hierarchy(cell, refinements_per_level):
return MeshHierarchy(mesh, 2)
elif cell in {"triangle", "triangle-nonnested", "triangle-submesh", "prism"}:
mesh = UnitSquareMesh(3, 3, quadrilateral=False)
elif cell in {"quadrilateral", "hexahedron"}:
elif cell in {"quadrilateral", "extrudedquad"}:
mesh = UnitSquareMesh(3, 3, quadrilateral=True)
elif cell == "tetrahedron":
mesh = UnitCubeMesh(2, 2, 2)
Expand All @@ -55,7 +55,7 @@ def hierarchy(cell, refinements_per_level):
nref = {2: 1, 1: 2}[refinements_per_level]
hierarchy = MeshHierarchy(mesh, nref, refinements_per_level=refinements_per_level)

if cell in {"prism", "hexahedron"}:
if cell in {"prism", "extrudedquad"}:
hierarchy = ExtrudedMeshHierarchy(hierarchy, base_layer=3, refinement_ratio=1, height=1)
if cell == "triangle-nonnested":
c2f = {}
Expand Down
20 changes: 14 additions & 6 deletions tests/firedrake/regression/test_mesh_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,24 +76,32 @@ def test_tensor_box():


@pytest.mark.parallel([1, 2])
def test_one_element_advection():
nx = 20
m = PeriodicRectangleMesh(nx, 1, 1.0, 1.0, quadrilateral=True)
@pytest.mark.parametrize("direction", ["x", "y"])
def test_one_element_advection(direction):
n = 20
if direction == "x":
m = PeriodicRectangleMesh(n, 1, 1.0, 1.0, quadrilateral=True)
else:
m = PeriodicRectangleMesh(1, n, 1.0, 1.0, quadrilateral=True)
nlayers = 20
mesh = ExtrudedMesh(m, nlayers, 1.0/nlayers)
x = SpatialCoordinate(mesh)
x, y, z = SpatialCoordinate(mesh)
fe_dg = FiniteElement("DQ", mesh.ufl_cell(), 1, variant="equispaced")
Vdg = FunctionSpace(mesh, fe_dg)
Vu = VectorFunctionSpace(mesh, fe_dg)
q0 = Function(Vdg).interpolate(cos(2*pi*x[0])*cos(pi*x[2]))
if direction == "x":
q0 = Function(Vdg).interpolate(cos(2*pi*x)*cos(pi*z))
u0 = Function(Vu).interpolate(Constant((1.0, 0.0, 0.0)))
else:
q0 = Function(Vdg).interpolate(cos(2*pi*y)*cos(pi*z))
u0 = Function(Vu).interpolate(Constant((0.0, 1.0, 0.0)))
q_init = Function(Vdg).assign(q0)
dq1 = Function(Vdg)
q1 = Function(Vdg)
Dt = 0.01
dt = Constant(Dt)
# Mesh-related functions
n = FacetNormal(mesh)
u0 = Function(Vu).interpolate(Constant((1.0, 0.0, 0.0)))
# ( dot(v, n) + |dot(v, n)| )/2.0
un = 0.5*(dot(u0, n) + abs(dot(u0, n)))
# advection equation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,17 +164,17 @@ def verify_vertexonly_mesh(m, vm, inputvertexcoords, name):
assert vm.topology._parent_mesh is m.topology
# Correct generic cell properties
if not skip_in_bounds_checks:
assert vm._fiat_cell_closures.shape == (vm.num_cells(), 1)
assert vm._flat_dm_closures_oriented(0).shape == (vm.num_cells(), 1)
else:
vm._fiat_cell_closures.shape
vm._flat_dm_closures_oriented(0).shape
with pytest.raises(AttributeError):
vm.exterior_facets
with pytest.raises(AttributeError):
vm.interior_facets
with pytest.raises(AttributeError):
vm.cell_to_facets
if not skip_in_bounds_checks:
assert vm.num_cells() == vm._fiat_cell_closures.shape[0] == vm.cells.local_size
assert vm.num_cells() == vm._flat_dm_closures_oriented(0).shape[0] == vm.cells.local_size
assert vm.cells.owned.local_size == len(inputvertexcoords[in_bounds])
assert vm.num_facets() == 0
assert vm.num_faces() == vm.num_entities(2) == 0
Expand Down
Loading