Skip to content

Commit

Permalink
Merge pull request #674 from RemDelaporteMathurin/fix-steadystate-T-xdmf
Browse files Browse the repository at this point in the history
Fix bug is_steady_state with TemperatureFromXDMF
  • Loading branch information
RemDelaporteMathurin authored Dec 20, 2023
2 parents 56089a5 + 22ecf3e commit 95a51c9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions festim/temperature/temperature_from_xdmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ def update(self, t):
refer to issue #499
"""
pass

def is_steady_state(self):
# TemperatureFromXDMF is always steady state
return True
20 changes: 20 additions & 0 deletions test/unit/test_temperature.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,23 @@ def test_temperature_from_xdmf_transient_case(tmpdir):
my_model.settings.final_time = 10
my_model.initialise()
my_model.run()


def test_temperature_from_xdmf(tmpdir):
"""
Tests that .is_steady_state() can be run for
a TemperatureFromXDMF object
"""
mesh = fenics.UnitSquareMesh(10, 10)
V = fenics.FunctionSpace(mesh, "CG", 1)
expr = fenics.Expression("1 + x[0] + 2*x[1]", degree=2)
T = fenics.interpolate(expr, V)
# write function to temporary file
T_file = str(tmpdir.join("T.xdmf"))
fenics.XDMFFile(T_file).write_checkpoint(
T, "T", 0, fenics.XDMFFile.Encoding.HDF5, append=False
)

temperature = festim.TemperatureFromXDMF(T_file, "T")

assert temperature.is_steady_state()

0 comments on commit 95a51c9

Please sign in to comment.