/*!\file Node.h
 * \brief: header file for node object
 */

#ifndef _NODE_H_
#define _NODE_H_

#include "./Object.h"
#include "../toolkits/toolkits.h"

#define MAXDOFSPERNODE 4
#define PSSTRINGLENGTH 20

class Node: public Object{

	private: 
		/*raw data coming from the model processor: */
		int	    id; /*! id, to track it*/
		int     partitionborder; /*! during parallel partitioning, does this grid belong to a partition border?*/
		int     numberofdofs; //real number of dofs, between 0 and MAXDOFSPERNODE
		int     clone;  /*!this nodes is one the partition border, and is cloned*/
		double	x[3]; /*! coordinates*/
		int	    onbed; /*! for 3d, on bedrock*/
		int	    onsurface; /*! for 3d, on surface*/

		/*for dof constraining: */
		int     mset[MAXDOFSPERNODE];
		int     nset[MAXDOFSPERNODE];
		int     fset[MAXDOFSPERNODE];
		int     sset[MAXDOFSPERNODE];

		/*data that is post processed : */
		int doflist[MAXDOFSPERNODE];

	public:

		Node();
		Node(int node_id,int node_partitionborder,int node_numdofs, double node_x[3],int node_onbed,int node_onsurface);
		~Node();

		void  Echo();
		void  Marshall(char** pmarshalled_dataset);
		int   MarshallSize();
		char* GetName();
		void  Demarshall(char** pmarshalled_dataset);
		int   Enum();
		int   GetId(void); 
		int   MyRank(void);
		void  DistributeDofs(int* pdofcount);
		void  UpdateDofs(int dofcount);
		void  ShowBorderDofs(int* borderdofs);
		void  UpdateBorderDofs(int* allborderdofs);
		void  CreatePartition(Vec partition);
		void  DistributeNumDofs(int* numdofspernode,int analysis_type);
		void  SetClone(int* minranks);
		int   GetNumberOfDofs();
		int   IsClone();
		void  ApplyConstraint(Vec yg,int dof,double value);
		void  DofInSSet(int dof);
		void  DofInMSet(int dof);
		int   GetDof(int dofindex);
		void  CreateVecSets(Vec pv_g,Vec pv_m,Vec pv_n,Vec pv_f,Vec pv_s);
		void  GetDofList(int* outdoflist,int* pnumberofdofspernode);
		double GetX();
		double GetY();
		double GetZ();
		Object* copy();

};

#endif  /* _NODE_H_ */

