Commit c8eeaa4c authored by Tom Fischer's avatar Tom Fischer
Browse files

Merge branch 'SignatureChangeGetCenterOfGravityII' into 'master'

Substitute `MeL::Node` by `MathLib::Point3d` at some locations

See merge request ogs/ogs!4181
parents 771ea9d3 1f8e84bc
......@@ -724,8 +724,7 @@ void FEFLOWMeshInterface::setMaterialIDs(
{
for (std::size_t i = 0; i < vec_elements.size(); ++i)
{
MeshLib::Node const gpt =
MeshLib::getCenterOfGravity(*vec_elements[i]);
auto const gpt = MeshLib::getCenterOfGravity(*vec_elements[i]);
std::size_t matId = 0;
for (std::size_t j = 0; j < lines.size(); j++)
{
......
......@@ -86,7 +86,7 @@ std::unique_ptr<MeshLib::Mesh> generateInitialMesh(
// returns the element the given node is projected on (or nullptr otherwise)
MeshLib::Element const* getProjectedElement(
MeshLib::MeshElementGrid const& grid,
MeshLib::Node const& node,
MathLib::Point3d const& node,
double const max_edge)
{
constexpr double max_val = std::numeric_limits<double>::max();
......@@ -102,9 +102,10 @@ MeshLib::Element const* getProjectedElement(
// casts vote if the given nodes belongs to lower layer, upper layer or no layer
// at all
void voteMatId(MeshLib::Node const& node, MeshLib::MeshElementGrid const& grid,
double const max_edge, std::size_t& nullptr_cnt,
std::size_t& upper_layer_cnt, std::size_t& lower_layer_cnt)
void voteMatId(MathLib::Point3d const& node,
MeshLib::MeshElementGrid const& grid, double const max_edge,
std::size_t& nullptr_cnt, std::size_t& upper_layer_cnt,
std::size_t& lower_layer_cnt)
{
auto const& proj_elem = getProjectedElement(grid, node, max_edge);
if (proj_elem == nullptr)
......@@ -148,7 +149,7 @@ void setMaterialIDs(MeshLib::Mesh& mesh,
std::size_t upper_layer_cnt(0);
std::size_t lower_layer_cnt(0);
MeshLib::Node const node = MeshLib::getCenterOfGravity(*elems[j]);
auto const& node = MeshLib::getCenterOfGravity(*elems[j]);
voteMatId(node, grid, max_edge, nullptr_cnt, upper_layer_cnt,
lower_layer_cnt);
if (nullptr_cnt)
......
......@@ -121,19 +121,15 @@ bool hasZeroVolume(MeshLib::Element const& element)
return element.getContent() < std::numeric_limits<double>::epsilon();
}
MeshLib::Node getCenterOfGravity(Element const& element)
MathLib::Point3d getCenterOfGravity(Element const& element)
{
const unsigned nNodes(element.getNumberOfBaseNodes());
MeshLib::Node center(0, 0, 0);
MathLib::Point3d center{{0, 0, 0}};
for (unsigned i = 0; i < nNodes; ++i)
{
center[0] += (*element.getNode(i))[0];
center[1] += (*element.getNode(i))[1];
center[2] += (*element.getNode(i))[2];
center.asEigenVector3d() += element.getNode(i)->asEigenVector3d();
}
center[0] /= nNodes;
center[1] /= nNodes;
center[2] /= nNodes;
center.asEigenVector3d() /= nNodes;
return center;
}
......
......@@ -205,7 +205,7 @@ bool areNeighbors(Element const* const element, Element const* const other);
bool hasZeroVolume(MeshLib::Element const& element);
/// Calculates the center of gravity for the mesh element
MeshLib::Node getCenterOfGravity(MeshLib::Element const& element);
MathLib::Point3d getCenterOfGravity(MeshLib::Element const& element);
/// Compute the minimum and maximum node distances for this element.
std::pair<double, double> computeSqrNodeDistanceRange(
......
......@@ -19,7 +19,7 @@ namespace MeshLib
namespace ProjectPointOnMesh
{
Element const* getProjectedElement(std::vector<const Element*> const& elements,
Node const& node)
MathLib::Point3d const& node)
{
auto is_right_of = [&node](Node const& a, Node const& b) {
return GeoLib::getOrientationFast(node, a, b) ==
......@@ -55,7 +55,7 @@ Element const* getProjectedElement(std::vector<const Element*> const& elements,
return nullptr;
}
double getElevation(Element const& element, Node const& node)
double getElevation(Element const& element, MathLib::Point3d const& node)
{
Eigen::Vector3d const v =
node.asEigenVector3d() - element.getNode(0)->asEigenVector3d();
......
......@@ -22,11 +22,11 @@ namespace ProjectPointOnMesh
/// Returns the element in which the given node is located when projected onto a
/// mesh, or nullptr if no such element was found.
Element const* getProjectedElement(std::vector<const Element*> const& elements,
Node const& node);
MathLib::Point3d const& node);
/// Returns the z-coordinate of a point projected onto the plane defined by a
/// mesh element.
double getElevation(Element const& element, Node const& node);
double getElevation(Element const& element, MathLib::Point3d const& node);
} // namespace ProjectPointOnMesh
......
......@@ -211,7 +211,7 @@ void LayeredVolume::removeCongruentElements(std::size_t nLayers,
}
else
{
MeshLib::Node attr = MeshLib::getCenterOfGravity(*high);
auto const& attr = MeshLib::getCenterOfGravity(*high);
_attribute_points.emplace_back(
attr[0],
attr[1],
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment