| 126 | } |
| 127 | |
| 128 | bool MaterialPropertyPhaseChange_Impl::addTemperatureEnthalpy(const TemperatureEnthalpy& temperatureEnthalpy) { |
| 129 | bool result; |
| 130 | |
| 131 | unsigned int num = numberofTemperatureEnthalpys(); |
| 132 | // Max number of temperature-enthalpys is 16 |
| 133 | if (num >= 16) { |
| 134 | LOG(Warn, briefDescription() << " already has 16 temperature-enthalpys which is the limit"); |
| 135 | result = false; |
| 136 | } else { |
| 137 | // Push an extensible group |
| 138 | auto eg = getObject<ModelObject>().pushExtensibleGroup().cast<WorkspaceExtensibleGroup>(); |
| 139 | bool temperature = eg.setDouble(OS_MaterialProperty_PhaseChangeExtensibleFields::Temperature, temperatureEnthalpy.temperature()); |
| 140 | bool enthalpy = eg.setDouble(OS_MaterialProperty_PhaseChangeExtensibleFields::Enthalpy, temperatureEnthalpy.enthalpy()); |
| 141 | if (temperature && enthalpy) { |
| 142 | result = true; |
| 143 | } else { |
| 144 | // Something went wrong |
| 145 | // So erase the new extensible group |
| 146 | getObject<ModelObject>().eraseExtensibleGroup(eg.groupIndex()); |
| 147 | result = false; |
| 148 | } |
| 149 | result = true; |
| 150 | } |
| 151 | return result; |
| 152 | } |
| 153 | |
| 154 | bool MaterialPropertyPhaseChange_Impl::addTemperatureEnthalpy(double temperature, double enthalpy) { |
| 155 | // Make a temperature-enthalpy, and then call the above function |