From 61dcb7f0736b0d58727acef5c8eb52250f0761b0 Mon Sep 17 00:00:00 2001 From: Karsten Rink <karsten.rink@ufz.de> Date: Wed, 2 May 2012 17:32:16 +0200 Subject: [PATCH] Added basic documentation --- MeshLib/Elements/Cell.h | 7 +++++++ MeshLib/Elements/Edge.h | 11 +++++++++++ MeshLib/Elements/Element.h | 12 ++++++++++++ MeshLib/Elements/Face.h | 7 +++++++ MeshLib/Elements/Hex.h | 6 ++++++ MeshLib/Elements/Prism.h | 8 ++++++++ MeshLib/Elements/Pyramid.h | 8 ++++++++ MeshLib/Elements/Quad.h | 8 ++++++++ MeshLib/Elements/Tet.h | 8 ++++++++ MeshLib/Elements/Tri.h | 8 ++++++++ MeshLib/FemMesh.h | 12 ++++++++++++ MeshLib/FemNode.h | 12 ++++++++++++ MeshLib/Mesh.h | 16 ++++++++++++++++ MeshLib/Node.cpp | 2 +- MeshLib/Node.h | 9 ++++++++- 15 files changed, 132 insertions(+), 2 deletions(-) diff --git a/MeshLib/Elements/Cell.h b/MeshLib/Elements/Cell.h index c6438980407..9cc9bba65ea 100644 --- a/MeshLib/Elements/Cell.h +++ b/MeshLib/Elements/Cell.h @@ -18,16 +18,23 @@ namespace MeshLib { class Cell : public Element { public: + /// Get the volume of this 3d element. virtual double getVolume() const { return _volume; }; + /// Get dimension of the mesh element. size_t getDimension() const { return 3; }; + /// Destructor virtual ~Cell(); protected: + /// Constructor for a generic mesh element containing an array of mesh nodes. 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); + /// Calculate the volume of this 3d element. virtual double calcVolume() = 0; double _volume; diff --git a/MeshLib/Elements/Edge.h b/MeshLib/Elements/Edge.h index 34b0ded9319..437459d5710 100644 --- a/MeshLib/Elements/Edge.h +++ b/MeshLib/Elements/Edge.h @@ -23,19 +23,30 @@ class Node; class Edge : public Element { public: + /// Constructor with an array of mesh nodes. Edge(Node* nodes[2], size_t value = 0); + + /// Constructor using single nodes Edge(Node* n1, Node* n2, size_t value = 0); + + /// Copy constructor Edge(const Edge &edge); + + /// Destructor virtual ~Edge(); + /// Get the length of this 1d element. double getLength() const { return _length; }; + /// Get dimension of the mesh element. size_t getDimension() const { return 1; }; + /// Get the number of nodes for this element. size_t getNNodes() const { return 2; }; protected: + /// Calculate the length of this 1d element. double calcLength(); double _length; diff --git a/MeshLib/Elements/Element.h b/MeshLib/Elements/Element.h index 6b00d1639aa..63de3757fd3 100644 --- a/MeshLib/Elements/Element.h +++ b/MeshLib/Elements/Element.h @@ -21,23 +21,35 @@ class Node; class Element { public: + /// Get node with local index i. const Node* getNode(size_t i) const; + + /// Get array of element nodes. Node* const* getNodes() const { return _nodes; }; + /// Get dimension of the mesh element. virtual size_t getDimension() const = 0; + /// Get the number of nodes for this element. virtual size_t getNNodes() const = 0; + /// Get the global index for the node with local index i. size_t getNodeIndex(size_t i) const; + /// Get the type of the mesh element (as a MshElemType-enum). MshElemType::type getType() const { return _type; }; + /// Get the value for this element. size_t getValue() const { return _value; }; + /// Destructor virtual ~Element(); protected: + /// Constructor for a generic mesh element containing an array of mesh nodes. 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); MshElemType::type _type; diff --git a/MeshLib/Elements/Face.h b/MeshLib/Elements/Face.h index 0e3500c8a4d..f79e0d77b34 100644 --- a/MeshLib/Elements/Face.h +++ b/MeshLib/Elements/Face.h @@ -18,16 +18,23 @@ namespace MeshLib { class Face : public Element { public: + /// Get the area of this 2d element. virtual double getArea() const { return _area; }; + /// Get dimension of the mesh element. size_t getDimension() const { return 2; }; + /// Destructor virtual ~Face(); protected: + /// Constructor for a generic mesh element containing an array of mesh nodes. 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); + /// Calculate the area of this 2d element. virtual double calcArea() = 0; double _area; diff --git a/MeshLib/Elements/Hex.h b/MeshLib/Elements/Hex.h index d2dbacbf66d..c6b1441fbeb 100644 --- a/MeshLib/Elements/Hex.h +++ b/MeshLib/Elements/Hex.h @@ -31,10 +31,16 @@ namespace MeshLib { class Hex : public Cell { public: + /// Constructor with an array of mesh nodes. Hex(Node* nodes[8], size_t value = 0); + + /// Copy constructor Hex(const Hex &hex); + + /// Destructor virtual ~Hex(); + /// Get the number of nodes for this element. size_t getNNodes() const { return 8; }; protected: diff --git a/MeshLib/Elements/Prism.h b/MeshLib/Elements/Prism.h index e73a3650e63..07ae3e7e77c 100644 --- a/MeshLib/Elements/Prism.h +++ b/MeshLib/Elements/Prism.h @@ -29,11 +29,19 @@ namespace MeshLib { class Prism : public Cell { public: + /// Constructor with an array of mesh nodes. 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); + + /// Copy constructor Prism(const Prism &prism); + + /// Destructor virtual ~Prism(); + /// Get the number of nodes for this element. size_t getNNodes() const { return 6; }; protected: diff --git a/MeshLib/Elements/Pyramid.h b/MeshLib/Elements/Pyramid.h index 86a0fb27c46..f8bf6a58a78 100644 --- a/MeshLib/Elements/Pyramid.h +++ b/MeshLib/Elements/Pyramid.h @@ -29,11 +29,19 @@ namespace MeshLib { class Pyramid : public Cell { public: + /// Constructor with an array of mesh nodes. 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); + + /// Copy constructor Pyramid(const Pyramid &pyramid); + + /// Destructor virtual ~Pyramid(); + /// Get the number of nodes for this element. size_t getNNodes() const { return 5; }; protected: diff --git a/MeshLib/Elements/Quad.h b/MeshLib/Elements/Quad.h index a938464ab17..68bdb65abcb 100644 --- a/MeshLib/Elements/Quad.h +++ b/MeshLib/Elements/Quad.h @@ -28,11 +28,19 @@ namespace MeshLib { class Quad : public Face { public: + /// Constructor with an array of mesh nodes. 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); + + /// Copy constructor Quad(const Quad &quad); + + /// Destructor virtual ~Quad(); + /// Get the number of nodes for this element. size_t getNNodes() const { return 4; }; protected: diff --git a/MeshLib/Elements/Tet.h b/MeshLib/Elements/Tet.h index 28cf9c1dec0..68c450e281f 100644 --- a/MeshLib/Elements/Tet.h +++ b/MeshLib/Elements/Tet.h @@ -30,11 +30,19 @@ namespace MeshLib { class Tet : public Cell { public: + /// Constructor with an array of mesh nodes. 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); + + /// Copy constructor Tet(const Tet &tet); + + /// Destructor virtual ~Tet(); + /// Get the number of nodes for this element. size_t getNNodes() const { return 4; }; protected: diff --git a/MeshLib/Elements/Tri.h b/MeshLib/Elements/Tri.h index f884b5c8753..2fe14123af0 100644 --- a/MeshLib/Elements/Tri.h +++ b/MeshLib/Elements/Tri.h @@ -29,11 +29,19 @@ namespace MeshLib { class Tri : public Face { public: + /// Constructor with an array of mesh nodes. Tri(Node* nodes[3], size_t value = 0); + + /// Constructor using single mesh nodes. Tri(Node* n0, Node* n1, Node* n2, size_t value = 0); + + /// Copy constructor Tri(const Tri &tri); + + /// Destructor virtual ~Tri(); + /// Get the number of nodes for this element. size_t getNNodes() const { return 3; }; protected: diff --git a/MeshLib/FemMesh.h b/MeshLib/FemMesh.h index 93975f25ca6..de95664fbf0 100644 --- a/MeshLib/FemMesh.h +++ b/MeshLib/FemMesh.h @@ -12,13 +12,25 @@ namespace MeshLib { +/** + * A finite element mesh. + */ class FemMesh : public Mesh { 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); + + /// Constructor using a basic mesh FemMesh(const Mesh &mesh); + + /// Copy constructor FemMesh(const FemMesh &mesh); + + /// Constructor for reading a mesh from a file FemMesh(const std::string &file_name); + + /// Destructor ~FemMesh(); diff --git a/MeshLib/FemNode.h b/MeshLib/FemNode.h index 988ab28123f..48b33071fad 100644 --- a/MeshLib/FemNode.h +++ b/MeshLib/FemNode.h @@ -12,13 +12,25 @@ namespace MeshLib { +/** + * A mesh node for finite element meshes. + */ class FemNode : public Node { public: + /// Constructor using a coordinate array 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()); + + /// Constructor using a mesh node FemNode(const Node &node); + + /// Copy constructor FemNode(const FemNode &node); + + /// Destructor ~FemNode(); }; /* class */ diff --git a/MeshLib/Mesh.h b/MeshLib/Mesh.h index 2237e49a2c4..ee4d0b54156 100644 --- a/MeshLib/Mesh.h +++ b/MeshLib/Mesh.h @@ -16,19 +16,35 @@ namespace MeshLib { class Node; class Element; +/** + * A basic mesh. + */ class Mesh { 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); + + /// Copy constructor Mesh(const Mesh &mesh); + + /// Constructor for reading a mesh from a file Mesh(const std::string &file_name); + + /// Destructor virtual ~Mesh(); + /// Get name of the mesh. const std::string getName() const { return _name; }; + + /// Get the nodes-vector for the mesh. const std::vector<Node*> getNodes() const { return _nodes; }; + + /// Get the element-vector for the mesh. const std::vector<Element*> getElements() const { return _elements; }; protected: + /// Checks the coordinates of all mesh nodes and removes identical nodes. Elements are adapted accordingly. void removeIdenticalNodes(); std::string _name; diff --git a/MeshLib/Node.cpp b/MeshLib/Node.cpp index 1da42acc9c0..588355fdc24 100644 --- a/MeshLib/Node.cpp +++ b/MeshLib/Node.cpp @@ -9,7 +9,7 @@ namespace MeshLib { -Node::Node(double const*const coords, size_t id) +Node::Node(const double coords[3], size_t id) : GEOLIB::PointWithID(coords, id) { } diff --git a/MeshLib/Node.h b/MeshLib/Node.h index 9c08f4a5d21..d6add956ac8 100644 --- a/MeshLib/Node.h +++ b/MeshLib/Node.h @@ -23,9 +23,16 @@ class Element; class Node : public GEOLIB::PointWithID { 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()); + + /// Copy constructor Node(const Node &node); + + /// Destructor ~Node(); private: -- GitLab