diff --git a/MeshLib/Elements/Pyramid.h b/MeshLib/Elements/Pyramid.h index 2dcaac5af6ac800e406a7d707127501e27e564f4..6d3a74363f35a44723fccec5f419620a27487aba 100644 --- a/MeshLib/Elements/Pyramid.h +++ b/MeshLib/Elements/Pyramid.h @@ -1,125 +1,23 @@ /** - * Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.org) + * Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.net) * Distributed under a Modified BSD License. * See accompanying file LICENSE.txt or - * http://www.opengeosys.org/project/license - * + * http://www.opengeosys.org/LICENSE.txt * * \file Pyramid.h * - * Created on 2012-05-02 by Karsten Rink + * Created on Sep 27, 2012 by Thomas Fischer */ #ifndef PYRAMID_H_ #define PYRAMID_H_ -#include "Cell.h" +#include "TemplatePyramid.h" namespace MeshLib { -/** - * This class represents a 3d pyramid element. The following sketch shows the node and edge numbering. - * @anchor PyramidNodeAndEdgeNumbering - * @code - * - * 4 - * //|\ - * // | \ - * 7// | \6 - * // |5 \ - * // | \ - * 3/.... |.....2 - * ./ | 2 / - * ./4 | / - * 3./ | /1 - * ./ | / - * ./ |/ - * 0------------1 - * 0 - * @endcode - */ -template <unsigned ORDER, unsigned NNODES> -class TemplatePyramid : public Cell -{ -public: - /// Constructor with an array of mesh nodes. - TemplatePyramid(Node* nodes[NNODES], unsigned value = 0); - - /// Copy constructor - TemplatePyramid(const TemplatePyramid<ORDER,NNODES> &pyramid); - - /// Destructor - virtual ~TemplatePyramid(); - - /// Returns the face i of the element. - const Element* getFace(unsigned i) const; - - /// Get the number of edges for this element. - unsigned getNEdges() const { return 8; }; - - /// Get the number of nodes for face i. - unsigned getNFaceNodes(unsigned i) const; - - /// Get the number of faces for this element. - unsigned getNFaces() const { return 5; }; - - /// Get the number of neighbors for this element. - unsigned getNNeighbors() const { return 5; }; - - /// Get the number of nodes for this element. - virtual unsigned getNNodes(unsigned order = 1) const - { - return order == ORDER ? NNODES : 5; - } - - /** - * Method returns the type of the element. In this case PYRAMID will be returned. - * @return MshElemType::PYRAMID - */ - virtual MshElemType::type getType() const { return MshElemType::PYRAMID; } - - /// Returns true if these two indeces form an edge and false otherwise - bool isEdge(unsigned i, unsigned j) const; - - /** - * Method clone is inherited from class Element. It makes a deep copy of the - * TemplatePyramid instance employing the copy constructor of class TemplatePyramid. - * @return an exact copy of the object - */ - virtual Element* clone() const; - - /** - * This method should be called after at least two nodes of the pyramid - * element are collapsed. As a consequence of the node collapsing an edge - * of the pyramid will be collapsed. If one of the edges 0, 1, 2 or 3 (see - * sketch @ref PyramidNodeAndEdgeNumbering) is collapsed we obtain a - * tetrahedron. In this case the method will create the appropriate - * object of class Tetrahedron. - * @return a Tetrahedron object or NULL - */ - virtual Element* reviseElement() const; - -protected: - /// Calculates the volume of a prism by subdividing it into two tetrahedra. - double computeVolume(); - - /// Return a specific edge node. - inline Node* getEdgeNode(unsigned edge_id, unsigned node_id) const { return _nodes[_edge_nodes[edge_id][node_id]]; }; - - /// Returns the ID of a face given an array of nodes. - unsigned identifyFace(Node* nodes[3]) const; - - static const unsigned _face_nodes[5][4]; - static const unsigned _edge_nodes[8][2]; - static const unsigned _n_face_nodes[5]; - -}; /* class */ - typedef TemplatePyramid<1,5> Pyramid; -} /* namespace */ - -#include "Pyramid.hpp" +} #endif /* PYRAMID_H_ */ - diff --git a/MeshLib/Elements/TemplatePyramid.h b/MeshLib/Elements/TemplatePyramid.h new file mode 100644 index 0000000000000000000000000000000000000000..469797675a4be322bc62ab8f5f3dece1adcd6926 --- /dev/null +++ b/MeshLib/Elements/TemplatePyramid.h @@ -0,0 +1,123 @@ +/** + * Copyright (c) 2012, OpenGeoSys Community (http://www.opengeosys.org) + * Distributed under a Modified BSD License. + * See accompanying file LICENSE.txt or + * http://www.opengeosys.org/project/license + * + * + * \file TemplatePyramid.h + * + * Created on 2012-05-02 by Karsten Rink + */ + +#ifndef TEMPLATEPYRAMID_H_ +#define TEMPLATEPYRAMID_H_ + +#include "Cell.h" + +namespace MeshLib { + +/** + * This class represents a 3d pyramid element. The following sketch shows the node and edge numbering. + * @anchor PyramidNodeAndEdgeNumbering + * @code + * + * 4 + * //|\ + * // | \ + * 7// | \6 + * // |5 \ + * // | \ + * 3/.... |.....2 + * ./ | 2 / + * ./4 | / + * 3./ | /1 + * ./ | / + * ./ |/ + * 0------------1 + * 0 + * @endcode + */ +template <unsigned ORDER, unsigned NNODES> +class TemplatePyramid : public Cell +{ +public: + /// Constructor with an array of mesh nodes. + TemplatePyramid(Node* nodes[NNODES], unsigned value = 0); + + /// Copy constructor + TemplatePyramid(const TemplatePyramid<ORDER,NNODES> &pyramid); + + /// Destructor + virtual ~TemplatePyramid(); + + /// Returns the face i of the element. + const Element* getFace(unsigned i) const; + + /// Get the number of edges for this element. + unsigned getNEdges() const { return 8; }; + + /// Get the number of nodes for face i. + unsigned getNFaceNodes(unsigned i) const; + + /// Get the number of faces for this element. + unsigned getNFaces() const { return 5; }; + + /// Get the number of neighbors for this element. + unsigned getNNeighbors() const { return 5; }; + + /// Get the number of nodes for this element. + virtual unsigned getNNodes(unsigned order = 1) const + { + return order == ORDER ? NNODES : 5; + } + + /** + * Method returns the type of the element. In this case PYRAMID will be returned. + * @return MshElemType::PYRAMID + */ + virtual MshElemType::type getType() const { return MshElemType::PYRAMID; } + + /// Returns true if these two indeces form an edge and false otherwise + bool isEdge(unsigned i, unsigned j) const; + + /** + * Method clone is inherited from class Element. It makes a deep copy of the + * TemplatePyramid instance employing the copy constructor of class TemplatePyramid. + * @return an exact copy of the object + */ + virtual Element* clone() const; + + /** + * This method should be called after at least two nodes of the pyramid + * element are collapsed. As a consequence of the node collapsing an edge + * of the pyramid will be collapsed. If one of the edges 0, 1, 2 or 3 (see + * sketch @ref PyramidNodeAndEdgeNumbering) is collapsed we obtain a + * tetrahedron. In this case the method will create the appropriate + * object of class Tetrahedron. + * @return a Tetrahedron object or NULL + */ + virtual Element* reviseElement() const; + +protected: + /// Calculates the volume of a prism by subdividing it into two tetrahedra. + double computeVolume(); + + /// Return a specific edge node. + inline Node* getEdgeNode(unsigned edge_id, unsigned node_id) const { return _nodes[_edge_nodes[edge_id][node_id]]; }; + + /// Returns the ID of a face given an array of nodes. + unsigned identifyFace(Node* nodes[3]) const; + + static const unsigned _face_nodes[5][4]; + static const unsigned _edge_nodes[8][2]; + static const unsigned _n_face_nodes[5]; + +}; /* class */ + +} /* namespace */ + +#include "TemplatePyramid.hpp" + +#endif /* TEMPLATEPYRAMID_H_ */ + diff --git a/MeshLib/Elements/Pyramid.hpp b/MeshLib/Elements/TemplatePyramid.hpp similarity index 99% rename from MeshLib/Elements/Pyramid.hpp rename to MeshLib/Elements/TemplatePyramid.hpp index 2ab54693881b216218dfd9e7672bbb127bf43144..09f9af86cc575b91158e3e26059a7a93d02f5dde 100644 --- a/MeshLib/Elements/Pyramid.hpp +++ b/MeshLib/Elements/TemplatePyramid.hpp @@ -5,7 +5,7 @@ * http://www.opengeosys.org/project/license * * - * \file Pyramid.hpp + * \file TemplatePyramid.hpp * * Created on 2012-05-02 by Karsten Rink */