Skip to content

Commit bb8447a

Browse files
authored
Adapt to UFL changing some methods to properties (#4629)
* Adapt to UFL changing some methods to properties See FEniCS/ufl#385.
1 parent 2b1dbf6 commit bb8447a

File tree

80 files changed

+271
-274
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+271
-274
lines changed

.github/workflows/core.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ jobs:
194194
: # because they rely on non-PyPI versions of petsc4py.
195195
pip install --no-build-isolation --no-deps \
196196
"$PETSC_DIR"/"$PETSC_ARCH"/externalpackages/git.slepc/src/binding/slepc4py
197-
pip install --no-deps git+https://github.com/NGSolve/ngsPETSc.git netgen-mesher netgen-occt
197+
# UNDO ME
198+
pip install --no-deps git+https://github.com/NGSolve/ngsPETSc.git@connorjward/ufl-cell-fix netgen-mesher netgen-occt
198199
199200
: # We have to pass '--no-build-isolation' to use a custom petsc4py
200201
EXTRA_BUILD_ARGS='--no-isolation'

demos/ma-demo/ma-demo.py.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ a Function, w. ::
111111

112112
n = FacetNormal(mesh)
113113

114-
I = Identity(mesh.geometric_dimension())
114+
I = Identity(mesh.geometric_dimension)
115115

116116
L = inner(sigma, tau)*dx
117117
L += (inner(div(tau), grad(u))*dx

docs/notebooks/03-elasticity.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"f = as_vector([0, -rho*g])\n",
119119
"mu = Constant(1)\n",
120120
"lambda_ = Constant(0.25)\n",
121-
"Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor"
121+
"Id = Identity(mesh.geometric_dimension) # 2x2 Identity tensor"
122122
]
123123
},
124124
{
@@ -285,7 +285,7 @@
285285
" f = as_vector([0, -rho*g])\n",
286286
" mu = Constant(1)\n",
287287
" lambda_ = Constant(0.25)\n",
288-
" Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor\n",
288+
" Id = Identity(mesh.geometric_dimension) # 2x2 Identity tensor\n",
289289
" \n",
290290
" bc = DirichletBC(V, Constant([0, 0]), 1)\n",
291291
" u = TrialFunction(V)\n",
@@ -393,7 +393,7 @@
393393
" f = as_vector([0, -rho*g])\n",
394394
" mu = Constant(1)\n",
395395
" lambda_ = Constant(0.25)\n",
396-
" Id = Identity(mesh.geometric_dimension()) # 2x2 Identity tensor\n",
396+
" Id = Identity(mesh.geometric_dimension) # 2x2 Identity tensor\n",
397397
" def epsilon(u):\n",
398398
" return 0.5*(grad(u) + grad(u).T)\n",
399399
"\n",

docs/notebooks/08-composable-solvers.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@
114114
"bc_value = as_vector([0.25 * x**2 * (2-x)**2 *y**2, 0])\n",
115115
"\n",
116116
"bcs = [DirichletBC(W.sub(0), bc_value, 4),\n",
117-
" DirichletBC(W.sub(0), zero(mesh.geometric_dimension()), (1, 2, 3))]"
117+
" DirichletBC(W.sub(0), zero(mesh.geometric_dimension), (1, 2, 3))]"
118118
]
119119
},
120120
{

docs/source/petsc-interface.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,8 +375,8 @@ Accordingly, set
375375

376376
.. code-block:: python3
377377
378-
dim = mesh.topological_dimension()
379-
gdim = mesh.geometrical_dimension()
378+
dim = mesh.topological_dimension
379+
gdim = mesh.geometric_dimension
380380
entity_dofs = np.zeros(dim+1, dtype=np.int32)
381381
entity_dofs[0] = gdim
382382
entity_dofs[1] = gdim*(p-1)

firedrake/assemble.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,9 +1871,9 @@ def _(_, self):
18711871
@_as_global_kernel_arg.register(CellFacetKernelArg)
18721872
def _as_global_kernel_arg_cell_facet(_, self):
18731873
if self._mesh.extruded:
1874-
num_facets = self._mesh._base_mesh.ufl_cell().num_facets()
1874+
num_facets = self._mesh._base_mesh.ufl_cell().num_facets
18751875
else:
1876-
num_facets = self._mesh.ufl_cell().num_facets()
1876+
num_facets = self._mesh.ufl_cell().num_facets
18771877
return op2.DatKernelArg((num_facets, 2))
18781878

18791879

firedrake/bcs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ def nodes(self):
130130
# First, we bail out on zany elements. We don't know how to do BC's for them.
131131
V = self._function_space
132132
if isinstance(V.finat_element, (finat.Argyris, finat.Morley, finat.Bell)) or \
133-
(isinstance(V.finat_element, finat.Hermite) and V.mesh().topological_dimension() > 1):
133+
(isinstance(V.finat_element, finat.Hermite) and V.mesh().topological_dimension > 1):
134134
raise NotImplementedError("Strong BCs not implemented for element %r, use Nitsche-type methods until we figure this out" % V.finat_element)
135135

136136
def hermite_stride(bcnodes):
137137
fe = self._function_space.finat_element
138-
tdim = self._function_space.mesh().topological_dimension()
138+
tdim = self._function_space.mesh().topological_dimension
139139
if isinstance(fe, finat.Hermite) and tdim == 1:
140140
bcnodes = bcnodes[::2] # every second dof is the vertex value
141141
elif fe.complex.is_macrocell() and self._function_space.ufl_element().sobolev_space == ufl.H1:

firedrake/checkpointing.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ def save_mesh(self, mesh, distribution_name=None, permutation_name=None):
593593
# Save tmesh.layers, which contains (start layer, stop layer)-tuple for each cell
594594
# Conceptually, we project these integer pairs onto DG0 vector space of dim=2.
595595
cell = base_tmesh.ufl_cell()
596-
element = finat.ufl.VectorElement("DP" if cell.is_simplex() else "DQ", cell, 0, dim=2)
596+
element = finat.ufl.VectorElement("DP" if cell.is_simplex else "DQ", cell, 0, dim=2)
597597
layers_tV = impl.FunctionSpace(base_tmesh, element)
598598
self._save_function_space_topology(layers_tV)
599599
# Note that _cell_numbering coincides with DG0 section, so we can use tmesh.layers directly.
@@ -1056,7 +1056,7 @@ def load_mesh(self, name=DEFAULT_MESH_NAME, reorder=None, distribution_parameter
10561056
variable_layers = self.get_attr(path, PREFIX_EXTRUDED + "_variable_layers")
10571057
if variable_layers:
10581058
cell = base_tmesh.ufl_cell()
1059-
element = finat.ufl.VectorElement("DP" if cell.is_simplex() else "DQ", cell, 0, dim=2)
1059+
element = finat.ufl.VectorElement("DP" if cell.is_simplex else "DQ", cell, 0, dim=2)
10601060
_ = self._load_function_space_topology(base_tmesh, element)
10611061
base_tmesh_key = self._generate_mesh_key_from_names(base_tmesh.name,
10621062
base_tmesh._distribution_name,
@@ -1119,7 +1119,7 @@ def load_mesh(self, name=DEFAULT_MESH_NAME, reorder=None, distribution_parameter
11191119
path = self._path_to_mesh_immersed(tmesh.name, name)
11201120
if path in self.h5pyfile:
11211121
cell = tmesh.ufl_cell()
1122-
element = finat.ufl.FiniteElement("DP" if cell.is_simplex() else "DQ", cell, 0)
1122+
element = finat.ufl.FiniteElement("DP" if cell.is_simplex else "DQ", cell, 0)
11231123
cell_orientations_tV = self._load_function_space_topology(tmesh, element)
11241124
tmesh_key = self._generate_mesh_key_from_names(tmesh.name,
11251125
tmesh._distribution_name,

firedrake/cython/extrusion_numbering.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ def top_bottom_boundary_nodes(mesh,
564564
layer_extents = mesh.layer_extents
565565
cell_closure = mesh.cell_closure
566566
ncell, nclosure = mesh.cell_closure.shape
567-
n_vert_facet = mesh._base_mesh.ufl_cell().num_facets()
567+
n_vert_facet = mesh._base_mesh.ufl_cell().num_facets
568568
assert facet_points.shape[0] == n_vert_facet + 2
569569

570570
bottom_facet = facet_points[n_vert_facet]

firedrake/cython/supermeshimpl.pyx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def assemble_mixed_mass_matrix(V_A, V_B, candidates,
6969
vertex_map_B = mesh_B.coordinates.cell_node_map().values_with_halo
7070

7171
num_vertices = vertex_map_A.shape[1]
72-
gdim = mesh_A.geometric_dimension()
72+
gdim = mesh_A.geometric_dimension
7373
simplex_A = numpy.empty((num_vertices, gdim), dtype=ScalarType)
7474
simplex_B = numpy.empty_like(simplex_A, dtype=ScalarType)
7575
simplices_C = numpy.empty(MAGIC[gdim], dtype=ScalarType)
@@ -119,10 +119,10 @@ def intersection_finder(mesh_A, mesh_B):
119119
long nnodes_A, nnodes_B, ncells_A, ncells_B
120120
int dim_A, dim_B, loc_A, loc_B
121121

122-
dim = mesh_A.geometric_dimension()
123-
assert dim == mesh_B.geometric_dimension()
124-
assert dim == mesh_A.topological_dimension()
125-
assert dim == mesh_B.topological_dimension()
122+
dim = mesh_A.geometric_dimension
123+
assert dim == mesh_B.geometric_dimension
124+
assert dim == mesh_A.topological_dimension
125+
assert dim == mesh_B.topological_dimension
126126

127127
assert mesh_A.coordinates.function_space().ufl_element().degree() == 1
128128
assert mesh_B.coordinates.function_space().ufl_element().degree() == 1
@@ -144,8 +144,8 @@ def intersection_finder(mesh_A, mesh_B):
144144
vertex_map_B = mesh_B.coordinates.cell_node_map().values_with_halo.astype(int)
145145
nnodes_A = mesh_A.coordinates.dof_dset.total_size
146146
nnodes_B = mesh_B.coordinates.dof_dset.total_size
147-
dim_A = mesh_A.geometric_dimension()
148-
dim_B = mesh_B.geometric_dimension()
147+
dim_A = mesh_A.geometric_dimension
148+
dim_B = mesh_B.geometric_dimension
149149
ncells_A = mesh_A.num_cells()
150150
ncells_B = mesh_B.num_cells()
151151
loc_A = vertex_map_A.shape[1]

0 commit comments

Comments
 (0)