Skip to content
Snippets Groups Projects
Mesh.h 1.81 KiB
Newer Older
  • Learn to ignore specific revisions
  • /**
     * Mesh.h
     *
     *      Date: 2012/05/02
     *      Author: KR
     */
    
    #ifndef MESH_H_
    #define MESH_H_
    
    #include <cstdlib>
    
    Karsten Rink's avatar
    Karsten Rink committed
    #include <string>
    
    Karsten Rink's avatar
    Karsten Rink committed
    /**
     * A basic mesh.
     */
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// 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);
    
    Karsten Rink's avatar
    Karsten Rink committed
    
    	/// Copy constructor
    
    Karsten Rink's avatar
    Karsten Rink committed
    
    	/// Destructor
    
    	/// Add a node to the mesh.
    	void addNode(Node* node);
    
    	/// Add an element to the mesh.
    	void addElement(Element* elem);
    
    	/// Get the node with the given index.
    
    	const Node* getNode(unsigned idx) const { return _nodes[idx]; };
    
    
    	/// Get the element with the given index.
    
    	const Element* getElement(unsigned idx) const { return _elements[idx]; };
    
    
    	/// Get the number of elements
    	size_t getNElements() const { return _elements.size(); };
    
    	/// Get the number of nodes
    	size_t getNNodes() const { return _nodes.size(); };
    
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Get name of the mesh.
    
    	const std::string getName() const { return _name; };
    
    Karsten Rink's avatar
    Karsten Rink committed
    
    	/// Get the nodes-vector for the mesh.
    
    	const std::vector<Node*> getNodes() const { return _nodes; };
    
    Karsten Rink's avatar
    Karsten Rink committed
    
    	/// Get the element-vector for the mesh.
    
    	const std::vector<Element*> getElements() const { return _elements; };
    
    Karsten Rink's avatar
    Karsten Rink committed
    	/// Checks the coordinates of all mesh nodes and removes identical nodes. Elements are adapted accordingly.
    
    	void makeNodesUnique();
    
    	/// Fills in the neighbor-information for nodes (i.e. which element each node belongs to).
    	void setElementInformationForNodes();
    
    	/// Fills in the neighbor-information for elements.
    	void setNeighborInformationForElements();
    
    
    	std::string _name;
    	std::vector<Node*> _nodes;
    	std::vector<Element*> _elements;
    
    }; /* class */
    
    } /* namespace */
    
    #endif /* MESH_H_ */