Skip to content
Snippets Groups Projects
Commit 6b6baa5d authored by wenqing's avatar wenqing Committed by Dmitri Naumov
Browse files

[MPL] Added a new common functions.

Conversion to Eigen matrices.
parent 58abb9e9
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,7 @@ append_source_files(SOURCES Fluid/WaterVaporProperties) ...@@ -17,6 +17,7 @@ append_source_files(SOURCES Fluid/WaterVaporProperties)
append_source_files(SOURCES MPL) append_source_files(SOURCES MPL)
append_source_files(SOURCES MPL/Properties) append_source_files(SOURCES MPL/Properties)
append_source_files(SOURCES MPL/Components) append_source_files(SOURCES MPL/Components)
append_source_files(SOURCES MPL/Utils)
append_source_files(SOURCES PorousMedium) append_source_files(SOURCES PorousMedium)
append_source_files(SOURCES PorousMedium/Porosity) append_source_files(SOURCES PorousMedium/Porosity)
......
/*
* \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
/*
* \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
/*
* \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
/*
* \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
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