Skip to content
Snippets Groups Projects
Commit 36f5dd50 authored by Tom Fischer's avatar Tom Fischer Committed by Dmitry Yu. Naumov
Browse files

[MeL] Improve const correctness.

This change makes it possible to use interface
function Element::getNode() in Element::addNeighbor
function.
parent e8502227
No related branches found
No related tags found
No related merge requests found
Showing
with 35 additions and 22 deletions
......@@ -55,7 +55,7 @@ std::optional<unsigned> Element::addNeighbor(Element* e)
return std::optional<unsigned>();
}
Node* face_nodes[3];
Node const* face_nodes[3];
const unsigned nNodes(this->getNumberOfBaseNodes());
const unsigned eNodes(e->getNumberOfBaseNodes());
const Node* const* e_nodes = e->getNodes();
......@@ -65,9 +65,9 @@ std::optional<unsigned> Element::addNeighbor(Element* e)
{
for (unsigned j(0); j < eNodes; j++)
{
if (_nodes[i] == e_nodes[j])
if (getNode(i) == e_nodes[j])
{
face_nodes[count] = _nodes[i];
face_nodes[count] = getNode(i);
// increment shared nodes counter and check if enough nodes are
// similar to be sure e is a neighbour of this
if ((++count) >= dim)
......
......@@ -167,7 +167,7 @@ public:
virtual double computeVolume() = 0;
/// Returns the ID of a face given an array of nodes.
virtual unsigned identifyFace(Node* nodes[3]) const = 0;
virtual unsigned identifyFace(Node const* nodes[3]) const = 0;
/**
* Checks if the node order of an element is correct by testing surface normals.
......
......@@ -93,7 +93,7 @@ bool HexRule8::isPntInElement(Node const* const* nodes,
pnt, *nodes[3], *nodes[7], *nodes[5], *nodes[2], eps));
}
unsigned HexRule8::identifyFace(Node const* const* _nodes, Node* nodes[3])
unsigned HexRule8::identifyFace(Node const* const* _nodes, Node const* nodes[3])
{
for (unsigned i = 0; i < 6; i++)
{
......
......@@ -92,7 +92,8 @@ public:
static ElementErrorCode validate(const Element* e);
/// Returns the ID of a face given an array of nodes.
static unsigned identifyFace(Node const* const* /*_nodes*/, Node* nodes[3]);
static unsigned identifyFace(Node const* const* /*_nodes*/,
Node const* nodes[3]);
/// Calculates the volume of a convex hexahedron by partitioning it into six tetrahedra.
static double computeVolume(Node const* const* _nodes);
......
......@@ -34,7 +34,8 @@ bool LineRule2::isPntInElement(Node const* const* nodes,
return (dist < eps);
}
unsigned LineRule2::identifyFace(Node const* const* _nodes, Node* nodes[1])
unsigned LineRule2::identifyFace(Node const* const* _nodes,
Node const* nodes[1])
{
if (nodes[0] == _nodes[0])
{
......
......@@ -61,7 +61,8 @@ public:
static ElementErrorCode validate(const Element* e);
/// Returns the ID of a face given an array of nodes.
static unsigned identifyFace(Node const* const* /*_nodes*/, Node* nodes[1]);
static unsigned identifyFace(Node const* const* /*_nodes*/,
Node const* nodes[1]);
/// Calculates the length of a line
static double computeVolume(Node const* const* _nodes);
......
......@@ -29,7 +29,8 @@ bool PointRule1::isPntInElement(Node const* const* nodes,
return (dist < eps);
}
unsigned PointRule1::identifyFace(Node const* const* _nodes, Node* nodes[1])
unsigned PointRule1::identifyFace(Node const* const* _nodes,
Node const* nodes[1])
{
if (nodes[0] == _nodes[0])
{
......
......@@ -56,7 +56,8 @@ public:
static ElementErrorCode validate(const Element* e);
/// Returns the ID of a face given an array of nodes.
static unsigned identifyFace(Node const* const* /*_nodes*/, Node* nodes[1]);
static unsigned identifyFace(Node const* const* /*_nodes*/,
Node const* nodes[1]);
/// Calculates the length of a line
static double computeVolume(Node const* const* _nodes);
......
......@@ -84,7 +84,8 @@ bool PrismRule6::isPntInElement(Node const* const* nodes,
pnt, *nodes[2], *nodes[4], *nodes[5], *nodes[3], eps));
}
unsigned PrismRule6::identifyFace(Node const* const* _nodes, Node* nodes[3])
unsigned PrismRule6::identifyFace(Node const* const* _nodes,
Node const* nodes[3])
{
for (unsigned i = 0; i < 5; i++)
{
......
......@@ -93,7 +93,8 @@ public:
static ElementErrorCode validate(const Element* e);
/// Returns the ID of a face given an array of nodes.
static unsigned identifyFace(Node const* const* /*_nodes*/, Node* nodes[3]);
static unsigned identifyFace(Node const* const* /*_nodes*/,
Node const* nodes[3]);
/// Calculates the volume of a convex hexahedron by partitioning it into six tetrahedra.
static double computeVolume(Node const* const* _nodes);
......
......@@ -79,7 +79,8 @@ bool PyramidRule5::isPntInElement(Node const* const* nodes,
pnt, *nodes[0], *nodes[2], *nodes[3], *nodes[4], eps));
}
unsigned PyramidRule5::identifyFace(Node const* const* _nodes, Node* nodes[3])
unsigned PyramidRule5::identifyFace(Node const* const* _nodes,
Node const* nodes[3])
{
for (unsigned i = 0; i < 5; i++)
{
......
......@@ -92,7 +92,8 @@ public:
static ElementErrorCode validate(const Element* e);
/// Returns the ID of a face given an array of nodes.
static unsigned identifyFace(Node const* const* /*_nodes*/, Node* nodes[3]);
static unsigned identifyFace(Node const* const* /*_nodes*/,
Node const* nodes[3]);
/// Calculates the volume of a convex hexahedron by partitioning it into six tetrahedra.
static double computeVolume(Node const* const* _nodes);
......
......@@ -37,7 +37,8 @@ bool QuadRule4::isPntInElement(Node const* const* nodes,
MathLib::isPointInTriangle(pnt, *nodes[0], *nodes[2], *nodes[3], eps));
}
unsigned QuadRule4::identifyFace(Node const* const* _nodes, Node* nodes[3])
unsigned QuadRule4::identifyFace(Node const* const* _nodes,
Node const* nodes[3])
{
for (unsigned i = 0; i < 4; i++)
{
......
......@@ -74,7 +74,8 @@ public:
static ElementErrorCode validate(const Element* e);
/// Returns the ID of a face given an array of nodes.
static unsigned identifyFace(Node const* const* /*_nodes*/, Node* nodes[3]);
static unsigned identifyFace(Node const* const* /*_nodes*/,
Node const* nodes[3]);
/// Calculates the volume of a convex hexahedron by partitioning it into six tetrahedra.
static double computeVolume(Node const* const* _nodes);
......
......@@ -177,7 +177,7 @@ public:
}
/// Returns the ID of a face given an array of nodes.
unsigned identifyFace(Node* nodes[3]) const override
unsigned identifyFace(Node const* nodes[3]) const override
{
return ELEMENT_RULE::identifyFace(this->_nodes, nodes);
}
......
......@@ -64,7 +64,7 @@ bool TetRule4::isPntInElement(Node const* const* nodes,
*nodes[3], eps);
}
unsigned TetRule4::identifyFace(Node const* const* _nodes, Node* nodes[3])
unsigned TetRule4::identifyFace(Node const* const* _nodes, Node const* nodes[3])
{
for (unsigned i = 0; i < 4; i++)
{
......
......@@ -87,7 +87,8 @@ public:
static ElementErrorCode validate(const Element* e);
/// Returns the ID of a face given an array of nodes.
static unsigned identifyFace(Node const* const* /*_nodes*/, Node* nodes[3]);
static unsigned identifyFace(Node const* const* /*_nodes*/,
Node const* nodes[3]);
/// Calculates the volume of the element
static double computeVolume(Node const* const* _nodes);
......
......@@ -33,7 +33,7 @@ bool TriRule3::isPntInElement(Node const* const* nodes,
eps);
}
unsigned TriRule3::identifyFace(Node const* const* _nodes, Node* nodes[3])
unsigned TriRule3::identifyFace(Node const* const* _nodes, Node const* nodes[3])
{
for (unsigned i = 0; i < 3; i++)
{
......
......@@ -75,7 +75,8 @@ public:
static ElementErrorCode validate(const Element* e);
/// Returns the ID of a face given an array of nodes.
static unsigned identifyFace(Node const* const* /*_nodes*/, Node* nodes[3]);
static unsigned identifyFace(Node const* const* /*_nodes*/,
Node const* nodes[3]);
/// Calculates the volume of a convex hexahedron by partitioning it into six tetrahedra.
static double computeVolume(Node const* const* _nodes);
......
......@@ -82,7 +82,7 @@ ConstraintDirichletBoundaryCondition::ConstraintDirichletBoundaryCondition(
[&](auto const bulk_element_id, MeshLib::Element const* bc_elem)
{
auto const* bulk_elem = _bulk_mesh.getElement(bulk_element_id);
std::array<MeshLib::Node*, 3> nodes{
std::array<MeshLib::Node const*, 3> nodes{
{bulk_nodes[(*bulk_node_ids)[bc_elem->getNode(0)->getID()]],
bulk_nodes[(*bulk_node_ids)[bc_elem->getNode(1)->getID()]],
bulk_nodes[(*bulk_node_ids)[bc_elem->getNode(2)->getID()]]}};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment