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

Added basic documentation

parent 67f3dea4
No related branches found
No related tags found
No related merge requests found
...@@ -18,16 +18,23 @@ namespace MeshLib { ...@@ -18,16 +18,23 @@ namespace MeshLib {
class Cell : public Element class Cell : public Element
{ {
public: public:
/// Get the volume of this 3d element.
virtual double getVolume() const { return _volume; }; virtual double getVolume() const { return _volume; };
/// Get dimension of the mesh element.
size_t getDimension() const { return 3; }; size_t getDimension() const { return 3; };
/// Destructor
virtual ~Cell(); virtual ~Cell();
protected: protected:
/// 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, size_t value = 0);
/// Constructor for a generic mesh element without an array of mesh nodes.
Cell(MshElemType::type type, size_t value = 0); Cell(MshElemType::type type, size_t value = 0);
/// Calculate the volume of this 3d element.
virtual double calcVolume() = 0; virtual double calcVolume() = 0;
double _volume; double _volume;
......
...@@ -23,19 +23,30 @@ class Node; ...@@ -23,19 +23,30 @@ class Node;
class Edge : public Element class Edge : public Element
{ {
public: public:
/// Constructor with an array of mesh nodes.
Edge(Node* nodes[2], size_t value = 0); Edge(Node* nodes[2], size_t value = 0);
/// Constructor using single nodes
Edge(Node* n1, Node* n2, size_t value = 0); Edge(Node* n1, Node* n2, size_t value = 0);
/// Copy constructor
Edge(const Edge &edge); Edge(const Edge &edge);
/// Destructor
virtual ~Edge(); virtual ~Edge();
/// Get the length of this 1d element.
double getLength() const { return _length; }; double getLength() const { return _length; };
/// Get dimension of the mesh element.
size_t getDimension() const { return 1; }; size_t getDimension() const { return 1; };
/// Get the number of nodes for this element.
size_t getNNodes() const { return 2; }; size_t getNNodes() const { return 2; };
protected: protected:
/// Calculate the length of this 1d element.
double calcLength(); double calcLength();
double _length; double _length;
......
...@@ -21,23 +21,35 @@ class Node; ...@@ -21,23 +21,35 @@ class Node;
class Element class Element
{ {
public: public:
/// Get node with local index i.
const Node* getNode(size_t i) const; const Node* getNode(size_t i) const;
/// Get array of element nodes.
Node* const* getNodes() const { return _nodes; }; Node* const* getNodes() const { return _nodes; };
/// Get dimension of the mesh element.
virtual size_t getDimension() const = 0; virtual size_t getDimension() const = 0;
/// Get the number of nodes for this element.
virtual size_t getNNodes() const = 0; virtual size_t getNNodes() const = 0;
/// Get the global index for the node with local index i.
size_t getNodeIndex(size_t i) const; size_t getNodeIndex(size_t i) const;
/// 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.
size_t getValue() const { return _value; }; size_t getValue() const { return _value; };
/// Destructor
virtual ~Element(); virtual ~Element();
protected: protected:
/// 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, size_t value = 0);
/// Constructor for a generic mesh element without an array of mesh nodes.
Element(MshElemType::type type, size_t value = 0); Element(MshElemType::type type, size_t value = 0);
MshElemType::type _type; MshElemType::type _type;
......
...@@ -18,16 +18,23 @@ namespace MeshLib { ...@@ -18,16 +18,23 @@ namespace MeshLib {
class Face : public Element class Face : public Element
{ {
public: public:
/// Get the area of this 2d element.
virtual double getArea() const { return _area; }; virtual double getArea() const { return _area; };
/// Get dimension of the mesh element.
size_t getDimension() const { return 2; }; size_t getDimension() const { return 2; };
/// Destructor
virtual ~Face(); virtual ~Face();
protected: protected:
/// 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, size_t value = 0);
/// Constructor for a generic mesh element without an array of mesh nodes.
Face(MshElemType::type type, size_t value = 0); Face(MshElemType::type type, size_t value = 0);
/// Calculate the area of this 2d element.
virtual double calcArea() = 0; virtual double calcArea() = 0;
double _area; double _area;
......
...@@ -31,10 +31,16 @@ namespace MeshLib { ...@@ -31,10 +31,16 @@ namespace MeshLib {
class Hex : public Cell class Hex : public Cell
{ {
public: public:
/// Constructor with an array of mesh nodes.
Hex(Node* nodes[8], size_t value = 0); Hex(Node* nodes[8], size_t value = 0);
/// Copy constructor
Hex(const Hex &hex); Hex(const Hex &hex);
/// Destructor
virtual ~Hex(); virtual ~Hex();
/// Get the number of nodes for this element.
size_t getNNodes() const { return 8; }; size_t getNNodes() const { return 8; };
protected: protected:
......
...@@ -29,11 +29,19 @@ namespace MeshLib { ...@@ -29,11 +29,19 @@ namespace MeshLib {
class Prism : public Cell class Prism : public Cell
{ {
public: public:
/// Constructor with an array of mesh nodes.
Prism(Node* nodes[6], size_t value = 0); Prism(Node* nodes[6], size_t value = 0);
/// 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, size_t value = 0);
/// Copy constructor
Prism(const Prism &prism); Prism(const Prism &prism);
/// Destructor
virtual ~Prism(); virtual ~Prism();
/// Get the number of nodes for this element.
size_t getNNodes() const { return 6; }; size_t getNNodes() const { return 6; };
protected: protected:
......
...@@ -29,11 +29,19 @@ namespace MeshLib { ...@@ -29,11 +29,19 @@ namespace MeshLib {
class Pyramid : public Cell class Pyramid : public Cell
{ {
public: public:
/// Constructor with an array of mesh nodes.
Pyramid(Node* nodes[5], size_t value = 0); Pyramid(Node* nodes[5], size_t value = 0);
/// 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, size_t value = 0);
/// Copy constructor
Pyramid(const Pyramid &pyramid); Pyramid(const Pyramid &pyramid);
/// Destructor
virtual ~Pyramid(); virtual ~Pyramid();
/// Get the number of nodes for this element.
size_t getNNodes() const { return 5; }; size_t getNNodes() const { return 5; };
protected: protected:
......
...@@ -28,11 +28,19 @@ namespace MeshLib { ...@@ -28,11 +28,19 @@ namespace MeshLib {
class Quad : public Face class Quad : public Face
{ {
public: public:
/// Constructor with an array of mesh nodes.
Quad(Node* nodes[4], size_t value = 0); Quad(Node* nodes[4], size_t value = 0);
/// Constructor using single mesh nodes.
Quad(Node* n0, Node* n1, Node* n2, Node* n3, size_t value = 0); Quad(Node* n0, Node* n1, Node* n2, Node* n3, size_t value = 0);
/// Copy constructor
Quad(const Quad &quad); Quad(const Quad &quad);
/// Destructor
virtual ~Quad(); virtual ~Quad();
/// Get the number of nodes for this element.
size_t getNNodes() const { return 4; }; size_t getNNodes() const { return 4; };
protected: protected:
......
...@@ -30,11 +30,19 @@ namespace MeshLib { ...@@ -30,11 +30,19 @@ namespace MeshLib {
class Tet : public Cell class Tet : public Cell
{ {
public: public:
/// Constructor with an array of mesh nodes.
Tet(Node* nodes[4], size_t value = 0); Tet(Node* nodes[4], size_t value = 0);
/// Constructor using single mesh nodes.
Tet(Node* n0, Node* n1, Node* n2, Node* n3, size_t value = 0); Tet(Node* n0, Node* n1, Node* n2, Node* n3, size_t value = 0);
/// Copy constructor
Tet(const Tet &tet); Tet(const Tet &tet);
/// Destructor
virtual ~Tet(); virtual ~Tet();
/// Get the number of nodes for this element.
size_t getNNodes() const { return 4; }; size_t getNNodes() const { return 4; };
protected: protected:
......
...@@ -29,11 +29,19 @@ namespace MeshLib { ...@@ -29,11 +29,19 @@ namespace MeshLib {
class Tri : public Face class Tri : public Face
{ {
public: public:
/// Constructor with an array of mesh nodes.
Tri(Node* nodes[3], size_t value = 0); Tri(Node* nodes[3], size_t value = 0);
/// Constructor using single mesh nodes.
Tri(Node* n0, Node* n1, Node* n2, size_t value = 0); Tri(Node* n0, Node* n1, Node* n2, size_t value = 0);
/// Copy constructor
Tri(const Tri &tri); Tri(const Tri &tri);
/// Destructor
virtual ~Tri(); virtual ~Tri();
/// Get the number of nodes for this element.
size_t getNNodes() const { return 3; }; size_t getNNodes() const { return 3; };
protected: protected:
......
...@@ -12,13 +12,25 @@ ...@@ -12,13 +12,25 @@
namespace MeshLib { namespace MeshLib {
/**
* A finite element mesh.
*/
class FemMesh : public Mesh class FemMesh : public Mesh
{ {
public: public:
/// Constructor using a mesh name and an array of nodes and elements
FemMesh(const std::string &name, const std::vector<Node*> &nodes, const std::vector<Element*> &elements); FemMesh(const std::string &name, const std::vector<Node*> &nodes, const std::vector<Element*> &elements);
/// Constructor using a basic mesh
FemMesh(const Mesh &mesh); FemMesh(const Mesh &mesh);
/// Copy constructor
FemMesh(const FemMesh &mesh); FemMesh(const FemMesh &mesh);
/// Constructor for reading a mesh from a file
FemMesh(const std::string &file_name); FemMesh(const std::string &file_name);
/// Destructor
~FemMesh(); ~FemMesh();
......
...@@ -12,13 +12,25 @@ ...@@ -12,13 +12,25 @@
namespace MeshLib { namespace MeshLib {
/**
* A mesh node for finite element meshes.
*/
class FemNode : public Node class FemNode : public Node
{ {
public: public:
/// Constructor using a coordinate array
FemNode(double const*const coords, size_t id = std::numeric_limits<size_t>::max()); FemNode(double const*const coords, size_t id = std::numeric_limits<size_t>::max());
/// Constructor using single coordinates
FemNode(double x, double y, double z, size_t id = std::numeric_limits<size_t>::max()); FemNode(double x, double y, double z, size_t id = std::numeric_limits<size_t>::max());
/// Constructor using a mesh node
FemNode(const Node &node); FemNode(const Node &node);
/// Copy constructor
FemNode(const FemNode &node); FemNode(const FemNode &node);
/// Destructor
~FemNode(); ~FemNode();
}; /* class */ }; /* class */
......
...@@ -16,19 +16,35 @@ namespace MeshLib { ...@@ -16,19 +16,35 @@ namespace MeshLib {
class Node; class Node;
class Element; class Element;
/**
* A basic mesh.
*/
class Mesh class Mesh
{ {
public: public:
/// Constructor using a mesh name and an array of nodes and elements
Mesh(const std::string &name, const std::vector<Node*> &nodes, const std::vector<Element*> &elements); Mesh(const std::string &name, const std::vector<Node*> &nodes, const std::vector<Element*> &elements);
/// Copy constructor
Mesh(const Mesh &mesh); Mesh(const Mesh &mesh);
/// Constructor for reading a mesh from a file
Mesh(const std::string &file_name); Mesh(const std::string &file_name);
/// Destructor
virtual ~Mesh(); virtual ~Mesh();
/// Get name of the mesh.
const std::string getName() const { return _name; }; const std::string getName() const { return _name; };
/// Get the nodes-vector for the mesh.
const std::vector<Node*> getNodes() const { return _nodes; }; const std::vector<Node*> getNodes() const { return _nodes; };
/// Get the element-vector for the mesh.
const std::vector<Element*> getElements() const { return _elements; }; const std::vector<Element*> getElements() const { return _elements; };
protected: protected:
/// Checks the coordinates of all mesh nodes and removes identical nodes. Elements are adapted accordingly.
void removeIdenticalNodes(); void removeIdenticalNodes();
std::string _name; std::string _name;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
namespace MeshLib { namespace MeshLib {
Node::Node(double const*const coords, size_t id) Node::Node(const double coords[3], size_t id)
: GEOLIB::PointWithID(coords, id) : GEOLIB::PointWithID(coords, id)
{ {
} }
......
...@@ -23,9 +23,16 @@ class Element; ...@@ -23,9 +23,16 @@ class Element;
class Node : public GEOLIB::PointWithID class Node : public GEOLIB::PointWithID
{ {
public: public:
Node(double const*const coords, size_t id = std::numeric_limits<size_t>::max()); /// Constructor using a coordinate array
Node(const double coords[3], size_t id = std::numeric_limits<size_t>::max());
/// Constructor using single coordinates
Node(double x, double y, double z, size_t id = std::numeric_limits<size_t>::max()); Node(double x, double y, double z, size_t id = std::numeric_limits<size_t>::max());
/// Copy constructor
Node(const Node &node); Node(const Node &node);
/// Destructor
~Node(); ~Node();
private: private:
......
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