From 2e3db7f9ec619fee8c5a2f13e40f5c12837d3158 Mon Sep 17 00:00:00 2001 From: Wenqing Wang Date: Thu, 23 May 2019 10:47:57 +0200 Subject: [PATCH 1/2] Correted fluid property output when the time init is Celsius --- FEM/rf_mfp_new.cpp | 11 +++++++++-- FEM/rf_mfp_new.h | 7 +++++-- FEM/rf_pcs.cpp | 14 ++++++++++---- 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/FEM/rf_mfp_new.cpp b/FEM/rf_mfp_new.cpp index 16900fd9e..da52b806d 100644 --- a/FEM/rf_mfp_new.cpp +++ b/FEM/rf_mfp_new.cpp @@ -3422,7 +3422,8 @@ double CFluidProperties::CalcEnthalpy(double temperature) 08/2008 OK last change: 11/2008 NB **************************************************************************/ -double MFPGetNodeValue(long node, const string& mfp_name, int phase_number) +double MFPGetNodeValue(long node, const std::string& mfp_name, + int phase_number, const bool for_output) { CFluidProperties* m_mfp = mfp_vector[max(phase_number, 0)]; const int restore_mode = m_mfp->mode; @@ -3473,7 +3474,13 @@ double MFPGetNodeValue(long node, const string& mfp_name, int phase_number) if ((*vec_var_names)[i] == "PRESSURE1") arguments[0] = pcs->GetNodeValue(node, var_idx); else if ((*vec_var_names)[i] == "TEMPERATURE1") - arguments[1] = pcs->GetNodeValue(node, var_idx); + { + arguments[1] = pcs->getTemperatureUnit() == + (FiniteElement::CELSIUS && for_output) + ? pcs->GetNodeValue(node, var_idx) + + PhysicalConstant::CelsiusZeroInKelvin + : pcs->GetNodeValue(node, var_idx); + } else if ((*vec_var_names)[i] == "CONCENTRATION1") arguments[2] = pcs->GetNodeValue(node, var_idx); else diff --git a/FEM/rf_mfp_new.h b/FEM/rf_mfp_new.h index fb4d41bf7..a7b9e96eb 100644 --- a/FEM/rf_mfp_new.h +++ b/FEM/rf_mfp_new.h @@ -305,7 +305,9 @@ class CFluidProperties friend CFluidProperties* MFPGet(const std::string&); friend CFluidProperties* MFPGet(int); friend void KNaplCalcDensity(); - friend double MFPGetNodeValue(long, const std::string&, int); + friend double MFPGetNodeValue(long node, const std::string& mfp_name, + int phase_number, + const bool for_output); friend void MMPCalcSecondaryVariablesNew(CRFProcess*, bool); }; @@ -326,5 +328,6 @@ extern void MFPDelete(); extern CFluidProperties* MFPGet(const std::string&); extern CFluidProperties* MFPGet(int); // NB JUN 09 // NB AUG 09 -double MFPGetNodeValue(long, const std::string&, int); +double MFPGetNodeValue(long node, const std::string& mfp_name, int phase_number, + const bool for_output = true); #endif diff --git a/FEM/rf_pcs.cpp b/FEM/rf_pcs.cpp index babc8d459..7ff9aed97 100644 --- a/FEM/rf_pcs.cpp +++ b/FEM/rf_pcs.cpp @@ -7886,11 +7886,13 @@ double CRFProcess::calcPressureFromHead(CBoundaryCondition const& bc, double const& fac) { double local_density; + const bool for_ouput = false; switch (bc.getPressureAsHeadModel()) { case 0: // use current density at node - local_density = MFPGetNodeValue(node_number, "DENSITY", 0); + local_density = MFPGetNodeValue(node_number, "DENSITY", 0, + for_ouput); break; case 1: // use given density @@ -7900,7 +7902,8 @@ double CRFProcess::calcPressureFromHead(CBoundaryCondition const& bc, std::cout << "Warning! No PressureAsHeadDensity specified. " "Calculating density (i.e. PressureAsHeadModel 0)!" << std::endl; - local_density = MFPGetNodeValue(node_number, "DENSITY", 0); + local_density = MFPGetNodeValue(node_number, "DENSITY", 0, + for_ouput); break; } @@ -7921,11 +7924,13 @@ double CRFProcess::calcHeadFromPressure(CBoundaryCondition const& bc, double const& fac) { double local_density; + const bool for_ouput = false; switch (bc.getPressureAsHeadModel()) { case 0: // use current density at node - local_density = MFPGetNodeValue(node_number, "DENSITY", 0); + local_density = MFPGetNodeValue(node_number, "DENSITY", 0, + for_ouput); break; case 1: // use given density @@ -7935,7 +7940,8 @@ double CRFProcess::calcHeadFromPressure(CBoundaryCondition const& bc, std::cout << "Warning! No PressureAsHeadDensity specified. " "Calculating density (i.e. PressureAsHeadModel 0)!" << std::endl; - local_density = MFPGetNodeValue(node_number, "DENSITY", 0); + local_density = MFPGetNodeValue(node_number, "DENSITY", 0, + for_ouput); break; } From cf835ec0ae26ccb113ae4386d7dee617eb250c19 Mon Sep 17 00:00:00 2001 From: Wenqing Wang Date: Fri, 24 May 2019 10:59:28 +0200 Subject: [PATCH 2/2] [MFPGetNodeValue] Corrected a ternary condition --- FEM/rf_mfp_new.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/FEM/rf_mfp_new.cpp b/FEM/rf_mfp_new.cpp index da52b806d..55ee8f40e 100644 --- a/FEM/rf_mfp_new.cpp +++ b/FEM/rf_mfp_new.cpp @@ -3475,8 +3475,8 @@ double MFPGetNodeValue(long node, const std::string& mfp_name, arguments[0] = pcs->GetNodeValue(node, var_idx); else if ((*vec_var_names)[i] == "TEMPERATURE1") { - arguments[1] = pcs->getTemperatureUnit() == - (FiniteElement::CELSIUS && for_output) + arguments[1] = ((pcs->getTemperatureUnit() == + FiniteElement::CELSIUS) && for_output) ? pcs->GetNodeValue(node, var_idx) + PhysicalConstant::CelsiusZeroInKelvin : pcs->GetNodeValue(node, var_idx);