diff --git a/ProcessLib/HeatTransportBHE/BHE/CreateFlowAndTemperatureControl.cpp b/ProcessLib/HeatTransportBHE/BHE/CreateFlowAndTemperatureControl.cpp index 76b738a1f4d14e45592167f4518e1e0aa6e89321..0ea8aad7b2c4e5fb4e0435b7fef7498648455313 100644 --- a/ProcessLib/HeatTransportBHE/BHE/CreateFlowAndTemperatureControl.cpp +++ b/ProcessLib/HeatTransportBHE/BHE/CreateFlowAndTemperatureControl.cpp @@ -11,6 +11,7 @@ #include "BaseLib/ConfigTree.h" #include "BaseLib/Error.h" +#include "BaseLib/Algorithm.h" #include "CreateFlowAndTemperatureControl.h" #include "RefrigerantProperties.h" @@ -28,20 +29,6 @@ FlowAndTemperatureControl createFlowAndTemperatureControl( curves, RefrigerantProperties const& refrigerant) { - auto find_curve_or_error = [&](std::string const& name, - std::string const& error_message) - -> MathLib::PiecewiseLinearInterpolation const& { - auto const it = curves.find(name); - if (it == curves.end()) - { - ERR(error_message.c_str()); - OGS_FATAL( - "Curve with name '%s' could not be found in the curves list.", - name.c_str()); - } - return *it->second; - }; - //! \ogs_file_param{prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__flow_and_temperature_control__type} auto const type = config.getConfigParameter<std::string>("type"); if (type == "TemperatureCurveConstantFlow") @@ -49,10 +36,11 @@ FlowAndTemperatureControl createFlowAndTemperatureControl( //! \ogs_file_param{prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__flow_and_temperature_control__TemperatureCurveConstantFlow__flow_rate} double const flow_rate = config.getConfigParameter<double>("flow_rate"); - auto const& temperature_curve = find_curve_or_error( - //! \ogs_file_param{prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__flow_and_temperature_control__TemperatureCurveConstantFlow__temperature_curve} - config.getConfigParameter<std::string>("temperature_curve"), - "Required temperature curve not found."); + auto const& temperature_curve = *BaseLib::getOrError( + curves, + //! \ogs_file_param{prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__flow_and_temperature_control__TemperatureCurveConstantFlow__temperature_curve} + config.getConfigParameter<std::string>("temperature_curve"), + "Required temperature curve not found."); return TemperatureCurveConstantFlow{flow_rate, temperature_curve}; } @@ -70,10 +58,11 @@ FlowAndTemperatureControl createFlowAndTemperatureControl( if (type == "FixedPowerFlowCurve") { - auto const& flow_rate_curve = find_curve_or_error( - //! \ogs_file_param{prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__flow_and_temperature_control__FixedPowerFlowCurve__flow_rate_curve} - config.getConfigParameter<std::string>("flow_rate_curve"), - "Required flow rate curve not found."); + auto const& flow_rate_curve = *BaseLib::getOrError( + curves, + //! \ogs_file_param{prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__flow_and_temperature_control__FixedPowerFlowCurve__flow_rate_curve} + config.getConfigParameter<std::string>("flow_rate_curve"), + "Required flow rate curve not found."); //! \ogs_file_param{prj__processes__process__HEAT_TRANSPORT_BHE__borehole_heat_exchangers__borehole_heat_exchanger__flow_and_temperature_control__FixedPowerFlowCurve__power} double const power = config.getConfigParameter<double>("power");