Skip to content
Snippets Groups Projects
Commit a1680324 authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

clang-format MeshLib

parent c89f1268
No related branches found
No related tags found
No related merge requests found
Showing
with 277 additions and 288 deletions
......@@ -9,19 +9,22 @@
#include "CoordinateSystem.h"
#include "MeshLib/Node.h"
#include "MeshLib/Elements/Element.h"
#include "MeshLib/Node.h"
namespace MeshLib
{
CoordinateSystem::CoordinateSystem(const Element &ele)
CoordinateSystem::CoordinateSystem(const Element& ele)
{
GeoLib::AABB const aabb(ele.getNodes(), ele.getNodes() + ele.getNumberOfNodes());
GeoLib::AABB const aabb(ele.getNodes(),
ele.getNodes() + ele.getNumberOfNodes());
CoordinateSystem const bboxCoordSys(getCoordinateSystem(aabb));
if (bboxCoordSys.getDimension() >= ele.getDimension()) {
if (bboxCoordSys.getDimension() >= ele.getDimension())
{
_type = bboxCoordSys.getType();
} else { // e.g. zero volume elements
}
else
{ // e.g. zero volume elements
if (ele.getDimension() >= 1)
{
_type = CoordinateSystemType::X;
......@@ -37,7 +40,8 @@ CoordinateSystem::CoordinateSystem(const Element &ele)
}
}
unsigned char CoordinateSystem::getCoordinateSystem(const GeoLib::AABB &bbox) const
unsigned char CoordinateSystem::getCoordinateSystem(
const GeoLib::AABB& bbox) const
{
unsigned char coords = 0;
......
......@@ -9,15 +9,14 @@
#include "ElementCoordinatesMappingLocal.h"
#include <limits>
#include <cassert>
#include <limits>
#include "GeoLib/AnalyticalGeometry.h"
#include "MeshLib/Elements/Element.h"
#include "MeshLib/Node.h"
#include "MathLib/MathTools.h"
#include "MathLib/Point3d.h"
#include "MeshLib/Elements/Element.h"
#include "MeshLib/Node.h"
namespace detail
{
......
......@@ -14,12 +14,12 @@
#include "ElementStatus.h"
#include "Elements/Element.h"
#include "Mesh.h"
#include "MeshLib/Node.h"
#include "Elements/Element.h"
namespace MeshLib {
namespace MeshLib
{
ElementStatus::ElementStatus(Mesh const* const mesh, bool hasAnyInactive)
: _mesh(mesh),
_element_status(mesh->getNumberOfElements(), true),
......@@ -39,9 +39,12 @@ ElementStatus::ElementStatus(Mesh const* const mesh,
{
auto* const materialIds =
mesh->getProperties().getPropertyVector<int>("MaterialIDs");
for (auto material_id : vec_inactive_matIDs) {
for (auto e : _mesh->getElements()) {
if ((*materialIds)[e->getID()] == material_id) {
for (auto material_id : vec_inactive_matIDs)
{
for (auto e : _mesh->getElements())
{
if ((*materialIds)[e->getID()] == material_id)
{
setElementStatus(e->getID(), false);
}
}
......@@ -49,7 +52,7 @@ ElementStatus::ElementStatus(Mesh const* const mesh,
}
_vec_active_eles.reserve(getNumberOfActiveElements());
const std::size_t nElems (_mesh->getNumberOfElements());
const std::size_t nElems(_mesh->getNumberOfElements());
for (std::size_t i = 0; i < nElems; ++i)
{
if (_element_status[i])
......@@ -60,7 +63,7 @@ ElementStatus::ElementStatus(Mesh const* const mesh,
}
_vec_active_nodes.reserve(this->getNumberOfActiveNodes());
const std::size_t nNodes (_mesh->getNumberOfNodes());
const std::size_t nNodes(_mesh->getNumberOfNodes());
for (std::size_t i = 0; i < nNodes; ++i)
{
if (_active_nodes[i] > 0)
......@@ -100,7 +103,8 @@ std::vector<MeshLib::Node*> const& ElementStatus::getActiveNodes() const
std::size_t ElementStatus::getNumberOfActiveNodes() const
{
return _active_nodes.size() - std::count(_active_nodes.cbegin(), _active_nodes.cend(), 0);
return _active_nodes.size() -
std::count(_active_nodes.cbegin(), _active_nodes.cend(), 0);
}
std::size_t ElementStatus::getNumberOfActiveElements() const
......@@ -115,9 +119,10 @@ void ElementStatus::setElementStatus(std::size_t i, bool status)
{
const int change = (status) ? 1 : -1;
_element_status[i] = status;
const unsigned nElemNodes (_mesh->getElement(i)->getNumberOfNodes());
MeshLib::Node const*const*const nodes = _mesh->getElement(i)->getNodes();
for (unsigned j=0; j<nElemNodes; ++j)
const unsigned nElemNodes(_mesh->getElement(i)->getNumberOfNodes());
MeshLib::Node const* const* const nodes =
_mesh->getElement(i)->getNodes();
for (unsigned j = 0; j < nElemNodes; ++j)
{
assert(_active_nodes[j] < 255); // if one node has >255 connected
// elements the data type is too
......@@ -129,7 +134,7 @@ void ElementStatus::setElementStatus(std::size_t i, bool status)
bool ElementStatus::isActiveNode(MeshLib::Node const* node) const
{
return _active_nodes[node->getID()]>0;
return _active_nodes[node->getID()] > 0;
}
} // namespace MeshLib
......@@ -10,12 +10,12 @@
#include "CellRule.h"
#include "MeshLib/Node.h"
#include "Element.h"
#include "FaceRule.h"
#include "MeshLib/Node.h"
namespace MeshLib {
namespace MeshLib
{
bool CellRule::testElementNodeOrder(const Element* e)
{
Eigen::Vector3d const cc =
......@@ -24,10 +24,10 @@ bool CellRule::testElementNodeOrder(const Element* e)
for (unsigned j = 0; j < nFaces; ++j)
{
MeshLib::Element const* const face(e->getFace(j));
// Node 1 is checked below because that way all nodes are used for the test
// at some point, while for node 0 at least one node in every element
// type would be used for checking twice and one wouldn't be checked at
// all. (based on the definition of the _face_nodes variable)
// Node 1 is checked below because that way all nodes are used for the
// test at some point, while for node 0 at least one node in every
// element type would be used for checking twice and one wouldn't be
// checked at all. (based on the definition of the _face_nodes variable)
auto const x =
Eigen::Map<Eigen::Vector3d const>(face->getNode(1)->getCoords());
Eigen::Vector3d const cx = x - cc;
......
......@@ -11,21 +11,19 @@
#include "EdgeReturn.h"
#include "BaseLib/Logging.h"
#include "MeshLib/Node.h"
#include "Element.h"
#include "Line.h"
#include "MeshLib/Node.h"
namespace MeshLib
{
const Element* LinearEdgeReturn::getEdge(const Element* e, unsigned i)
{
if (i < e->getNumberOfEdges())
{
auto** nodes = new Node*[2];
nodes[0] = const_cast<Node*>(e->getEdgeNode(i,0));
nodes[1] = const_cast<Node*>(e->getEdgeNode(i,1));
nodes[0] = const_cast<Node*>(e->getEdgeNode(i, 0));
nodes[1] = const_cast<Node*>(e->getEdgeNode(i, 1));
return new Line(nodes, e->getID());
}
ERR("Error in MeshLib::Element::getEdge() - Index does not exist.");
......@@ -37,9 +35,9 @@ const Element* QuadraticEdgeReturn::getEdge(const Element* e, unsigned i)
if (i < e->getNumberOfEdges())
{
auto** nodes = new Node*[3];
nodes[0] = const_cast<Node*>(e->getEdgeNode(i,0));
nodes[1] = const_cast<Node*>(e->getEdgeNode(i,1));
nodes[2] = const_cast<Node*>(e->getEdgeNode(i,2));
nodes[0] = const_cast<Node*>(e->getEdgeNode(i, 0));
nodes[1] = const_cast<Node*>(e->getEdgeNode(i, 1));
nodes[2] = const_cast<Node*>(e->getEdgeNode(i, 2));
return new Line3(nodes, e->getID());
}
ERR("Error in MeshLib::Element::getEdge() - Index does not exist.");
......
......@@ -15,15 +15,13 @@
#include "Element.h"
#include "BaseLib/Logging.h"
#include "Line.h"
#include "MathLib/GeometricBasics.h"
#include "MathLib/MathTools.h"
#include "MeshLib/Node.h"
#include "Line.h"
namespace MeshLib {
namespace MeshLib
{
Element::Element(std::size_t id)
: _nodes(nullptr), _id(id), _content(-1.0), _neighbors(nullptr)
{
......@@ -31,8 +29,8 @@ Element::Element(std::size_t id)
Element::~Element()
{
delete [] this->_nodes;
delete [] this->_neighbors;
delete[] this->_nodes;
delete[] this->_neighbors;
}
void Element::setNeighbor(Element* neighbor, unsigned const face_id)
......@@ -58,11 +56,11 @@ std::optional<unsigned> Element::addNeighbor(Element* e)
}
Node* face_nodes[3];
const unsigned nNodes (this->getNumberOfBaseNodes());
const unsigned eNodes (e->getNumberOfBaseNodes());
const unsigned nNodes(this->getNumberOfBaseNodes());
const unsigned eNodes(e->getNumberOfBaseNodes());
const Node* const* e_nodes = e->getNodes();
unsigned count(0);
const unsigned dim (this->getDimension());
const unsigned dim(this->getDimension());
for (unsigned i(0); i < nNodes; i++)
{
for (unsigned j(0); j < eNodes; j++)
......@@ -70,10 +68,11 @@ std::optional<unsigned> Element::addNeighbor(Element* e)
if (_nodes[i] == e_nodes[j])
{
face_nodes[count] = _nodes[i];
// increment shared nodes counter and check if enough nodes are similar to be sure e is a neighbour of this
if ((++count)>=dim)
// increment shared nodes counter and check if enough nodes are
// similar to be sure e is a neighbour of this
if ((++count) >= dim)
{
_neighbors[ this->identifyFace(face_nodes) ] = e;
_neighbors[this->identifyFace(face_nodes)] = e;
return std::optional<unsigned>(e->identifyFace(face_nodes));
}
}
......@@ -99,7 +98,7 @@ const Element* Element::getNeighbor(unsigned i) const
unsigned Element::getNodeIDinElement(const MeshLib::Node* node) const
{
const unsigned nNodes (this->getNumberOfNodes());
const unsigned nNodes(this->getNumberOfNodes());
for (unsigned i(0); i < nNodes; i++)
{
if (node == _nodes[i])
......@@ -151,21 +150,22 @@ std::size_t Element::getNodeIndex(unsigned i) const
bool Element::isBoundaryElement() const
{
return std::any_of(_neighbors, _neighbors + this->getNumberOfNeighbors(),
[](MeshLib::Element const*const e){ return e == nullptr; });
return std::any_of(
_neighbors, _neighbors + this->getNumberOfNeighbors(),
[](MeshLib::Element const* const e) { return e == nullptr; });
}
#ifndef NDEBUG
std::ostream& operator<<(std::ostream& os, Element const& e)
{
os << "Element #" << e._id << " @ " << &e << " with " << e.getNumberOfNeighbors()
<< " neighbours\n";
os << "Element #" << e._id << " @ " << &e << " with "
<< e.getNumberOfNeighbors() << " neighbours\n";
unsigned const nnodes = e.getNumberOfNodes();
MeshLib::Node* const* const nodes = e.getNodes();
os << "MeshElemType: "
<< static_cast<std::underlying_type<MeshElemType>::type>(e.getGeomType())
<< " with " << nnodes << " nodes: { ";
<< static_cast<std::underlying_type<MeshElemType>::type>(e.getGeomType())
<< " with " << nnodes << " nodes: { ";
for (unsigned n = 0; n < nnodes; ++n)
{
os << nodes[n]->getID() << " @ " << nodes[n] << " ";
......@@ -246,7 +246,8 @@ std::pair<double, double> computeSqrEdgeLengthRange(Element const& element)
bool isPointInElementXY(MathLib::Point3d const& p, Element const& e)
{
for(std::size_t i(0); i<e.getNumberOfBaseNodes(); ++i) {
for (std::size_t i(0); i < e.getNumberOfBaseNodes(); ++i)
{
if (MathLib::sqrDist2d(p, *e.getNode(i)) <
std::numeric_limits<double>::epsilon())
{
......
......@@ -10,9 +10,9 @@
#include "FaceRule.h"
#include "Element.h"
#include "MathLib/MathTools.h"
#include "MeshLib/Node.h"
#include "Element.h"
namespace MeshLib
{
......
......@@ -13,12 +13,12 @@
#include <array>
#include "BaseLib/Logging.h"
#include "Line.h"
#include "MeshLib/Node.h"
#include "Quad.h"
#include "Line.h"
namespace MeshLib {
namespace MeshLib
{
const unsigned HexRule20::face_nodes[6][8] = {
{0, 3, 2, 1, 11, 10, 9, 8}, // Face 0
{0, 1, 5, 4, 8, 17, 12, 16}, // Face 1
......@@ -28,20 +28,19 @@ const unsigned HexRule20::face_nodes[6][8] = {
{4, 5, 6, 7, 12, 13, 14, 15} // Face 5
};
const unsigned HexRule20::edge_nodes[12][3] =
{
{0, 1, 8}, // Edge 0
{1, 2, 9}, // Edge 1
{2, 3, 10}, // Edge 2
{0, 3, 11}, // Edge 3
{4, 5, 12}, // Edge 4
{5, 6, 13}, // Edge 5
{6, 7, 14}, // Edge 6
{4, 7, 15}, // Edge 7
{0, 4, 16}, // Edge 8
{1, 5, 17}, // Edge 9
{2, 6, 18}, // Edge 10
{3, 7, 19} // Edge 11
const unsigned HexRule20::edge_nodes[12][3] = {
{0, 1, 8}, // Edge 0
{1, 2, 9}, // Edge 1
{2, 3, 10}, // Edge 2
{0, 3, 11}, // Edge 3
{4, 5, 12}, // Edge 4
{5, 6, 13}, // Edge 5
{6, 7, 14}, // Edge 6
{4, 7, 15}, // Edge 7
{0, 4, 16}, // Edge 8
{1, 5, 17}, // Edge 9
{2, 6, 18}, // Edge 10
{3, 7, 19} // Edge 11
};
const Element* HexRule20::getFace(const Element* e, unsigned i)
......@@ -59,4 +58,4 @@ const Element* HexRule20::getFace(const Element* e, unsigned i)
return nullptr;
}
} // end namespace MeshLib
} // end namespace MeshLib
......@@ -13,39 +13,35 @@
#include <array>
#include "BaseLib/Logging.h"
#include "Line.h"
#include "MathLib/GeometricBasics.h"
#include "MeshLib/Node.h"
#include "Quad.h"
#include "Line.h"
namespace MeshLib {
const unsigned HexRule8::face_nodes[6][4] =
namespace MeshLib
{
{0, 3, 2, 1}, // Face 0
{0, 1, 5, 4}, // Face 1
{1, 2, 6, 5}, // Face 2
{2, 3, 7, 6}, // Face 3
{3, 0, 4, 7}, // Face 4
{4, 5, 6, 7} // Face 5
const unsigned HexRule8::face_nodes[6][4] = {
{0, 3, 2, 1}, // Face 0
{0, 1, 5, 4}, // Face 1
{1, 2, 6, 5}, // Face 2
{2, 3, 7, 6}, // Face 3
{3, 0, 4, 7}, // Face 4
{4, 5, 6, 7} // Face 5
};
const unsigned HexRule8::edge_nodes[12][2] =
{
{0, 1}, // Edge 0
{1, 2}, // Edge 1
{2, 3}, // Edge 2
{0, 3}, // Edge 3
{4, 5}, // Edge 4
{5, 6}, // Edge 5
{6, 7}, // Edge 6
{4, 7}, // Edge 7
{0, 4}, // Edge 8
{1, 5}, // Edge 9
{2, 6}, // Edge 10
{3, 7} // Edge 11
const unsigned HexRule8::edge_nodes[12][2] = {
{0, 1}, // Edge 0
{1, 2}, // Edge 1
{2, 3}, // Edge 2
{0, 3}, // Edge 3
{4, 5}, // Edge 4
{5, 6}, // Edge 5
{6, 7}, // Edge 6
{4, 7}, // Edge 7
{0, 4}, // Edge 8
{1, 5}, // Edge 9
{2, 6}, // Edge 10
{3, 7} // Edge 11
};
const Element* HexRule8::getFace(const Element* e, unsigned i)
......@@ -65,12 +61,18 @@ const Element* HexRule8::getFace(const Element* e, unsigned i)
double HexRule8::computeVolume(Node const* const* _nodes)
{
return MathLib::calcTetrahedronVolume(*_nodes[4], *_nodes[7], *_nodes[5], *_nodes[0])
+ MathLib::calcTetrahedronVolume(*_nodes[5], *_nodes[3], *_nodes[1], *_nodes[0])
+ MathLib::calcTetrahedronVolume(*_nodes[5], *_nodes[7], *_nodes[3], *_nodes[0])
+ MathLib::calcTetrahedronVolume(*_nodes[5], *_nodes[7], *_nodes[6], *_nodes[2])
+ MathLib::calcTetrahedronVolume(*_nodes[1], *_nodes[3], *_nodes[5], *_nodes[2])
+ MathLib::calcTetrahedronVolume(*_nodes[3], *_nodes[7], *_nodes[5], *_nodes[2]);
return MathLib::calcTetrahedronVolume(
*_nodes[4], *_nodes[7], *_nodes[5], *_nodes[0]) +
MathLib::calcTetrahedronVolume(
*_nodes[5], *_nodes[3], *_nodes[1], *_nodes[0]) +
MathLib::calcTetrahedronVolume(
*_nodes[5], *_nodes[7], *_nodes[3], *_nodes[0]) +
MathLib::calcTetrahedronVolume(
*_nodes[5], *_nodes[7], *_nodes[6], *_nodes[2]) +
MathLib::calcTetrahedronVolume(
*_nodes[1], *_nodes[3], *_nodes[5], *_nodes[2]) +
MathLib::calcTetrahedronVolume(
*_nodes[3], *_nodes[7], *_nodes[5], *_nodes[2]);
}
bool HexRule8::isPntInElement(Node const* const* nodes,
......@@ -93,7 +95,7 @@ bool HexRule8::isPntInElement(Node const* const* nodes,
unsigned HexRule8::identifyFace(Node const* const* _nodes, Node* nodes[3])
{
for (unsigned i=0; i<6; i++)
for (unsigned i = 0; i < 6; i++)
{
unsigned flag(0);
for (unsigned j = 0; j < 4; j++)
......@@ -119,19 +121,19 @@ ElementErrorCode HexRule8::validate(const Element* e)
ElementErrorCode error_code;
error_code[ElementErrorFlag::ZeroVolume] = hasZeroVolume(*e);
for (unsigned i=0; i<6; ++i)
for (unsigned i = 0; i < 6; ++i)
{
if (error_code.all())
{
break;
}
const MeshLib::Element* quad (e->getFace(i));
const MeshLib::Element* quad(e->getFace(i));
error_code |= quad->validate();
delete quad;
}
error_code[ElementErrorFlag::NodeOrder] = !e->testElementNodeOrder();
error_code[ElementErrorFlag::NodeOrder] = !e->testElementNodeOrder();
return error_code;
}
} // end namespace MeshLib
} // end namespace MeshLib
......@@ -13,11 +13,10 @@
#include "MathLib/MathTools.h"
#include "MeshLib/Node.h"
namespace MeshLib {
const unsigned LineRule2::edge_nodes[1][2] =
namespace MeshLib
{
{0, 1} // Edge 0
const unsigned LineRule2::edge_nodes[1][2] = {
{0, 1} // Edge 0
};
double LineRule2::computeVolume(Node const* const* _nodes)
......@@ -55,4 +54,4 @@ ElementErrorCode LineRule2::validate(const Element* e)
return error_code;
}
} // end namespace MeshLib
} // end namespace MeshLib
......@@ -8,10 +8,10 @@
*
*/
#include <array>
#include "MapBulkElementPoint.h"
#include <array>
namespace MeshLib
{
MathLib::Point3d getBulkElementPoint(MeshLib::Tri const& /*tri*/,
......@@ -37,17 +37,20 @@ MathLib::Point3d getBulkElementPoint(MeshLib::Quad const& /*quad*/,
std::size_t const face_id,
MathLib::WeightedPoint1D const& wp)
{
switch (face_id) {
case 0:
return MathLib::Point3d{std::array<double, 3>{{wp[0], 0.0, 0.0}}};
case 1:
return MathLib::Point3d{std::array<double, 3>{{1.0, wp[0], 0.0}}};
case 2:
return MathLib::Point3d{std::array<double, 3>{{1.0 - wp[0], 1.0, 0.0}}};
case 3:
return MathLib::Point3d{std::array<double, 3>{{0.0, 1.0 - wp[0], 0.0}}};
default:
OGS_FATAL("Invalid face id '{:d}' for the quad.", face_id);
switch (face_id)
{
case 0:
return MathLib::Point3d{std::array<double, 3>{{wp[0], 0.0, 0.0}}};
case 1:
return MathLib::Point3d{std::array<double, 3>{{1.0, wp[0], 0.0}}};
case 2:
return MathLib::Point3d{
std::array<double, 3>{{1.0 - wp[0], 1.0, 0.0}}};
case 3:
return MathLib::Point3d{
std::array<double, 3>{{0.0, 1.0 - wp[0], 0.0}}};
default:
OGS_FATAL("Invalid face id '{:d}' for the quad.", face_id);
}
}
......@@ -89,16 +92,15 @@ MathLib::Point3d getBulkElementPoint(MeshLib::Prism const& /*prism*/,
std::array<double, 3>{{wp[1], wp[0], -1.0}}};
case 1:
return MathLib::Point3d{
std::array<double, 3>{{wp[0]/2.0 + 0.5, 0.0, wp[1]}}};
std::array<double, 3>{{wp[0] / 2.0 + 0.5, 0.0, wp[1]}}};
case 2:
return MathLib::Point3d{
std::array<double, 3>{{0.5 - wp[0]/2.0, 0.5 + wp[0]/2.0, wp[1]}}};
return MathLib::Point3d{std::array<double, 3>{
{0.5 - wp[0] / 2.0, 0.5 + wp[0] / 2.0, wp[1]}}};
case 3:
return MathLib::Point3d{
std::array<double, 3>{{0, -wp[0]/2.0 + 0.5, wp[1]}}};
std::array<double, 3>{{0, -wp[0] / 2.0 + 0.5, wp[1]}}};
case 4:
return MathLib::Point3d{
std::array<double, 3>{{wp[0], wp[1], 1.0}}};
return MathLib::Point3d{std::array<double, 3>{{wp[0], wp[1], 1.0}}};
default:
OGS_FATAL("Invalid face id '{:d}' for the prism.", face_id);
}
......@@ -120,8 +122,8 @@ MathLib::Point3d getBulkElementPoint(MeshLib::Pyramid const& /*pyramid*/,
return MathLib::Point3d{
std::array<double, 3>{{1 - 2 * wp[0], 1.0, 2 * wp[1] - 1}}};
case 3:
return MathLib::Point3d{std::array<double, 3>{
{-1.0, 2 * wp[1] - 1, 2 * wp[0] - 1}}};
return MathLib::Point3d{
std::array<double, 3>{{-1.0, 2 * wp[1] - 1, 2 * wp[0] - 1}}};
case 4:
return MathLib::Point3d{
std::array<double, 3>{{-wp[0], wp[1], -1.0}}};
......@@ -144,8 +146,7 @@ MathLib::Point3d getBulkElementPoint(MeshLib::Tet const& /*tet*/,
return MathLib::Point3d{
std::array<double, 3>{{1 - wp[0] - wp[1], wp[0], wp[1]}}};
case 3:
return MathLib::Point3d{
std::array<double, 3>{{0, wp[1], wp[0]}}};
return MathLib::Point3d{std::array<double, 3>{{0, wp[1], wp[0]}}};
default:
OGS_FATAL("Invalid face id '{:d}' for the tetrahedron.", face_id);
}
......
......@@ -13,12 +13,9 @@
#include "MathLib/Point3d.h"
#include "MeshLib/Node.h"
namespace MeshLib {
const unsigned PointRule1::edge_nodes[1][1] =
namespace MeshLib
{
{0}
};
const unsigned PointRule1::edge_nodes[1][1] = {{0}};
double PointRule1::computeVolume(Node const* const* /*_nodes*/)
{
......@@ -48,4 +45,4 @@ ElementErrorCode PointRule1::validate(const Element* e)
return error_code;
}
} // end namespace MeshLib
} // end namespace MeshLib
......@@ -11,36 +11,33 @@
#include "PrismRule15.h"
#include "BaseLib/Logging.h"
#include "MeshLib/Node.h"
#include "Quad.h"
#include "Tri.h"
namespace MeshLib {
const unsigned PrismRule15::face_nodes[5][8] =
namespace MeshLib
{
{0, 2, 1, 8, 7, 6, 99, 99}, // Face 0
{0, 1, 4, 3, 6, 10, 12, 9}, // Face 1
{1, 2, 5, 4, 7, 11, 13, 10}, // Face 2
{2, 0, 3, 5, 8, 9, 14, 11}, // Face 3
const unsigned PrismRule15::face_nodes[5][8] = {
{0, 2, 1, 8, 7, 6, 99, 99}, // Face 0
{0, 1, 4, 3, 6, 10, 12, 9}, // Face 1
{1, 2, 5, 4, 7, 11, 13, 10}, // Face 2
{2, 0, 3, 5, 8, 9, 14, 11}, // Face 3
{3, 4, 5, 12, 13, 14, 99, 99} // Face 4
};
const unsigned PrismRule15::edge_nodes[9][3] =
{
{0, 1, 6}, // Edge 0
{1, 2, 7}, // Edge 1
{0, 2, 8}, // Edge 2
{0, 3, 9}, // Edge 3
{1, 4, 10}, // Edge 4
{2, 5, 11}, // Edge 5
{3, 4, 12}, // Edge 6
{4, 5, 13}, // Edge 7
{3, 5, 14} // Edge 8
const unsigned PrismRule15::edge_nodes[9][3] = {
{0, 1, 6}, // Edge 0
{1, 2, 7}, // Edge 1
{0, 2, 8}, // Edge 2
{0, 3, 9}, // Edge 3
{1, 4, 10}, // Edge 4
{2, 5, 11}, // Edge 5
{3, 4, 12}, // Edge 6
{4, 5, 13}, // Edge 7
{3, 5, 14} // Edge 8
};
const unsigned PrismRule15::n_face_nodes[5] = { 6, 8, 8, 8, 6 };
const unsigned PrismRule15::n_face_nodes[5] = {6, 8, 8, 8, 6};
const Element* PrismRule15::getFace(const Element* e, unsigned i)
{
......@@ -64,4 +61,4 @@ const Element* PrismRule15::getFace(const Element* e, unsigned i)
return nullptr;
}
} // end namespace MeshLib
} // end namespace MeshLib
......@@ -11,38 +11,34 @@
#include "PrismRule6.h"
#include "BaseLib/Logging.h"
#include "MathLib/GeometricBasics.h"
#include "MeshLib/Node.h"
#include "Quad.h"
#include "Tri.h"
namespace MeshLib {
const unsigned PrismRule6::face_nodes[5][4] =
namespace MeshLib
{
{0, 2, 1, 99}, // Face 0
{0, 1, 4, 3}, // Face 1
{1, 2, 5, 4}, // Face 2
{2, 0, 3, 5}, // Face 3
{3, 4, 5, 99} // Face 4
const unsigned PrismRule6::face_nodes[5][4] = {
{0, 2, 1, 99}, // Face 0
{0, 1, 4, 3}, // Face 1
{1, 2, 5, 4}, // Face 2
{2, 0, 3, 5}, // Face 3
{3, 4, 5, 99} // Face 4
};
const unsigned PrismRule6::edge_nodes[9][2] =
{
{0, 1}, // Edge 0
{1, 2}, // Edge 1
{0, 2}, // Edge 2
{0, 3}, // Edge 3
{1, 4}, // Edge 4
{2, 5}, // Edge 5
{3, 4}, // Edge 6
{4, 5}, // Edge 7
{3, 5} // Edge 8
const unsigned PrismRule6::edge_nodes[9][2] = {
{0, 1}, // Edge 0
{1, 2}, // Edge 1
{0, 2}, // Edge 2
{0, 3}, // Edge 3
{1, 4}, // Edge 4
{2, 5}, // Edge 5
{3, 4}, // Edge 6
{4, 5}, // Edge 7
{3, 5} // Edge 8
};
const unsigned PrismRule6::n_face_nodes[5] = { 3, 4, 4, 4, 3 };
const unsigned PrismRule6::n_face_nodes[5] = {3, 4, 4, 4, 3};
const Element* PrismRule6::getFace(const Element* e, unsigned i)
{
......@@ -68,9 +64,12 @@ const Element* PrismRule6::getFace(const Element* e, unsigned i)
double PrismRule6::computeVolume(Node const* const* _nodes)
{
return MathLib::calcTetrahedronVolume(*_nodes[0], *_nodes[1], *_nodes[2], *_nodes[3])
+ MathLib::calcTetrahedronVolume(*_nodes[1], *_nodes[4], *_nodes[2], *_nodes[3])
+ MathLib::calcTetrahedronVolume(*_nodes[2], *_nodes[4], *_nodes[5], *_nodes[3]);
return MathLib::calcTetrahedronVolume(
*_nodes[0], *_nodes[1], *_nodes[2], *_nodes[3]) +
MathLib::calcTetrahedronVolume(
*_nodes[1], *_nodes[4], *_nodes[2], *_nodes[3]) +
MathLib::calcTetrahedronVolume(
*_nodes[2], *_nodes[4], *_nodes[5], *_nodes[3]);
}
bool PrismRule6::isPntInElement(Node const* const* nodes,
......@@ -87,7 +86,7 @@ bool PrismRule6::isPntInElement(Node const* const* nodes,
unsigned PrismRule6::identifyFace(Node const* const* _nodes, Node* nodes[3])
{
for (unsigned i=0; i<5; i++)
for (unsigned i = 0; i < 5; i++)
{
unsigned flag(0);
for (unsigned j = 0; j < 4; j++)
......@@ -114,7 +113,7 @@ ElementErrorCode PrismRule6::validate(const Element* e)
ElementErrorCode error_code;
error_code[ElementErrorFlag::ZeroVolume] = hasZeroVolume(*e);
for (unsigned i=1; i<4; ++i)
for (unsigned i = 1; i < 4; ++i)
{
const auto* quad(dynamic_cast<const MeshLib::Quad*>(e->getFace(i)));
if (quad)
......@@ -131,4 +130,4 @@ ElementErrorCode PrismRule6::validate(const Element* e)
return error_code;
}
} // end namespace MeshLib
} // end namespace MeshLib
......@@ -11,39 +11,36 @@
#include "PyramidRule13.h"
#include "BaseLib/Logging.h"
#include "MeshLib/Node.h"
#include "Quad.h"
#include "Tri.h"
namespace MeshLib {
const unsigned PyramidRule13::face_nodes[5][8] =
namespace MeshLib
{
{0, 1, 4, 5, 10, 9, 99, 99}, // Face 0
{1, 2, 4, 6, 11, 10, 99, 99}, // Face 1
{2, 3, 4, 7, 12, 11, 99, 99}, // Face 2
{3, 0, 4, 8, 9, 12, 99, 99}, // Face 3
{0, 3, 2, 1, 8, 7, 6, 5} // Face 4
const unsigned PyramidRule13::face_nodes[5][8] = {
{0, 1, 4, 5, 10, 9, 99, 99}, // Face 0
{1, 2, 4, 6, 11, 10, 99, 99}, // Face 1
{2, 3, 4, 7, 12, 11, 99, 99}, // Face 2
{3, 0, 4, 8, 9, 12, 99, 99}, // Face 3
{0, 3, 2, 1, 8, 7, 6, 5} // Face 4
};
const unsigned PyramidRule13::edge_nodes[8][3] =
{
{0, 1, 5}, // Edge 0
{1, 2, 6}, // Edge 1
{2, 3, 7}, // Edge 2
{0, 3, 8}, // Edge 3
{0, 4, 9}, // Edge 4
{1, 4, 10}, // Edge 5
{2, 4, 11}, // Edge 6
{3, 4, 12} // Edge 7
const unsigned PyramidRule13::edge_nodes[8][3] = {
{0, 1, 5}, // Edge 0
{1, 2, 6}, // Edge 1
{2, 3, 7}, // Edge 2
{0, 3, 8}, // Edge 3
{0, 4, 9}, // Edge 4
{1, 4, 10}, // Edge 5
{2, 4, 11}, // Edge 6
{3, 4, 12} // Edge 7
};
const unsigned PyramidRule13::n_face_nodes[5] = { 6, 6, 6, 6, 8 };
const unsigned PyramidRule13::n_face_nodes[5] = {6, 6, 6, 6, 8};
const Element* PyramidRule13::getFace(const Element* e, unsigned i)
{
if (i<e->getNumberOfFaces())
if (i < e->getNumberOfFaces())
{
unsigned nFaceNodes(PyramidRule13::n_face_nodes[i]);
auto** nodes = new Node*[nFaceNodes];
......@@ -63,4 +60,4 @@ const Element* PyramidRule13::getFace(const Element* e, unsigned i)
return nullptr;
}
} // end namespace MeshLib
} // end namespace MeshLib
......@@ -11,41 +11,37 @@
#include "PyramidRule5.h"
#include "BaseLib/Logging.h"
#include "MathLib/GeometricBasics.h"
#include "MeshLib/Node.h"
#include "Quad.h"
#include "Tri.h"
namespace MeshLib {
const unsigned PyramidRule5::face_nodes[5][4] =
namespace MeshLib
{
{0, 1, 4, 99}, // Face 0
{1, 2, 4, 99}, // Face 1
{2, 3, 4, 99}, // Face 2
{3, 0, 4, 99}, // Face 3
{0, 3, 2, 1} // Face 4
const unsigned PyramidRule5::face_nodes[5][4] = {
{0, 1, 4, 99}, // Face 0
{1, 2, 4, 99}, // Face 1
{2, 3, 4, 99}, // Face 2
{3, 0, 4, 99}, // Face 3
{0, 3, 2, 1} // Face 4
};
const unsigned PyramidRule5::edge_nodes[8][2] =
{
{0, 1}, // Edge 0
{1, 2}, // Edge 1
{2, 3}, // Edge 2
{0, 3}, // Edge 3
{0, 4}, // Edge 4
{1, 4}, // Edge 5
{2, 4}, // Edge 6
{3, 4} // Edge 7
const unsigned PyramidRule5::edge_nodes[8][2] = {
{0, 1}, // Edge 0
{1, 2}, // Edge 1
{2, 3}, // Edge 2
{0, 3}, // Edge 3
{0, 4}, // Edge 4
{1, 4}, // Edge 5
{2, 4}, // Edge 6
{3, 4} // Edge 7
};
const unsigned PyramidRule5::n_face_nodes[5] = { 3, 3, 3, 3, 4 };
const unsigned PyramidRule5::n_face_nodes[5] = {3, 3, 3, 3, 4};
const Element* PyramidRule5::getFace(const Element* e, unsigned i)
{
if (i<e->getNumberOfFaces())
if (i < e->getNumberOfFaces())
{
unsigned nFaceNodes(PyramidRule5::n_face_nodes[i]);
auto** nodes = new Node*[nFaceNodes];
......@@ -67,8 +63,10 @@ const Element* PyramidRule5::getFace(const Element* e, unsigned i)
double PyramidRule5::computeVolume(Node const* const* _nodes)
{
return MathLib::calcTetrahedronVolume(*_nodes[0], *_nodes[1], *_nodes[2], *_nodes[4])
+ MathLib::calcTetrahedronVolume(*_nodes[2], *_nodes[3], *_nodes[0], *_nodes[4]);
return MathLib::calcTetrahedronVolume(
*_nodes[0], *_nodes[1], *_nodes[2], *_nodes[4]) +
MathLib::calcTetrahedronVolume(
*_nodes[2], *_nodes[3], *_nodes[0], *_nodes[4]);
}
bool PyramidRule5::isPntInElement(Node const* const* nodes,
......@@ -83,7 +81,7 @@ bool PyramidRule5::isPntInElement(Node const* const* nodes,
unsigned PyramidRule5::identifyFace(Node const* const* _nodes, Node* nodes[3])
{
for (unsigned i=0; i<5; i++)
for (unsigned i = 0; i < 5; i++)
{
unsigned flag(0);
for (unsigned j = 0; j < 4; j++)
......@@ -125,4 +123,4 @@ ElementErrorCode PyramidRule5::validate(const Element* e)
return error_code;
}
} // end namespace MeshLib
} // end namespace MeshLib
......@@ -11,23 +11,21 @@
#include "QuadRule4.h"
#include "MathLib/GeometricBasics.h"
#include "MeshLib/Node.h"
namespace MeshLib {
const unsigned QuadRule4::edge_nodes[4][2] =
namespace MeshLib
{
{0, 1}, // Edge 0
{1, 2}, // Edge 1
{2, 3}, // Edge 2
{3, 0} // Edge 3
const unsigned QuadRule4::edge_nodes[4][2] = {
{0, 1}, // Edge 0
{1, 2}, // Edge 1
{2, 3}, // Edge 2
{3, 0} // Edge 3
};
double QuadRule4::computeVolume(Node const* const* _nodes)
{
return MathLib::calcTriangleArea(*_nodes[0], *_nodes[1], *_nodes[2])
+ MathLib::calcTriangleArea(*_nodes[2], *_nodes[3], *_nodes[0]);
return MathLib::calcTriangleArea(*_nodes[0], *_nodes[1], *_nodes[2]) +
MathLib::calcTriangleArea(*_nodes[2], *_nodes[3], *_nodes[0]);
}
bool QuadRule4::isPntInElement(Node const* const* nodes,
......@@ -41,7 +39,7 @@ bool QuadRule4::isPntInElement(Node const* const* nodes,
unsigned QuadRule4::identifyFace(Node const* const* _nodes, Node* nodes[3])
{
for (unsigned i=0; i<4; i++)
for (unsigned i = 0; i < 4; i++)
{
unsigned flag(0);
for (unsigned j = 0; j < 2; j++)
......@@ -83,4 +81,4 @@ ElementErrorCode QuadRule4::validate(const Element* e)
return error_code;
}
} // end namespace MeshLib
} // end namespace MeshLib
......@@ -10,14 +10,13 @@
#include "QuadRule8.h"
namespace MeshLib {
const unsigned QuadRule8::edge_nodes[4][3] =
namespace MeshLib
{
{0, 1, 4}, // Edge 0
{1, 2, 5}, // Edge 1
{2, 3, 6}, // Edge 2
{0, 3, 7} // Edge 3
const unsigned QuadRule8::edge_nodes[4][3] = {
{0, 1, 4}, // Edge 0
{1, 2, 5}, // Edge 1
{2, 3, 6}, // Edge 2
{0, 3, 7} // Edge 3
};
} // end namespace MeshLib
} // end namespace MeshLib
......@@ -11,8 +11,8 @@
#include "TemplateElement.h"
#include "MeshLib/Elements/Hex.h"
#include "MeshLib/Elements/Point.h"
#include "MeshLib/Elements/Line.h"
#include "MeshLib/Elements/Point.h"
#include "MeshLib/Elements/Prism.h"
#include "MeshLib/Elements/Pyramid.h"
#include "MeshLib/Elements/Quad.h"
......@@ -30,7 +30,7 @@ const unsigned MeshLib::TemplateElement<ELEMENT_RULE>::n_base_nodes;
template <class ELEMENT_RULE>
const unsigned MeshLib::TemplateElement<ELEMENT_RULE>::dimension;
#endif // WIN32
#endif // WIN32
template class MeshLib::TemplateElement<MeshLib::HexRule20>;
template class MeshLib::TemplateElement<MeshLib::HexRule8>;
......
......@@ -13,36 +13,32 @@
#include <array>
#include "BaseLib/Logging.h"
#include "MeshLib/Node.h"
#include "Tri.h"
namespace MeshLib
{
const unsigned TetRule10::face_nodes[4][6] =
{
{0, 2, 1, 6, 5, 4}, // Face 0
{0, 1, 3, 4, 8, 7}, // Face 1
{1, 2, 3, 5, 9, 8}, // Face 2
{2, 0, 3, 6, 7, 9} // Face 3
const unsigned TetRule10::face_nodes[4][6] = {
{0, 2, 1, 6, 5, 4}, // Face 0
{0, 1, 3, 4, 8, 7}, // Face 1
{1, 2, 3, 5, 9, 8}, // Face 2
{2, 0, 3, 6, 7, 9} // Face 3
};
const unsigned TetRule10::edge_nodes[6][3] =
{
{0, 1, 4}, // Edge 0
{1, 2, 5}, // Edge 1
{0, 2, 6}, // Edge 2
{0, 3, 7}, // Edge 3
{1, 3, 8}, // Edge 4
{2, 3, 9} // Edge 5
const unsigned TetRule10::edge_nodes[6][3] = {
{0, 1, 4}, // Edge 0
{1, 2, 5}, // Edge 1
{0, 2, 6}, // Edge 2
{0, 3, 7}, // Edge 3
{1, 3, 8}, // Edge 4
{2, 3, 9} // Edge 5
};
const Element* TetRule10::getFace(const Element* e, unsigned i)
{
if (i<n_faces)
if (i < n_faces)
{
std::array<Node*,6> nodes{};
std::array<Node*, 6> nodes{};
for (unsigned j = 0; j < 6; j++)
{
nodes[j] = const_cast<Node*>(e->getNode(face_nodes[i][j]));
......@@ -53,4 +49,4 @@ const Element* TetRule10::getFace(const Element* e, unsigned i)
return nullptr;
}
} // end namespace MeshLib
} // end namespace MeshLib
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