From eec3e1a0d3bdc4e8a2721c62bd15e549f807f751 Mon Sep 17 00:00:00 2001 From: Ian Bell Date: Thu, 20 Aug 2015 13:30:45 -0500 Subject: [PATCH] Add a SimpleState fill() function and use it Signed-off-by: Ian Bell --- include/DataStructures.h | 5 ++++- src/AbstractState.cpp | 13 ++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/DataStructures.h b/include/DataStructures.h index d9a94789..085ee700 100644 --- a/include/DataStructures.h +++ b/include/DataStructures.h @@ -16,7 +16,10 @@ namespace CoolProp { struct SimpleState { double rhomolar, T, p, hmolar, smolar, umolar, Q; - SimpleState() : rhomolar(_HUGE), T(_HUGE), p(_HUGE), hmolar(_HUGE), smolar(_HUGE), umolar(_HUGE), Q(_HUGE) {} + SimpleState() { fill(_HUGE); } + void fill(double v){ + rhomolar = v; T = v; p = v; hmolar = v; smolar = v; umolar = v; Q = v; + } bool is_valid(){return ValidNumber(rhomolar) && ValidNumber(T) && ValidNumber(hmolar) && ValidNumber(p);} }; diff --git a/src/AbstractState.cpp b/src/AbstractState.cpp index 2e14f161..9b4ba17b 100644 --- a/src/AbstractState.cpp +++ b/src/AbstractState.cpp @@ -112,17 +112,8 @@ bool AbstractState::clear() { this->_TVanc.clear(); this->_TLanc.clear(); - this->_critical.T = -_HUGE; - this->_critical.hmolar = -_HUGE; - this->_critical.p = -_HUGE; - this->_critical.rhomolar = -_HUGE; - this->_critical.smolar = -_HUGE; - - this->_reducing.T = -_HUGE; - this->_reducing.hmolar = -_HUGE; - this->_reducing.p = -_HUGE; - this->_reducing.rhomolar = -_HUGE; - this->_reducing.smolar = -_HUGE; + this->_critical.fill(_HUGE); + this->_reducing.fill(_HUGE); /// Bulk values this->_rhomolar = -_HUGE;