Skip to content
Snippets Groups Projects
Commit 372155c9 authored by Karsten Rink's avatar Karsten Rink
Browse files

changed size_t to unsigned; included a few (yet unimplemented) methods for...

changed size_t to unsigned; included a few (yet unimplemented) methods for mesh-consistency checking
parent 3fbc9815
No related branches found
No related tags found
No related merge requests found
Showing
with 109 additions and 115 deletions
...@@ -31,6 +31,7 @@ ENDIF() # GCC AND GPROF_PATH ...@@ -31,6 +31,7 @@ ENDIF() # GCC AND GPROF_PATH
# Add subdirectories with the projects # Add subdirectories with the projects
ADD_SUBDIRECTORY( Base ) ADD_SUBDIRECTORY( Base )
ADD_SUBDIRECTORY( FileIO )
ADD_SUBDIRECTORY( GeoLib ) ADD_SUBDIRECTORY( GeoLib )
ADD_SUBDIRECTORY( MathLib ) ADD_SUBDIRECTORY( MathLib )
ADD_SUBDIRECTORY( MeshLib ) ADD_SUBDIRECTORY( MeshLib )
......
...@@ -227,17 +227,6 @@ void PointVec::makePntsUnique (std::vector<GEOLIB::Point*>* pnt_vec, std::vector ...@@ -227,17 +227,6 @@ void PointVec::makePntsUnique (std::vector<GEOLIB::Point*>* pnt_vec, std::vector
} }
} }
// KR correct renumbering of indices
// size_t cnt(0);
// std::map<size_t, size_t> reg_ids;
// for (size_t k(0); k < n_pnts_in_file; k++) {
// if (pnt_id_map[k] == k) {
// reg_ids.insert(std::pair<size_t, size_t>(k, cnt));
// cnt++;
// } else reg_ids.insert(std::pair<size_t, size_t>(k, reg_ids[pnt_id_map[k]]));
// }
// for (size_t k(0); k < n_pnts_in_file; k++)
// pnt_id_map[k] = reg_ids[k];
} }
void PointVec::calculateShortestDistance () void PointVec::calculateShortestDistance ()
......
...@@ -86,7 +86,7 @@ double getAngle (const double p0[3], const double p1[3], const double p2[3]) ...@@ -86,7 +86,7 @@ double getAngle (const double p0[3], const double p1[3], const double p2[3])
return acos (scpr (v0,v1,3) / (sqrt(scpr(v0,v0,3)) * sqrt(scpr (v1,v1,3)))); return acos (scpr (v0,v1,3) / (sqrt(scpr(v0,v0,3)) * sqrt(scpr (v1,v1,3))));
} }
double calcDetTriangle(const double p0[3], const double p1[3], const double p2[3]) double calcTriangleaArea(const double p0[3], const double p1[3], const double p2[3])
{ {
const double u0 (p2[0] - p0[0]); const double u0 (p2[0] - p0[0]);
const double u1 (p2[1] - p0[1]); const double u1 (p2[1] - p0[1]);
...@@ -103,7 +103,7 @@ double calcDetTriangle(const double p0[3], const double p1[3], const double p2[3 ...@@ -103,7 +103,7 @@ double calcDetTriangle(const double p0[3], const double p1[3], const double p2[3
return 0.5 * sqrt(z0*z0 + z1*z1 + z2 * z2); return 0.5 * sqrt(z0*z0 + z1*z1 + z2 * z2);
} }
double calcDetTetrahedron(const double* x1, const double* x2, const double* x3, const double* x4) double calcTetrahedronVolume(const double* x1, const double* x2, const double* x3, const double* x4)
{ {
return fabs((x1[0] - x4[0]) * ((x2[1] - x4[1]) * (x3[2] - x4[2]) - (x2[2] - x4[2]) * (x3[1] - x4[1])) return fabs((x1[0] - x4[0]) * ((x2[1] - x4[1]) * (x3[2] - x4[2]) - (x2[2] - x4[2]) * (x3[1] - x4[1]))
- (x1[1] - x4[1]) * ((x2[0] - x4[0]) * (x3[2] - x4[2]) - (x2[2] - x4[2]) * (x3[0] - x4[0])) - (x1[1] - x4[1]) * ((x2[0] - x4[0]) * (x3[2] - x4[2]) - (x2[2] - x4[2]) * (x3[0] - x4[0]))
......
...@@ -94,9 +94,17 @@ float normalize(float min, float max, float val); ...@@ -94,9 +94,17 @@ float normalize(float min, float max, float val);
*/ */
double getAngle (const double p0[3], const double p1[3], const double p2[3]); double getAngle (const double p0[3], const double p1[3], const double p2[3]);
double calcDetTriangle(const double p0[3], const double p1[3], const double p2[3]); /**
* Calculates the area of a triangle.
* The formula is A=.5*|u x v|, i.e. half of the area of the parallelogram specified by u=p0->p1 and v=p0->p2.
*/
double calcTriangleArea(const double p0[3], const double p1[3], const double p2[3]);
double calcDetTetrahedron(const double* x1, const double* x2, const double* x3, const double* x4); /**
* Calculates the volume of a tetrahedron.
* The formula is V=1/6*|a(b x c)| with a=x1->x2, b=x1->x3 and c=x1->x4.
*/
double calcTetrahedronVolume(const double* x1, const double* x2, const double* x3, const double* x4);
/** /**
* simple power function that takes as a second argument an integer instead of a float * simple power function that takes as a second argument an integer instead of a float
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
namespace MeshLib { namespace MeshLib {
/* /*
Cell::Cell(Node** nodes, MshElemType::type type, size_t value) Cell::Cell(Node** nodes, MshElemType::type type, unsigned value)
: Element(nodes, type, value) : Element(nodes, type, value)
{ {
} }
*/ */
Cell::Cell(MshElemType::type type, size_t value) Cell::Cell(MshElemType::type type, unsigned value)
: Element(type, value) : Element(type, value)
{ {
} }
......
...@@ -22,7 +22,7 @@ public: ...@@ -22,7 +22,7 @@ public:
virtual double getVolume() const { return _volume; }; virtual double getVolume() const { return _volume; };
/// Get dimension of the mesh element. /// Get dimension of the mesh element.
size_t getDimension() const { return 3; }; unsigned getDimension() const { return 3; };
/// Destructor /// Destructor
virtual ~Cell(); virtual ~Cell();
...@@ -30,10 +30,10 @@ public: ...@@ -30,10 +30,10 @@ public:
protected: protected:
/* /*
/// Constructor for a generic mesh element containing an array of mesh nodes. /// Constructor for a generic mesh element containing an array of mesh nodes.
Cell(Node** nodes, MshElemType::type type, size_t value = 0); Cell(Node** nodes, MshElemType::type type, unsigned value = 0);
*/ */
/// Constructor for a generic mesh element without an array of mesh nodes. /// Constructor for a generic mesh element without an array of mesh nodes.
Cell(MshElemType::type type, size_t value = 0); Cell(MshElemType::type type, unsigned value = 0);
/// Calculate the volume of this 3d element. /// Calculate the volume of this 3d element.
virtual double calcVolume() = 0; virtual double calcVolume() = 0;
...@@ -42,7 +42,7 @@ protected: ...@@ -42,7 +42,7 @@ protected:
}; /* class */ }; /* class */
} /* namespace */ }
#endif /* CELL_H_ */ #endif /* CELL_H_ */
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
namespace MeshLib { namespace MeshLib {
Edge::Edge(Node* nodes[2], size_t value) Edge::Edge(Node* nodes[2], unsigned value)
: Element(MshElemType::LINE, value) : Element(MshElemType::LINE, value)
{ {
_nodes = nodes; _nodes = nodes;
this->_length = this->calcLength(); this->_length = this->calcLength();
} }
Edge::Edge(Node* n0, Node* n1, size_t value) Edge::Edge(Node* n0, Node* n1, unsigned value)
: Element(MshElemType::LINE, value) : Element(MshElemType::LINE, value)
{ {
_nodes = new Node*[2]; _nodes = new Node*[2];
......
...@@ -27,10 +27,10 @@ class Edge : public Element ...@@ -27,10 +27,10 @@ class Edge : public Element
{ {
public: public:
/// Constructor with an array of mesh nodes. /// Constructor with an array of mesh nodes.
Edge(Node* nodes[2], size_t value = 0); Edge(Node* nodes[2], unsigned value = 0);
/// Constructor using single nodes /// Constructor using single nodes
Edge(Node* n1, Node* n2, size_t value = 0); Edge(Node* n1, Node* n2, unsigned value = 0);
/// Copy constructor /// Copy constructor
Edge(const Edge &edge); Edge(const Edge &edge);
...@@ -39,22 +39,22 @@ public: ...@@ -39,22 +39,22 @@ public:
virtual ~Edge(); virtual ~Edge();
/// 1D elements have no edges /// 1D elements have no edges
size_t getNEdges() const { return 0; }; unsigned getNEdges() const { return 0; };
/// Get the number of faces for this element. /// Get the number of faces for this element.
size_t getNFaces() const { return 0; }; unsigned getNFaces() const { return 0; };
/// Get the length of this 1d element. /// Get the length of this 1d element.
double getLength() const { return _length; }; double getLength() const { return _length; };
/// Get dimension of the mesh element. /// Get dimension of the mesh element.
size_t getDimension() const { return 1; }; unsigned getDimension() const { return 1; };
/// Get the number of neighbors for this element. /// Get the number of neighbors for this element.
size_t getNNeighbors() const { return 0; }; unsigned getNNeighbors() const { return 0; };
/// Get the number of nodes for this element. /// Get the number of nodes for this element.
virtual size_t getNNodes() const { return 2; }; virtual unsigned getNNodes() const { return 2; };
protected: protected:
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
namespace MeshLib { namespace MeshLib {
/* /*
Element::Element(Node** nodes, MshElemType::type type, size_t value) Element::Element(Node** nodes, MshElemType::type type, unsigned value)
: _nodes(nodes), _type(type), _value(value) : _nodes(nodes), _type(type), _value(value)
{ {
} }
*/ */
Element::Element(MshElemType::type type, size_t value) Element::Element(MshElemType::type type, unsigned value)
: _nodes(NULL), _type(type), _value(value) : _nodes(NULL), _type(type), _value(value)
{ {
} }
...@@ -29,20 +29,20 @@ Element::~Element() ...@@ -29,20 +29,20 @@ Element::~Element()
delete[] this->_neighbors; delete[] this->_neighbors;
} }
const Element* Element::getNeighbor(size_t i) const const Element* Element::getNeighbor(unsigned i) const
{ {
assert(i < getNNeighbors() && "Error in MeshLib::Element::getNeighbor() - Index does not exist."); assert(i < getNNeighbors() && "Error in MeshLib::Element::getNeighbor() - Index does not exist.");
return _neighbors[i]; return _neighbors[i];
} }
const Node* Element::getNode(size_t i) const const Node* Element::getNode(unsigned i) const
{ {
assert(i < getNNodes() && "Error in MeshLib::Element::getNode() - Index does not exist."); assert(i < getNNodes() && "Error in MeshLib::Element::getNode() - Index does not exist.");
assert(_nodes[i] != NULL && "Error in MeshLib::Element::getNode() - Node is NULL."); assert(_nodes[i] != NULL && "Error in MeshLib::Element::getNode() - Node is NULL.");
return _nodes[i]; return _nodes[i];
} }
size_t Element::getNodeIndex(size_t i) const unsigned Element::getNodeIndex(unsigned i) const
{ {
assert(i<getNNodes() && "Error in MeshLib::Element::getNodeIndex() - Index does not exist."); assert(i<getNNodes() && "Error in MeshLib::Element::getNodeIndex() - Index does not exist.");
return _nodes[i]->getID(); return _nodes[i]->getID();
...@@ -50,8 +50,8 @@ size_t Element::getNodeIndex(size_t i) const ...@@ -50,8 +50,8 @@ size_t Element::getNodeIndex(size_t i) const
bool Element::hasNeighbor(Element* elem) const bool Element::hasNeighbor(Element* elem) const
{ {
size_t nNeighbors (this->getNNeighbors()); unsigned nNeighbors (this->getNNeighbors());
for (size_t i=0; i<nNeighbors; i++) for (unsigned i=0; i<nNeighbors; i++)
if (this->_neighbors[i]==elem) if (this->_neighbors[i]==elem)
return true; return true;
return false; return false;
......
...@@ -21,39 +21,44 @@ class Node; ...@@ -21,39 +21,44 @@ class Node;
*/ */
class Element class Element
{ {
/* friend functions: */
friend void Mesh::setElementInformationForNodes();
friend void Mesh::addElement(Element*);
public: public:
/// Get node with local index i. /// Get node with local index i.
const Node* getNode(size_t i) const; const Node* getNode(unsigned i) const;
/// Get array of element nodes. /// Get array of element nodes.
Node* const* getNodes() const { return _nodes; }; Node* const* getNodes() const { return _nodes; };
/// Get dimension of the mesh element. /// Get dimension of the mesh element.
virtual size_t getDimension() const = 0; virtual unsigned getDimension() const = 0;
/// Get the number of edges for this element. /// Get the number of edges for this element.
virtual size_t getNEdges() const = 0; virtual unsigned getNEdges() const = 0;
/// Get the number of faces for this element. /// Get the number of faces for this element.
virtual size_t getNFaces() const = 0; virtual unsigned getNFaces() const = 0;
/// Get the specified neighbor. /// Get the specified neighbor.
const Element* getNeighbor(size_t i) const; const Element* getNeighbor(unsigned i) const;
/// Get the number of neighbors for this element. /// Get the number of neighbors for this element.
virtual size_t getNNeighbors() const = 0; virtual unsigned getNNeighbors() const = 0;
/// Get the number of nodes for this element. /// Get the number of nodes for this element.
virtual size_t getNNodes() const = 0; virtual unsigned getNNodes() const = 0;
/// Get the global index for the node with local index i. /// Get the global index for the node with local index i.
size_t getNodeIndex(size_t i) const; unsigned getNodeIndex(unsigned i) const;
/// Get the type of the mesh element (as a MshElemType-enum). /// Get the type of the mesh element (as a MshElemType-enum).
MshElemType::type getType() const { return _type; }; MshElemType::type getType() const { return _type; };
/// Get the value for this element. /// Get the value for this element.
size_t getValue() const { return _value; }; unsigned getValue() const { return _value; };
bool hasNeighbor(Element* elem) const; bool hasNeighbor(Element* elem) const;
...@@ -63,27 +68,18 @@ public: ...@@ -63,27 +68,18 @@ public:
protected: protected:
/* /*
/// Constructor for a generic mesh element containing an array of mesh nodes. /// Constructor for a generic mesh element containing an array of mesh nodes.
Element(Node** nodes, MshElemType::type type, size_t value = 0); Element(Node** nodes, MshElemType::type type, unsigned value = 0);
*/ */
/// Constructor for a generic mesh element without an array of mesh nodes. /// Constructor for a generic mesh element without an array of mesh nodes.
Element(MshElemType::type type, size_t value = 0); Element(MshElemType::type type, unsigned value = 0);
/**
* Get an editale Node.
* This method is called by Mesh::addElement(Element*), see friend definition.
*/
Node* getNode(size_t i);
Node** _nodes; Node** _nodes;
MshElemType::type _type; MshElemType::type _type;
size_t _value; unsigned _value;
Element** _neighbors; Element** _neighbors;
private: private:
/* friend functions: */
friend void Mesh::addElement(Element*);
}; /* class */ }; /* class */
} /* namespace */ } /* namespace */
......
...@@ -9,12 +9,12 @@ ...@@ -9,12 +9,12 @@
namespace MeshLib { namespace MeshLib {
/* /*
Face::Face(Node** nodes, MshElemType::type type, size_t value) Face::Face(Node** nodes, MshElemType::type type, unsigned value)
: Element(nodes, type, value) : Element(nodes, type, value)
{ {
} }
*/ */
Face::Face(MshElemType::type type, size_t value) Face::Face(MshElemType::type type, unsigned value)
: Element(type, value) : Element(type, value)
{ {
} }
......
...@@ -22,10 +22,10 @@ public: ...@@ -22,10 +22,10 @@ public:
virtual double getArea() const { return _area; }; virtual double getArea() const { return _area; };
/// Get dimension of the mesh element. /// Get dimension of the mesh element.
size_t getDimension() const { return 2; }; unsigned getDimension() const { return 2; };
/// 2D elements have no faces. /// 2D elements have no faces.
size_t getNFaces() const { return 0; }; unsigned getNFaces() const { return 0; };
/// Destructor /// Destructor
virtual ~Face(); virtual ~Face();
...@@ -33,10 +33,10 @@ public: ...@@ -33,10 +33,10 @@ public:
protected: protected:
/* /*
/// Constructor for a generic mesh element containing an array of mesh nodes. /// Constructor for a generic mesh element containing an array of mesh nodes.
Face(Node** nodes, MshElemType::type type, size_t value = 0); Face(Node** nodes, MshElemType::type type, unsigned value = 0);
*/ */
/// Constructor for a generic mesh element without an array of mesh nodes. /// Constructor for a generic mesh element without an array of mesh nodes.
Face(MshElemType::type type, size_t value = 0); Face(MshElemType::type type, unsigned value = 0);
/// Calculate the area of this 2d element. /// Calculate the area of this 2d element.
virtual double calcArea() = 0; virtual double calcArea() = 0;
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
namespace MeshLib { namespace MeshLib {
FemElem::FemElem() FemElem::FemElem()
: _centre_of_gravity(GEOLIB::Point(0,0,0)) : _centroid(GEOLIB::Point(0,0,0))
{ {
} }
FemElem::FemElem(const FemElem &elem) FemElem::FemElem(const FemElem &elem)
: _centre_of_gravity(elem.getCentreOfGravity()) : _centroid(elem.getCentroid())
{ {
} }
......
...@@ -22,7 +22,7 @@ public: ...@@ -22,7 +22,7 @@ public:
virtual ~FemElem(); virtual ~FemElem();
/// Get the number of nodes for this element. /// Get the number of nodes for this element.
const GEOLIB::Point& getCentreOfGravity() const { return _centre_of_gravity; }; const GEOLIB::Point& getCentroid() const { return _centroid; };
protected: protected:
/// Constructor. /// Constructor.
...@@ -32,9 +32,9 @@ protected: ...@@ -32,9 +32,9 @@ protected:
FemElem(const FemElem &elem); FemElem(const FemElem &elem);
/// Calculate centre of gravity /// Calculate centre of gravity
virtual void calcCoG() = 0; virtual void calcCentroid() = 0;
GEOLIB::Point _centre_of_gravity; GEOLIB::Point _centroid;
}; /* class */ }; /* class */
......
...@@ -13,17 +13,17 @@ ...@@ -13,17 +13,17 @@
namespace MeshLib { namespace MeshLib {
Hex::Hex(Node* nodes[8], size_t value) Hex::Hex(Node* nodes[8], unsigned value)
: Cell(MshElemType::HEXAHEDRON, value) : Cell(MshElemType::HEXAHEDRON, value)
{ {
_nodes = nodes; _nodes = nodes;
_neighbors = new Element*[6]; _neighbors = new Element*[6];
for (size_t i=0; i<6; i++) for (unsigned i=0; i<6; i++)
_neighbors[i] = NULL; _neighbors[i] = NULL;
this->_volume = this->calcVolume(); this->_volume = this->calcVolume();
} }
Hex::Hex(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, Node* n6, Node* n7, size_t value) Hex::Hex(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, Node* n6, Node* n7, unsigned value)
: Cell(MshElemType::HEXAHEDRON, value) : Cell(MshElemType::HEXAHEDRON, value)
{ {
_nodes = new Node*[8]; _nodes = new Node*[8];
...@@ -36,7 +36,7 @@ Hex::Hex(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, Node* n6, N ...@@ -36,7 +36,7 @@ Hex::Hex(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, Node* n6, N
_nodes[6] = n6; _nodes[6] = n6;
_nodes[7] = n7; _nodes[7] = n7;
_neighbors = new Element*[6]; _neighbors = new Element*[6];
for (size_t i=0; i<6; i++) for (unsigned i=0; i<6; i++)
_neighbors[i] = NULL; _neighbors[i] = NULL;
this->_volume = this->calcVolume(); this->_volume = this->calcVolume();
} }
...@@ -45,10 +45,10 @@ Hex::Hex(const Hex &hex) ...@@ -45,10 +45,10 @@ Hex::Hex(const Hex &hex)
: Cell(MshElemType::HEXAHEDRON, hex.getValue()) : Cell(MshElemType::HEXAHEDRON, hex.getValue())
{ {
_nodes = new Node*[8]; _nodes = new Node*[8];
for (size_t i=0; i<8; i++) for (unsigned i=0; i<8; i++)
_nodes[i] = hex._nodes[i]; _nodes[i] = hex._nodes[i];
_neighbors = new Element*[6]; _neighbors = new Element*[6];
for (size_t i=0; i<6; i++) for (unsigned i=0; i<6; i++)
_neighbors[i] = hex._neighbors[i]; _neighbors[i] = hex._neighbors[i];
_volume = hex.getVolume(); _volume = hex.getVolume();
} }
...@@ -59,12 +59,12 @@ Hex::~Hex() ...@@ -59,12 +59,12 @@ Hex::~Hex()
double Hex::calcVolume() double Hex::calcVolume()
{ {
return MathLib::calcDetTetrahedron(_nodes[4]->getData(), _nodes[7]->getData(), _nodes[5]->getData(), _nodes[0]->getData()) return MathLib::calcTetrahedronVolume(_nodes[4]->getData(), _nodes[7]->getData(), _nodes[5]->getData(), _nodes[0]->getData())
+ MathLib::calcDetTetrahedron(_nodes[5]->getData(), _nodes[3]->getData(), _nodes[1]->getData(), _nodes[0]->getData()) + MathLib::calcTetrahedronVolume(_nodes[5]->getData(), _nodes[3]->getData(), _nodes[1]->getData(), _nodes[0]->getData())
+ MathLib::calcDetTetrahedron(_nodes[5]->getData(), _nodes[7]->getData(), _nodes[3]->getData(), _nodes[0]->getData()) + MathLib::calcTetrahedronVolume(_nodes[5]->getData(), _nodes[7]->getData(), _nodes[3]->getData(), _nodes[0]->getData())
+ MathLib::calcDetTetrahedron(_nodes[5]->getData(), _nodes[7]->getData(), _nodes[6]->getData(), _nodes[2]->getData()) + MathLib::calcTetrahedronVolume(_nodes[5]->getData(), _nodes[7]->getData(), _nodes[6]->getData(), _nodes[2]->getData())
+ MathLib::calcDetTetrahedron(_nodes[1]->getData(), _nodes[3]->getData(), _nodes[5]->getData(), _nodes[2]->getData()) + MathLib::calcTetrahedronVolume(_nodes[1]->getData(), _nodes[3]->getData(), _nodes[5]->getData(), _nodes[2]->getData())
+ MathLib::calcDetTetrahedron(_nodes[3]->getData(), _nodes[7]->getData(), _nodes[5]->getData(), _nodes[2]->getData()); + MathLib::calcTetrahedronVolume(_nodes[3]->getData(), _nodes[7]->getData(), _nodes[5]->getData(), _nodes[2]->getData());
} }
} }
......
...@@ -35,10 +35,10 @@ class Hex : public Cell ...@@ -35,10 +35,10 @@ class Hex : public Cell
{ {
public: public:
/// Constructor with an array of mesh nodes. /// Constructor with an array of mesh nodes.
Hex(Node* nodes[8], size_t value = 0); Hex(Node* nodes[8], unsigned value = 0);
/// Constructor using single mesh nodes. /// Constructor using single mesh nodes.
Hex(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, Node* n6, Node* n7, size_t value); Hex(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, Node* n6, Node* n7, unsigned value);
/// Copy constructor /// Copy constructor
Hex(const Hex &hex); Hex(const Hex &hex);
...@@ -47,16 +47,16 @@ public: ...@@ -47,16 +47,16 @@ public:
virtual ~Hex(); virtual ~Hex();
/// Get the number of edges for this element. /// Get the number of edges for this element.
size_t getNEdges() const { return 12; }; unsigned getNEdges() const { return 12; };
/// Get the number of faces for this element. /// Get the number of faces for this element.
size_t getNFaces() const { return 6; }; unsigned getNFaces() const { return 6; };
/// Get the number of neighbors for this element. /// Get the number of neighbors for this element.
size_t getNNeighbors() const { return 6; }; unsigned getNNeighbors() const { return 6; };
/// Get the number of nodes for this element. /// Get the number of nodes for this element.
virtual size_t getNNodes() const { return 8; }; virtual unsigned getNNodes() const { return 8; };
protected: protected:
/// Calculates the volume of a convex hexahedron by partitioning it into six tetrahedra. /// Calculates the volume of a convex hexahedron by partitioning it into six tetrahedra.
......
...@@ -12,17 +12,17 @@ ...@@ -12,17 +12,17 @@
namespace MeshLib { namespace MeshLib {
Prism::Prism(Node* nodes[6], size_t value) Prism::Prism(Node* nodes[6], unsigned value)
: Cell(MshElemType::PRISM, value) : Cell(MshElemType::PRISM, value)
{ {
_nodes = _nodes; _nodes = _nodes;
_neighbors = new Element*[5]; _neighbors = new Element*[5];
for (size_t i=0; i<5; i++) for (unsigned i=0; i<5; i++)
_neighbors[i] = NULL; _neighbors[i] = NULL;
this->_volume = this->calcVolume(); this->_volume = this->calcVolume();
} }
Prism::Prism(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, size_t value) Prism::Prism(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, unsigned value)
: Cell(MshElemType::PRISM, value) : Cell(MshElemType::PRISM, value)
{ {
_nodes = new Node*[6]; _nodes = new Node*[6];
...@@ -33,7 +33,7 @@ Prism::Prism(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, size_t ...@@ -33,7 +33,7 @@ Prism::Prism(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, size_t
_nodes[4] = n4; _nodes[4] = n4;
_nodes[5] = n5; _nodes[5] = n5;
_neighbors = new Element*[5]; _neighbors = new Element*[5];
for (size_t i=0; i<5; i++) for (unsigned i=0; i<5; i++)
_neighbors[i] = NULL; _neighbors[i] = NULL;
this->_volume = this->calcVolume(); this->_volume = this->calcVolume();
} }
...@@ -42,10 +42,10 @@ Prism::Prism(const Prism &prism) ...@@ -42,10 +42,10 @@ Prism::Prism(const Prism &prism)
: Cell(MshElemType::PRISM, prism.getValue()) : Cell(MshElemType::PRISM, prism.getValue())
{ {
_nodes = new Node*[6]; _nodes = new Node*[6];
for (size_t i=0; i<6; i++) for (unsigned i=0; i<6; i++)
_nodes[i] = prism._nodes[i]; _nodes[i] = prism._nodes[i];
_neighbors = new Element*[5]; _neighbors = new Element*[5];
for (size_t i=0; i<5; i++) for (unsigned i=0; i<5; i++)
_neighbors[i] = prism._neighbors[i]; _neighbors[i] = prism._neighbors[i];
_volume = prism.getVolume(); _volume = prism.getVolume();
} }
...@@ -56,9 +56,9 @@ Prism::~Prism() ...@@ -56,9 +56,9 @@ Prism::~Prism()
double Prism::calcVolume() double Prism::calcVolume()
{ {
return MathLib::calcDetTetrahedron(_nodes[0]->getData(), _nodes[1]->getData(), _nodes[2]->getData(), _nodes[3]->getData()) return MathLib::calcTetrahedronVolume(_nodes[0]->getData(), _nodes[1]->getData(), _nodes[2]->getData(), _nodes[3]->getData())
+ MathLib::calcDetTetrahedron(_nodes[1]->getData(), _nodes[4]->getData(), _nodes[2]->getData(), _nodes[3]->getData()) + MathLib::calcTetrahedronVolume(_nodes[1]->getData(), _nodes[4]->getData(), _nodes[2]->getData(), _nodes[3]->getData())
+ MathLib::calcDetTetrahedron(_nodes[2]->getData(), _nodes[4]->getData(), _nodes[5]->getData(), _nodes[3]->getData()); + MathLib::calcTetrahedronVolume(_nodes[2]->getData(), _nodes[4]->getData(), _nodes[5]->getData(), _nodes[3]->getData());
} }
} }
......
...@@ -33,10 +33,10 @@ class Prism : public Cell ...@@ -33,10 +33,10 @@ class Prism : public Cell
{ {
public: public:
/// Constructor with an array of mesh nodes. /// Constructor with an array of mesh nodes.
Prism(Node* nodes[6], size_t value = 0); Prism(Node* nodes[6], unsigned value = 0);
/// Constructor using single mesh nodes. /// Constructor using single mesh nodes.
Prism(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, size_t value = 0); Prism(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, Node* n5, unsigned value = 0);
/// Copy constructor /// Copy constructor
Prism(const Prism &prism); Prism(const Prism &prism);
...@@ -45,16 +45,16 @@ public: ...@@ -45,16 +45,16 @@ public:
virtual ~Prism(); virtual ~Prism();
/// Get the number of edges for this element. /// Get the number of edges for this element.
size_t getNEdges() const { return 9; }; unsigned getNEdges() const { return 9; };
/// Get the number of faces for this element. /// Get the number of faces for this element.
size_t getNFaces() const { return 5; }; unsigned getNFaces() const { return 5; };
/// Get the number of neighbors for this element. /// Get the number of neighbors for this element.
size_t getNNeighbors() const { return 5; }; unsigned getNNeighbors() const { return 5; };
/// Get the number of nodes for this element. /// Get the number of nodes for this element.
virtual size_t getNNodes() const { return 6; }; virtual unsigned getNNodes() const { return 6; };
protected: protected:
/// Calculates the volume of a prism by subdividing it into three tetrahedra. /// Calculates the volume of a prism by subdividing it into three tetrahedra.
......
...@@ -12,17 +12,17 @@ ...@@ -12,17 +12,17 @@
namespace MeshLib { namespace MeshLib {
Pyramid::Pyramid(Node* nodes[5], size_t value) Pyramid::Pyramid(Node* nodes[5], unsigned value)
: Cell(MshElemType::PYRAMID, value) : Cell(MshElemType::PYRAMID, value)
{ {
_nodes = nodes; _nodes = nodes;
_neighbors = new Element*[5]; _neighbors = new Element*[5];
for (size_t i=0; i<5; i++) for (unsigned i=0; i<5; i++)
_neighbors[i] = NULL; _neighbors[i] = NULL;
this->_volume = this->calcVolume(); this->_volume = this->calcVolume();
} }
Pyramid::Pyramid(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, size_t value) Pyramid::Pyramid(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, unsigned value)
: Cell(MshElemType::PYRAMID, value) : Cell(MshElemType::PYRAMID, value)
{ {
_nodes = new Node*[5]; _nodes = new Node*[5];
...@@ -32,7 +32,7 @@ Pyramid::Pyramid(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, size_t value) ...@@ -32,7 +32,7 @@ Pyramid::Pyramid(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, size_t value)
_nodes[3] = n3; _nodes[3] = n3;
_nodes[4] = n4; _nodes[4] = n4;
_neighbors = new Element*[5]; _neighbors = new Element*[5];
for (size_t i=0; i<5; i++) for (unsigned i=0; i<5; i++)
_neighbors[i] = NULL; _neighbors[i] = NULL;
this->_volume = this->calcVolume(); this->_volume = this->calcVolume();
...@@ -43,7 +43,7 @@ Pyramid::Pyramid(const Pyramid &pyramid) ...@@ -43,7 +43,7 @@ Pyramid::Pyramid(const Pyramid &pyramid)
{ {
_nodes = new Node*[5]; _nodes = new Node*[5];
_neighbors = new Element*[5]; _neighbors = new Element*[5];
for (size_t i=0; i<5; i++) for (unsigned i=0; i<5; i++)
{ {
_nodes[i] = pyramid._nodes[i]; _nodes[i] = pyramid._nodes[i];
_neighbors[i] = pyramid._neighbors[i]; _neighbors[i] = pyramid._neighbors[i];
...@@ -57,8 +57,8 @@ Pyramid::~Pyramid() ...@@ -57,8 +57,8 @@ Pyramid::~Pyramid()
double Pyramid::calcVolume() double Pyramid::calcVolume()
{ {
return MathLib::calcDetTetrahedron(_nodes[0]->getData(), _nodes[1]->getData(), _nodes[2]->getData(), _nodes[4]->getData()) return MathLib::calcTetrahedronVolume(_nodes[0]->getData(), _nodes[1]->getData(), _nodes[2]->getData(), _nodes[4]->getData())
+ MathLib::calcDetTetrahedron(_nodes[2]->getData(), _nodes[3]->getData(), _nodes[0]->getData(), _nodes[4]->getData()); + MathLib::calcTetrahedronVolume(_nodes[2]->getData(), _nodes[3]->getData(), _nodes[0]->getData(), _nodes[4]->getData());
} }
} }
......
...@@ -33,10 +33,10 @@ class Pyramid : public Cell ...@@ -33,10 +33,10 @@ class Pyramid : public Cell
{ {
public: public:
/// Constructor with an array of mesh nodes. /// Constructor with an array of mesh nodes.
Pyramid(Node* nodes[5], size_t value = 0); Pyramid(Node* nodes[5], unsigned value = 0);
/// Constructor using single mesh nodes. /// Constructor using single mesh nodes.
Pyramid(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, size_t value = 0); Pyramid(Node* n0, Node* n1, Node* n2, Node* n3, Node* n4, unsigned value = 0);
/// Copy constructor /// Copy constructor
Pyramid(const Pyramid &pyramid); Pyramid(const Pyramid &pyramid);
...@@ -45,16 +45,16 @@ public: ...@@ -45,16 +45,16 @@ public:
virtual ~Pyramid(); virtual ~Pyramid();
/// Get the number of edges for this element. /// Get the number of edges for this element.
size_t getNEdges() const { return 8; }; unsigned getNEdges() const { return 8; };
/// Get the number of faces for this element. /// Get the number of faces for this element.
size_t getNFaces() const { return 5; }; unsigned getNFaces() const { return 5; };
/// Get the number of neighbors for this element. /// Get the number of neighbors for this element.
size_t getNNeighbors() const { return 5; }; unsigned getNNeighbors() const { return 5; };
/// Get the number of nodes for this element. /// Get the number of nodes for this element.
virtual size_t getNNodes() const { return 5; }; virtual unsigned getNNodes() const { return 5; };
protected: protected:
/// Calculates the volume of a prism by subdividing it into two tetrahedra. /// Calculates the volume of a prism by subdividing it into two tetrahedra.
......
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