Skip to content
Snippets Groups Projects
Element.h 1.87 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * Element.h
     *
     *      Date: 2012/05/02
     *      Author: KR
     */
    
    #ifndef ELEMENT_H_
    #define ELEMENT_H_
    
    #include <vector>
    #include "MshEnums.h"
    
    
    namespace MeshLib {
    
    class Node;
    
    /**
     * Virtual base class for mesh elements.
     */
    class Element
    {
    
    	/* friend functions: */
    	friend void Mesh::setElementInformationForNodes();
    	friend void Mesh::addElement(Element*);
    	
    
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Get node with local index i.
    
    	const Node* getNode(unsigned i) const;
    
    Karsten Rink's avatar
    Karsten Rink committed
    
    	/// Get array of element nodes.
    
    	Node* const* getNodes() const { return _nodes; };
    
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Get dimension of the mesh element.
    
    	virtual unsigned getDimension() const = 0;
    
    	/// Get the number of edges for this element.
    
    	virtual unsigned getNEdges() const = 0;
    
    
    	/// Get the number of faces for this element.
    
    	virtual unsigned getNFaces() const = 0;
    
    
    	/// Get the specified neighbor.
    
    	const Element* getNeighbor(unsigned i) const;
    
    
    	/// Get the number of neighbors for this element.
    
    	virtual unsigned getNNeighbors() const = 0;
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Get the number of nodes for this element.
    
    	virtual unsigned getNNodes() const = 0;
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Get the global index for the node with local index i.
    
    	unsigned getNodeIndex(unsigned i) const;
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Get the type of the mesh element (as a MshElemType-enum).
    
    	MshElemType::type getType() const { return _type; };
    
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Get the value for this element.
    
    	unsigned getValue() const { return _value; };
    
    	bool hasNeighbor(Element* elem) const;
    
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Destructor
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Constructor for a generic mesh element containing an array of mesh nodes.
    
    	Element(Node** nodes, MshElemType::type type, unsigned value = 0);
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Constructor for a generic mesh element without an array of mesh nodes.
    
    	Element(MshElemType::type type, unsigned value = 0);
    
    	MshElemType::type _type;
    
    	Element** _neighbors;
    
    
    private:
    
    }; /* class */
    
    } /* namespace */
    
    #endif /* ELEMENT_H_ */