Skip to content
Snippets Groups Projects
Commit 98af01aa authored by Chaofan Chen's avatar Chaofan Chen
Browse files

Using existed function to get value from map or output error message.

parent a4394d4b
No related branches found
No related tags found
No related merge requests found
......@@ -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");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment