diff --git a/CMakeLists.txt b/CMakeLists.txt index a493dd9bb014ab13ceaf4f272b0436245d9f979c..6fc4e08d77a279e6e3e991b46a5ad96a3ffa0af3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,7 +73,7 @@ option(OGS_USE_PETSC "Use PETSc routines" OFF) option(OGS_USE_MPI "Use MPI" OFF) # Eigen -option(OGS_USE_EIGEN "Use EIGEN for local matrix and vector" ON) +option(OGS_USE_EIGEN "Use Eigen linear solver" ON) option(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES "Use dynamically allocated shape matrices" ON) option(EIGEN_NO_DEBUG "Disables Eigen's assertions" OFF) @@ -134,15 +134,16 @@ if(OGS_USE_MPI) add_definitions(-DUSE_MPI) endif() +add_definitions(-DEIGEN_INITIALIZE_MATRICES_BY_ZERO) # TODO check if needed +if (EIGEN_NO_DEBUG) + add_definitions(-DEIGEN_NO_DEBUG) +endif() +if(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES) + add_definitions(-DOGS_EIGEN_DYNAMIC_SHAPE_MATRICES) +endif() + if(OGS_USE_EIGEN) - add_definitions(-DEIGEN_INITIALIZE_MATRICES_BY_ZERO) # TODO check if needed add_definitions(-DOGS_USE_EIGEN) - if (EIGEN_NO_DEBUG) - add_definitions(-DEIGEN_NO_DEBUG) - endif() - if(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES) - add_definitions(-DOGS_EIGEN_DYNAMIC_SHAPE_MATRICES) - endif() endif() if (OGS_USE_EIGENLIS) @@ -175,10 +176,8 @@ else() endif() include_directories( SYSTEM ${Boost_INCLUDE_DIRS} ) -if(OGS_USE_EIGEN) - include(scripts/cmake/ExternalProjectEigen.cmake) - include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR}) -endif() +include(scripts/cmake/ExternalProjectEigen.cmake) +include_directories(SYSTEM ${EIGEN3_INCLUDE_DIR}) # Add subdirectories with the projects add_subdirectory( ThirdParty ) diff --git a/MathLib/LinAlg/MatrixTools.h b/MathLib/LinAlg/MatrixTools.h index 61b1c003746e9e94da9160c208a54f2ae61a2cef..0c049b9c3d25f25a5e84dbfef304f3d439aec7fe 100644 --- a/MathLib/LinAlg/MatrixTools.h +++ b/MathLib/LinAlg/MatrixTools.h @@ -12,15 +12,12 @@ #include <type_traits> -#ifdef OGS_USE_EIGEN #include <Eigen/Eigen> -#endif namespace MathLib { -#ifdef OGS_USE_EIGEN namespace details { @@ -116,9 +113,6 @@ void inverse(Eigen::MatrixBase<Derived> const& mat, double det_mat, Eigen::Matri return details::Inverse<MatrixType, MatrixType::SizeAtCompileTime>::eval(mat, det_mat, result); } - -#endif - } // namespace #endif /* MATHLIB_MATRIXTOOLS_H_ */ diff --git a/MeshLib/ElementCoordinatesMappingLocal.cpp b/MeshLib/ElementCoordinatesMappingLocal.cpp index c31a9c34e25fc5333d1845084636fa50a6c8f5fd..f3d6200a8bb0d61db74916174a09233b1f729fc2 100644 --- a/MeshLib/ElementCoordinatesMappingLocal.cpp +++ b/MeshLib/ElementCoordinatesMappingLocal.cpp @@ -86,13 +86,7 @@ ElementCoordinatesMappingLocal::ElementCoordinatesMappingLocal( } detail::getRotationMatrixToGlobal(element_dimension, global_dimension, _points, _matR2global); -#ifdef OGS_USE_EIGEN detail::rotateToLocal(_matR2global.transpose(), _points); -#else - RotationMatrix* m(_matR2global.transpose()); - detail::rotateToLocal(*m, _points); - delete m; -#endif } } // MeshLib diff --git a/MeshLib/ElementCoordinatesMappingLocal.h b/MeshLib/ElementCoordinatesMappingLocal.h index 8f26f21f5b733733167fcba5f7c5849b4bf4f73b..c1d74d07000160b33c0896b9d743c213c962e317 100644 --- a/MeshLib/ElementCoordinatesMappingLocal.h +++ b/MeshLib/ElementCoordinatesMappingLocal.h @@ -11,11 +11,7 @@ #include <vector> -#ifdef OGS_USE_EIGEN #include <Eigen/Eigen> -#else -#include "MathLib/LinAlg/Dense/DenseMatrix.h" -#endif #include "MathLib/Point3d.h" @@ -28,11 +24,7 @@ namespace MeshLib namespace MeshLib { -#ifdef OGS_USE_EIGEN typedef Eigen::Matrix<double, 3u, 3u, Eigen::RowMajor> RotationMatrix; -#else -typedef MathLib::DenseMatrix<double> RotationMatrix; -#endif /** * This class maps node coordinates on intrinsic coordinates of the given element. diff --git a/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h b/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h index a467ccec811207b154f2408e3df3613a702bc49b..6f2bdf06acbb6c97056458b096bdc1130ceb84d4 100644 --- a/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h +++ b/NumLib/Fem/CoordinatesMapping/ShapeMatrices.h @@ -15,9 +15,8 @@ #include <ostream> -#ifdef OGS_USE_EIGEN #include <Eigen/Eigen> -#endif + namespace NumLib { @@ -105,9 +104,7 @@ struct ShapeMatrices */ void write (std::ostream& out) const; -#ifdef OGS_USE_EIGEN EIGEN_MAKE_ALIGNED_OPERATOR_NEW -#endif }; // ShapeMatrices diff --git a/NumLib/Fem/ShapeMatrixPolicy.h b/NumLib/Fem/ShapeMatrixPolicy.h index 26f47811943565af4ed78a8841f0c9b89f6746f9..b3ff581cc17b13596d4909c7a04a61d00764687f 100644 --- a/NumLib/Fem/ShapeMatrixPolicy.h +++ b/NumLib/Fem/ShapeMatrixPolicy.h @@ -12,7 +12,6 @@ #include "NumLib/Fem/CoordinatesMapping/ShapeMatrices.h" -#ifdef OGS_USE_EIGEN #include <Eigen/Dense> namespace detail @@ -119,8 +118,6 @@ using ShapeMatrixPolicyType = EigenFixedShapeMatrixPolicy<ShapeFunction, GlobalD const unsigned OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_FLAG = 0; #endif -#endif // OGS_USE_EIGEN - //static_assert(std::is_class<ShapeMatrixPolicyType<>::value, //"ShapeMatrixPolicyType was not defined."); diff --git a/Tests/MathLib/TestLocalMatrixFunctions.cpp b/Tests/MathLib/TestLocalMatrixFunctions.cpp index 1281babcbc0f9d55c540bfaef0a9f6175667749c..e577578e5ad2e978ce2785fb88d23e6920adb4ec 100644 --- a/Tests/MathLib/TestLocalMatrixFunctions.cpp +++ b/Tests/MathLib/TestLocalMatrixFunctions.cpp @@ -8,15 +8,12 @@ #include <gtest/gtest.h> -#ifdef OGS_USE_EIGEN #include <Eigen/Eigen> -#endif #include "MathLib/LinAlg/MatrixTools.h" #include "Tests/TestTools.h" -#ifdef OGS_USE_EIGEN TEST(MathLib, LocalMatrixDeterminantInverse_Eigen) { Eigen::Matrix3d fMat, fInv; @@ -34,4 +31,3 @@ TEST(MathLib, LocalMatrixDeterminantInverse_Eigen) ASSERT_NEAR(fMat_det, dMat_det, std::numeric_limits<double>::epsilon()); ASSERT_ARRAY_NEAR(fInv.data(), dInv.data(), fInv.size(), std::numeric_limits<double>::epsilon()); } -#endif diff --git a/Tests/MeshLib/MeshProperties.cpp b/Tests/MeshLib/MeshProperties.cpp index 222dd6253c4b88767edc0c85846bd6404c9c4715..d2009d7e836be4a20860b7d4381a203867562441 100644 --- a/Tests/MeshLib/MeshProperties.cpp +++ b/Tests/MeshLib/MeshProperties.cpp @@ -8,9 +8,7 @@ #include <numeric> -#ifdef OGS_USE_EIGEN #include <Eigen/Eigen> -#endif #include "gtest/gtest.h" @@ -360,7 +358,6 @@ TEST_F(MeshLibProperties, AddVariousDifferentProperties) } // *** add a 3rd property *** -#ifdef OGS_USE_EIGEN std::string const& prop_name_3("ItemwiseEigenMatrixProperties"); // check if the property is already assigned to the mesh ASSERT_FALSE(mesh->getProperties().hasPropertyVector(prop_name_3)); @@ -403,7 +400,6 @@ TEST_F(MeshLibProperties, AddVariousDifferentProperties) } } } -#endif } TEST_F(MeshLibProperties, CopyConstructor) diff --git a/Tests/MeshLib/TestCoordinatesMappingLocal.cpp b/Tests/MeshLib/TestCoordinatesMappingLocal.cpp index 8bc92b2c03a6fb78c63e894c237fa4cc3773dacd..df645d0ae4b1296f1471063d6f097dbe46198aef 100644 --- a/Tests/MeshLib/TestCoordinatesMappingLocal.cpp +++ b/Tests/MeshLib/TestCoordinatesMappingLocal.cpp @@ -14,9 +14,7 @@ #include <cmath> #include <memory> -#ifdef OGS_USE_EIGEN #include <Eigen/Eigen> -#endif #include "GeoLib/AnalyticalGeometry.h" #include "MathLib/LinAlg/Dense/DenseMatrix.h" diff --git a/Tests/NumLib/TestCoordinatesMapping.cpp b/Tests/NumLib/TestCoordinatesMapping.cpp index 10834d39e887513bb53dd148dfbd0e06631e6cf9..0f99182d3ffda718e0e60132ef61a89a1447b4eb 100644 --- a/Tests/NumLib/TestCoordinatesMapping.cpp +++ b/Tests/NumLib/TestCoordinatesMapping.cpp @@ -12,9 +12,7 @@ #include <algorithm> #include <vector> -#ifdef OGS_USE_EIGEN #include <Eigen/Eigen> -#endif #include "NumLib/Fem/CoordinatesMapping/ShapeMatrices.h" #include "NumLib/Fem/CoordinatesMapping/NaturalCoordinatesMapping.h" @@ -52,12 +50,10 @@ public: static const unsigned e_nnodes = T_TEST::e_nnodes; static const unsigned global_dim = T_TEST::global_dim; // Matrix types -#ifdef OGS_USE_EIGEN typedef Eigen::Matrix<double, e_nnodes, 1> NodalVector; typedef Eigen::Matrix<double, dim, e_nnodes, Eigen::RowMajor> DimNodalMatrix; typedef Eigen::Matrix<double, dim, dim, Eigen::RowMajor> DimMatrix; typedef Eigen::Matrix<double, global_dim, e_nnodes, Eigen::RowMajor> GlobalDimNodalMatrix; -#endif // Shape data type typedef ShapeMatrices<NodalVector,DimNodalMatrix,DimMatrix,GlobalDimNodalMatrix> ShapeMatricesType; // Natural coordinates mapping type @@ -282,12 +278,10 @@ TYPED_TEST(NumLibFemNaturalCoordinatesMappingTest, CheckZeroVolume) TEST(NumLib, FemNaturalCoordinatesMappingLineY) { -#ifdef OGS_USE_EIGEN typedef Eigen::Matrix<double, 2, 1> NodalVector; typedef Eigen::Matrix<double, 1, 2, Eigen::RowMajor> DimNodalMatrix; typedef Eigen::Matrix<double, 1, 1, Eigen::RowMajor> DimMatrix; typedef Eigen::Matrix<double, 2, 2, Eigen::RowMajor> GlobalDimNodalMatrix; -#endif // Shape data type typedef ShapeMatrices<NodalVector,DimNodalMatrix,DimMatrix,GlobalDimNodalMatrix> ShapeMatricesType; typedef NaturalCoordinatesMapping<MeshLib::Line, ShapeLine2, ShapeMatricesType> MappingType; diff --git a/Tests/NumLib/TestFe.cpp b/Tests/NumLib/TestFe.cpp index 0dd2b318b429df6ac15549c4088e68700e829b3c..8b04746d7b6db0a39e7165c6319088e07d79dfdb 100644 --- a/Tests/NumLib/TestFe.cpp +++ b/Tests/NumLib/TestFe.cpp @@ -11,9 +11,8 @@ #include <vector> #include <cmath> -#ifdef OGS_USE_EIGEN + #include <Eigen/Eigen> -#endif #include "MeshLib/ElementCoordinatesMappingLocal.h" #include "MeshLib/CoordinateSystem.h" @@ -53,7 +52,6 @@ struct TestCase }; typedef ::testing::Types< -#ifdef OGS_USE_EIGEN TestCase<TestFeHEX8, EigenDynamicShapeMatrixPolicy>, TestCase<TestFeLINE2, EigenDynamicShapeMatrixPolicy>, TestCase<TestFeLINE2Y, EigenDynamicShapeMatrixPolicy>, @@ -73,7 +71,6 @@ typedef ::testing::Types< TestCase<TestFeQUAD4, EigenFixedShapeMatrixPolicy>, TestCase<TestFeTET4, EigenFixedShapeMatrixPolicy>, TestCase<TestFeTRI3, EigenFixedShapeMatrixPolicy> -#endif > TestTypes; } @@ -160,9 +157,7 @@ class NumLibFemIsoTest : public ::testing::Test, public T::TestFeType MeshElementType* mesh_element; public: -#ifdef OGS_USE_EIGEN EIGEN_MAKE_ALIGNED_OPERATOR_NEW // required to use fixed size Eigen matrices -#endif }; // NumLibFemIsoTest template <class T> diff --git a/Tests/NumLib/TestShapeMatrices.cpp b/Tests/NumLib/TestShapeMatrices.cpp index 3158b812eb32f54ccd2ba7bebafa21efff4d011c..041adddeb1bb9c6d5e58c09a8fda85360cb73bb3 100644 --- a/Tests/NumLib/TestShapeMatrices.cpp +++ b/Tests/NumLib/TestShapeMatrices.cpp @@ -11,9 +11,7 @@ #include <gtest/gtest.h> -#ifdef OGS_USE_EIGEN #include <Eigen/Eigen> -#endif #include "NumLib/Fem/CoordinatesMapping/ShapeMatrices.h" @@ -22,7 +20,6 @@ using namespace NumLib; -#ifdef OGS_USE_EIGEN TEST(NumLib, FemShapeMatricesWithEigen) { const static unsigned dim = 2; @@ -127,6 +124,3 @@ TEST(NumLib, FemShapeMatricesWithEigen) EXPECT_TRUE(shape.invJ.isZero()); EXPECT_EQ(0.0, shape.detJ); } -#endif - -