From 40cb1dd797d778c01887527c65ff7bf26d979f03 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Mon, 6 Jun 2016 17:05:15 +0200 Subject: [PATCH] [MaL] moved part of NumConf and MatSpecs to separate files --- MathLib/LinAlg/GlobalMatrixVectorTypes.h | 78 ++++++++++++++++++++++++ MathLib/LinAlg/MatrixSpecifications.h | 37 +++++++++++ NumLib/DOF/MatrixProviderUser.h | 22 +------ NumLib/NumericsConfig.h | 66 +------------------- 4 files changed, 117 insertions(+), 86 deletions(-) create mode 100644 MathLib/LinAlg/GlobalMatrixVectorTypes.h create mode 100644 MathLib/LinAlg/MatrixSpecifications.h diff --git a/MathLib/LinAlg/GlobalMatrixVectorTypes.h b/MathLib/LinAlg/GlobalMatrixVectorTypes.h new file mode 100644 index 00000000000..6b91a620c3f --- /dev/null +++ b/MathLib/LinAlg/GlobalMatrixVectorTypes.h @@ -0,0 +1,78 @@ +/** + * \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 + * + */ + +#ifndef MATHLIB_LINALG_GLOBALMATRIXVECTORTYPES_H +#define MATHLIB_LINALG_GLOBALMATRIXVECTORTYPES_H + +#include "SparsityPattern.h" + +// +// Global vector/matrix types and linear solver. +// +#if defined(OGS_USE_EIGENLIS) + + #include "MathLib/LinAlg/Eigen/EigenMatrix.h" + #include "MathLib/LinAlg/Eigen/EigenVector.h" + #include "MathLib/LinAlg/EigenLis/EigenLisLinearSolver.h" + + namespace detail + { + using GlobalVectorType = MathLib::EigenVector; + using GlobalMatrixType = MathLib::EigenMatrix; + + using LinearSolverType = MathLib::EigenLisLinearSolver; + } + +#elif defined(USE_PETSC) + #include "MathLib/LinAlg/PETSc/PETScVector.h" + #include "MathLib/LinAlg/PETSc/PETScMatrix.h" + #include "MathLib/LinAlg/PETSc/PETScLinearSolver.h" +namespace detail +{ + using GlobalVectorType = MathLib::PETScVector; + using GlobalMatrixType = MathLib::PETScMatrix; + + using LinearSolverType = MathLib::PETScLinearSolver; +} + +#else +#ifdef OGS_USE_EIGEN + #include "MathLib/LinAlg/Eigen/EigenVector.h" + #include "MathLib/LinAlg/Eigen/EigenMatrix.h" + #include "MathLib/LinAlg/Eigen/EigenLinearSolver.h" +namespace detail +{ + using GlobalVectorType = MathLib::EigenVector; + using GlobalMatrixType = MathLib::EigenMatrix; + + using LinearSolverType = MathLib::EigenLinearSolver; +} +#else // OGS_USE_EIGEN + #include "MathLib/LinAlg/Dense/DenseVector.h" + #include "MathLib/LinAlg/Dense/GlobalDenseMatrix.h" + #include "MathLib/LinAlg/Solvers/GaussAlgorithm.h" +namespace detail +{ + using GlobalVectorType = MathLib::DenseVector<double>; + using GlobalMatrixType = MathLib::GlobalDenseMatrix<double>; + + using LinearSolverType = + MathLib::GaussAlgorithm<GlobalMatrixType, GlobalVectorType>; +} + +#endif // USE_LIS +#endif // OGS_USE_EIGEN + + +/// A type used for indexing of global vectors and matrices. It is equal to the +/// GlobalMatrixType::IndexType and the GlobalVectorType::IndexType. +using GlobalIndexType = detail::GlobalMatrixType::IndexType; +using GlobalSparsityPattern = MathLib::SparsityPattern<GlobalIndexType>; + +#endif // MATHLIB_LINALG_GLOBALMATRIXVECTORTYPES_H diff --git a/MathLib/LinAlg/MatrixSpecifications.h b/MathLib/LinAlg/MatrixSpecifications.h new file mode 100644 index 00000000000..07a9f016e68 --- /dev/null +++ b/MathLib/LinAlg/MatrixSpecifications.h @@ -0,0 +1,37 @@ +/** + * \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 + * + */ + +#ifndef MATHLIB_LINALG_MATRIXSPECIFICATIONS_H +#define MATHLIB_LINALG_MATRIXSPECIFICATIONS_H + +#include "GlobalMatrixVectorTypes.h" + +namespace MathLib +{ + +struct MatrixSpecifications +{ + MatrixSpecifications(std::size_t const nrows_, std::size_t const ncols_, + std::vector<GlobalIndexType> const*const ghost_indices_, + GlobalSparsityPattern const*const sparsity_pattern_) + : nrows(nrows_), ncols(ncols_), ghost_indices(ghost_indices_) + , sparsity_pattern(sparsity_pattern_) + { + } + + std::size_t const nrows; + std::size_t const ncols; + std::vector<GlobalIndexType> const*const ghost_indices; + GlobalSparsityPattern const*const sparsity_pattern; +}; + +} // namespace MathLib + + +#endif // MATHLIB_LINALG_MATRIXSPECIFICATIONS_H diff --git a/NumLib/DOF/MatrixProviderUser.h b/NumLib/DOF/MatrixProviderUser.h index 82cfe2d8f6a..ca58846b5df 100644 --- a/NumLib/DOF/MatrixProviderUser.h +++ b/NumLib/DOF/MatrixProviderUser.h @@ -12,31 +12,11 @@ #include <cstddef> -#include "NumLib/NumericsConfig.h" - -namespace NumLib { class LocalToGlobalIndexMap; } -namespace MeshLib { class Mesh; } +#include "MathLib/LinAlg/MatrixSpecifications.h" namespace MathLib { -struct MatrixSpecifications -{ - MatrixSpecifications(std::size_t const nrows_, std::size_t const ncols_, - GlobalSparsityPattern const*const sparsity_pattern_, - NumLib::LocalToGlobalIndexMap const*const dof_table_, - MeshLib::Mesh const*const mesh_) - : nrows(nrows_), ncols(ncols_), sparsity_pattern(sparsity_pattern_) - , dof_table(dof_table_), mesh(mesh_) - {} - - std::size_t const nrows; - std::size_t const ncols; - GlobalSparsityPattern const*const sparsity_pattern; - NumLib::LocalToGlobalIndexMap const*const dof_table; - MeshLib::Mesh const*const mesh; -}; - class MatrixSpecificationsProvider { public: diff --git a/NumLib/NumericsConfig.h b/NumLib/NumericsConfig.h index 43d22fa4734..19147bd6dfb 100644 --- a/NumLib/NumericsConfig.h +++ b/NumLib/NumericsConfig.h @@ -11,8 +11,7 @@ #define APPLICATIONS_NUMERICSCONFIG_H_ #include <type_traits> - -#include "MathLib/LinAlg/SparsityPattern.h" +#include "MathLib/LinAlg/GlobalMatrixVectorTypes.h" /** * This file provides a configuration of the global matrix/vector and @@ -22,64 +21,6 @@ * The existence of the GlobalSetupType is checked at the end of the file. */ -// -// Global vector/matrix types and linear solver. -// -#if defined(OGS_USE_EIGENLIS) - - #include "MathLib/LinAlg/Eigen/EigenMatrix.h" - #include "MathLib/LinAlg/Eigen/EigenVector.h" - #include "MathLib/LinAlg/EigenLis/EigenLisLinearSolver.h" - - namespace detail - { - using GlobalVectorType = MathLib::EigenVector; - using GlobalMatrixType = MathLib::EigenMatrix; - - using LinearSolverType = MathLib::EigenLisLinearSolver; - } - -#elif defined(USE_PETSC) - #include "MathLib/LinAlg/PETSc/PETScVector.h" - #include "MathLib/LinAlg/PETSc/PETScMatrix.h" - #include "MathLib/LinAlg/PETSc/PETScLinearSolver.h" -namespace detail -{ - using GlobalVectorType = MathLib::PETScVector; - using GlobalMatrixType = MathLib::PETScMatrix; - - using LinearSolverType = MathLib::PETScLinearSolver; -} - -#else -#ifdef OGS_USE_EIGEN - #include "MathLib/LinAlg/Eigen/EigenVector.h" - #include "MathLib/LinAlg/Eigen/EigenMatrix.h" - #include "MathLib/LinAlg/Eigen/EigenLinearSolver.h" -namespace detail -{ - using GlobalVectorType = MathLib::EigenVector; - using GlobalMatrixType = MathLib::EigenMatrix; - - using LinearSolverType = MathLib::EigenLinearSolver; -} -#else // OGS_USE_EIGEN - #include "MathLib/LinAlg/Dense/DenseVector.h" - #include "MathLib/LinAlg/Dense/GlobalDenseMatrix.h" - #include "MathLib/LinAlg/Solvers/GaussAlgorithm.h" -namespace detail -{ - using GlobalVectorType = MathLib::DenseVector<double>; - using GlobalMatrixType = MathLib::GlobalDenseMatrix<double>; - - using LinearSolverType = - MathLib::GaussAlgorithm<GlobalMatrixType, GlobalVectorType>; -} - -#endif // USE_LIS -#endif // OGS_USE_EIGEN - - // // Global vector/matrix builder. // @@ -127,9 +68,4 @@ static_assert(std::is_same<detail::GlobalMatrixType::IndexType, "The global matrix and vector index types do not match."); // Both types are integral types and equal, define a single GlobalIndexType. -/// A type used for indexing of global vectors and matrices. It is equal to the -/// GlobalMatrixType::IndexType and the GlobalVectorType::IndexType. -using GlobalIndexType = detail::GlobalMatrixType::IndexType; -using GlobalSparsityPattern = MathLib::SparsityPattern<GlobalIndexType>; - #endif // APPLICATIONS_NUMERICSCONFIG_H_ -- GitLab