Skip to content

Commit e4439cc

Browse files
authored
Remove "create" prefix from some functions (#2763)
* Remove "create" prefix from some functions. Fixes #2760. * Rename function * Fix import * Type name fix
1 parent 766b653 commit e4439cc

19 files changed

+45
-45
lines changed

python/demo/demo_axis/demo_axis.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ def create_eps_mu(pml, rho, eps_bkg, mu_bkg):
349349
# Visually check of the mesh and of the subdomains using PyVista:
350350

351351
if have_pyvista:
352-
topology, cell_types, geometry = plot.create_vtk_mesh(msh, 2)
352+
topology, cell_types, geometry = plot.vtk_mesh(msh, 2)
353353
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)
354354
plotter = pyvista.Plotter()
355355
num_local_cells = msh.topology.index_map(msh.topology.dim).size_local

python/demo/demo_biharmonic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@
231231
# +
232232
try:
233233
import pyvista
234-
cells, types, x = plot.create_vtk_mesh(V)
234+
cells, types, x = plot.vtk_mesh(V)
235235
grid = pyvista.UnstructuredGrid(cells, types, x)
236236
grid.point_data["u"] = uh.x.array.real
237237
grid.set_active_scalars("u")

python/demo/demo_cahn-hilliard.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@
289289
# Prepare viewer for plotting the solution during the computation
290290
if have_pyvista:
291291
# Create a VTK 'mesh' with 'nodes' at the function dofs
292-
topology, cell_types, x = plot.create_vtk_mesh(V0)
292+
topology, cell_types, x = plot.vtk_mesh(V0)
293293
grid = pv.UnstructuredGrid(topology, cell_types, x)
294294

295295
# Set output data

python/demo/demo_interpolation-io.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
try:
7777
import pyvista
78-
cells, types, x = plot.create_vtk_mesh(V0)
78+
cells, types, x = plot.vtk_mesh(V0)
7979
grid = pyvista.UnstructuredGrid(cells, types, x)
8080
values = np.zeros((x.shape[0], 3), dtype=np.float64)
8181
values[:, :msh.topology.dim] = u0.x.array.reshape(x.shape[0], msh.topology.dim).real

python/demo/demo_pml/demo_pml.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def pml_coordinates(x: ufl.indexed.Indexed, alpha: float, k0: complex, l_dom: fl
186186
# [PyVista](https://docs.pyvista.org/)
187187

188188
if have_pyvista:
189-
topology, cell_types, geometry = plot.create_vtk_mesh(msh, 2)
189+
topology, cell_types, geometry = plot.vtk_mesh(msh, 2)
190190
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)
191191
plotter = pyvista.Plotter()
192192
num_local_cells = msh.topology.index_map(msh.topology.dim).size_local
@@ -435,7 +435,7 @@ def create_eps_mu(pml: ufl.tensors.ListTensor,
435435
# DOLFINx demo.
436436

437437
if have_pyvista:
438-
V_cells, V_types, V_x = plot.create_vtk_mesh(V_dg)
438+
V_cells, V_types, V_x = plot.vtk_mesh(V_dg)
439439
V_grid = pyvista.UnstructuredGrid(V_cells, V_types, V_x)
440440
Esh_values = np.zeros((V_x.shape[0], 3), dtype=np.float64)
441441
Esh_values[:, :msh.topology.dim] = Esh_dg.x.array.reshape(V_x.shape[0], msh.topology.dim).real

python/demo/demo_poisson.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
# +
152152
try:
153153
import pyvista
154-
cells, types, x = plot.create_vtk_mesh(V)
154+
cells, types, x = plot.vtk_mesh(V)
155155
grid = pyvista.UnstructuredGrid(cells, types, x)
156156
grid.point_data["u"] = uh.x.array.real
157157
grid.set_active_scalars("u")

python/demo/demo_pyvista.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def plot_scalar():
5959

6060
# To visualize the function u, we create a VTK-compatible grid to
6161
# values of u to
62-
cells, types, x = plot.create_vtk_mesh(V)
62+
cells, types, x = plot.vtk_mesh(V)
6363
grid = pyvista.UnstructuredGrid(cells, types, x)
6464
grid.point_data["u"] = u.x.array
6565

@@ -110,7 +110,7 @@ def in_circle(x):
110110
cell_tags = meshtags(msh, msh.topology.dim, np.arange(num_cells), in_circle(midpoints))
111111

112112
# Create VTK mesh
113-
cells, types, x = plot.create_vtk_mesh(msh)
113+
cells, types, x = plot.vtk_mesh(msh)
114114
grid = pyvista.UnstructuredGrid(cells, types, x)
115115

116116
# Attach the cells tag data to the pyvita grid
@@ -128,7 +128,7 @@ def in_circle(x):
128128
# We can visualize subsets of data, by creating a smaller topology
129129
# (set of cells). Here we create VTK mesh data for only cells with
130130
# that tag '1'.
131-
cells, types, x = plot.create_vtk_mesh(msh, entities=cell_tags.find(1))
131+
cells, types, x = plot.vtk_mesh(msh, entities=cell_tags.find(1))
132132

133133
# Add this grid to the second plotter window
134134
sub_grid = pyvista.UnstructuredGrid(cells, types, x)
@@ -173,7 +173,7 @@ def in_circle(x):
173173

174174
# Create a topology that has a 1-1 correspondence with the
175175
# degrees-of-freedom in the function space V
176-
cells, types, x = plot.create_vtk_mesh(V)
176+
cells, types, x = plot.vtk_mesh(V)
177177

178178
# Create a pyvista mesh and attach the values of u
179179
grid = pyvista.UnstructuredGrid(cells, types, x)
@@ -184,7 +184,7 @@ def in_circle(x):
184184
# that as we have done previously
185185
num_cells = msh.topology.index_map(msh.topology.dim).size_local
186186
cell_entities = np.arange(num_cells, dtype=np.int32)
187-
cells, types, x = plot.create_vtk_mesh(msh, entities=cell_entities)
187+
cells, types, x = plot.vtk_mesh(msh, entities=cell_entities)
188188
org_grid = pyvista.UnstructuredGrid(cells, types, x)
189189

190190
# We visualize the data
@@ -218,7 +218,7 @@ def plot_nedelec():
218218
position="upper_edge", font_size=14, color="black")
219219

220220
# Next, we create a pyvista.UnstructuredGrid based on the mesh
221-
pyvista_cells, cell_types, x = plot.create_vtk_mesh(msh)
221+
pyvista_cells, cell_types, x = plot.vtk_mesh(msh)
222222
grid = pyvista.UnstructuredGrid(pyvista_cells, cell_types, x)
223223

224224
# Add this grid (as a wireframe) to the plotter
@@ -241,7 +241,7 @@ def plot_nedelec():
241241

242242
# Create a second grid, whose geometry and topology is based on the
243243
# output function space
244-
cells, cell_types, x = plot.create_vtk_mesh(V0)
244+
cells, cell_types, x = plot.vtk_mesh(V0)
245245
grid = pyvista.UnstructuredGrid(cells, cell_types, x)
246246

247247
# Create point cloud of vertices, and add the vertex values to the cloud
@@ -271,7 +271,7 @@ def plot_streamlines():
271271
u = Function(V, dtype=np.float64)
272272
u.interpolate(lambda x: np.vstack((-(x[1] - 0.5), x[0] - 0.5, np.zeros(x.shape[1]))))
273273

274-
cells, types, x = plot.create_vtk_mesh(V)
274+
cells, types, x = plot.vtk_mesh(V)
275275
num_dofs = x.shape[0]
276276
values = np.zeros((num_dofs, 3), dtype=np.float64)
277277
values[:, :msh.geometry.dim] = u.x.array.reshape(num_dofs, V.dofmap.index_map_bs)

python/demo/demo_scattering_boundary_conditions/demo_scattering_boundary_conditions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def curl_2d(f: fem.Function):
243243
# The mesh is visualized with [PyVista](https://docs.pyvista.org/)
244244

245245
if have_pyvista:
246-
topology, cell_types, geometry = plot.create_vtk_mesh(domain, 2)
246+
topology, cell_types, geometry = plot.vtk_mesh(domain, 2)
247247
grid = pyvista.UnstructuredGrid(topology, cell_types, geometry)
248248
plotter = pyvista.Plotter()
249249
num_local_cells = domain.topology.index_map(domain.topology.dim).size_local
@@ -424,7 +424,7 @@ def curl_2d(f: fem.Function):
424424
# DOLFINx demo.
425425

426426
if have_pyvista:
427-
V_cells, V_types, V_x = plot.create_vtk_mesh(V_dg)
427+
V_cells, V_types, V_x = plot.vtk_mesh(V_dg)
428428
V_grid = pyvista.UnstructuredGrid(V_cells, V_types, V_x)
429429
Esh_values = np.zeros((V_x.shape[0], 3), dtype=np.float64)
430430
Esh_values[:, : domain.topology.dim] = Esh_dg.x.array.reshape(V_x.shape[0], domain.topology.dim).real

python/demo/demo_types.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def display_scalar(u, name, filter=np.real):
4545
"""Plot the solution using pyvista"""
4646
try:
4747
import pyvista
48-
cells, types, x = plot.create_vtk_mesh(u.function_space)
48+
cells, types, x = plot.vtk_mesh(u.function_space)
4949
grid = pyvista.UnstructuredGrid(cells, types, x)
5050
grid.point_data["u"] = filter(u.x.array)
5151
grid.set_active_scalars("u")
@@ -67,7 +67,7 @@ def display_vector(u, name, filter=np.real):
6767
try:
6868
import pyvista
6969
V = u.function_space
70-
cells, types, x = plot.create_vtk_mesh(V)
70+
cells, types, x = plot.vtk_mesh(V)
7171
grid = pyvista.UnstructuredGrid(cells, types, x)
7272
grid.point_data["u"] = filter(np.insert(u.x.array.reshape(x.shape[0], V.dofmap.index_map_bs), 2, 0, axis=1))
7373
plotter = pyvista.Plotter()

python/demo/demo_waveguide/demo_half_loaded_waveguide.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def Omega_v(x):
376376

377377
# Visualize solutions with Pyvista
378378
if have_pyvista:
379-
V_cells, V_types, V_x = plot.create_vtk_mesh(V_dg)
379+
V_cells, V_types, V_x = plot.vtk_mesh(V_dg)
380380
V_grid = pyvista.UnstructuredGrid(V_cells, V_types, V_x)
381381
Et_values = np.zeros((V_x.shape[0], 3), dtype=np.float64)
382382
Et_values[:, : msh.topology.dim] = Et_dg.x.array.reshape(V_x.shape[0], msh.topology.dim).real
@@ -395,7 +395,7 @@ def Omega_v(x):
395395

396396
if have_pyvista:
397397
V_lagr, lagr_dofs = V.sub(1).collapse()
398-
V_cells, V_types, V_x = plot.create_vtk_mesh(V_lagr)
398+
V_cells, V_types, V_x = plot.vtk_mesh(V_lagr)
399399
V_grid = pyvista.UnstructuredGrid(V_cells, V_types, V_x)
400400
V_grid.point_data["u"] = ezh.x.array.real[lagr_dofs]
401401
plotter = pyvista.Plotter()

python/dolfinx/fem/function.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def __init__(self, e: ufl.core.expr.Expr, X: np.ndarray,
166166
else:
167167
raise RuntimeError("Expressions with more that one Argument not allowed.")
168168

169-
def create_expression(dtype):
169+
def _create_expression(dtype):
170170
if dtype == np.float32:
171171
return _cpp.fem.create_expression_float32
172172
elif dtype == np.float64:
@@ -179,8 +179,8 @@ def create_expression(dtype):
179179
raise NotImplementedError(f"Type {dtype} not supported.")
180180

181181
ffi = module.ffi
182-
self._cpp_object = create_expression(dtype)(ffi.cast("uintptr_t", ffi.addressof(self._ufcx_expression)),
183-
coeffs, constants, self.argument_function_space)
182+
self._cpp_object = _create_expression(dtype)(ffi.cast("uintptr_t", ffi.addressof(self._ufcx_expression)),
183+
coeffs, constants, self.argument_function_space)
184184

185185
def eval(self, mesh: Mesh, cells: np.ndarray, values: typing.Optional[np.ndarray] = None) -> np.ndarray:
186186
"""Evaluate Expression in cells.

python/dolfinx/graph.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@
3131
pass
3232

3333

34-
__all__ = ["create_adjacencylist", "partitioner"]
34+
__all__ = ["adjacencylist", "partitioner"]
3535

3636

37-
def create_adjacencylist(data: np.ndarray, offsets=None):
37+
def adjacencylist(data: np.ndarray, offsets=None):
3838
"""Create an AdjacencyList for int32 or int64 datasets.
3939
4040
Args:

python/dolfinx/plot.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131

3232
@functools.singledispatch
33-
def create_vtk_mesh(msh: mesh.Mesh, dim: typing.Optional[int] = None, entities=None):
33+
def vtk_mesh(msh: mesh.Mesh, dim: typing.Optional[int] = None, entities=None):
3434
"""Create vtk mesh topology data for mesh entities of a given
3535
dimension. The vertex indices in the returned topology array are the
3636
indices for the associated entry in the mesh geometry.
@@ -88,7 +88,7 @@ def create_vtk_mesh(msh: mesh.Mesh, dim: typing.Optional[int] = None, entities=N
8888
return topology.reshape(-1), cell_types, msh.geometry.x
8989

9090

91-
@create_vtk_mesh.register(fem.FunctionSpaceBase)
91+
@vtk_mesh.register(fem.FunctionSpaceBase)
9292
def _(V: fem.FunctionSpaceBase, entities=None):
9393
"""Creates a VTK mesh topology (topology array and array of cell
9494
types) that is based on the degree-of-freedom coordinates.

python/test/unit/fem/test_assembler.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -948,16 +948,16 @@ def test_assemble_empty_rank_mesh():
948948
def partitioner(comm, nparts, local_graph, num_ghost_nodes):
949949
"""Leave cells on the curent rank"""
950950
dest = np.full(len(cells), comm.rank, dtype=np.int32)
951-
return graph.create_adjacencylist(dest)
951+
return graph.adjacencylist(dest)
952952

953953
if comm.rank == 0:
954954
# Put cells on rank 0
955955
cells = np.array([[0, 1, 2], [0, 2, 3]], dtype=np.int64)
956-
cells = graph.create_adjacencylist(cells)
956+
cells = graph.adjacencylist(cells)
957957
x = np.array([[0., 0.], [1., 0.], [1., 1.], [0., 1.]], dtype=default_real_type)
958958
else:
959959
# No cells on other ranks
960-
cells = graph.create_adjacencylist(np.empty((0, 3), dtype=np.int64))
960+
cells = graph.adjacencylist(np.empty((0, 3), dtype=np.int64))
961961
x = np.empty((0, 2), dtype=default_real_type)
962962

963963
mesh = create_mesh(comm, cells, x, domain, partitioner)

python/test/unit/graph/test_adjacencylist.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
import numpy as np
88
import pytest
99

10-
from dolfinx.graph import create_adjacencylist
10+
from dolfinx.graph import adjacencylist
1111

1212

1313
@pytest.mark.parametrize("dtype", [np.int32, np.int64])
1414
def test_create_adj2d(dtype):
1515
data = np.zeros([2, 4], dtype=dtype)
16-
adj = create_adjacencylist(data)
16+
adj = adjacencylist(data)
1717
num_nodes, num_links = data.shape[0], data.shape[1]
1818
assert np.array_equal(adj.offsets, np.arange(0, num_nodes * num_links + num_links, num_links, dtype=np.int32))

python/test/unit/io/test_adios2.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from basix.ufl import element
1313
from dolfinx.common import has_adios2
1414
from dolfinx.fem import Function, FunctionSpace
15-
from dolfinx.graph import create_adjacencylist
15+
from dolfinx.graph import adjacencylist
1616
from dolfinx.mesh import (CellType, create_mesh, create_unit_cube,
1717
create_unit_square)
1818
from mpi4py import MPI
@@ -271,14 +271,14 @@ def test_empty_rank_mesh(tempdir):
271271
def partitioner(comm, nparts, local_graph, num_ghost_nodes):
272272
"""Leave cells on the current rank"""
273273
dest = np.full(len(cells), comm.rank, dtype=np.int32)
274-
return create_adjacencylist(dest)
274+
return adjacencylist(dest)
275275

276276
if comm.rank == 0:
277277
cells = np.array([[0, 1, 2], [0, 2, 3]], dtype=np.int64)
278-
cells = create_adjacencylist(cells)
278+
cells = adjacencylist(cells)
279279
x = np.array([[0., 0.], [1., 0.], [1., 1.], [0., 1.]], dtype=default_real_type)
280280
else:
281-
cells = create_adjacencylist(np.empty((0, 3), dtype=np.int64))
281+
cells = adjacencylist(np.empty((0, 3), dtype=np.int64))
282282
x = np.empty((0, 2), dtype=default_real_type)
283283

284284
mesh = create_mesh(comm, cells, x, domain, partitioner)

python/test/unit/io/test_vtk.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from dolfinx.io.utils import cell_perm_vtk # noqa F401
1616
from dolfinx.mesh import (CellType, create_mesh, create_unit_cube,
1717
create_unit_interval, create_unit_square)
18-
from dolfinx.plot import create_vtk_mesh
18+
from dolfinx.plot import vtk_mesh
1919
from mpi4py import MPI
2020
from numpy.testing import assert_array_equal
2121

@@ -268,4 +268,4 @@ def test_vtk_mesh():
268268
comm = MPI.COMM_WORLD
269269
mesh = create_unit_square(comm, 2 * comm.size, 2 * comm.size)
270270
V = FunctionSpace(mesh, ("Lagrange", 1))
271-
create_vtk_mesh(V)
271+
vtk_mesh(V)

python/test/unit/mesh/test_mesh.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -506,14 +506,14 @@ def test_empty_rank_mesh(dtype):
506506
def partitioner(comm, nparts, local_graph, num_ghost_nodes):
507507
"""Leave cells on the curent rank"""
508508
dest = np.full(len(cells), comm.rank, dtype=np.int32)
509-
return graph.create_adjacencylist(dest)
509+
return graph.adjacencylist(dest)
510510

511511
if comm.rank == 0:
512512
cells = np.array([[0, 1, 2], [0, 2, 3]], dtype=np.int64)
513-
cells = graph.create_adjacencylist(cells)
513+
cells = graph.adjacencylist(cells)
514514
x = np.array([[0., 0.], [1., 0.], [1., 1.], [0., 1.]], dtype=dtype)
515515
else:
516-
cells = graph.create_adjacencylist(np.empty((0, 3), dtype=np.int64))
516+
cells = graph.adjacencylist(np.empty((0, 3), dtype=np.int64))
517517
x = np.empty((0, 2), dtype=dtype)
518518

519519
mesh = _mesh.create_mesh(comm, cells, x, domain, partitioner)

python/test/unit/mesh/test_meshtags.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import numpy as np
88
import pytest
99

10-
from dolfinx.graph import create_adjacencylist
10+
from dolfinx.graph import adjacencylist
1111
from dolfinx.mesh import (CellType, create_unit_cube, locate_entities,
1212
meshtags_from_entities)
1313
from ufl import Measure
@@ -25,7 +25,7 @@ def test_create(cell_type):
2525
marked_lines = locate_entities(mesh, 1, lambda x: np.isclose(x[1], 0.5))
2626
f_v = mesh.topology.connectivity(1, 0).array.reshape(-1, 2)
2727

28-
entities = create_adjacencylist(f_v[marked_lines])
28+
entities = adjacencylist(f_v[marked_lines])
2929
values = np.full(marked_lines.shape[0], 2, dtype=np.int32)
3030
mt = meshtags_from_entities(mesh, 1, entities, values)
3131

@@ -43,7 +43,7 @@ def test_ufl_id():
4343
marked_facets = locate_entities(msh, tdim - 1, lambda x: np.isclose(x[1], 1))
4444
f_v = msh.topology.connectivity(tdim - 1, 0).array.reshape(-1, 3)
4545

46-
entities = create_adjacencylist(f_v[marked_facets])
46+
entities = adjacencylist(f_v[marked_facets])
4747
values = np.full(marked_facets.shape[0], 2, dtype=np.int32)
4848
ft = meshtags_from_entities(msh, tdim - 1, entities, values)
4949
ds = Measure("ds", domain=msh, subdomain_data=ft, subdomain_id=(2, 3))

0 commit comments

Comments
 (0)