OGS
GetSpaceDimension.cpp
Go to the documentation of this file.
1 
12 #include "GetSpaceDimension.h"
13 
14 #include <algorithm>
15 #include <array>
16 #include <limits>
17 
18 #include "BaseLib/Error.h"
19 #include "MeshLib/Node.h"
20 
21 namespace MeshLib
22 {
23 int getSpaceDimension(std::vector<Node*> const& nodes)
24 {
25  std::array x_magnitude = {0.0, 0.0, 0.0};
26 
27  double const* const x_ref = nodes[0]->getCoords();
28  for (auto const& node : nodes)
29  {
30  auto const x = node->getCoords();
31  for (int i = 0; i < 3; i++)
32  {
33  x_magnitude[i] += std::fabs(x[i] - x_ref[i]);
34  }
35  }
36 
37  return static_cast<int>(std::count_if(
38  x_magnitude.begin(), x_magnitude.end(),
39  [](const double x_i_magnitude)
40  { return x_i_magnitude > std::numeric_limits<double>::epsilon(); }));
41 }
42 }; // namespace MeshLib
Definition of the Node class.
int getSpaceDimension(std::vector< Node * > const &nodes)
Computes dimension of the embedding space containing the set of given points.