diff --git a/MeshLib/Elements/Cell.h b/MeshLib/Elements/Cell.h index c64389804075a34ad9eb21dd1f48cfdb286097c6..9cc9bba65ea8d1bcea66a92676e23d52301c9eb2 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 34b0ded93193eb5c91460ee7ae45afa2d338163c..437459d5710041f1b82759c47fa7c77be9244ac6 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 6b00d1639aaeb5d7818d2caa0b805f15f69adce9..63de3757fd3c4d1ca9d1dea644903cdbedab7ad4 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 0e3500c8a4dd786c33d2802af4a816ca180d2cc8..f79e0d77b34a600898bdd60f8016f29e9de017ca 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 d2dbacbf66d22bb4371da0c7f312618adcc721f3..c6b1441fbeb805ef933caaad5f24ba71e502a4a5 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 e73a3650e63ba50c9dd79aee0628b2757fe22fec..07ae3e7e77c4d52c955e978884d03bdd65265dda 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 86a0fb27c464fe456604f710bc7a80a1c4f04a38..f8bf6a58a78fb15fa7439712879a7f767b22e490 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 a938464ab170a50a04a2072dfc02361be1906d3c..68bdb65abcbb427dd9ec9573d98209bcd00bdec3 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 28cf9c1dec0443301931c5054343e66e672a3077..68c450e281f912ba65b9993e1a46443fe420c9b4 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 f884b5c8753dbfdcb36636e3b48d645aaf30df50..2fe14123af01c978b5b1b4ed4945a1be77e1787f 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 93975f25ca6dd1b31eff3de5cc39d352c8a5a267..de95664fbf0e53b17c4abc78c7e229fb4a20d764 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 988ab28123feb17a32b09e5701dea98985af0ec2..48b33071fad00aeb48195e8022b13305dc7d3f34 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 2237e49a2c4c6fc0bd74487854934122a6074fb7..ee4d0b54156a57385e5177bf5566268a1d5b1af0 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 1da42acc9c0bf5c3651050bbc8e6b8d1c3eba4db..588355fdc24fe823bdb45ed14c87040bcb1d312c 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 9c08f4a5d210e25cef78f6746f4762859aacac60..d6add956ac8ff8edd1ff4a628a6ed71c308da334 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: