Skip to content

Commit 0ae0dee

Browse files
authored
Merge branch 'main' into main
2 parents f715228 + d52139f commit 0ae0dee

11 files changed

+25
-34
lines changed

python/demo/demo_biharmonic.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,10 @@
155155
facets = mesh.locate_entities_boundary(
156156
msh,
157157
dim=1,
158-
marker=lambda x: np.logical_or.reduce(
159-
(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0), np.isclose(x[1], 0.0), np.isclose(x[1], 1.0))
160-
),
158+
marker=lambda x: np.isclose(x[0], 0.0)
159+
| np.isclose(x[0], 1.0)
160+
| np.isclose(x[1], 0.0)
161+
| np.isclose(x[1], 1.0),
161162
)
162163

163164
# We now find the degrees-of-freedom that are associated with the

python/demo/demo_elasticity.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def σ(v):
146146
# a Dirichlet boundary condition object.
147147

148148
facets = locate_entities_boundary(
149-
msh, dim=2, marker=lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[1], 1.0))
149+
msh, dim=2, marker=lambda x: np.isclose(x[0], 0.0) | np.isclose(x[1], 1.0)
150150
)
151151
bc = dirichletbc(
152152
np.zeros(3, dtype=dtype), locate_dofs_topological(V, entity_dim=2, entities=facets), V=V

python/demo/demo_lagrange_variants.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
)
125125
V = fem.functionspace(msh, ufl_element)
126126
facets = mesh.locate_entities_boundary(
127-
msh, dim=1, marker=lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 2.0))
127+
msh, dim=1, marker=lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 2.0)
128128
)
129129
dofs = fem.locate_dofs_topological(V=V, entity_dim=1, entities=facets)
130130
bc = fem.dirichletbc(value=default_scalar_type(0), dofs=dofs, V=V)

python/demo/demo_poisson.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
facets = mesh.locate_entities_boundary(
112112
msh,
113113
dim=(msh.topology.dim - 1),
114-
marker=lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 2.0)),
114+
marker=lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 2.0),
115115
)
116116

117117
# We now find the degrees-of-freedom that are associated with the

python/demo/demo_stokes.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,7 @@
120120

121121
# Function to mark x = 0, x = 1 and y = 0
122122
def noslip_boundary(x):
123-
return np.logical_or(
124-
np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0)), np.isclose(x[1], 0.0)
125-
)
123+
return np.isclose(x[0], 0.0) | np.isclose(x[0], 1.0) | np.isclose(x[1], 0.0)
126124

127125

128126
# Function to mark the lid (y = 1)

python/demo/demo_types.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def poisson(dtype):
105105
dtype=np.real(dtype(0)).dtype,
106106
)
107107
facets = mesh.locate_entities_boundary(
108-
msh, dim=1, marker=lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 2.0))
108+
msh, dim=1, marker=lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 2.0)
109109
)
110110

111111
# Define a variational problem.
@@ -167,7 +167,7 @@ def elasticity(dtype) -> fem.Function:
167167
dtype=np.real(dtype(0)).dtype,
168168
)
169169
facets = mesh.locate_entities_boundary(
170-
msh, dim=1, marker=lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 2.0))
170+
msh, dim=1, marker=lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 2.0)
171171
)
172172

173173
# Define the variational problem.

python/test/unit/fem/test_assembler.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,7 @@ def test_assembly_bcs(mode):
207207
a = form(inner(u, v) * dx + inner(u, v) * ds)
208208
L = form(inner(1.0, v) * dx)
209209

210-
bdofsV = locate_dofs_geometrical(
211-
V, lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0))
212-
)
210+
bdofsV = locate_dofs_geometrical(V, lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 1.0))
213211
bc = dirichletbc(PETSc.ScalarType(1), bdofsV, V)
214212

215213
# Assemble and apply 'global' lifting of bcs
@@ -295,7 +293,7 @@ def test_matrix_assembly_block(mode):
295293
# Locate facets on boundary
296294
facetdim = mesh.topology.dim - 1
297295
bndry_facets = locate_entities_boundary(
298-
mesh, facetdim, lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0))
296+
mesh, facetdim, lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 1.0)
299297
)
300298
bdofsV1 = locate_dofs_topological(V1, facetdim, bndry_facets)
301299
u_bc = PETSc.ScalarType(50.0)
@@ -419,7 +417,7 @@ def test_assembly_solve_block(mode):
419417
# Locate facets on boundary
420418
facetdim = mesh.topology.dim - 1
421419
bndry_facets = locate_entities_boundary(
422-
mesh, facetdim, lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0))
420+
mesh, facetdim, lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 1.0)
423421
)
424422

425423
bdofsV0 = locate_dofs_topological(V0, facetdim, bndry_facets)

python/test/unit/fem/test_nonlinear_assembler.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def bc_value(x):
8383

8484
facetdim = mesh.topology.dim - 1
8585
bndry_facets = locate_entities_boundary(
86-
mesh, facetdim, lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0))
86+
mesh, facetdim, lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 1.0)
8787
)
8888

8989
u_bc = Function(V1)
@@ -332,7 +332,7 @@ def initial_guess_p(x):
332332

333333
facetdim = mesh.topology.dim - 1
334334
bndry_facets = locate_entities_boundary(
335-
mesh, facetdim, lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0))
335+
mesh, facetdim, lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 1.0)
336336
)
337337

338338
u_bc0 = Function(V0)

python/test/unit/mesh/test_mesh.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -485,17 +485,17 @@ def test_unit_hex_mesh_assemble():
485485

486486

487487
def boundary_0(x):
488-
lr = np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0))
489-
tb = np.logical_or(np.isclose(x[1], 0.0), np.isclose(x[1], 1.0))
490-
return np.logical_or(lr, tb)
488+
lr = np.isclose(x[0], 0.0) | np.isclose(x[0], 1.0)
489+
tb = np.isclose(x[1], 0.0) | np.isclose(x[1], 1.0)
490+
return lr | tb
491491

492492

493493
def boundary_1(x):
494-
return np.logical_or(np.isclose(x[0], 1.0), np.isclose(x[1], 1.0))
494+
return np.isclose(x[0], 1.0) | np.isclose(x[1], 1.0)
495495

496496

497497
def boundary_2(x):
498-
return np.logical_and(np.isclose(x[1], 1), x[0] >= 0.5)
498+
return np.isclose(x[1], 1) & (x[0] >= 0.5)
499499

500500

501501
# TODO Test that submesh of full mesh is a copy of the mesh

python/test/unit/mesh/test_refinement.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import numpy as np
1010
import pytest
11-
from numpy import isclose, logical_and
11+
from numpy import isclose
1212

1313
import ufl
1414
from dolfinx.fem import assemble_matrix, form, functionspace
@@ -98,7 +98,7 @@ def test_sub_refine():
9898
mesh.topology.create_entities(1)
9999

100100
def left_corner_edge(x, tol=1e-7):
101-
return logical_and(isclose(x[0], 0), x[1] < 1 / 4 + tol)
101+
return isclose(x[0], 0) & (x[1] < 1 / 4 + tol)
102102

103103
edges = locate_entities_boundary(mesh, 1, left_corner_edge)
104104
if MPI.COMM_WORLD.size == 0:

python/test/unit/nls/test_newton.py

+3-9
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,7 @@ def test_linear_pde():
103103

104104
bc = dirichletbc(
105105
PETSc.ScalarType(1.0),
106-
locate_dofs_geometrical(
107-
V, lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0))
108-
),
106+
locate_dofs_geometrical(V, lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 1.0)),
109107
V,
110108
)
111109

@@ -144,9 +142,7 @@ def test_nonlinear_pde():
144142

145143
bc = dirichletbc(
146144
PETSc.ScalarType(1.0),
147-
locate_dofs_geometrical(
148-
V, lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0))
149-
),
145+
locate_dofs_geometrical(V, lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 1.0)),
150146
V,
151147
)
152148

@@ -184,9 +180,7 @@ def test_nonlinear_pde_snes():
184180
u_bc.x.array[:] = 1.0
185181
bc = dirichletbc(
186182
u_bc,
187-
locate_dofs_geometrical(
188-
V, lambda x: np.logical_or(np.isclose(x[0], 0.0), np.isclose(x[0], 1.0))
189-
),
183+
locate_dofs_geometrical(V, lambda x: np.isclose(x[0], 0.0) | np.isclose(x[0], 1.0)),
190184
)
191185

192186
# Create nonlinear problem

0 commit comments

Comments
 (0)