00001 #ifndef PARFUM_TYPES_H 00002 #define PARFUM_TYPES_H 00003 00004 #include <pup.h> 00005 00006 // ghosts and spatial symmetries 00007 #define FEM_Is_ghost_index(idx) ((idx)<-1) 00008 #define FEM_To_ghost_index(idx) (-(idx)-2) 00009 #define FEM_From_ghost_index(idx) (-(idx)-2) 00010 00011 00013 class ElemID{ 00014 public: 00016 int type; 00018 int id; 00019 00021 ElemID(){ 00022 type=-1; 00023 id = -1; 00024 }; 00026 ElemID(int _type,int _id){ 00027 if(_id < 0) { 00028 type = -(_type+1); 00029 id = FEM_To_ghost_index(_id); 00030 } 00031 else { 00032 type = _type; 00033 id = _id; 00034 } 00035 }; 00036 bool operator ==(const ElemID &rhs)const { 00037 return (type == rhs.type) && (id == rhs.id); 00038 } 00039 bool operator < (const ElemID &rhs)const { 00040 return (type < rhs.type) || ( type == rhs.type && id < rhs.id); 00041 } 00042 const ElemID& operator =(const ElemID &rhs) { 00043 type = rhs.type; 00044 id = rhs.id; 00045 return *this; 00046 } 00047 virtual void pup(PUP::er &p){ 00048 p | type; 00049 p | id; 00050 }; 00051 00052 static ElemID createNodeID(int type,int node){ 00053 ElemID temp(type, node); 00054 return temp; 00055 } 00056 int getSignedId() { 00057 if(type<0){ 00058 return FEM_From_ghost_index(id); 00059 } 00060 else return id; 00061 } 00062 int getSignedType(){ 00063 return type; 00064 } 00066 int getUnsignedType(){ 00067 if(type>=0) 00068 return type; 00069 else 00070 return -(type+1); 00071 } 00072 00073 00074 }; 00075 00076 00077 00078 #endif