@@ -546,3 +546,56 @@ def test_error_raised_when_no_IC_heat_transfer():
546
546
match = "Initial condition is required for transient heat transfer simulations" ,
547
547
):
548
548
my_model .initialise ()
549
+
550
+
551
+ def test_catch_bug_738 (tmpdir ):
552
+ """
553
+ Test to catch bug #738
554
+ Set up a simple simulation with and XDMFExport in write mode "last"
555
+ The stepsize is such that the first timestep is almost the final time (ie. dt = t_final - epsilon)
556
+ The simulation should detect that this is the last timestep and export the data.
557
+
558
+ We then check that the files are created
559
+ """
560
+ filename = str (tmpdir .join ("mobile_re.xdmf" ))
561
+ my_model = F .Simulation (log_level = 40 )
562
+
563
+ my_model .mesh = F .MeshFromVertices (vertices = np .linspace (0 , 1 , num = 10 ))
564
+
565
+ my_model .materials = F .Material (id = 1 , D_0 = 1 , E_D = 0 )
566
+
567
+ my_model .T = F .Temperature (value = 1500 )
568
+
569
+ my_model .dt = F .Stepsize (
570
+ initial_value = 1e-10 - 1e-15 ,
571
+ )
572
+
573
+ my_model .settings = F .Settings (
574
+ absolute_tolerance = 1e10 ,
575
+ relative_tolerance = 1e-10 ,
576
+ final_time = 1e-10 ,
577
+ maximum_iterations = 100 ,
578
+ )
579
+
580
+ my_model .exports = [
581
+ F .XDMFExport (
582
+ field = "solute" ,
583
+ filename = filename ,
584
+ checkpoint = False , # needed in 1D
585
+ mode = "last" ,
586
+ )
587
+ ]
588
+
589
+ # remove old xdmf file
590
+ if os .path .exists (filename ):
591
+ os .remove (filename )
592
+ os .remove (str (tmpdir .join ("mobile_re.h5" )))
593
+
594
+ my_model .initialise ()
595
+
596
+ my_model .run ()
597
+
598
+ # check that xdmf file exists
599
+
600
+ assert os .path .exists (filename )
601
+ assert os .path .exists (str (tmpdir .join ("mobile_re.h5" )))
0 commit comments