Commit f7333a8d by Dmitry Yu. Naumov

### Merge branch 'formEigenVector' into 'master'

```add FormEigenVector MPL util

See merge request ogs/ogs!3442```
parents 84c64bc5 df6bcabf
 /* * \file * \copyright * Copyright (c) 2012-2021, 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 "FormEigenVector.h" #include "MaterialLib/MPL/PropertyType.h" namespace MaterialPropertyLib { template struct FormEigenVector { Eigen::Matrix operator()(double const value) const { if constexpr (GlobalDim == 1) { return Eigen::Matrix{value}; } if constexpr (GlobalDim == 2) { return Eigen::Matrix{ value, value }; } if constexpr (GlobalDim == 3) { return Eigen::Matrix{ value, value, value }; } } Eigen::Matrix operator()( Eigen::Vector2d const& values) const { if constexpr (GlobalDim == 2) { return values; } OGS_FATAL("Cannot convert 2d vector to {:d}d vector.", GlobalDim); } Eigen::Matrix operator()( Eigen::Vector3d const& values) const { if constexpr (GlobalDim == 3) { return values; } OGS_FATAL("Cannot convert 3d vector to a {:d}d vector.", GlobalDim); } Eigen::Matrix operator()( Eigen::Matrix const& /*values*/) const { OGS_FATAL("Cannot convert a 2d tensor to a {:d}d Vector.", GlobalDim); } Eigen::Matrix operator()( Eigen::Matrix const& /*values*/) const { OGS_FATAL("Cannot convert a 3d tensor to a {:d}d Vector.", GlobalDim); } Eigen::Matrix operator()( Eigen::Matrix const& /*values*/) const { OGS_FATAL("Cannot convert a 4d vector to a {:d}d vector.", GlobalDim); } Eigen::Matrix operator()( Eigen::Matrix const& /*values*/) const { OGS_FATAL("Cannot convert a 6d vector to a {:d}d vector.", GlobalDim); } }; template Eigen::Matrix formEigenVector( MaterialPropertyLib::PropertyDataType const& values) { return std::visit(FormEigenVector(), values); } template Eigen::Matrix formEigenVector<1>( MaterialPropertyLib::PropertyDataType const& values); template Eigen::Matrix formEigenVector<2>( MaterialPropertyLib::PropertyDataType const& values); template Eigen::Matrix formEigenVector<3>( MaterialPropertyLib::PropertyDataType const& values); } // namespace MaterialPropertyLib
 /* * \file * \copyright * Copyright (c) 2012-2021, 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 #include "MaterialLib/MPL/Property.h" namespace MaterialPropertyLib { template Eigen::Matrix formEigenVector( MaterialPropertyLib::PropertyDataType const& values); } // namespace MaterialPropertyLib
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!