diff --git a/MaterialLib/CMakeLists.txt b/MaterialLib/CMakeLists.txt index 92a8bd4cfa244568506e7ff36586f4a658a1326a..6af23f988eb9a916ddd63dc5d84d751fdb973d82 100644 --- a/MaterialLib/CMakeLists.txt +++ b/MaterialLib/CMakeLists.txt @@ -17,6 +17,7 @@ append_source_files(SOURCES Fluid/WaterVaporProperties) append_source_files(SOURCES MPL) append_source_files(SOURCES MPL/Properties) append_source_files(SOURCES MPL/Components) +append_source_files(SOURCES MPL/Utils) append_source_files(SOURCES PorousMedium) append_source_files(SOURCES PorousMedium/Porosity) diff --git a/MaterialLib/MPL/Utils/FormEffectiveThermalConductivity.cpp b/MaterialLib/MPL/Utils/FormEffectiveThermalConductivity.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8b0f1bb55aab13fdf2c11f06453c99c3baf24c42 --- /dev/null +++ b/MaterialLib/MPL/Utils/FormEffectiveThermalConductivity.cpp @@ -0,0 +1,39 @@ +/* + * \file + * \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 + * + * Created on July 31, 2019, 12:10 PM + */ + +#include "FormEffectiveThermalConductivity.h" + +#include "FormEigenTensor.h" + +namespace MaterialPropertyLib +{ +template <int GlobalDim> +Eigen::Matrix<double, GlobalDim, GlobalDim> formEffectiveThermalConductivity( + MaterialPropertyLib::PropertyDataType const& solid_thermal_conductivity, + const double fluid_thermal_conductivity, const double porosity) +{ + return (1.0 - porosity) * + formEigenTensor<GlobalDim>(solid_thermal_conductivity) + + porosity * fluid_thermal_conductivity * + Eigen::Matrix<double, GlobalDim, GlobalDim>::Identity(); +} + +template Eigen::Matrix<double, 1, 1> formEffectiveThermalConductivity<1>( + MaterialPropertyLib::PropertyDataType const& solid_thermal_conductivity, + const double fluid_thermal_conductivity, const double porosity); +template Eigen::Matrix<double, 2, 2> formEffectiveThermalConductivity<2>( + MaterialPropertyLib::PropertyDataType const& solid_thermal_conductivity, + const double fluid_thermal_conductivity, const double porosity); +template Eigen::Matrix<double, 3, 3> formEffectiveThermalConductivity<3>( + MaterialPropertyLib::PropertyDataType const& solid_thermal_conductivity, + const double fluid_thermal_conductivity, const double porosity); + +} // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/Utils/FormEffectiveThermalConductivity.h b/MaterialLib/MPL/Utils/FormEffectiveThermalConductivity.h new file mode 100644 index 0000000000000000000000000000000000000000..52942f6ec65c219d6ee9f2e357d4909347bd7751 --- /dev/null +++ b/MaterialLib/MPL/Utils/FormEffectiveThermalConductivity.h @@ -0,0 +1,24 @@ +/* + * \file + * \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 + * + * Created on July 31, 2019, 12:10 PM + */ + +#pragma once + +#include <Eigen/Dense> + +#include "MaterialLib/MPL/Property.h" + +namespace MaterialPropertyLib +{ +template <int GlobalDim> +Eigen::Matrix<double, GlobalDim, GlobalDim> formEffectiveThermalConductivity( + MaterialPropertyLib::PropertyDataType const& solid_thermal_conductivity, + const double fluid_thermal_conductivity, const double porosity); +} // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/Utils/FormEigenTensor.cpp b/MaterialLib/MPL/Utils/FormEigenTensor.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6479e24fdbfa4b0898cd2936c39cc0354ad8343d --- /dev/null +++ b/MaterialLib/MPL/Utils/FormEigenTensor.cpp @@ -0,0 +1,89 @@ +/* + * \file + * \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 + * + * Created on July 31, 2019, 11:28 AM + */ + +#include "FormEigenTensor.h" + +#include <boost/variant/static_visitor.hpp> + +#include "MaterialLib/MPL/PropertyType.h" + +namespace MaterialPropertyLib +{ +template <int GlobalDim> +struct FormEigenTensor + : boost::static_visitor<Eigen::Matrix<double, GlobalDim, GlobalDim>> +{ + Eigen::Matrix<double, GlobalDim, GlobalDim> operator()( + double const& value) const + { + return Eigen::Matrix<double, GlobalDim, GlobalDim>::Identity() * value; + } + + Eigen::Matrix<double, GlobalDim, GlobalDim> operator()( + MaterialPropertyLib::Vector const& values) const + { + return Eigen::Map<Eigen::Matrix<double, GlobalDim, 1> const>( + values.data(), GlobalDim, 1) + .asDiagonal(); + } + + Eigen::Matrix<double, GlobalDim, GlobalDim> operator()( + MaterialPropertyLib::Tensor2d const& values) const + { + return Eigen::Map<Eigen::Matrix<double, GlobalDim, GlobalDim> const>( + values.data(), GlobalDim, GlobalDim); + } + + Eigen::Matrix<double, GlobalDim, GlobalDim> operator()( + MaterialPropertyLib::Tensor const& values) const + { + return Eigen::Map<Eigen::Matrix<double, GlobalDim, GlobalDim> const>( + values.data(), GlobalDim, GlobalDim); + } + + Eigen::Matrix<double, GlobalDim, GlobalDim> operator()( + MaterialPropertyLib::SymmTensor const& /*values*/) const + { + OGS_FATAL( + "The value of MaterialPropertyLib::SymmTensor is inapplicable"); + } + + Eigen::Matrix<double, GlobalDim, GlobalDim> operator()( + std::string const& /*values*/) const + { + OGS_FATAL("The value of std::string is inapplicable"); + } + + Eigen::Matrix<double, GlobalDim, GlobalDim> operator()( + MaterialPropertyLib::Pair const& /*values*/) const + { + OGS_FATAL("The size of tensor is neither one nor %d nor %d squared.", + GlobalDim, GlobalDim); + } +}; + +template <int GlobalDim> +Eigen::Matrix<double, GlobalDim, GlobalDim> formEigenTensor( + MaterialPropertyLib::PropertyDataType const& values) +{ + return boost::apply_visitor(FormEigenTensor<GlobalDim>(), values); +} + +template Eigen::Matrix<double, 1, 1> formEigenTensor<1>( + MaterialPropertyLib::PropertyDataType const& values); + +template Eigen::Matrix<double, 2, 2> formEigenTensor<2>( + MaterialPropertyLib::PropertyDataType const& values); + +template Eigen::Matrix<double, 3, 3> formEigenTensor<3>( + MaterialPropertyLib::PropertyDataType const& values); + +} // namespace MaterialPropertyLib diff --git a/MaterialLib/MPL/Utils/FormEigenTensor.h b/MaterialLib/MPL/Utils/FormEigenTensor.h new file mode 100644 index 0000000000000000000000000000000000000000..9c72b96de0f475e4f185ed4a6cdecfed347b5b2e --- /dev/null +++ b/MaterialLib/MPL/Utils/FormEigenTensor.h @@ -0,0 +1,23 @@ +/* + * \file + * \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 + * + * Created on July 29, 2019, 2:48 PM + */ + +#pragma once + +#include <Eigen/Dense> + +#include "MaterialLib/MPL/Property.h" + +namespace MaterialPropertyLib +{ +template <int GlobalDim> +Eigen::Matrix<double, GlobalDim, GlobalDim> formEigenTensor( + MaterialPropertyLib::PropertyDataType const& values); +} // namespace MaterialPropertyLib