diff --git a/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp new file mode 100644 index 0000000000000000000000000000000000000000..7173661106f03e0b68847abf2044ef2e1d28a6cd --- /dev/null +++ b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.cpp @@ -0,0 +1,100 @@ +/** + * \copyright + * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + * \file CreateFluidProperties.cpp + * + * Created on December 13, 2016, 3:32 PM + */ + +#include "CreateFluidProperties.h" + +#include <string> + +#include "BaseLib/ConfigTree.h" + +#include "FluidProperties.h" +#include "PrimaryVariableDependentFluidProperties.h" +#include "FluidPropertiesWithDensityDependentModels.h" + +#include "MaterialLib/Fluid/FluidPropertyHeaders.h" +#include "MaterialLib/Fluid/SpecificHeatCapacity/CreateSpecificFluidHeatCapacityModel.h" +#include "MaterialLib/Fluid/ThermalConductivity/CreateFluidThermalConductivityModel.h" + +namespace MaterialLib +{ +namespace Fluid +{ +std::unique_ptr<FluidProperties> createFluidProperties( + BaseLib::ConfigTree const& config) +{ + //! \ogs_file_param{material__fluid__density} + auto const& rho_conf = config.getConfigSubtree("density"); + auto liquid_density = MaterialLib::Fluid::createFluidDensityModel(rho_conf); + + //! \ogs_file_param{material__fluid__viscosity} + auto const& mu_conf = config.getConfigSubtree("viscosity"); + auto viscosity = MaterialLib::Fluid::createViscosityModel(mu_conf); + const bool is_mu_density_dependent = + (viscosity->getName().find("density dependent") != std::string::npos) + ? true + : false; + + bool is_cp_density_dependent = false; + std::unique_ptr<MaterialLib::Fluid::FluidProperty> specific_heat_capacity = + nullptr; + auto heat_capacity__opt_conf = + //! \ogs_file_param{material__fluid__specific_heat_capacity} + config.getConfigSubtreeOptional("specific_heat_capacity"); + if (heat_capacity__opt_conf) + { + const auto& heat_capacity_conf = *heat_capacity__opt_conf; + specific_heat_capacity = + createSpecificFluidHeatCapacityModel(heat_capacity_conf); + is_cp_density_dependent = + (specific_heat_capacity->getName().find("density dependent") != + std::string::npos) + ? true + : false; + } + + bool is_KT_density_dependent = false; + std::unique_ptr<MaterialLib::Fluid::FluidProperty> thermal_conductivity = + nullptr; + auto const& thermal_conductivity_opt_conf = + //! \ogs_file_param{material__fluid__thermal_conductivity} + config.getConfigSubtreeOptional("thermal_conductivity"); + if (thermal_conductivity_opt_conf) + { + auto& thermal_conductivity_conf = *thermal_conductivity_opt_conf; + thermal_conductivity = + MaterialLib::Fluid::createFluidThermalConductivityModel( + thermal_conductivity_conf); + is_KT_density_dependent = + (specific_heat_capacity->getName().find("density dependent") != + std::string::npos) + ? true + : false; + } + + if (is_mu_density_dependent || is_cp_density_dependent || + is_KT_density_dependent) + return std::unique_ptr<MaterialLib::Fluid::FluidProperties>( + new MaterialLib::Fluid::FluidPropertiesWithDensityDependentModels( + std::move(liquid_density), std::move(viscosity), + std::move(specific_heat_capacity), + std::move(thermal_conductivity), is_mu_density_dependent, + is_cp_density_dependent, is_KT_density_dependent)); + else + return std::unique_ptr<MaterialLib::Fluid::FluidProperties>( + new MaterialLib::Fluid::PrimaryVariableDependentFluidProperties( + std::move(liquid_density), std::move(viscosity), + std::move(specific_heat_capacity), + std::move(thermal_conductivity))); +} + +} // end namespace +} // end namespace diff --git a/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.h b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.h new file mode 100644 index 0000000000000000000000000000000000000000..9037c0ffc6e46c69f76ee455b1e098ec32f8ff13 --- /dev/null +++ b/MaterialLib/Fluid/FluidProperties/CreateFluidProperties.h @@ -0,0 +1,35 @@ +/** + * \copyright + * Copyright (c) 2012-2016, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + * \file CreateFluidProperties.h + * + * Created on December 13, 2016, 3:32 PM + */ + +#ifndef OGS_CREATE_FLUID_PROPERTIES_H +#define OGS_CREATE_FLUID_PROPERTIES_H + +#include <memory> + +namespace BaseLib +{ +class ConfigTree; +} + +namespace MaterialLib +{ +namespace Fluid +{ +class FluidProperties; +/// Create an instance of class FluidProperties +/// \param config ConfigTree object has tags of `<fluid>` +std::unique_ptr<FluidProperties> createFluidProperties( + BaseLib::ConfigTree const& config); +} // end namespace +} // end namespace + +#endif /* OGS_CREATE_FLUID_PROPERTIES_H */