src/FieldLayout/Vnode.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  *
00007  * Visit http://people.web.psi.ch/adelmann/ for more details
00008  *
00009  ***************************************************************************/
00010 
00011 #ifndef VNODE_H
00012 #define VNODE_H
00013 
00014 // include files
00015 #include "Utility/RefCounted.h"
00016 #include "Utility/Pooled.h"
00017 #include "Index/NDIndex.h"
00018 
00019 #ifdef IPPL_USE_STANDARD_HEADERS
00020 #include <iostream>
00021 using namespace std;
00022 #else
00023 #include <iostream.h>
00024 #endif
00025 
00026 // forward declarations
00027 template <unsigned Dim> class Vnode;
00028 template <unsigned Dim>
00029 ostream& operator<<(ostream&, const Vnode<Dim>&);
00030 
00031 
00032 //----------------------------------------------------------------------
00033 //
00034 // Vnodes really have very little information.
00035 // It knows its domain and what processor it resides on.
00036 // 
00037 // Also, it has a global integer index for the vnode (useful with more recent
00038 // FieldLayouts which store a logical "array" of vnodes; user specifies numbers
00039 // of vnodes along each direction). Classes or user codes that use Vnode are
00040 // responsible for setting and managing the values of this index; if unset, it
00041 // has the value -1.
00042 //
00043 //----------------------------------------------------------------------
00044 
00045 template<unsigned Dim>
00046 class Vnode : public RefCounted, public Pooled< Vnode<Dim> >
00047 {
00048 
00049 private:
00050   NDIndex<Dim> Domain;
00051   int Node;
00052   int vnode_m; // Global vnode ID number (between 0 and nvnodes - 1)
00053 
00054 public: 
00055   // Null ctor does nothing.
00056   Vnode() {}
00057 
00058   // Normal ctor:
00059   Vnode(const NDIndex<Dim>& domain, int node, int vnode=-1) : 
00060     Domain(domain), Node(node), vnode_m(vnode) {}
00061 
00062   // Copy ctor:
00063   Vnode(const Vnode<Dim>& vn) :
00064     Domain(vn.Domain), Node(vn.Node), vnode_m(vn.vnode_m) {}
00065 
00066   // operator= to copy one vnode into another
00067   Vnode<Dim> &operator=(const Vnode<Dim> &vn) {
00068     Domain = vn.Domain;
00069     Node = vn.Node;
00070     vnode_m = vn.vnode_m;
00071     return *this;
00072   }
00073 
00074   int getNode() const { return Node; }
00075   int getVnode() const { return vnode_m; }
00076   const NDIndex<Dim>& getDomain() const { return Domain; }
00077   
00078   // put data into a message to send to another node
00079   Message& putMessage(Message& m) const {
00080     Domain.putMessage(m);
00081     m.put(Node);
00082     m.put(vnode_m);
00083     return m;
00084   }
00085 
00086   // get data out from a message
00087   Message& getMessage(Message& m) {
00088     Domain.getMessage(m);
00089     m.get(Node);
00090     m.get(vnode_m);
00091     return m;
00092   }
00093 
00094 };
00095 
00097 
00098 template <unsigned Dim>
00099 inline ostream&
00100 operator<<(ostream& out, const Vnode<Dim>& v) {
00101   out << "Node = " << v.getNode() << " ; vnode_m = " << v.getVnode()
00102       << " ; Domain = " << v.getDomain();
00103   return out;
00104 }
00105 
00106 
00107 #endif // VNODE_H
00108 
00109 /***************************************************************************
00110  * $RCSfile: Vnode.h,v $   $Author: adelmann $
00111  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:27 $
00112  * IPPL_VERSION_ID: $Id: Vnode.h,v 1.1.1.1 2003/01/23 07:40:27 adelmann Exp $ 
00113  ***************************************************************************/

Generated on Mon Jan 16 13:23:47 2006 for IPPL by  doxygen 1.4.6