diff --git a/MaterialLib/CMakeLists.txt b/MaterialLib/CMakeLists.txt index a173181bb77446b500c900e61f153852a5b56106..6eb3884711e3f306ee990f9a14ad5092a49c9acc 100644 --- a/MaterialLib/CMakeLists.txt +++ b/MaterialLib/CMakeLists.txt @@ -10,6 +10,7 @@ append_source_files(SOURCES Fluid/Density) append_source_files(SOURCES Fluid/Viscosity) append_source_files(SOURCES Fluid/GibbsFreeEnergy) append_source_files(SOURCES Fluid/FluidProperties) +append_source_files(SOURCES Fluid/FluidType) append_source_files(SOURCES Fluid/SpecificHeatCapacity) append_source_files(SOURCES Fluid/ThermalConductivity) append_source_files(SOURCES Fluid/WaterVaporProperties) diff --git a/MaterialLib/Fluid/FluidType/FluidType.cpp b/MaterialLib/Fluid/FluidType/FluidType.cpp new file mode 100644 index 0000000000000000000000000000000000000000..2faf9aa782893dbc168a645c3e6cd87c9138cf40 --- /dev/null +++ b/MaterialLib/Fluid/FluidType/FluidType.cpp @@ -0,0 +1,54 @@ +/** + * \copyright + * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#include "FluidType.h" +#include "BaseLib/Error.h" +#include <math.h> + +namespace FluidType +{ + +Fluid_Type strToFluidType(std::string const& s) +{ + if (s == "incompressible_fluid") + return Fluid_Type::INCOMPRESSIBLE_FLUID; + if (s == "compressible_fluid") + return Fluid_Type::COMPRESSIBLE_FLUID; + if (s == "ideal_gas") + return Fluid_Type::IDEAL_GAS; + OGS_FATAL("This fluid type is unavailable. The available types are \n" + "incompressible_fluid, compressible_fluid and ideal_gas.\n"); +} + +bool checkRequiredParams(Fluid_Type const& f_type, + double const& /*fluid_compressibility*/ beta_p, + double const& /*reference_temperature*/ T_ref, + double const& /*specific_gas_constant*/ R_s) +{ + return !((f_type == Fluid_Type::COMPRESSIBLE_FLUID && isnan(beta_p)) || + (f_type == Fluid_Type::IDEAL_GAS && + (isnan(T_ref) || isnan(R_s)))); +} + +const char* getErrorMsg(Fluid_Type const& f_type) +{ + if (f_type == Fluid_Type::COMPRESSIBLE_FLUID) + { + return "The fluid type compressible_fluid requires the parameter\n" + "fluid_compressibility"; + } + if (f_type == Fluid_Type::IDEAL_GAS) + { + return "The fluid type ideal_gas requires the parameters\n" + "reference_temperature and specific_gas_constant."; + } + return "The required parameters for this fluid type are missing."; +} + +} // namespace FluidType diff --git a/MaterialLib/Fluid/FluidType/FluidType.h b/MaterialLib/Fluid/FluidType/FluidType.h new file mode 100644 index 0000000000000000000000000000000000000000..0a57efe54b12dbbc9170d1375a0dbbb2f771b36b --- /dev/null +++ b/MaterialLib/Fluid/FluidType/FluidType.h @@ -0,0 +1,33 @@ +/** + * \copyright + * Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + */ + +#pragma once + +#include <string> + +namespace FluidType +{ + +enum class Fluid_Type +{ + INCOMPRESSIBLE_FLUID, + COMPRESSIBLE_FLUID, + IDEAL_GAS +}; + +Fluid_Type strToFluidType(std::string const& s); + +bool checkRequiredParams(Fluid_Type const& f_type, + double const& /*fluid_compressibility*/ beta_p, + double const& /*reference_temperature*/ T_ref, + double const& /*specific_gas_constant*/ R_s); + +const char* getErrorMsg(Fluid_Type const& f_type); + +} // namespace FluidTypeLib