/
TestMonodomainProblem.hpp
1818 lines (1511 loc) · 82.4 KB
/
TestMonodomainProblem.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
Copyright (c) 2005-2024, University of Oxford.
All rights reserved.
University of Oxford means the Chancellor, Masters and Scholars of the
University of Oxford, having an administrative office at Wellington
Square, Oxford OX1 2JD, UK.
This file is part of Chaste.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of the University of Oxford nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _TESTMONODOMAINPROBLEM_HPP_
#define _TESTMONODOMAINPROBLEM_HPP_
#include <boost/archive/text_iarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <cxxtest/TestSuite.h>
#include <vector>
#include "AbstractCardiacCellFactory.hpp"
#include "AbstractCvodeCell.hpp"
#include "LuoRudy1991.hpp"
#include "LuoRudy1991Cvode.hpp"
#include "MonodomainProblem.hpp"
//#include "LuoRudy1991BackwardEulerOpt.hpp"
#include "ActivationOutputModifier.hpp"
#include "ArchiveOpener.hpp"
#include "CardiacSimulationArchiver.hpp"
#include "ChasteSyscalls.hpp"
#include "CheckMonoLr91Vars.hpp"
#include "CmguiMeshWriter.hpp"
#include "CompareHdf5ResultsFiles.hpp"
#include "FaberRudy2000.hpp"
#include "FileComparison.hpp"
#include "Hdf5DataReader.hpp"
#include "NumericFileComparison.hpp"
#include "PetscTools.hpp"
#include "PlaneStimulusCellFactory.hpp"
#include "ReplicatableVector.hpp"
#include "SingleTraceOutputModifier.hpp"
#include "TetrahedralMesh.hpp"
#include "VtkMeshReader.hpp"
#include "Warnings.hpp"
#include "PetscSetupAndFinalize.hpp"
/*
* This cell factory introduces a stimulus in the very centre of mesh/test/data/2D_0_to_1mm_400_elements.
* This is node 60 at (0.5, 0.5)
*/
class PointStimulus2dCellFactory : public AbstractCardiacCellFactory<2>
{
private:
boost::shared_ptr<SimpleStimulus> mpStimulus;
unsigned mFoundMiddlePoint;
public:
PointStimulus2dCellFactory()
: AbstractCardiacCellFactory<2>(),
mpStimulus(new SimpleStimulus(-6000.0, 0.5)),
mFoundMiddlePoint(0)
{
}
AbstractCardiacCell* CreateCardiacCellForTissueNode(Node<2>* pNode)
{
ChastePoint<2> location = pNode->GetPoint();
if (fabs(location[0] - 0.05) < 1e-6 && fabs(location[1] - 0.05) < 1e-6)
{
mFoundMiddlePoint++;
return new CellLuoRudy1991FromCellML(mpSolver, mpStimulus);
}
else
{
return new CellLuoRudy1991FromCellML(mpSolver, mpZeroStimulus);
}
}
void FinaliseCellCreation(std::vector<AbstractCardiacCellInterface*>* pCellsDistributed, unsigned lo, unsigned hi)
{
unsigned found_middle_point_reduced;
MPI_Allreduce(&mFoundMiddlePoint, &found_middle_point_reduced, 1, MPI_UNSIGNED, MPI_SUM, PETSC_COMM_WORLD);
assert(found_middle_point_reduced == 1); // Only 1 cell should be stimulated
}
};
#ifdef CHASTE_CVODE
/*
* Cell factory for TestOutputDoesNotDependOnPrintTimestep. Returns CVODE cells
*/
class Cvode1dCellFactory : public AbstractCardiacCellFactory<1>
{
private:
boost::shared_ptr<SimpleStimulus> mpStimulus;
public:
Cvode1dCellFactory() : AbstractCardiacCellFactory<1>(),
mpStimulus(new SimpleStimulus(-70000.0, 1.0, 0.0))
{
}
AbstractCvodeCell* CreateCardiacCellForTissueNode(Node<1>* pNode)
{
AbstractCvodeCell* p_cell;
boost::shared_ptr<AbstractIvpOdeSolver> p_empty_solver;
double x = pNode->rGetLocation()[0];
if (x < 0.3)
{
p_cell = new CellLuoRudy1991FromCellMLCvode(p_empty_solver, mpStimulus);
}
else
{
p_cell = new CellLuoRudy1991FromCellMLCvode(p_empty_solver, mpZeroStimulus);
}
// Beefed-up CVODE tolerances.
p_cell->SetTolerances(1e-7, 1e-9);
return p_cell;
}
};
#endif // CHASTE_CVODE
class TestMonodomainProblem : public CxxTest::TestSuite
{
private:
std::vector<double> mVoltageReplicated1d2ms; ///<Used to test differences between tests
public:
void setUp()
{
HeartConfig::Reset();
}
// This is a test on a very small mesh (where there may be more processes than there are nodes)
//
// NOTE: This test uses NON-PHYSIOLOGICAL parameters values (conductivities,
// surface-area-to-volume ratio, capacitance, stimulus amplitude). Essentially,
// the equations have been divided through by the surface-area-to-volume ratio.
// (Historical reasons...)
void TestMonodomainProblemSimplestMesh1D()
{
if (PetscTools::GetNumProcs() > 2u)
{
// There are only 2 nodes in this simulation
TS_TRACE("This test is not suitable for more than 2 processes.");
return;
}
DistributedTetrahedralMesh<1, 1> mesh;
//TrianglesMeshReader<1,1> reader("mesh/test/data/1D_0_to_1_1_element");
mesh.ConstructLinearMesh(1);
TS_ASSERT_EQUALS(mesh.GetNumNodes(), 2u);
TS_ASSERT_EQUALS(mesh.GetNumElements(), 1u);
if (!PetscTools::IsSequential())
{
if (PetscTools::GetMyRank() < 2)
{
TS_ASSERT_EQUALS(mesh.GetNumLocalNodes(), 1u);
TS_ASSERT_EQUALS(mesh.GetNumLocalElements(), 1u);
}
else
{
TS_ASSERT_EQUALS(mesh.GetNumLocalNodes(), 0u);
TS_ASSERT_EQUALS(mesh.GetNumLocalElements(), 0u);
}
}
HeartConfig::Instance()->SetIntracellularConductivities(Create_c_vector(0.0005));
HeartConfig::Instance()->SetSimulationDuration(2.0); //ms
HeartConfig::Instance()->SetOutputDirectory("MonoProblem1dSimplest");
HeartConfig::Instance()->SetOutputFilenamePrefix("MonodomainLR91_1d");
//HeartConfig::Instance()->SetMeshFileName("mesh/test/data/1D_0_to_1_1_element");
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 1> cell_factory;
MonodomainProblem<1> monodomain_problem(&cell_factory);
monodomain_problem.SetMesh(&mesh);
monodomain_problem.Initialise();
HeartConfig::Instance()->SetSurfaceAreaToVolumeRatio(1.0);
HeartConfig::Instance()->SetCapacitance(10.0);
monodomain_problem.Solve();
// test whether voltages and gating variables are in correct ranges
CheckMonoLr91Vars<1>(monodomain_problem);
// check some voltages
ReplicatableVector voltage_replicated(monodomain_problem.GetSolution());
double atol = 5e-3;
TS_ASSERT_DELTA(voltage_replicated[0], -52.1698, atol);
TS_ASSERT_DELTA(voltage_replicated[1], -83.8381, atol);
}
// Solve on a 1D string of cells, 1mm long with a space step of 0.1mm.
//
// NOTE: This test uses NON-PHYSIOLOGICAL parameters values (conductivities,
// surface-area-to-volume ratio, capacitance, stimulus amplitude). Essentially,
// the equations have been divided through by the surface-area-to-volume ratio.
// (Historical reasons...)
void TestMonodomainProblem1D()
{
HeartConfig::Instance()->SetIntracellularConductivities(Create_c_vector(0.0005));
HeartConfig::Instance()->SetSimulationDuration(2.0); //ms
HeartConfig::Instance()->SetMeshFileName("mesh/test/data/1D_0_to_1mm_10_elements");
HeartConfig::Instance()->SetOutputDirectory("MonoProblem1d");
HeartConfig::Instance()->SetOutputFilenamePrefix("MonodomainLR91_1d");
// Set extra variable (to cover extension of HDF5 with named variables) in a later test
std::vector<std::string> output_variables;
/*
* HOW_TO_TAG Cardiac/Output
* Calculating and outputting ionic currents ('derived quantities') in a tissue simulation using
* [HeartConfig](/doxygen-latest/classHeartConfig.html) - see also
* [chaste_codegen documentation](/docs/user-guides/code-generation-from-cellml/#derived-quantities).
*/
// This is how to output an additional state variable
output_variables.push_back("cytosolic_calcium_concentration");
// or indeed an additional parameter or derived quantity. In the CellML
// the variable 'potassium_currents' (sum of potassium currents) is annotated as a
// derived quantity to be calculated.
output_variables.push_back("potassium_currents");
HeartConfig::Instance()->SetOutputVariables(output_variables);
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 1> cell_factory;
MonodomainProblem<1> monodomain_problem(&cell_factory);
// Just checking an exception message here.
TS_ASSERT_THROWS_THIS(monodomain_problem.GetTissue(),
"Tissue not yet set up, you may need to call Initialise() before GetTissue().");
monodomain_problem.Initialise();
HeartConfig::Instance()->SetSurfaceAreaToVolumeRatio(1.0);
HeartConfig::Instance()->SetCapacitance(1.0);
monodomain_problem.Solve();
// test whether voltages and gating variables are in correct ranges
CheckMonoLr91Vars<1>(monodomain_problem);
// check some voltages
ReplicatableVector voltage_replicated(monodomain_problem.GetSolution());
double atol = 5e-3;
TS_ASSERT_DELTA(voltage_replicated[1], 20.7710232, atol);
TS_ASSERT_DELTA(voltage_replicated[3], 21.5319692, atol);
TS_ASSERT_DELTA(voltage_replicated[5], 22.9280817, atol);
TS_ASSERT_DELTA(voltage_replicated[7], 24.0611303, atol);
TS_ASSERT_DELTA(voltage_replicated[9], -0.770330519, atol);
TS_ASSERT_DELTA(voltage_replicated[10], -19.2234919, atol);
for (unsigned index = 0; index < voltage_replicated.GetSize(); index++)
{
mVoltageReplicated1d2ms.push_back(voltage_replicated[index]);
}
//How close is our "standard" answer?
atol = 5e-3;
TS_ASSERT_DELTA(mVoltageReplicated1d2ms[1], 20.7710232, atol);
TS_ASSERT_DELTA(mVoltageReplicated1d2ms[3], 21.5319692, atol);
TS_ASSERT_DELTA(mVoltageReplicated1d2ms[5], 22.9280817, atol);
TS_ASSERT_DELTA(mVoltageReplicated1d2ms[7], 24.0611303, atol);
TS_ASSERT_DELTA(mVoltageReplicated1d2ms[9], -0.770330519, atol);
TS_ASSERT_DELTA(mVoltageReplicated1d2ms[10], -19.2234919, atol);
// coverage
monodomain_problem.GetTissue();
// check a progress report exists
OutputFileHandler handler("MonoProblem1d", false);
TS_ASSERT(handler.FindFile("progress_status.txt").Exists());
}
// NOTE: This test uses NON-PHYSIOLOGICAL parameters values (conductivities,
// surface-area-to-volume ratio, capacitance, stimulus amplitude). Essentially,
// the equations have been divided through by the surface-area-to-volume ratio.
// (Historical reasons...)
void TestMonodomainProblem1DWithRelativeTolerance()
{
HeartConfig::Instance()->SetIntracellularConductivities(Create_c_vector(0.0005));
HeartConfig::Instance()->SetSimulationDuration(2.0); //ms
HeartConfig::Instance()->SetSurfaceAreaToVolumeRatio(1.0);
HeartConfig::Instance()->SetCapacitance(1.0);
HeartConfig::Instance()->SetUseRelativeTolerance(1e-9);
HeartConfig::Instance()->SetMeshFileName("mesh/test/data/1D_0_to_1mm_10_elements");
HeartConfig::Instance()->SetOutputDirectory("MonoProblem1dRelTol");
HeartConfig::Instance()->SetOutputFilenamePrefix("MonodomainLR91_1d");
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 1> cell_factory;
MonodomainProblem<1> monodomain_problem(&cell_factory);
monodomain_problem.Initialise();
monodomain_problem.Solve();
// test whether voltages and gating variables are in correct ranges
CheckMonoLr91Vars<1>(monodomain_problem);
// check some voltages
ReplicatableVector voltage_replicated(monodomain_problem.GetSolution());
/// \todo: If we request "relative" tolerance we shouldn't testing in an "absolute" manner
double atol = 2e-5;
TS_ASSERT_DELTA(voltage_replicated[1], 20.7710232, atol);
TS_ASSERT_DELTA(voltage_replicated[3], 21.5319692, atol);
TS_ASSERT_DELTA(voltage_replicated[5], 22.9280817, atol);
TS_ASSERT_DELTA(voltage_replicated[7], 24.0611303, atol);
TS_ASSERT_DELTA(voltage_replicated[9], -0.770330519, atol);
TS_ASSERT_DELTA(voltage_replicated[10], -19.2234919, atol);
for (unsigned index = 0; index < voltage_replicated.GetSize(); index++)
{
TS_ASSERT_DELTA(voltage_replicated[index], mVoltageReplicated1d2ms[index], 5e-3);
}
}
// Same as TestMonodomainProblem1D, except the 1D mesh is embedded in 3D space.
//
// NOTE: This test uses NON-PHYSIOLOGICAL parameters values (conductivities,
// surface-area-to-volume ratio, capacitance, stimulus amplitude). Essentially,
// the equations have been divided through by the surface-area-to-volume ratio.
// (Historical reasons...)
void TestMonodomainProblem1Din3D()
{
HeartConfig::Instance()->SetIntracellularConductivities(Create_c_vector(0.0005));
HeartConfig::Instance()->SetSimulationDuration(2.0); //ms
HeartConfig::Instance()->SetMeshFileName("mesh/test/data/1D_in_3D_0_to_1mm_10_elements");
HeartConfig::Instance()->SetOutputDirectory("MonoProblem1din3d");
HeartConfig::Instance()->SetOutputFilenamePrefix("MonodomainLR91_1din3d");
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 1, 3> cell_factory;
MonodomainProblem<1, 3> monodomain_problem(&cell_factory);
monodomain_problem.Initialise();
HeartConfig::Instance()->SetSurfaceAreaToVolumeRatio(1.0);
HeartConfig::Instance()->SetCapacitance(1.0);
monodomain_problem.Solve();
// test whether voltages and gating variables are in correct ranges
CheckMonoLr91Vars(monodomain_problem);
// check some voltages
ReplicatableVector voltage_replicated(monodomain_problem.GetSolution());
double atol = 5e-3;
TS_ASSERT_DELTA(voltage_replicated[1], 20.7710232, atol);
TS_ASSERT_DELTA(voltage_replicated[3], 21.5319692, atol);
TS_ASSERT_DELTA(voltage_replicated[5], 22.9280817, atol);
TS_ASSERT_DELTA(voltage_replicated[7], 24.0611303, atol);
TS_ASSERT_DELTA(voltage_replicated[9], -0.770330519, atol);
TS_ASSERT_DELTA(voltage_replicated[10], -19.2234919, atol);
// Now compare with the TestMonodomainProblem1D simulation above
for (unsigned index = 0; index < voltage_replicated.GetSize(); index++)
{
TS_ASSERT_DELTA(voltage_replicated[index], mVoltageReplicated1d2ms[index], 5e-12);
}
// cover get pde
monodomain_problem.GetTissue();
// check a progress report exists
OutputFileHandler handler("MonoProblem1din3d", false);
TS_ASSERT(handler.FindFile("progress_status.txt").Exists());
}
// NOTE: This test uses NON-PHYSIOLOGICAL parameters values (conductivities,
// surface-area-to-volume ratio, capacitance, stimulus amplitude). Essentially,
// the equations have been divided through by the surface-area-to-volume ratio.
// (Historical reasons...)
void TestMonodomainProblem1DWithAbsoluteTolerance()
{
double atol = 1e-4;
HeartConfig::Instance()->SetIntracellularConductivities(Create_c_vector(0.0005));
HeartConfig::Instance()->SetSimulationDuration(2); //ms
HeartConfig::Instance()->SetSurfaceAreaToVolumeRatio(1.0);
HeartConfig::Instance()->SetCapacitance(1.0);
TS_ASSERT_EQUALS(HeartConfig::Instance()->GetAbsoluteTolerance(), 2e-4);
HeartConfig::Instance()->SetUseAbsoluteTolerance(atol / 20.0);
///\todo this is dependent on the number of processes used
TS_ASSERT_EQUALS(HeartConfig::Instance()->GetAbsoluteTolerance(), 5e-6);
HeartConfig::Instance()->SetMeshFileName("mesh/test/data/1D_0_to_1mm_10_elements");
HeartConfig::Instance()->SetOutputDirectory("MonoProblem1dAbsTol");
HeartConfig::Instance()->SetOutputFilenamePrefix("MonodomainLR91_1d");
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 1> cell_factory;
MonodomainProblem<1> monodomain_problem(&cell_factory);
monodomain_problem.Initialise();
monodomain_problem.Solve();
// test whether voltages and gating variables are in correct ranges
CheckMonoLr91Vars<1>(monodomain_problem);
// check some voltages
ReplicatableVector voltage_replicated(monodomain_problem.GetSolution());
TS_ASSERT_DELTA(voltage_replicated[1], 20.7710232, atol);
TS_ASSERT_DELTA(voltage_replicated[3], 21.5319692, atol);
TS_ASSERT_DELTA(voltage_replicated[5], 22.9280817, atol);
TS_ASSERT_DELTA(voltage_replicated[7], 24.0611303, atol);
TS_ASSERT_DELTA(voltage_replicated[9], -0.770330519, atol);
TS_ASSERT_DELTA(voltage_replicated[10], -19.2234919, atol);
for (unsigned index = 0; index < voltage_replicated.GetSize(); index++)
{
TS_ASSERT_DELTA(voltage_replicated[index], mVoltageReplicated1d2ms[index], 5e-3);
}
}
// Solve on a 2D 1mm by 1mm mesh (space step = 0.1mm), stimulating the left
// edge.
// Should behave like the 1D case, extrapolated.
// See also TestMonodomainSlab.hpp (nightly test) for the 3D version.
//
// NOTE: This test uses NON-PHYSIOLOGICAL parameters values (conductivities,
// surface-area-to-volume ratio, capacitance, stimulus amplitude). Essentially,
// the equations have been divided through by the surface-area-to-volume ratio.
// (Historical reasons...)
void TestMonodomainProblem2DWithEdgeStimulus()
{
HeartConfig::Instance()->SetIntracellularConductivities(Create_c_vector(0.0005, 0.0005));
HeartConfig::Instance()->SetSimulationDuration(2); //ms
HeartConfig::Instance()->SetMeshFileName("mesh/test/data/2D_0_to_1mm_400_elements");
HeartConfig::Instance()->SetOutputDirectory("MonoProblem2dWithEdgeStimulus");
HeartConfig::Instance()->SetOutputFilenamePrefix("MonodomainLR91_2dWithEdgeStimulus");
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 2> cell_factory;
// using the criss-cross mesh so wave propagates properly
MonodomainProblem<2> monodomain_problem(&cell_factory);
// Coverage
TS_ASSERT(!monodomain_problem.GetHasBath());
monodomain_problem.Initialise();
HeartConfig::Instance()->SetSurfaceAreaToVolumeRatio(1.0);
HeartConfig::Instance()->SetCapacitance(1.0);
monodomain_problem.Solve();
// test whether voltages and gating variables are in correct ranges
CheckMonoLr91Vars(monodomain_problem);
//Since we are going to compare voltages that may be owned by
//various processes it makes sense to replicate the data.
Vec voltage = monodomain_problem.GetSolution();
ReplicatableVector voltage_replicated;
voltage_replicated.ReplicatePetscVector(voltage);
/*
* Test the top right node against the right one in the 1D case,
* comparing voltage, and then test all the nodes on the right hand
* side of the square against the top right one, comparing voltage.
*/
bool need_initialisation = true;
double probe_voltage = 0.0;
need_initialisation = true;
// Test the RHS of the mesh
AbstractTetrahedralMesh<2, 2>& r_mesh = monodomain_problem.rGetMesh();
for (AbstractTetrahedralMesh<2, 2>::NodeIterator iter = r_mesh.GetNodeIteratorBegin();
iter != r_mesh.GetNodeIteratorEnd();
++iter)
{
unsigned i = (*iter).GetIndex();
if ((*iter).GetPoint()[0] == 0.1)
{
// x = 0 is where the stimulus has been applied
// x = 0.1cm is the other end of the mesh and where we want to
// to test the value of the nodes
if (need_initialisation)
{
probe_voltage = voltage_replicated[i];
need_initialisation = false;
}
else
{
// Tests the final voltages for all the RHS edge nodes
// are close to each other.
// This works as we are using the 'criss-cross' mesh,
// the voltages would vary more with a mesh with all the
// triangles aligned in the same direction.
TS_ASSERT_DELTA(voltage_replicated[i], probe_voltage, 7e-4);
}
// Check against 1d case - THIS TEST HAS BEEN REMOVED AS THE MESH
// IS FINER THAN THE 1D MESH SO WE DONT EXPECT THE RESULTS TO BE THE SAME
// TS_ASSERT_DELTA(p_voltage_array[i], -35.1363, 35*0.1);
// test the RHS edge voltages
// hardcoded result that looks accurate - this is a test to see
// that nothing has changed
// assumes endtime = 2ms
TS_ASSERT_DELTA(voltage_replicated[i], -59.6488, 5e-4);
}
}
}
// Solve on a 2D 1mm by 1mm mesh (space step = 0.1mm), stimulating in the
// very centre of the mesh.
//
// NOTE: This test uses NON-PHYSIOLOGICAL parameters values (conductivities,
// surface-area-to-volume ratio, capacitance, stimulus amplitude). Essentially,
// the equations have been divided through by the surface-area-to-volume ratio.
// (Historical reasons...)
void TestMonodomainProblem2DWithPointStimulusInTheVeryCentreOfTheMesh()
{
HeartConfig::Instance()->SetIntracellularConductivities(Create_c_vector(0.0005, 0.0005));
HeartConfig::Instance()->SetSimulationDuration(1.3); //ms - needs to be 1.3 ms to pass test
HeartConfig::Instance()->SetMeshFileName("mesh/test/data/2D_0_to_1mm_400_elements");
HeartConfig::Instance()->SetOutputDirectory("MonoProblem2dWithPointStimulus");
HeartConfig::Instance()->SetOutputFilenamePrefix("MonodomainLR91_2dWithPointStimulus");
// To time the solve
time_t start, end;
time(&start);
PointStimulus2dCellFactory cell_factory;
MonodomainProblem<2> monodomain_problem(&cell_factory);
monodomain_problem.Initialise();
HeartConfig::Instance()->SetSurfaceAreaToVolumeRatio(1.0);
HeartConfig::Instance()->SetCapacitance(1.0);
monodomain_problem.Solve();
// To time the solve
time(&end);
//double dif;
//dif = difftime (end,start);
//printf ("\nSolve took %.2lf seconds. \n", dif );
// test whether voltages and gating variables are in correct ranges
CheckMonoLr91Vars(monodomain_problem);
/*
* Test that corners are 'equal', and centres of sides.
* Irregularities in which way the triangles are oriented make
* this rather difficult, especially since the edges are sampled
* during the upstroke.
*/
DistributedVector voltage = monodomain_problem.GetSolutionDistributedVector();
// corners -> 0, 10, 110, 120
// hardcoded result to check against
// assumes endtime = 1.3
unsigned corners_checked = 0;
for (DistributedVector::Iterator node_index = voltage.Begin();
node_index != voltage.End();
++node_index)
{
ChastePoint<2> location = monodomain_problem.rGetMesh().GetNode(node_index.Global)->GetPoint();
if (fabs(location[0] - 0.0) < 1e-6 && fabs(location[1] - 0.0) < 1e-6) // Corner 0
{
TS_ASSERT_DELTA(voltage[node_index.Global], -34.3481, 1e-3);
corners_checked++;
}
if (fabs(location[0] - 0.1) < 1e-6 && fabs(location[1] - 0.0) < 1e-6) // Corner 10
{
TS_ASSERT_DELTA(voltage[node_index.Global], -34.3481, 1e-3);
corners_checked++;
}
if (fabs(location[0] - 0.0) < 1e-6 && fabs(location[1] - 0.0) < 1e-6) // Corner 110
{
TS_ASSERT_DELTA(voltage[node_index.Global], -34.3481, 1e-3);
corners_checked++;
}
if (fabs(location[0] - 0.0) < 1e-6 && fabs(location[1] - 0.0) < 1e-6) // Corner 120
{
TS_ASSERT_DELTA(voltage[node_index.Global], -34.3481, 1e-3);
corners_checked++;
}
}
unsigned corners_checked_reduced;
MPI_Allreduce(&corners_checked, &corners_checked_reduced, 1, MPI_UNSIGNED, MPI_SUM, PETSC_COMM_WORLD);
TS_ASSERT(corners_checked_reduced == 4);
// centre of edges -> 5, 55, 65, 115
// hardcoded result to check against
// assumes endtime = 1.3
unsigned edges_checked = 0;
for (DistributedVector::Iterator node_index = voltage.Begin();
node_index != voltage.End();
++node_index)
{
ChastePoint<2> location = monodomain_problem.rGetMesh().GetNode(node_index.Global)->GetPoint();
if (fabs(location[0] - 0.05) < 1e-6 && fabs(location[1] - 0.0) < 1e-6) // Node 5
{
TS_ASSERT_DELTA(voltage[node_index.Global], 34.6692, 1e-3);
edges_checked++;
}
if (fabs(location[0] - 0.0) < 1e-6 && fabs(location[1] - 0.05) < 1e-6) // Node 55
{
TS_ASSERT_DELTA(voltage[node_index.Global], 34.6692, 1e-3);
edges_checked++;
}
if (fabs(location[0] - 0.1) < 1e-6 && fabs(location[1] - 0.05) < 1e-6) // Node 65
{
TS_ASSERT_DELTA(voltage[node_index.Global], 34.6692, 1e-3);
edges_checked++;
}
if (fabs(location[0] - 0.05) < 1e-6 && fabs(location[1] - 0.1) < 1e-6) // Node 115
{
TS_ASSERT_DELTA(voltage[node_index.Global], 34.6692, 1e-3);
edges_checked++;
}
}
unsigned edges_checked_reduced;
MPI_Allreduce(&edges_checked, &edges_checked_reduced, 1, MPI_UNSIGNED, MPI_SUM, PETSC_COMM_WORLD);
TS_ASSERT(edges_checked_reduced == 4);
}
///////////////////////////////////////////////////////////////////
// Solve a simple simulation and check the output was only
// printed out at the correct times
///////////////////////////////////////////////////////////////////
void TestMonodomainProblemPrintsOnlyAtRequestedTimes()
{
HeartConfig::Instance()->SetPrintingTimeStep(0.1);
HeartConfig::Instance()->SetSimulationDuration(0.3); //ms
HeartConfig::Instance()->SetMeshFileName("mesh/test/data/1D_0_to_1mm_10_elements");
HeartConfig::Instance()->SetOutputDirectory("MonoProblem1dRequestedTimes");
HeartConfig::Instance()->SetOutputFilenamePrefix("mono_testPrintTimes");
// run testing PrintingTimeSteps
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 1> cell_factory;
MonodomainProblem<1>* p_monodomain_problem = new MonodomainProblem<1>(&cell_factory);
p_monodomain_problem->Initialise();
p_monodomain_problem->SetWriteInfo();
p_monodomain_problem->Solve();
// read data entries for the time file and check correct
//Hdf5DataReader data_reader1("MonoProblem1d", "mono_testPrintTimes");
Hdf5DataReader data_reader1 = p_monodomain_problem->GetDataReader();
delete p_monodomain_problem;
std::vector<double> times = data_reader1.GetUnlimitedDimensionValues();
TS_ASSERT_EQUALS(times.size(), 4u);
TS_ASSERT_DELTA(times[0], 0.00, 1e-12);
TS_ASSERT_DELTA(times[1], 0.10, 1e-12);
TS_ASSERT_DELTA(times[2], 0.20, 1e-12);
TS_ASSERT_DELTA(times[3], 0.30, 1e-12);
}
// NOTE: This test uses NON-PHYSIOLOGICAL parameters values (conductivities,
// surface-area-to-volume ratio, capacitance, stimulus amplitude). Essentially,
// the equations have been divided through by the surface-area-to-volume ratio.
// (Historical reasons...)
void TestMonodomainWithMeshInMemoryToMeshalyzer()
{
HeartConfig::Instance()->SetIntracellularConductivities(Create_c_vector(0.0005, 0.0005));
HeartConfig::Instance()->SetSimulationDuration(0.1); //ms
HeartConfig::Instance()->SetOutputDirectory("Monodomain2d");
HeartConfig::Instance()->SetOutputFilenamePrefix("monodomain2d");
HeartConfig::Instance()->SetVisualizeWithMeshalyzer();
//set the postprocessing information we want
std::vector<unsigned> origin_nodes;
origin_nodes.push_back(0u);
HeartConfig::Instance()->SetConductionVelocityMaps(origin_nodes);
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 2> cell_factory;
///////////////////////////////////////////////////////////////////
// monodomain
///////////////////////////////////////////////////////////////////
MonodomainProblem<2> monodomain_problem(&cell_factory);
TetrahedralMesh<2, 2> mesh;
mesh.ConstructRegularSlabMesh(0.01, 0.1, 0.1);
monodomain_problem.SetMesh(&mesh);
monodomain_problem.Initialise();
HeartConfig::Instance()->SetSurfaceAreaToVolumeRatio(1.0);
HeartConfig::Instance()->SetCapacitance(1.0);
//Clean previous output
OutputFileHandler handler1("Monodomain2d", true); //This one makes sure that we leave a signature file in Monodomain2d so that we can clean up later
OutputFileHandler handler("Monodomain2d/output", true);
PetscTools::Barrier();
// Checking that the following files don't exist in the output directory before calling Solve()
unsigned num_files = 5;
std::string test_file_names[5] = { "monodomain2d_mesh.pts", "monodomain2d_mesh.tri", "monodomain2d_V.dat",
"ChasteParameters.xml", "ConductionVelocityFromNode0.dat" };
for (unsigned i = 0; i < num_files; i++)
{
TS_ASSERT(!handler.FindFile(test_file_names[i]).Exists());
}
// now solve
monodomain_problem.Solve();
PetscTools::Barrier();
// Compare output files
for (unsigned i = 0; i < num_files; i++)
{
if (test_file_names[i] == "monodomain2d_V.dat")
{
/**
* Since we started using bjacobi as the default preconditioner, parallel and sequential tests
* may return different results (always accurate to the tolerance requested).
* A straight FileComparison is unable to take this consideration into account.
* \todo can we use a NumericFileComparison then?
*
* We will test that the file exists though.
*/
TS_ASSERT(handler.FindFile(test_file_names[i]).Exists());
}
else
{
std::string file_1 = handler.GetOutputDirectoryFullPath() + "/" + test_file_names[i];
std::string file_2 = "heart/test/data/Monodomain2d/" + test_file_names[i];
/* In parallel, we want result (below) to be consistent across processes. For this to happen no process
* should abort the file check. This is why we pretend not to be called collectively.
*/
FileComparison comparer(file_1, file_2, false /*Pretend that it's not called collectively*/);
comparer.SetIgnoreLinesBeginningWith("<cp:ChasteParameters");
comparer.IgnoreBlankLines(); // Needed for XSD 4.0, which strips blanks on writing
bool result = comparer.CompareFiles(0, false); // Don't throw a TS_ASSERT
if (!result && (i == 3))
{
// For "ChasteParameters.xml" there is an alternative file
// This is because different versions of XSD produce rounded/full precision floating point numbers
FileComparison comparer2(file_1, file_2 + "_alt");
comparer2.SetIgnoreLinesBeginningWith("<cp:ChasteParameters");
TS_ASSERT(comparer2.CompareFiles());
}
else
{
TS_ASSERT(comparer.CompareFiles());
}
}
}
}
void TestMonodomainProblemCreates1DGeometry()
{
HeartConfig::Instance()->SetSpaceDimension(1);
HeartConfig::Instance()->SetFibreLength(1, 0.01);
HeartConfig::Instance()->SetSimulationDuration(5.0); //ms
HeartConfig::Instance()->SetOutputDirectory("MonodomainCreates1dGeometry");
HeartConfig::Instance()->SetOutputFilenamePrefix("monodomain1d");
// Switch on 1D VTK output
HeartConfig::Instance()->SetVisualizeWithVtk(true);
HeartConfig::Instance()->SetVisualizeWithParallelVtk(true);
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 1> cell_factory(-600 * 5000);
MonodomainProblem<1> monodomain_problem(&cell_factory);
monodomain_problem.Initialise();
monodomain_problem.Solve();
// check some voltages
ReplicatableVector voltage_replicated(monodomain_problem.GetSolution());
double atol = 5e-3;
TS_ASSERT_DELTA(voltage_replicated[1], 13.9682, atol);
TS_ASSERT_DELTA(voltage_replicated[3], 13.9149, atol);
TS_ASSERT_DELTA(voltage_replicated[5], 13.8216, atol);
TS_ASSERT_DELTA(voltage_replicated[7], 13.7275, atol);
#ifdef CHASTE_VTK
// Requires "sudo aptitude install libvtk5-dev" or similar
std::string filepath = OutputFileHandler::GetChasteTestOutputDirectory() + "MonodomainCreates1dGeometry/vtk_output/";
std::string basename = filepath + "monodomain1d";
if (PetscTools::IsParallel())
{
FileFinder pvtk_file(basename + ".pvtu", RelativeTo::Absolute);
TS_ASSERT(pvtk_file.Exists());
}
FileFinder vtu_file(basename + ".vtu", RelativeTo::Absolute);
TS_ASSERT(vtu_file.Exists());
#endif //CHASTE_VTK
}
void TestMonodomainProblemCreates2DGeometry()
{
HeartConfig::Instance()->SetSpaceDimension(2);
HeartConfig::Instance()->SetSheetDimensions(0.3, 0.3, 0.01);
HeartConfig::Instance()->SetSimulationDuration(4.0); //ms
HeartConfig::Instance()->SetOutputDirectory("MonodomainCreatesGeometry");
HeartConfig::Instance()->SetOutputFilenamePrefix("monodomain2d");
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 2> cell_factory(-600 * 5000);
MonodomainProblem<2> monodomain_problem(&cell_factory);
monodomain_problem.Initialise();
monodomain_problem.Solve();
// check some voltages
ReplicatableVector voltage_replicated(monodomain_problem.GetSolution());
double atol = 5e-3;
TS_ASSERT_DELTA(voltage_replicated[1], 17.5728, atol);
TS_ASSERT_DELTA(voltage_replicated[3], 17.4562, atol);
TS_ASSERT_DELTA(voltage_replicated[5], 17.2559, atol);
TS_ASSERT_DELTA(voltage_replicated[7], 17.0440, atol);
}
void TestMonodomainProblemCreates3DGeometry()
{
HeartConfig::Instance()->SetSpaceDimension(3);
HeartConfig::Instance()->SetSlabDimensions(0.1, 0.1, 0.1, 0.01);
HeartConfig::Instance()->SetSimulationDuration(2.0); //ms
HeartConfig::Instance()->SetOutputDirectory("MonodomainCreatesGeometry");
HeartConfig::Instance()->SetOutputFilenamePrefix("monodomain3d");
PlaneStimulusCellFactory<CellLuoRudy1991FromCellML, 3> cell_factory(-600 * 5000);
MonodomainProblem<3> monodomain_problem(&cell_factory);
HeartConfig::Instance()->SetVisualizeWithMeshalyzer(true);
HeartConfig::Instance()->SetVisualizeWithCmgui(true);
HeartConfig::Instance()->SetVisualizeWithVtk(true);
HeartConfig::Instance()->SetVisualizeWithParallelVtk(true);
HeartConfig::Instance()->SetVisualizerOutputPrecision(6);
monodomain_problem.Initialise();
monodomain_problem.Solve();
// check some voltages
ReplicatableVector voltage_replicated(monodomain_problem.GetSolution());
double atol = 5e-3;
TS_ASSERT_DELTA(voltage_replicated[1], 31.8958, atol);
TS_ASSERT_DELTA(voltage_replicated[3], 32.1109, atol);
TS_ASSERT_DELTA(voltage_replicated[5], 32.7315, atol);
TS_ASSERT_DELTA(voltage_replicated[7], 33.7011, atol);
#ifdef CHASTE_VTK
// Requires "sudo aptitude install libvtk5-dev" or similar
if (PetscTools::IsParallel())
{
std::string filepath = OutputFileHandler::GetChasteTestOutputDirectory() + "MonodomainCreatesGeometry/vtk_output/";
std::string basename = filepath + "monodomain3d";
std::stringstream vtu_path;
vtu_path << basename << "_" << PetscTools::GetMyRank() << ".vtu";
FileFinder pvtk_file(basename + ".pvtu", RelativeTo::Absolute);
TS_ASSERT(pvtk_file.Exists());
FileFinder vtk_file(vtu_path.str(), RelativeTo::Absolute);
TS_ASSERT(vtk_file.Exists());
FileFinder param_file(filepath + "ChasteParameters.xml", RelativeTo::Absolute);
TS_ASSERT(param_file.Exists());
FileFinder info_file(basename + "_times.info", RelativeTo::Absolute);
TS_ASSERT(info_file.Exists());
}
#else
std::cout << "This test ran, but did not test VTK-dependent functions as VTK visualization is not enabled." << std::endl;
std::cout << "If required please install and alter your hostconfig settings to switch on chaste support." << std::endl;
#endif //CHASTE_VTK
// We check that the cmgui files generated by the convert command in the problem class are OK
// We compare against mesh files and one data file that are known to be visualized correctly in Cmgui.
// The files written in parallel are different from the ones written in sequential because of the different node
// numbering, therefore we test only the sequential case.
// Note that the outputs of sequential and parallel simulations look the same when loaded with cmgui.
// There are also minor rounding differences at the last decimal figure between sequential and parallel.
EXIT_IF_PARALLEL
std::string results_dir = OutputFileHandler::GetChasteTestOutputDirectory() + "MonodomainCreatesGeometry/cmgui_output/";
//the mesh files...
std::string node_file1 = results_dir + "/monodomain3d.exnode";
std::string node_file2 = "heart/test/data/CmguiData/monodomain/monodomain3dValid.exnode";
std::string elem_file1 = results_dir + "/monodomain3d.exelem";
std::string elem_file2 = "heart/test/data/CmguiData/monodomain/monodomain3dValid.exelem";
FileComparison comparer(node_file1, node_file2);
TS_ASSERT(comparer.CompareFiles());
FileComparison comparer2(elem_file1, elem_file2);
TS_ASSERT(comparer2.CompareFiles());
//...and one data file as example
FileComparison comparer3(results_dir + "/monodomain3d_43.exnode", "heart/test/data/CmguiData/monodomain/monodomain3dValidData.exnode");
TS_ASSERT(comparer3.CompareFiles());
//Info file
FileComparison comparer4(results_dir + "/monodomain3d_times.info", "heart/test/data/CmguiData/monodomain/monodomain3dValidData_times.info");
TS_ASSERT(comparer4.CompareFiles());
//HeartConfig XML
TS_ASSERT(FileFinder(results_dir + "ChasteParameters.xml").Exists());
#ifdef CHASTE_VTK
// Requires "sudo aptitude install libvtk5-dev" or similar
results_dir = OutputFileHandler::GetChasteTestOutputDirectory() + "MonodomainCreatesGeometry/vtk_output/";
VtkMeshReader<3, 3> mesh_reader(results_dir + "monodomain3d.vtu");
TS_ASSERT_EQUALS(mesh_reader.GetNumNodes(), 1331U);
TS_ASSERT_EQUALS(mesh_reader.GetNumElements(), 6000U);
std::vector<double> first_node = mesh_reader.GetNextNode();
TS_ASSERT_DELTA(first_node[0], 0.0, 1e-6);
TS_ASSERT_DELTA(first_node[1], 0.0, 1e-6);
TS_ASSERT_DELTA(first_node[2], 0.0, 1e-6);
std::vector<double> next_node = mesh_reader.GetNextNode();
TS_ASSERT_DELTA(next_node[0], 0.01, 1e-6);
TS_ASSERT_DELTA(next_node[1], 0.0, 1e-6);
TS_ASSERT_DELTA(next_node[2], 0.0, 1e-6);
//Last time step and midway time step for V_m
std::vector<double> v_at_last, v_at_100;
mesh_reader.GetPointData("V_000100", v_at_100);
TS_ASSERT_DELTA(v_at_100[0], 48.0637, 1e-3);
TS_ASSERT_DELTA(v_at_100[665], 26.5404, 1e-3);
TS_ASSERT_DELTA(v_at_100[1330], -55.3058, 1e-3);
mesh_reader.GetPointData("V_000200", v_at_last);
TS_ASSERT_DELTA(v_at_last[0], 31.8730, 1e-3);
TS_ASSERT_DELTA(v_at_last[665], 32.6531, 1e-3);
TS_ASSERT_DELTA(v_at_last[1330], 34.5152, 1e-3);
//HeartConfig XML
TS_ASSERT(FileFinder(results_dir + "ChasteParameters.xml").Exists());
#else
std::cout << "This test ran, but did not test VTK-dependent functions as VTK visualization is not enabled." << std::endl;
std::cout << "If required please install and alter your hostconfig settings to switch on chaste support." << std::endl;
#endif //CHASTE_VTK
}
// Test the functionality for outputing the values of requested cell state variables
void TestMonodomainProblemPrintsMultipleVariables()
{
// Set configuration file
HeartConfig::Instance()->SetParametersFile("heart/test/data/xml/MultipleVariablesMonodomain.xml");
// Set up problem
PlaneStimulusCellFactory<CellFaberRudy2000FromCellML, 1> cell_factory;
MonodomainProblem<1> monodomain_problem(&cell_factory);
// Solve
monodomain_problem.Initialise();
monodomain_problem.Solve();
// Get a reference to a reader object for the simulation results
Hdf5DataReader data_reader1 = monodomain_problem.GetDataReader();
std::vector<double> times = data_reader1.GetUnlimitedDimensionValues();
// Check there is information about 101 timesteps (0, 0.01, 0.02, ...)
TS_ASSERT_EQUALS(times.size(), 11u);
TS_ASSERT_DELTA(times[0], 0.0, 1e-12);
TS_ASSERT_DELTA(times[1], 0.01, 1e-12);
TS_ASSERT_DELTA(times[2], 0.02, 1e-12);
TS_ASSERT_DELTA(times[3], 0.03, 1e-12);