fei_Dof.hpp

00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2009 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #ifndef _fei_Dof_hpp_
00010 #define _fei_Dof_hpp_
00011 
00012 #include <fei_macros.hpp>
00013 
00014 namespace fei {
00015 
00039 template<class LocalOrdinal, class GlobalOrdinal>
00040 class Dof {
00041  public:
00043   Dof(LocalOrdinal rank, GlobalOrdinal id, LocalOrdinal field)
00044    : m_rank(rank), m_id(id), m_field(field) {}
00045 
00047   ~Dof(){}
00048 
00049   LocalOrdinal rank() const { return m_rank; }
00050   GlobalOrdinal id() const { return m_id; }
00051   LocalOrdinal field() const { return m_field; }
00052 
00053  private:
00054   LocalOrdinal m_rank;
00055   GlobalOrdinal m_id;
00056   LocalOrdinal m_field;
00057 };//class Dof
00058 
00061 template<class LocalOrdinal, class GlobalOrdinal>
00062 struct less_rank_id_field {
00063   bool operator()(const Dof<LocalOrdinal,GlobalOrdinal>& dof1,
00064                  const Dof<LocalOrdinal,GlobalOrdinal>& dof2) const
00065   {
00066     if (dof1.rank()==dof2.rank()) {
00067       if (dof1.id() == dof2.id()) return dof1.field() < dof2.field();
00068       else return dof1.id() < dof2.id();
00069     }
00070     else {
00071       return dof1.rank() < dof2.rank();
00072     }
00073   }
00074 
00075   bool operator()(const Dof<LocalOrdinal,GlobalOrdinal>* dof1,
00076                  const Dof<LocalOrdinal,GlobalOrdinal>* dof2) const
00077   {
00078     if (dof1->rank()==dof2->rank()) {
00079       if (dof1->id() == dof2->id()) return dof1->field() < dof2->field();
00080       else return dof1->id() < dof2->id();
00081     }
00082     else {
00083       return dof1->rank() < dof2->rank();
00084     }
00085   }
00086 };
00087 
00090 template<class LocalOrdinal, class GlobalOrdinal>
00091 struct less_field_rank_id {
00092   bool operator()(const Dof<LocalOrdinal,GlobalOrdinal>& dof1,
00093                  const Dof<LocalOrdinal,GlobalOrdinal>& dof2) const
00094   {
00095     if (dof1.field()==dof2.field()) {
00096       if (dof1.rank() == dof2.rank()) return dof1.id() < dof2.id();
00097       else return dof1.rank() < dof2.rank();
00098     }
00099     else {
00100       return dof1.field() < dof2.field();
00101     }
00102   }
00103 
00104   bool operator()(const Dof<LocalOrdinal,GlobalOrdinal>* dof1,
00105                  const Dof<LocalOrdinal,GlobalOrdinal>* dof2) const
00106   {
00107     if (dof1->field()==dof2->field()) {
00108       if (dof1->rank() == dof2->rank()) return dof1->id() < dof2->id();
00109       else return dof1->rank() < dof2->rank();
00110     }
00111     else {
00112       return dof1->field() < dof2->field();
00113     }
00114   }
00115 };
00116 
00117 }//namespace fei
00118 #endif
00119 

Generated on Tue Jul 13 09:27:44 2010 for FEI by  doxygen 1.4.7