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
3 changes: 2 additions & 1 deletion .github/workflows/core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ jobs:
: # because they rely on non-PyPI versions of petsc4py.
pip install --no-build-isolation --no-deps \
"$PETSC_DIR"/"$PETSC_ARCH"/externalpackages/git.slepc/src/binding/slepc4py
pip install --no-deps git+https://github.com/NGSolve/ngsPETSc.git netgen-mesher netgen-occt
# UNDO ME
pip install --no-deps git+https://github.com/NGSolve/ngsPETSc.git@connorjward/ufl-cell-fix netgen-mesher netgen-occt

: # We have to pass '--no-build-isolation' to use a custom petsc4py
EXTRA_BUILD_ARGS='--no-isolation'
Expand Down
2 changes: 1 addition & 1 deletion demos/ma-demo/ma-demo.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ a Function, w. ::

n = FacetNormal(mesh)

I = Identity(mesh.geometric_dimension())
I = Identity(mesh.geometric_dimension)

L = inner(sigma, tau)*dx
L += (inner(div(tau), grad(u))*dx
Expand Down
6 changes: 3 additions & 3 deletions docs/notebooks/03-elasticity.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"f = as_vector([0, -rho*g])\n",
"mu = Constant(1)\n",
"lambda_ = Constant(0.25)\n",
"Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor"
"Id = Identity(mesh.geometric_dimension) # 2x2 Identity tensor"
]
},
{
Expand Down Expand Up @@ -285,7 +285,7 @@
" f = as_vector([0, -rho*g])\n",
" mu = Constant(1)\n",
" lambda_ = Constant(0.25)\n",
" Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor\n",
" Id = Identity(mesh.geometric_dimension) # 2x2 Identity tensor\n",
" \n",
" bc = DirichletBC(V, Constant([0, 0]), 1)\n",
" u = TrialFunction(V)\n",
Expand Down Expand Up @@ -393,7 +393,7 @@
" f = as_vector([0, -rho*g])\n",
" mu = Constant(1)\n",
" lambda_ = Constant(0.25)\n",
" Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor\n",
" Id = Identity(mesh.geometric_dimension) # 2x2 Identity tensor\n",
" def epsilon(u):\n",
" return 0.5*(grad(u) + grad(u).T)\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/notebooks/08-composable-solvers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"bc_value = as_vector([0.25 * x**2 * (2-x)**2 *y**2, 0])\n",
"\n",
"bcs = [DirichletBC(W.sub(0), bc_value, 4),\n",
" DirichletBC(W.sub(0), zero(mesh.geometric_dimension()), (1, 2, 3))]"
" DirichletBC(W.sub(0), zero(mesh.geometric_dimension), (1, 2, 3))]"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions docs/source/petsc-interface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ Accordingly, set

.. code-block:: python3

dim = mesh.topological_dimension()
gdim = mesh.geometrical_dimension()
dim = mesh.topological_dimension
gdim = mesh.geometric_dimension
entity_dofs = np.zeros(dim+1, dtype=np.int32)
entity_dofs[0] = gdim
entity_dofs[1] = gdim*(p-1)
Expand Down
4 changes: 2 additions & 2 deletions firedrake/assemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -1808,9 +1808,9 @@ def _as_global_kernel_arg_interior_facet_orientation(_, self):
@_as_global_kernel_arg.register(CellFacetKernelArg)
def _as_global_kernel_arg_cell_facet(_, self):
if self._mesh.extruded:
num_facets = self._mesh._base_mesh.ufl_cell().num_facets()
num_facets = self._mesh._base_mesh.ufl_cell().num_facets
else:
num_facets = self._mesh.ufl_cell().num_facets()
num_facets = self._mesh.ufl_cell().num_facets
return op2.DatKernelArg((num_facets, 2))


Expand Down
4 changes: 2 additions & 2 deletions firedrake/bcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,12 +130,12 @@ def nodes(self):
# First, we bail out on zany elements. We don't know how to do BC's for them.
V = self._function_space
if isinstance(V.finat_element, (finat.Argyris, finat.Morley, finat.Bell)) or \
(isinstance(V.finat_element, finat.Hermite) and V.mesh().topological_dimension() > 1):
(isinstance(V.finat_element, finat.Hermite) and V.mesh().topological_dimension > 1):
raise NotImplementedError("Strong BCs not implemented for element %r, use Nitsche-type methods until we figure this out" % V.finat_element)

def hermite_stride(bcnodes):
fe = self._function_space.finat_element
tdim = self._function_space.mesh().topological_dimension()
tdim = self._function_space.mesh().topological_dimension
if isinstance(fe, finat.Hermite) and tdim == 1:
bcnodes = bcnodes[::2] # every second dof is the vertex value
elif fe.complex.is_macrocell() and self._function_space.ufl_element().sobolev_space == ufl.H1:
Expand Down
6 changes: 3 additions & 3 deletions firedrake/checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ def save_mesh(self, mesh, distribution_name=None, permutation_name=None):
# Save tmesh.layers, which contains (start layer, stop layer)-tuple for each cell
# Conceptually, we project these integer pairs onto DG0 vector space of dim=2.
cell = base_tmesh.ufl_cell()
element = finat.ufl.VectorElement("DP" if cell.is_simplex() else "DQ", cell, 0, dim=2)
element = finat.ufl.VectorElement("DP" if cell.is_simplex else "DQ", cell, 0, dim=2)
layers_tV = impl.FunctionSpace(base_tmesh, element)
self._save_function_space_topology(layers_tV)
# Note that _cell_numbering coincides with DG0 section, so we can use tmesh.layers directly.
Expand Down Expand Up @@ -1050,7 +1050,7 @@ def load_mesh(self, name=DEFAULT_MESH_NAME, reorder=None, distribution_parameter
variable_layers = self.get_attr(path, PREFIX_EXTRUDED + "_variable_layers")
if variable_layers:
cell = base_tmesh.ufl_cell()
element = finat.ufl.VectorElement("DP" if cell.is_simplex() else "DQ", cell, 0, dim=2)
element = finat.ufl.VectorElement("DP" if cell.is_simplex else "DQ", cell, 0, dim=2)
_ = self._load_function_space_topology(base_tmesh, element)
base_tmesh_key = self._generate_mesh_key_from_names(base_tmesh.name,
base_tmesh._distribution_name,
Expand Down Expand Up @@ -1113,7 +1113,7 @@ def load_mesh(self, name=DEFAULT_MESH_NAME, reorder=None, distribution_parameter
path = self._path_to_mesh_immersed(tmesh.name, name)
if path in self.h5pyfile:
cell = tmesh.ufl_cell()
element = finat.ufl.FiniteElement("DP" if cell.is_simplex() else "DQ", cell, 0)
element = finat.ufl.FiniteElement("DP" if cell.is_simplex else "DQ", cell, 0)
cell_orientations_tV = self._load_function_space_topology(tmesh, element)
tmesh_key = self._generate_mesh_key_from_names(tmesh.name,
tmesh._distribution_name,
Expand Down
2 changes: 1 addition & 1 deletion firedrake/cython/extrusion_numbering.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def top_bottom_boundary_nodes(mesh,
layer_extents = mesh.layer_extents
cell_closure = mesh.cell_closure
ncell, nclosure = mesh.cell_closure.shape
n_vert_facet = mesh._base_mesh.ufl_cell().num_facets()
n_vert_facet = mesh._base_mesh.ufl_cell().num_facets
assert facet_points.shape[0] == n_vert_facet + 2

bottom_facet = facet_points[n_vert_facet]
Expand Down
14 changes: 7 additions & 7 deletions firedrake/cython/supermeshimpl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def assemble_mixed_mass_matrix(V_A, V_B, candidates,
vertex_map_B = mesh_B.coordinates.cell_node_map().values_with_halo

num_vertices = vertex_map_A.shape[1]
gdim = mesh_A.geometric_dimension()
gdim = mesh_A.geometric_dimension
simplex_A = numpy.empty((num_vertices, gdim), dtype=ScalarType)
simplex_B = numpy.empty_like(simplex_A, dtype=ScalarType)
simplices_C = numpy.empty(MAGIC[gdim], dtype=ScalarType)
Expand Down Expand Up @@ -119,10 +119,10 @@ def intersection_finder(mesh_A, mesh_B):
long nnodes_A, nnodes_B, ncells_A, ncells_B
int dim_A, dim_B, loc_A, loc_B

dim = mesh_A.geometric_dimension()
assert dim == mesh_B.geometric_dimension()
assert dim == mesh_A.topological_dimension()
assert dim == mesh_B.topological_dimension()
dim = mesh_A.geometric_dimension
assert dim == mesh_B.geometric_dimension
assert dim == mesh_A.topological_dimension
assert dim == mesh_B.topological_dimension

assert mesh_A.coordinates.function_space().ufl_element().degree() == 1
assert mesh_B.coordinates.function_space().ufl_element().degree() == 1
Expand All @@ -144,8 +144,8 @@ def intersection_finder(mesh_A, mesh_B):
vertex_map_B = mesh_B.coordinates.cell_node_map().values_with_halo.astype(int)
nnodes_A = mesh_A.coordinates.dof_dset.total_size
nnodes_B = mesh_B.coordinates.dof_dset.total_size
dim_A = mesh_A.geometric_dimension()
dim_B = mesh_B.geometric_dimension()
dim_A = mesh_A.geometric_dimension
dim_B = mesh_B.geometric_dimension
ncells_A = mesh_A.num_cells()
ncells_B = mesh_B.num_cells()
loc_A = vertex_map_A.shape[1]
Expand Down
4 changes: 2 additions & 2 deletions firedrake/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

def get_embedding_dg_element(element, value_shape, broken_cg=False):
cell = element.cell
family = lambda c: "DG" if c.is_simplex() else "DQ"
family = lambda c: "DG" if c.is_simplex else "DQ"
if isinstance(cell, ufl.TensorProductCell):
degree = element.degree()
if type(degree) is int:
scalar_element = finat.ufl.FiniteElement("DQ", cell=cell, degree=degree)
else:
scalar_element = finat.ufl.TensorProductElement(*(finat.ufl.FiniteElement(family(c), cell=c, degree=d)
for (c, d) in zip(cell.sub_cells(), degree)))
for (c, d) in zip(cell.sub_cells, degree)))
else:
degree = element.embedded_superdegree
scalar_element = finat.ufl.FiniteElement(family(cell), cell=cell, degree=degree)
Expand Down
2 changes: 1 addition & 1 deletion firedrake/extrusion_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def _get_lp_domains(_inames, _extents):
elif extrusion_type == 'radial_hedgehog':
# Only implemented for interval in 2D and triangle in 3D.
# gdim != tdim already checked in ExtrudedMesh constructor.
tdim = extract_unique_domain(base_coords).ufl_cell().topological_dimension()
tdim = extract_unique_domain(base_coords).ufl_cell().topological_dimension
if tdim not in [1, 2]:
raise NotImplementedError("Hedgehog extrusion not implemented for %s" % extract_unique_domain(base_coords).ufl_cell())
# tdim == 1:
Expand Down
4 changes: 2 additions & 2 deletions firedrake/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def _at(self, arg, *args, **kwargs):
raise NotImplementedError("Point evaluation not implemented for variable layers")

# Validate geometric dimension
gdim = mesh.geometric_dimension()
gdim = mesh.geometric_dimension
if arg.shape[-1] == gdim:
pass
elif len(arg.shape) == 1 and gdim == 1:
Expand Down Expand Up @@ -728,7 +728,7 @@ def __init__(self, mesh: MeshGeometry, points: np.ndarray | list, tolerance: flo
self.points = np.asarray(points, dtype=utils.ScalarType)
if not self.points.shape:
self.points = self.points.reshape(-1)
gdim = mesh.geometric_dimension()
gdim = mesh.geometric_dimension
if self.points.shape[-1] != gdim and (len(self.points.shape) != 1 or gdim != 1):
raise ValueError(f"Point dimension ({self.points.shape[-1]}) does not match geometric dimension ({gdim}).")
self.points = self.points.reshape(-1, gdim)
Expand Down
6 changes: 3 additions & 3 deletions firedrake/functionspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def make_scalar_element(mesh, family, degree, vfamily, vdegree, variant):
if isinstance(cell, ufl.TensorProductCell) \
and vfamily is not None and vdegree is not None:
la = finat.ufl.FiniteElement(family,
cell=cell.sub_cells()[0],
cell=cell.sub_cells[0],
degree=degree, variant=variant)
# If second element was passed in, use it
lb = finat.ufl.FiniteElement(vfamily,
Expand Down Expand Up @@ -180,7 +180,7 @@ def VectorFunctionSpace(mesh, family, degree=None, dim=None,
"""
sub_element = make_scalar_element(mesh, family, degree, vfamily, vdegree, variant)
if dim is None:
dim = mesh.geometric_dimension()
dim = mesh.geometric_dimension
if not isinstance(dim, numbers.Integral) and dim > 0:
raise ValueError(f"Can't make VectorFunctionSpace with dim={dim}")
element = finat.ufl.VectorElement(sub_element, dim=dim)
Expand Down Expand Up @@ -232,7 +232,7 @@ def TensorFunctionSpace(mesh, family, degree=None, shape=None,
"""
sub_element = make_scalar_element(mesh, family, degree, vfamily, vdegree, variant)
if shape is None:
shape = (mesh.geometric_dimension(),) * 2
shape = (mesh.geometric_dimension,) * 2
element = finat.ufl.TensorElement(sub_element, shape=shape, symmetry=symmetry)
return FunctionSpace(mesh, element, name=name)

Expand Down
2 changes: 1 addition & 1 deletion firedrake/functionspaceimpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def check_element(element, top=True):
ValueError
If the element is illegal.
"""
if element.cell.cellname() == "hexahedron" and \
if element.cell.cellname == "hexahedron" and \
element.family() not in ["Q", "DQ", "Real"]:
raise NotImplementedError("Currently can only use 'Q', 'DQ', and/or 'Real' elements on hexahedral meshes, not", element.family())
if type(element) in (finat.ufl.BrokenElement, finat.ufl.RestrictedElement,
Expand Down
12 changes: 6 additions & 6 deletions firedrake/interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def __new__(cls, expr, V, **kwargs):
submesh_interp_implemented = \
all(isinstance(m.topology, firedrake.mesh.MeshTopology) for m in [target_mesh, source_mesh]) and \
target_mesh.submesh_ancesters[-1] is source_mesh.submesh_ancesters[-1] and \
target_mesh.topological_dimension() == source_mesh.topological_dimension()
target_mesh.topological_dimension == source_mesh.topological_dimension
if target_mesh is source_mesh or submesh_interp_implemented:
return object.__new__(SameMeshInterpolator)
else:
Expand Down Expand Up @@ -498,8 +498,8 @@ def __init__(
V_dest = V.function_space() if isinstance(V, firedrake.Function) else V
src_mesh = extract_unique_domain(expr)
dest_mesh = as_domain(V_dest)
src_mesh_gdim = src_mesh.geometric_dimension()
dest_mesh_gdim = dest_mesh.geometric_dimension()
src_mesh_gdim = src_mesh.geometric_dimension
dest_mesh_gdim = dest_mesh.geometric_dimension
if src_mesh_gdim != dest_mesh_gdim:
raise ValueError(
"geometric dimensions of source and destination meshes must match"
Expand Down Expand Up @@ -870,7 +870,7 @@ def make_interpolator(expr, V, subset, access, bcs=None, matfree=True):
if isinstance(target_mesh.topology, VertexOnlyMeshTopology) and target_mesh is not source_mesh and not vom_onto_other_vom:
if not isinstance(target_mesh.topology, VertexOnlyMeshTopology):
raise NotImplementedError("Can only interpolate onto a VertexOnlyMesh")
if target_mesh.geometric_dimension() != source_mesh.geometric_dimension():
if target_mesh.geometric_dimension != source_mesh.geometric_dimension:
raise ValueError("Cannot interpolate onto a mesh of a different geometric dimension")
if not hasattr(target_mesh, "_parent_mesh") or target_mesh._parent_mesh is not source_mesh:
raise ValueError("Can only interpolate across meshes where the source mesh is the parent of the target")
Expand Down Expand Up @@ -1005,7 +1005,7 @@ def _interpolator(tensor, expr, subset, access, bcs=None):
if target_mesh is not source_mesh:
if not isinstance(target_mesh.topology, VertexOnlyMeshTopology):
raise NotImplementedError("Can only interpolate onto a Vertex Only Mesh")
if target_mesh.geometric_dimension() != source_mesh.geometric_dimension():
if target_mesh.geometric_dimension != source_mesh.geometric_dimension:
raise ValueError("Cannot interpolate onto a mesh of a different geometric dimension")
if not hasattr(target_mesh, "_parent_mesh") or target_mesh._parent_mesh is not source_mesh:
raise ValueError("Can only interpolate across meshes where the source mesh is the parent of the target")
Expand Down Expand Up @@ -1239,7 +1239,7 @@ def rebuild_dg(element, expr_cell, rt_var_name):
# dual basis. This exists on the same reference cell as the input element
# and we can interpolate onto it before mapping the result back onto the
# target space.
expr_tdim = expr_cell.topological_dimension()
expr_tdim = expr_cell.topological_dimension
# Need point evaluations and matching weights from dual basis.
# This could use FIAT's dual basis as below:
# num_points = sum(len(dual.get_point_dict()) for dual in element.fiat_equivalent.dual_basis())
Expand Down
Loading
Loading