|
| 1 | +from mpi4py import MPI |
| 2 | + |
1 | 3 | import dolfinx |
2 | 4 | import numpy as np |
3 | 5 | import pytest |
@@ -352,3 +354,38 @@ def test_timesteps(): |
352 | 354 |
|
353 | 355 | expected_timesteps = np.linspace(0, 10, num=10, endpoint=False) |
354 | 356 | assert np.allclose(my_model.timesteps, expected_timesteps) |
| 357 | + |
| 358 | + |
| 359 | +def test_sub_temperature_as_function_mixed_domain_not_updated(): |
| 360 | + |
| 361 | + my_model = F.HydrogenTransportProblemDiscontinuous() |
| 362 | + |
| 363 | + n = 8 |
| 364 | + mesh = dolfinx.mesh.create_unit_square(MPI.COMM_WORLD, n, n) |
| 365 | + my_model.mesh = F.Mesh(mesh) |
| 366 | + |
| 367 | + surface_1 = F.SurfaceSubdomain(id=1) |
| 368 | + |
| 369 | + material_1 = F.Material(D_0=1, E_D=0, name="material_1") |
| 370 | + volume_1 = F.VolumeSubdomain(id=2, material=material_1) |
| 371 | + |
| 372 | + my_model.subdomains = [surface_1, volume_1] |
| 373 | + |
| 374 | + H = F.Species(name="H", subdomains=my_model.volume_subdomains) |
| 375 | + my_model.species = [H] |
| 376 | + |
| 377 | + my_model.boundary_conditions = [ |
| 378 | + F.FixedConcentrationBC(species=H, subdomain=surface_1, value=lambda T: 2 * T) |
| 379 | + ] |
| 380 | + |
| 381 | + my_model.temperature = lambda t, x: 1 + x[0] + x[1] + t |
| 382 | + |
| 383 | + my_model.settings = F.Settings(final_time=1, atol=1e-9, rtol=1e-9, stepsize=0.1) |
| 384 | + |
| 385 | + avg_surf = F.AverageSurface(field=H, surface=surface_1) |
| 386 | + my_model.exports = [avg_surf] |
| 387 | + |
| 388 | + my_model.initialise() |
| 389 | + my_model.run() |
| 390 | + |
| 391 | + assert not np.allclose(avg_surf.data, 4.0) |
0 commit comments