OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
FieldLoc.h
Go to the documentation of this file.
1// -*- C++ -*-
2/***************************************************************************
3 *
4 * The IPPL Framework
5 *
6 *
7 * Visit http://people.web.psi.ch/adelmann/ for more details
8 *
9 ***************************************************************************/
10
11#ifndef FIELD_LOC_H
12#define FIELD_LOC_H
13
14/***************************************************************************
15 *
16 * This simple class stores information about where in a Field
17 * iterator the user wants to refer to. You can ask a Field::iterator
18 * for its current FieldLoc, and set that iterator to point to the
19 * location of a given FieldLoc. It stores the current LField, and the
20 * global index of the current point.
21 *
22 ***************************************************************************/
23
24// include files
25#include "Utility/Vec.h"
26
27
28template <unsigned Dim>
29class FieldLoc {
30
31public:
32 // constructor: provide the global index of the point, and an LField
33 // 'index', which refers to the Nth LField in the relevant FieldLayout's
34 // list of local vnodes.
35 FieldLoc(const vec<int,Dim>& v, int f) : loc(v), LFIndex(f) { }
36
37 // copy constructor
38 FieldLoc(const FieldLoc<Dim>& fl) : loc(fl.loc), LFIndex(fl.LFIndex) { }
39
40 // default constructor
41 FieldLoc() : LFIndex(-1) { }
42
43 // destructor
45
46 // equals operator
48 if (&fl != this) {
49 loc = fl.loc;
50 LFIndex = fl.LFIndex;
51 }
52 return *this;
53 }
54
55 // query for the current global location
56 int &operator[](int n) { return loc[n]; }
57 int operator[](int n) const { return loc[n]; }
58
59 // query for the current LField index. If -1, this does not point to any
60 // LField.
61 int getIndex() const { return LFIndex; }
62
63 // change the index of the LField
64 void setIndex(int newval) { LFIndex = newval; }
65
66 // return an NDIndex with the point as one-element Index objects
68 NDIndex<Dim> retval;
69 for (unsigned int d=0; d < Dim; ++d)
70 retval[d] = Index(loc[d], loc[d]);
71 return retval;
72 }
73
74private:
75 // the global index for this point
77
78 // the index of the LField in FieldLayout's list of local LField's
80};
81
82
83#endif // FIELD_LOC_H
84
85/***************************************************************************
86 * $RCSfile: FieldLoc.h,v $ $Author: adelmann $
87 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:26 $
88 * IPPL_VERSION_ID: $Id: FieldLoc.h,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $
89 ***************************************************************************/
const unsigned Dim
int & operator[](int n)
Definition: FieldLoc.h:56
FieldLoc< Dim > & operator=(const FieldLoc< Dim > &fl)
Definition: FieldLoc.h:47
int LFIndex
Definition: FieldLoc.h:79
FieldLoc(const FieldLoc< Dim > &fl)
Definition: FieldLoc.h:38
~FieldLoc()
Definition: FieldLoc.h:44
vec< int, Dim > loc
Definition: FieldLoc.h:76
int getIndex() const
Definition: FieldLoc.h:61
NDIndex< Dim > getDomain() const
Definition: FieldLoc.h:67
FieldLoc()
Definition: FieldLoc.h:41
FieldLoc(const vec< int, Dim > &v, int f)
Definition: FieldLoc.h:35
void setIndex(int newval)
Definition: FieldLoc.h:64
int operator[](int n) const
Definition: FieldLoc.h:57
Definition: Index.h:237