src/Field/FieldLoc.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 FIELD_LOC_H
00012 #define FIELD_LOC_H
00013 
00014 /***************************************************************************
00015  *
00016  * This simple class stores information about where in a Field
00017  * iterator the user wants to refer to.  You can ask a Field::iterator
00018  * for its current FieldLoc, and set that iterator to point to the
00019  * location of a given FieldLoc.  It stores the current LField, and the
00020  * global index of the current point.
00021  *
00022  ***************************************************************************/
00023 
00024 // include files
00025 #include "Utility/Vec.h"
00026 
00027 
00028 template <unsigned Dim>
00029 class FieldLoc {
00030 
00031 public:
00032   // constructor: provide the global index of the point, and an LField
00033   // 'index', which refers to the Nth LField in the relevant FieldLayout's
00034   // list of local vnodes.
00035   FieldLoc(const vec<int,Dim>& v, int f) : loc(v), LFIndex(f) { }
00036 
00037   // copy constructor
00038   FieldLoc(const FieldLoc<Dim>& fl) : loc(fl.loc), LFIndex(fl.LFIndex) { }
00039   
00040   // default constructor
00041   FieldLoc() : LFIndex(-1) { }
00042 
00043   // destructor
00044   ~FieldLoc() { }
00045 
00046   // equals operator
00047   FieldLoc<Dim>& operator=(const FieldLoc<Dim>& fl) {
00048     if (&fl != this) {
00049       loc = fl.loc;
00050       LFIndex = fl.LFIndex;
00051     }
00052     return *this;
00053   }
00054 
00055   // query for the current global location
00056   int &operator[](int n) { return loc[n]; }
00057   int operator[](int n) const { return loc[n]; }
00058 
00059   // query for the current LField index.  If -1, this does not point to any
00060   // LField.
00061   int getIndex() const { return LFIndex; }
00062 
00063   // change the index of the LField
00064   void setIndex(int newval) { LFIndex = newval; }
00065 
00066   // return an NDIndex with the point as one-element Index objects
00067   NDIndex<Dim> getDomain() const {
00068     NDIndex<Dim> retval;
00069     for (int d=0; d < Dim; ++d)
00070       retval[d] = Index(loc[d], loc[d]);
00071     return retval;
00072   }
00073 
00074 private:
00075   // the global index for this point
00076   vec<int,Dim> loc;
00077 
00078   // the index of the LField in FieldLayout's list of local LField's
00079   int LFIndex;
00080 };
00081 
00082 
00083 #endif // FIELD_LOC_H
00084 
00085 /***************************************************************************
00086  * $RCSfile: FieldLoc.h,v $   $Author: adelmann $
00087  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:26 $
00088  * IPPL_VERSION_ID: $Id: FieldLoc.h,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $ 
00089  ***************************************************************************/

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