Skip to content

Commit 583360a

Browse files
committed
Try forcing manual integration
1 parent 3e69f79 commit 583360a

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

tests/test_average_coefficient.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -158,23 +158,20 @@ def f(x):
158158
J_gamma = assemble_scalar(J)
159159

160160
# Symbolic integration of cylinder
161-
if domain.comm.rank == 0:
162-
x, y, z, R_s, Z_lower, Z_upper = sp.symbols("x y z R Z_lower Z_upper")
163-
integral_result = sp.integrate(
164-
1 / (sp.pi * R_s**2) * f([x, y, z]),
165-
(z, Z_lower, Z_upper),
166-
(
167-
y,
168-
y_c - sp.sqrt(R_s**2 - (x - x_c) ** 2),
169-
y_c + sp.sqrt(R_s**2 - (x - x_c) ** 2),
170-
),
171-
(x, x_c - R_s, x_c + R_s),
172-
)
173-
float_result = complex(
174-
integral_result.subs({R_s: R, Z_lower: c_min, Z_upper: c_max})
175-
).real
176-
reference = domain.comm.bcast(
177-
float_result if domain.comm.rank == 0 else None, root=0
161+
x, y, z, R_s, Z_lower, Z_upper = sp.symbols("x y z R Z_lower Z_upper")
162+
integral_result = sp.integrate(
163+
1 / (sp.pi * R_s**2) * f([x, y, z]),
164+
(z, Z_lower, Z_upper),
165+
(
166+
y,
167+
y_c - sp.sqrt(R_s**2 - (x - x_c) ** 2),
168+
y_c + sp.sqrt(R_s**2 - (x - x_c) ** 2),
169+
),
170+
(x, x_c - R_s, x_c + R_s),
171+
manual=True,
178172
)
173+
float_result = complex(
174+
integral_result.subs({R_s: R, Z_lower: c_min, Z_upper: c_max})
175+
).real
179176

180-
np.testing.assert_allclose(reference, J_gamma)
177+
np.testing.assert_allclose(float_result, J_gamma)

0 commit comments

Comments
 (0)