From d72a8c34ea9553910ee18de031799a648bc14247 Mon Sep 17 00:00:00 2001 From: Dmitri Naumov <github@naumov.de> Date: Sun, 16 Jul 2023 15:41:52 +0200 Subject: [PATCH] [MeL] Use Eigen operations on nodes' coordinates --- MeshLib/Utils/GetSpaceDimension.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/MeshLib/Utils/GetSpaceDimension.cpp b/MeshLib/Utils/GetSpaceDimension.cpp index f7ce4d3a789..b0bbbc2626b 100644 --- a/MeshLib/Utils/GetSpaceDimension.cpp +++ b/MeshLib/Utils/GetSpaceDimension.cpp @@ -11,8 +11,8 @@ #include "GetSpaceDimension.h" +#include <Eigen/Core> #include <algorithm> -#include <array> #include <limits> #include "BaseLib/Error.h" @@ -22,16 +22,13 @@ namespace MeshLib { int getSpaceDimension(std::vector<Node*> const& nodes) { - std::array x_magnitude = {0.0, 0.0, 0.0}; + Eigen::Vector3d x_magnitude = Eigen::Vector3d::Zero(); + auto const x_ref = nodes[0]->asEigenVector3d(); - double const* const x_ref = nodes[0]->data(); for (auto const& node : nodes) { - auto const x = node->data(); - for (int i = 0; i < 3; i++) - { - x_magnitude[i] += std::fabs(x[i] - x_ref[i]); - } + auto const x = node->asEigenVector3d(); + x_magnitude += (x - x_ref).cwiseAbs(); } // Z coordinate norm is not zero whichever 1D, 2D or 3D mesh: -- GitLab