examples.diffusion.steadyState.otherMeshes.prismΒΆ

This input file again solves a 1D diffusion problem as in ./examples/diffusion/steadyState/mesh1D/input.py. The difference being that it uses a triangular mesh loaded in using the Gmsh.

The result is again tested in the same way:

>>> from fipy import CellVariable, GmshGrid3D, DiffusionTerm
>>> valueLeft = 0.
>>> valueRight = 1.
>>> mesh = GmshGrid3D(dx=1, dy=1, dz=1, nx=20, ny=1, nz=1)
>>> var = CellVariable(name = "solution variable",
...                    mesh = mesh,
...                    value = valueLeft)
>>> exteriorFaces = mesh.exteriorFaces
>>> xFace = mesh.faceCenters[0]
>>> var.constrain(valueLeft, exteriorFaces & (xFace ** 2 < 0.000000000000001))
>>> var.constrain(valueRight, exteriorFaces & ((xFace - 20) ** 2 < 0.000000000000001))
>>> DiffusionTerm().solve(var)
>>> Lx = 20
>>> x = mesh.cellCenters[0]
>>> analyticalArray = valueLeft + (valueRight - valueLeft) * x / Lx
>>> print(var.allclose(analyticalArray, atol = 0.027))
1
Last updated on May 15, 2026. Created using Sphinx 9.1.0.