Cantera  2.0
LiquidTransportData.cpp
Go to the documentation of this file.
1 /**
2  * @file LiquidTransportData.cpp
3  * Source code for liquid transport property evaluations.
4  */
5 
7 using namespace std;
8 
9 #ifndef SAFE_DELETE
10 #define SAFE_DELETE(x) if (x) { delete (x); x = 0; }
11 #endif
12 namespace Cantera
13 {
14 
15 //====================================================================================================================
16 LiquidTransportData::LiquidTransportData() :
17  speciesName("-"),
18  hydroRadius(0),
19  viscosity(0),
20  ionConductivity(0),
21  mobilityRatio(0),
22  selfDiffusion(0),
23  thermalCond(0),
24  electCond(0),
25  speciesDiffusivity(0)
26 {
27 
28 }
29 //====================================================================================================================
30 // Copy constructor
32  speciesName("-"),
33  hydroRadius(0),
34  viscosity(0),
35  ionConductivity(0),
36  mobilityRatio(0),
37  selfDiffusion(0),
38  thermalCond(0),
39  electCond(0),
40  speciesDiffusivity(0)
41 {
42  *this = right; //use assignment operator to do other work
43 }
44 //====================================================================================================================
45 // Assignment operator
47 {
48  if (&right != this) {
49  // These are all shallow pointer copies - yes, yes, yes horrible crime.
50  speciesName = right.speciesName;
51  if (right.hydroRadius) {
52  hydroRadius = (right.hydroRadius)->duplMyselfAsLTPspecies();
53  }
54  if (right.viscosity) {
55  viscosity = (right.viscosity)->duplMyselfAsLTPspecies();
56  }
57  if (right.ionConductivity) {
58  ionConductivity = (right.ionConductivity)->duplMyselfAsLTPspecies();
59  }
60 
62  for (size_t k = 0; k < mobilityRatio.size(); k++) {
63  if (right.mobilityRatio[k]) {
64  mobilityRatio[k] = (right.mobilityRatio[k])->duplMyselfAsLTPspecies();
65  }
66  }
67 
69  for (size_t k = 0; k < selfDiffusion.size(); k++) {
70  if (right.selfDiffusion[k]) {
71  selfDiffusion[k] = (right.selfDiffusion[k])->duplMyselfAsLTPspecies();
72  }
73  }
74 
75  if (right.thermalCond) {
76  thermalCond = (right.thermalCond)->duplMyselfAsLTPspecies();
77  }
78  if (right.electCond) {
79  electCond = (right.electCond)->duplMyselfAsLTPspecies();
80  }
81  if (right.speciesDiffusivity) {
82  speciesDiffusivity = (right.speciesDiffusivity)->duplMyselfAsLTPspecies();
83  }
84  }
85  return *this;
86 }
87 //====================================================================================================================
89 {
90 
91  SAFE_DELETE(hydroRadius);
92  SAFE_DELETE(viscosity);
93  SAFE_DELETE(ionConductivity);
94 
95  for (size_t k = 0; k < mobilityRatio.size(); k++) {
96  if (mobilityRatio[k]) {
97  SAFE_DELETE(mobilityRatio[k]);
98  }
99  }
100  for (size_t k = 0; k < selfDiffusion.size(); k++) {
101  if (selfDiffusion[k]) {
102  SAFE_DELETE(selfDiffusion[k]);
103  }
104  }
105 
106  SAFE_DELETE(thermalCond);
107  SAFE_DELETE(electCond);
108  SAFE_DELETE(speciesDiffusivity);
109 
110 }
111 //====================================================================================================================
112 }