From 8d0437b89de04e3c80070b6ed3aaa78c51a8f93f Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Thu, 1 Sep 2016 17:14:47 +0200 Subject: [PATCH] renamed toZeroedMatrix -> createZeroedMatrix --- MathLib/LinAlg/Eigen/EigenMapTools.h | 27 ++++++++++--------- .../CentralDifferencesJacobianAssembler.cpp | 2 +- .../GroundwaterFlow/GroundwaterFlowFEM.h | 2 +- ProcessLib/TES/TESLocalAssembler-impl.h | 6 ++--- Tests/ProcessLib/TestJacobianAssembler.cpp | 22 +++++++-------- 5 files changed, 31 insertions(+), 28 deletions(-) diff --git a/MathLib/LinAlg/Eigen/EigenMapTools.h b/MathLib/LinAlg/Eigen/EigenMapTools.h index 4887a9bb0c5..e4095e73241 100644 --- a/MathLib/LinAlg/Eigen/EigenMapTools.h +++ b/MathLib/LinAlg/Eigen/EigenMapTools.h @@ -16,7 +16,8 @@ namespace MathLib { -/*! Creates an Eigen mapped matrix from the given data vector. +/*! Creates an Eigen mapped matrix having its entries stored in the given + * \c data vector. * * \return An Eigen mapped matrix of the given size. All values of the matrix * are set to zero. @@ -28,9 +29,9 @@ namespace MathLib * as the requested matrix type. */ template <typename Matrix> -Eigen::Map<Matrix> toZeroedMatrix(std::vector<double>& data, - Eigen::MatrixXd::Index rows, - Eigen::MatrixXd::Index cols) +Eigen::Map<Matrix> createZeroedMatrix(std::vector<double>& data, + Eigen::MatrixXd::Index rows, + Eigen::MatrixXd::Index cols) { static_assert(Matrix::IsRowMajor || Matrix::IsVectorAtCompileTime, "The default storage order in OGS is row major storage for " @@ -45,18 +46,19 @@ Eigen::Map<Matrix> toZeroedMatrix(std::vector<double>& data, return {data.data(), rows, cols}; } -/*! Creates an Eigen mapped matrix from the given data vector. +/*! Creates an Eigen mapped matrix having its entries stored in the given + * \c data vector. * * This is a convienence method which makes the specification of dynamically * allocated Eigen matrices as return type easier. */ inline Eigen::Map< Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>> -toZeroedMatrix(std::vector<double>& data, - Eigen::MatrixXd::Index rows, - Eigen::MatrixXd::Index cols) +createZeroedMatrix(std::vector<double>& data, + Eigen::MatrixXd::Index rows, + Eigen::MatrixXd::Index cols) { - return toZeroedMatrix< + return createZeroedMatrix< Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>>( data, rows, cols); } @@ -138,7 +140,8 @@ toMatrix(std::vector<double>& data, data, rows, cols); } -/*! Creates an Eigen mapped vector from the given data vector. +/*! Creates an Eigen mapped vector having its entries stored in the given + * \c data vector. * * \return An Eigen mapped vector of the given size. All values of the vector * are set to zero. @@ -147,8 +150,8 @@ toMatrix(std::vector<double>& data, * \post The \c data has size \c size. */ template <typename Vector> -Eigen::Map<Vector> toZeroedVector(std::vector<double>& data, - Eigen::VectorXd::Index size) +Eigen::Map<Vector> createZeroedVector(std::vector<double>& data, + Eigen::VectorXd::Index size) { static_assert(Vector::IsVectorAtCompileTime, "A vector type is required."); assert(Vector::SizeAtCompileTime == Eigen::Dynamic || diff --git a/ProcessLib/CentralDifferencesJacobianAssembler.cpp b/ProcessLib/CentralDifferencesJacobianAssembler.cpp index 77b88b3a12a..85f74a235f2 100644 --- a/ProcessLib/CentralDifferencesJacobianAssembler.cpp +++ b/ProcessLib/CentralDifferencesJacobianAssembler.cpp @@ -45,7 +45,7 @@ void CentralDifferencesJacobianAssembler::assembleWithJacobian( auto const local_xdot = MathLib::toVector<Eigen::VectorXd>(local_xdot_data, num_r_c); - auto local_Jac = MathLib::toZeroedMatrix(local_Jac_data, + auto local_Jac = MathLib::createZeroedMatrix(local_Jac_data, num_r_c, num_r_c); _local_x_perturbed_data = local_x_data; diff --git a/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h b/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h index e7072c2f921..f253ac48409 100644 --- a/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h +++ b/ProcessLib/GroundwaterFlow/GroundwaterFlowFEM.h @@ -86,7 +86,7 @@ public: // This assertion is valid only if all nodal d.o.f. use the same shape matrices. assert(local_matrix_size == ShapeFunction::NPOINTS * NUM_NODAL_DOF); - auto local_K = MathLib::toZeroedMatrix<NodalMatrixType>( + auto local_K = MathLib::createZeroedMatrix<NodalMatrixType>( local_K_data, local_matrix_size, local_matrix_size); unsigned const n_integration_points = diff --git a/ProcessLib/TES/TESLocalAssembler-impl.h b/ProcessLib/TES/TESLocalAssembler-impl.h index ddc02a240f3..eb7cf350464 100644 --- a/ProcessLib/TES/TESLocalAssembler-impl.h +++ b/ProcessLib/TES/TESLocalAssembler-impl.h @@ -136,11 +136,11 @@ void TESLocalAssembler<ShapeFunction_, IntegrationMethod_, GlobalDim>::assemble( // This assertion is valid only if all nodal d.o.f. use the same shape matrices. assert(local_matrix_size == ShapeFunction::NPOINTS * NODAL_DOF); - auto local_M = MathLib::toZeroedMatrix<NodalMatrixType>( + auto local_M = MathLib::createZeroedMatrix<NodalMatrixType>( local_M_data, local_matrix_size, local_matrix_size); - auto local_K = MathLib::toZeroedMatrix<NodalMatrixType>( + auto local_K = MathLib::createZeroedMatrix<NodalMatrixType>( local_K_data, local_matrix_size, local_matrix_size); - auto local_b = MathLib::toZeroedVector<NodalVectorType>(local_b_data, + auto local_b = MathLib::createZeroedVector<NodalVectorType>(local_b_data, local_matrix_size); unsigned const n_integration_points = diff --git a/Tests/ProcessLib/TestJacobianAssembler.cpp b/Tests/ProcessLib/TestJacobianAssembler.cpp index 010daca24c1..8bc11da5369 100644 --- a/Tests/ProcessLib/TestJacobianAssembler.cpp +++ b/Tests/ProcessLib/TestJacobianAssembler.cpp @@ -47,7 +47,7 @@ struct MatDiagX std::vector<double>& mat_data) { auto mat = - MathLib::toZeroedMatrix(mat_data, x_data.size(), x_data.size()); + MathLib::createZeroedMatrix(mat_data, x_data.size(), x_data.size()); mat.diagonal().noalias() = MathLib::toVector<Eigen::VectorXd>(x_data, x_data.size()); } @@ -58,7 +58,7 @@ struct MatDiagX std::vector<double>& dMdxTy_data) { auto dMdxTy = - MathLib::toZeroedMatrix(dMdxTy_data, x_data.size(), x_data.size()); + MathLib::createZeroedMatrix(dMdxTy_data, x_data.size(), x_data.size()); dMdxTy.diagonal().noalias() = MathLib::toVector<Eigen::VectorXd>(y_data, y_data.size()); } @@ -78,7 +78,7 @@ struct VecX std::vector<double>& mat_data) { auto mat = - MathLib::toZeroedMatrix(mat_data, x_data.size(), x_data.size()); + MathLib::createZeroedMatrix(mat_data, x_data.size(), x_data.size()); mat = Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor>::Identity(x_data.size(), x_data.size()); @@ -96,7 +96,7 @@ struct MatXY std::vector<double>& mat_data) { auto mat = - MathLib::toZeroedMatrix(mat_data, x_data.size(), x_data.size()); + MathLib::createZeroedMatrix(mat_data, x_data.size(), x_data.size()); for (std::size_t r=0; r<x_data.size(); ++r) { for (std::size_t c=0; c<x_data.size(); ++c) { mat(r, c) = x_data[r] * x_data[c]; @@ -118,7 +118,7 @@ struct MatXY auto const x_dot_y = MathLib::toVector<Eigen::VectorXd>(x_data, N).dot( MathLib::toVector<Eigen::VectorXd>(y_data, N)); auto dMdxTy = - MathLib::toZeroedMatrix(dMdxTy_data, N, N); + MathLib::createZeroedMatrix(dMdxTy_data, N, N); for (std::size_t r=0; r<N; ++r) { for (std::size_t c=0; c<N; ++c) { dMdxTy(r, c) = x_data[r] * y_data[c]; @@ -150,7 +150,7 @@ struct VecXRevX std::vector<double>& mat_data) { auto mat = - MathLib::toZeroedMatrix(mat_data, x_data.size(), x_data.size()); + MathLib::createZeroedMatrix(mat_data, x_data.size(), x_data.size()); auto const N = x_data.size(); for (std::size_t i=0; i<N; ++i) { mat(i, i) += x_data[N-i-1]; @@ -166,7 +166,7 @@ struct MatDiagXSquared std::vector<double>& mat_data) { auto mat = - MathLib::toZeroedMatrix(mat_data, x_data.size(), x_data.size()); + MathLib::createZeroedMatrix(mat_data, x_data.size(), x_data.size()); for (std::size_t i=0; i<x_data.size(); ++i) mat(i, i) = x_data[i] * x_data[i]; @@ -178,7 +178,7 @@ struct MatDiagXSquared std::vector<double>& dMdxTy_data) { auto dMdxTy = - MathLib::toZeroedMatrix(dMdxTy_data, x_data.size(), x_data.size()); + MathLib::createZeroedMatrix(dMdxTy_data, x_data.size(), x_data.size()); for (std::size_t i=0; i<x_data.size(); ++i) dMdxTy(i, i) = 2.0 * x_data[i] * y_data[i]; @@ -201,7 +201,7 @@ struct VecXSquared std::vector<double>& mat_data) { auto mat = - MathLib::toZeroedMatrix(mat_data, x_data.size(), x_data.size()); + MathLib::createZeroedMatrix(mat_data, x_data.size(), x_data.size()); for (std::size_t i=0; i< x_data.size(); ++i) { mat(i, i) = 2.0 * x_data[i]; } @@ -221,7 +221,7 @@ struct MatXSquaredShifted { auto const N = x_data.size(); auto mat = - MathLib::toZeroedMatrix(mat_data, N, N); + MathLib::createZeroedMatrix(mat_data, N, N); for (std::size_t r=0; r<N; ++r) { for (std::size_t c=0; c<N; ++c) { auto const i = (r + c) % N; @@ -241,7 +241,7 @@ struct MatXSquaredShifted { auto const N = x_data.size(); auto dMdxTy = - MathLib::toZeroedMatrix(dMdxTy_data, N, N); + MathLib::createZeroedMatrix(dMdxTy_data, N, N); for (std::size_t r=0; r<N; ++r) { for (std::size_t c=0; c<N; ++c) { auto const i = (r + c) % N; -- GitLab