<
    Kitware and KbPort announce the launch of SimPulse
×
CommonDataModelTest.h
1 // The following tests will be exported and runnable
2 
3 #include "CommonDefs.h"
4 #include "utils/testing/SETestManager.h"
5 class SEFluidCircuit;
6 class SECircuitManager;
7 class SEGasCompartment;
11 class SESubstanceManager;
14 class SETestSuite;
15 class SETestCase;
16 
17 
18 #define CDM_TEST_DECL
19 #ifdef SHARED_CDM_TEST
20  #if defined (__clang__)
21  #define CDM_TEST_DECL
22  #elif defined(__gnu_linux__)
23  #define CDM_TEST_DECL __attribute__ ((visibility ("default")))
24  #else
25  #ifdef SHARED_CDM_TEST
26  #define CDM_TEST_DECL __declspec(dllexport)
27  #else
28  #define CDM_TEST_DECL __declspec(dllimport)
29  #endif
30  #endif
31 #endif
32 
33 enum enumCDMTestSourceType
34 {
35  DC,
36  SIN,
37  PULSE,
38  ZEROCENTEREDSIN
39 };
40 
41 class CDM_TEST_DECL CommonDataModelTest : public SETestManager
42 {
43 public:
44  CommonDataModelTest(Logger* logger=nullptr);
45  virtual ~CommonDataModelTest();
46 
47  virtual bool RunTest(const std::string& testName, const std::string& sOutputDirectory) override;
48 
49 protected:
50  virtual void FillFunctionMap() override;
52  std::string m_OutDirectory;
53 
54  typedef void(CommonDataModelTest::*testFunction)(const std::string&);
55  typedef std::map<std::string, testFunction> testMap;
56  testMap cdmMap;
57 
58 
60  // Circuits //
62 public:
63  //Basic Circuit Tests
64  void BasicCircuitTest(const std::string& sOutputDirectory);
65 
66  void SeriesRCDCTest(const std::string& sOutputDirectory);
67  void SeriesRCSINTest(const std::string& sOutputDirectory);
68  void SeriesRCPULSETest(const std::string& sOutputDirectory);
69 
70  void SeriesRDCTest(const std::string& sOutputDirectory);
71  void SeriesRSINTest(const std::string& sOutputDirectory);
72  void SeriesRPULSETest(const std::string& sOutputDirectory);
73 
74  void SeriesRLDCTest(const std::string& sOutputDirectory);
75  void SeriesRLSINTest(const std::string& sOutputDirectory);
76  void SeriesRLPULSETest(const std::string& sOutputDirectory);
77 
78  void ParallelRDCTest(const std::string& sOutputDirectory);
79  void ParallelRSINTest(const std::string& sOutputDirectory);
80  void ParallelRPULSETest(const std::string& sOutputDirectory);
81 
82  void ParallelRCDCTest(const std::string& sOutputDirectory);
83  void ParallelRCSINTest(const std::string& sOutputDirectory);
84  void ParallelRCPULSETest(const std::string& sOutputDirectory);
85 
86  void ParallelRLDCTest(const std::string& sOutputDirectory);
87  void ParallelRLSINTest(const std::string& sOutputDirectory);
88  void ParallelRLPULSETest(const std::string& sOutputDirectory);
89  void ParallelRLSINCenteredTest(const std::string& sOutputDirectory);
90 
91  void SeriesRLCDCTest(const std::string& sOutputDirectory);
92  void SeriesRLCSINTest(const std::string& sOutputDirectory);
93  void SeriesRLCPULSETest(const std::string& sOutputDirectory);
94 
95  void ParallelRLCDCTest(const std::string& sOutputDirectory);
96  void ParallelRLCSINTest(const std::string& sOutputDirectory);
97  void ParallelRLCPULSETest(const std::string& sOutputDirectory);
98 
99  void SwitchRCDCTest(const std::string& sOutputDirectory);
100  void SwitchRCSINTest(const std::string& sOutputDirectory);
101  void SwitchRCPULSETest(const std::string& sOutputDirectory);
102 
103  void Comprehensive1DCTest(const std::string& sOutputDirectory);
104  void Comprehensive1SINTest(const std::string& sOutputDirectory);
105  void Comprehensive1PULSETest(const std::string& sOutputDirectory);
106 
107  void SimpleDiodeDCTest(const std::string& sOutputDirectory);
108  void SimpleDiodeSINTest(const std::string& sOutputDirectory);
109  void SimpleDiodePULSETest(const std::string& sOutputDirectory);
110 
111  void SeriesRCDCCurrentTest(const std::string& sOutputDirectory);
112  void SeriesRCSINCurrentTest(const std::string& sOutputDirectory);
113  void SeriesRCPULSECurrentTest(const std::string& sOutputDirectory);
114 
115  void ParallelRCDCCurrentTest(const std::string& sOutputDirectory);
116  void ParallelRCSINCurrentTest(const std::string& sOutputDirectory);
117  void ParallelRCPULSECurrentTest(const std::string& sOutputDirectory);
118 
119  void SeriesCapDCTest(const std::string& sOutputDirectory);
120  void SeriesCapSINTest(const std::string& sOutputDirectory);
121  void SeriesCapPULSETest(const std::string& sOutputDirectory);
122 
123  void ParallelRDCCurrentTest(const std::string& sOutputDirectory);
124  void ParallelRSINCurrentTest(const std::string& sOutputDirectory);
125  void ParallelRPULSECurrentTest(const std::string& sOutputDirectory);
126 
127  void CurrentCompDCTest(const std::string& sOutputDirectory);
128  void CurrentCompSINTest(const std::string& sOutputDirectory);
129  void CurrentCompPULSETest(const std::string& sOutputDirectory);
130 
131  void SeriesRLDCCurrentTest(const std::string& sOutputDirectory);
132  void SeriesRLSINCurrentTest(const std::string& sOutputDirectory);
133  void SeriesRLPULSECurrentTest(const std::string& sOutputDirectory);
134 
135  void ParallelRLDCCurrentTest(const std::string& sOutputDirectory);
136  void ParallelRLSINCurrentTest(const std::string& sOutputDirectory);
137  void ParallelRLPULSECurrentTest(const std::string& sOutputDirectory);
138 
139  void BasicDiodeDCCurrentTest(const std::string& sOutputDirectory);
140  void BasicDiodeSINCurrentTest(const std::string& sOutputDirectory);
141  void BasicDiodePULSECurrentTest(const std::string& sOutputDirectory);
142 
143  //NOTE: These next three tests seem to give errors while running, but they produce output...
144  void SwitchRCDCCurrentTest(const std::string& sOutputDirectory);
145  void SwitchRCSINCurrentTest(const std::string& sOutputDirectory);
146  void SwitchRCPULSECurrentTest(const std::string& sOutputDirectory);
147 
148  void SeriesRLCDCCurrentTest(const std::string& sOutputDirectory);
149  void SeriesRLCSINCurrentTest(const std::string& sOutputDirectory);
150  void SeriesRLCPULSECurrentTest(const std::string& sOutputDirectory);
151 
152  void ParallelRLCDCCurrentTest(const std::string& sOutputDirectory);
153  void ParallelRLCSINCurrentTest(const std::string& sOutputDirectory);
154  void ParallelRLCPULSECurrentTest(const std::string& sOutputDirectory);
155 
156  void SeriesPressureSourceAdditionDCTest(const std::string& sOutputDirectory);
157  void SeriesPressureSourceAdditionSINTest(const std::string& sOutputDirectory);
158  void SeriesPressureSourceAdditionPULSETest(const std::string& sOutputDirectory);
159 
160  //NOTE: These next six tests seem to give errors while running, but it's intentional
161  void SeriesCurrentSourceAdditionDCTest(const std::string& sOutputDirectory);
162  void SeriesCurrentSourceAdditionSINTest(const std::string& sOutputDirectory);
163  void SeriesCurrentSourceAdditionPULSETest(const std::string& sOutputDirectory);
164 
165  void ParallelPressureSourceAdditionDCTest(const std::string& sOutputDirectory);
166  void ParallelPressureSourceAdditionSINTest(const std::string& sOutputDirectory);
167  void ParallelPressureSourceAdditionPULSETest(const std::string& sOutputDirectory);
168 
169  void ParallelCurrentSourceAdditionDCTest(const std::string& sOutputDirectory);
170  void ParallelCurrentSourceAdditionSINTest(const std::string& sOutputDirectory);
171  void ParallelCurrentSourceAdditionPULSETest(const std::string& sOutputDirectory);
172 
173  void SeriesCapDCCurrentTest(const std::string& sOutputDirectory);
174  void SeriesCapSINCurrentTest(const std::string& sOutputDirectory);
175  void SeriesCapPULSECurrentTest(const std::string& sOutputDirectory);
176 
177  void ParallelCapDCTest(const std::string& sOutputDirectory);
178  void ParallelCapSINTest(const std::string& sOutputDirectory);
179  void ParallelCapPULSETest(const std::string& sOutputDirectory);
180 
181  void ParallelCapDCCurrentTest(const std::string& sOutputDirectory);
182  void ParallelCapSINCurrentTest(const std::string& sOutputDirectory);
183  void ParallelCapPULSECurrentTest(const std::string& sOutputDirectory);
184 
185  void SeriesIndDCTest(const std::string& sOutputDirectory);
186  void SeriesIndSINTest(const std::string& sOutputDirectory);
187  void SeriesIndPULSETest(const std::string& sOutputDirectory);
188 
189  void SeriesIndDCCurrentTest(const std::string& sOutputDirectory);
190  void SeriesIndSINCurrentTest(const std::string& sOutputDirectory);
191  void SeriesIndPULSECurrentTest(const std::string& sOutputDirectory);
192 
193  void ParallelIndDCTest(const std::string& sOutputDirectory);
194  void ParallelIndSINTest(const std::string& sOutputDirectory);
195  void ParallelIndPULSETest(const std::string& sOutputDirectory);
196 
197  void ParallelIndDCCurrentTest(const std::string& sOutputDirectory);
198  void ParallelIndSINCurrentTest(const std::string& sOutputDirectory);
199  void ParallelIndPULSECurrentTest(const std::string& sOutputDirectory);
200 
201  //These next three tests intentionally fail
202  void BadDiodeDCTest(const std::string& sOutputDirectory);
203  void BadDiodeSINTest(const std::string& sOutputDirectory);
204  void BadDiodePULSETest(const std::string& sOutputDirectory);
205 
206  void ValidationComprehensive1DCTest(const std::string& sOutputDirectory);
207  void ValidationComprehensive1SINTest(const std::string& sOutputDirectory);
208  void ValidationComprehensive1PULSETest(const std::string& sOutputDirectory);
209  void ValidationComprehensive1SINCenteredTest(const std::string& sOutputDirectory);
210 
211  void ValidationComprehensive2DCTest(const std::string& sOutputDirectory);
212  void ValidationComprehensive2SINTest(const std::string& sOutputDirectory);
213  void ValidationComprehensive2PULSETest(const std::string& sOutputDirectory);
214  void ValidationComprehensive2SINCenteredTest(const std::string& sOutputDirectory);
215 
216  //Advanced Circuit Tests
217  void ElectricalCircuitTest(const std::string& sOutputDirectory);
218  void FluidCircuitTest(const std::string& sOutputDirectory);
219  void ThermalCircuitTest(const std::string& sOutputDirectory);
220  void CombinedCircuitTest(const std::string& sOutputDirectory);
221  void CircuitErrorTest(const std::string& sOutputDirectory); //This one doesn't output anything right now
222  void DynamicallyChangingCircuitTest(const std::string& sOutputDirectory); //This one has some really strange output (-1.$)
223  void NonZeroReferencePositive(const std::string& sOutputDirectory);
224  void NonZeroReferenceNegative(const std::string& sOutputDirectory);
225  void PolarizedCapacitorTest(const std::string& sOutputDirectory);
226  void PreChargeComplianceZeroVolume(const std::string& sOutputDirectory);
227  void PreChargeComplianceNonZeroVolume(const std::string& sOutputDirectory);
228  void ComplianceVolumeChange(const std::string& sOutputDirectory);
229  void CircuitLockingTest(const std::string& sOutputDirectory);
230 
231 protected:
232  //Used to generalize Basic Tests
233  void RunTest(const std::string& sOutputDirectory, const std::string& testName, enumCDMTestSourceType sourceType, int testIndex);
234 
235  //Setup and preprocess methods for Basic Tests
236  void TestSetup7SeriesRCDC();
237  void TestSetup7SeriesRCSIN();
238  void TestSetup7SeriesRCPULSE();
239  void TestSetup8SeriesRDC();
240  void TestSetup8SeriesRSIN();
241  void TestSetup8SeriesRPULSE();
242  void TestSetup9SeriesRLDC();
243  void TestSetup9SeriesRLSIN();
244  void TestSetup9SeriesRLPULSE();
245  void TestSetup10ParallelRDC();
246  void TestSetup10ParallelRSIN();
247  void TestSetup10ParallelRPULSE();
248  void TestSetup11ParallelRCDC();
249  void TestSetup11ParallelRCSIN();
250  void TestSetup11ParallelRCPULSE();
251  void TestSetup12ParallelRLDC();
252  void TestSetup12ParallelRLSIN();
253  void TestSetup12ParallelRLPULSE();
254  void TestSetup12ParallelRLSINCentered();
255  void TestSetup13SeriesRLCDC();
256  void TestSetup13SeriesRLCSIN();
257  void TestSetup13SeriesRLCPULSE();
258  void TestSetup14ParallelRLCDC();
259  void TestSetup14ParallelRLCSIN();
260  void TestSetup14ParallelRLCPULSE();
261  void TestSetup15SwitchRCDC();
262  void TestSetup15SwitchRCSIN();
263  void TestSetup15SwitchRCPULSE();
264  void TestSetup16Comprehensive1DC();
265  void TestSetup16Comprehensive1SIN();
266  void TestSetup16Comprehensive1PULSE();
267  void TestSetup17BasicDiodeDC();
268  void TestSetup17BasicDiodeSIN();
269  void TestSetup17BasicDiodePULSE();
270  void TestSetup18RCSeriesDCCurrent();
271  void TestSetup18RCSeriesSINCurrent();
272  void TestSetup18RCSeriesPulseCurrent();
273  void TestSetup19RCParallelDCCurrent();
274  void TestSetup19RCParallelSINCurrent();
275  void TestSetup19RCParallelPulseCurrent();
276  void TestSetup20SeriesCapDC();
277  void TestSetup20SeriesCapSIN();
278  void TestSetup20SeriesCapPulse();
279  void TestSetup21ParallelRDCCurrent();
280  void TestSetup21ParallelRSINCurrent();
281  void TestSetup21ParallelRPulseCurrent();
282  void TestSetup22CurrentCompDC();
283  void TestSetup22CurrentCompSIN();
284  void TestSetup22CurrentCompPulse();
285  void TestSetup23SeriesRLDCCurrent();
286  void TestSetup23SeriesRLSINCurrent();
287  void TestSetup23SeriesRLPULSECurrent();
288  void TestSetup24ParallelRLDCCurrent();
289  void TestSetup24ParallelRLSINCurrent();
290  void TestSetup24ParallelRLPULSECurrent();
291  void TestSetup25BasicDiodeDCCurrent();
292  void TestSetup25BasicDiodeSINCurrent();
293  void TestSetup25BasicDiodePULSECurrent();
294  void TestSetup26SwitchRCDCCurrent();
295  void TestSetup26SwitchRCSINCurrent();
296  void TestSetup26SwitchRCPULSECurrent();
297  void TestSetup27SeriesRLCDCCurrent();
298  void TestSetup27SeriesRLCSINCurrent();
299  void TestSetup27SeriesRLCPULSECurrent();
300  void TestSetup28ParallelRLCDCCurrent();
301  void TestSetup28ParallelRLCSINCurrent();
302  void TestSetup28ParallelRLCPULSECurrent();
303  void TestSetup29SeriesPressureSourceAdditionDC();
304  void TestSetup29SeriesPressureSourceAdditionSIN();
305  void TestSetup29SeriesPressureSourceAdditionPULSE();
306  void TestSetup30SeriesCurrentSourceAdditionDC();
307  void TestSetup30SeriesCurrentSourceAdditionSIN();
308  void TestSetup30SeriesCurrentSourceAdditionPULSE();
309  void TestSetup31ParallelPressureSourceAdditionDC();
310  void TestSetup31ParallelPressureSourceAdditionSIN();
311  void TestSetup31ParallelPressureSourceAdditionPULSE();
312  void TestSetup32ParallelCurrentSourceAdditionDC();
313  void TestSetup32ParallelCurrentSourceAdditionSIN();
314  void TestSetup32ParallelCurrrentSourceAdditionPULSE();
315  void TestSetup33SeriesCapDCCurrent();
316  void TestSetup33SeriesCapSINCurrent();
317  void TestSetup33SeriesCapPulseCurrent();
318  void TestSetup34ParallelCapDC();
319  void TestSetup34ParallelCapSIN();
320  void TestSetup34ParallelCapPulse();
321  void TestSetup35ParallelCapDCCurrent();
322  void TestSetup35ParallelCapSINCurrent();
323  void TestSetup35ParallelCapPulseCurrent();
324  void TestSetup36SeriesIndDC();
325  void TestSetup36SeriesIndSIN();
326  void TestSetup36SeriesIndPulse();
327  void TestSetup37SeriesIndDCCurrent();
328  void TestSetup37SeriesIndSINCurrent();
329  void TestSetup37SeriesIndPulseCurrent();
330  void TestSetup38ParallelIndDC();
331  void TestSetup38ParallelIndSIN();
332  void TestSetup38ParallelIndPulse();
333  void TestSetup39ParallelIndDCCurrent();
334  void TestSetup39ParallelIndSINCurrent();
335  void TestSetup39ParallelIndPulseCurrent();
336  void TestSetup40BadDiodeDC();
337  void TestSetup40BadDiodeSIN();
338  void TestSetup40BadDiodePulse();
339  void TestSetup41ValidationComprehensive1DC();
340  void TestSetup41ValidationComprehensive1SIN();
341  void TestSetup41ValidationComprehensive1Pulse();
342  void TestSetup41ValidationComprehensive1SINCentered();
343  void TestSetup42ValidationComprehensive2DC();
344  void TestSetup42ValidationComprehensive2SIN();
345  void TestSetup42ValidationComprehensive2Pulse();
346  void TestSetup42ValidationComprehensive2SINCentered();
347 
348  void TestPreProcess1(double dT, int i);
349  void TestPreProcess2(double dT, int i);
350  void TestPreProcess3(double dT, int i);
351  void TestPreProcess4(double dT, int i);
352  void BasicCircuitPreProcess(double dT);
353  //Advanced pre-process
354  void FluidPreProcess(SEFluidCircuit& c, double dT);
355  void TestCircuitSerialization(const std::string& fileName);
356 
358 
359 
361  // Compartments //
363 public:
364  void GasCompartmentTest(const std::string& sOutputDirectory);
365  void LiquidCompartmentTest(const std::string& sOutputDirectory);
366  void ThermalCompartmentTest(const std::string& sOutputDirectory);
367  void TissueCompartmentTest(const std::string& sOutputDirectory); //there is nothing being tested here
368 
369 protected:
370  void TestCompartmentSerialization(SECompartmentManager& mgr, const std::string& fileName);
371  //Gas Compartments
372  void TestGasFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
373  void TestGasHierarchyFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
374  void TestFlow(SETestCase& testCase, SEGasCompartment& cmpt, double inflow_mL_Per_s, double outflow_mL_Per_s);
375  void TestGasHierarchy(SETestSuite& testSuite, SESubstanceManager& subMgr);
376  void TestGasCircuitVolumesPressuresAndFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
377  void CheckGasPressureAndVolume(SETestCase& testCase, SEGasCompartment& cmpt);
378  void TestGasSubstanceQuantity(SETestCase& testCase, SEGasCompartment& cmpt, SEGasSubstanceQuantity& subQ, double totalSubVolume_mL, double totalVolume_mL);
379  void TestUpdateGasLinks(SETestSuite& testSuite, SESubstanceManager& subMgr);
380  //Liquid Compartments
381  void TestLiquidFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
382  void TestLiquidHierarchyFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
383  void TestFlow(SETestCase& testCase, SELiquidCompartment& cmpt, double inflow_mL_Per_s, double outflow_mL_Per_s);
384  void TestLiquidHierarchy(SETestSuite& testSuite, SESubstanceManager& subMgr);
385  void TestLiquidCircuitVolumesPressuresAndFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
386  void TestLiquidHierarchySaturation(SETestSuite& testSuite, SESubstanceManager& subMgr);
387  void CheckLiquidPressureAndVolume(SETestCase& testCase, SELiquidCompartment& cmpt);
388  void TestLiquidSubstanceQuantity(SETestCase& testCase, SELiquidCompartment& cmpt, SELiquidSubstanceQuantity& subQ, double totalMass_mg, double totalVolume_mL);
389  void TestUpdateLiquidLinks(SETestSuite& testSuite, SESubstanceManager& subMgr);
390  //Thermal Compartments
391  void TestThermalFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
392  void TestThermalFlowHierarchy(SETestSuite& testSuite, SESubstanceManager& subMgr);
393  void TestFlow(SETestCase& testCase, SEThermalCompartment& cmpt, double inflow_kcal_Per_s, double outflow_kcal_Per_s);
394  void TestThermalHierarchy(SETestSuite& testSuite, SESubstanceManager& subMgr);
395  void TestCircuitHeatTemperatureAndFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
396  void CheckTemperatureAndHeat(SETestCase& testCase, SEThermalCompartment& cmpt);
397 
399  // Transport //
401 public:
402  void LargeFlowTransportTest(const std::string& sOutputDirectory);
403  void LiquidTransportTest(const std::string& sOutputDirectory);
404  void GasTransportTest(const std::string& sOutputDirectory);
405 
407  // Black Box //
409 
410 public:
411  void BasicBlackBoxComparisonTest(const std::string& sOutputDirectory);
412  void BasicBlackBoxTest(const std::string& sOutputDirectory);
413  void SimpleBlackBoxTest(const std::string& sOutputDirectory);
414  void WindkesselBlackBoxTest(const std::string& sOutputDirectory);
415 
417  // I/O Tests //
419 public:
420  void ReadPatientDirectory(const std::string& sOutputDirectory);
421  void ReadSubstanceDirectory(const std::string& sOutputDirectory);
422 
424  // Properties Tests //
426 public:
427  void ScalarTest(const std::string& sOutputDirectory);
428  void UnitsTest(const std::string& sOutputDirectory);
429 protected:
430  void ConvertList(std::vector<std::string> stringList);
431  // These property tests are not outputting any reports or anything, kind of just a sandbox at this point
432  // Maybe one day I will set something up, but these are generally not a problem (no jinx!)
433 
434 };
Definition: SESubstanceManager.h:8
virtual void FillFunctionMap()=0
SECircuitManager * m_Circuits
Definition: CommonDataModelTest.h:357
double m_PercentTolerance
Definition: CommonDataModelTest.h:51
Definition: SETestManager.h:22
Definition: SEGasCompartment.h:13
Definition: Logger.h:66
Definition: SETestSuite.h:9
testMap cdmMap
Definition: CommonDataModelTest.h:56
virtual bool RunTest(const std::string &testName, const std::string &sOutputDirectory)=0
Definition: SELiquidSubstanceQuantity.h:11
Definition: SELiquidCompartment.h:11
Definition: SECompartmentManager.h:24
Definition: SETestCase.h:8
Definition: SEFluidCircuit.h:11
Definition: SECircuitManager.h:37
std::string m_OutDirectory
Definition: CommonDataModelTest.h:52
std::map< std::string, testFunction > testMap
Definition: CommonDataModelTest.h:55
Definition: SEGasSubstanceQuantity.h:9
Definition: SEThermalCompartment.h:11
Definition: CommonDataModelTest.h:41

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.