OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
GuardCellSizes.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 GUARD_CELL_SIZES_H
12 #define GUARD_CELL_SIZES_H
13 
14 // include files
15 #include "Index/NDIndex.h"
16 
17 #include <iostream>
18 
19 template<unsigned Dim>
20 class GuardCellSizes
21 {
22 
23 public:
24 
26  {
27  for (unsigned d=0; d<Dim; ++d)
28  Left[d] = Right[d] = 0;
29  }
30  GuardCellSizes(unsigned s);
31  GuardCellSizes(unsigned *s);
32  GuardCellSizes(unsigned l, unsigned r);
33  GuardCellSizes(unsigned *l, unsigned *r);
34 
36  {
37  for (unsigned d=0; d<Dim; ++d) {
38  Left[d] = gc.Left[d];
39  Right[d] = gc.Right[d];
40  }
41  return *this;
42  }
43 
44  void set_Left(unsigned s);
45  void set_Left(unsigned *s);
46  void set_Left(unsigned d, unsigned *s);
47 
48  void set_Right(unsigned s);
49  void set_Right(unsigned *s);
50  void set_Right(unsigned d, unsigned *s);
51 
52  unsigned left(unsigned d) const { return Left[d]; }
53  unsigned right(unsigned d) const { return Right[d]; }
54 
55  // Lexigraphic compare of two GuardCellSizes so we can
56  // use them as a Key in a map.
57  bool operator<(const GuardCellSizes<Dim>& r) const ;
58  bool operator==(const GuardCellSizes<Dim>& r) const;
59 
60 private:
61 
62  unsigned Left[Dim];
63  unsigned Right[Dim];
64 
65 };
66 
67 template<unsigned Dim>
68 inline NDIndex<Dim>
70 {
71  NDIndex<Dim> ret;
72  for (unsigned int d=0; d<Dim; ++d)
73  ret[d] = Index(idx[d].min() - g.left(d), idx[d].max() + g.right(d));
74  return ret;
75 }
76 
77 
78 template<unsigned Dim>
79 // Lexigraphic compare of two GuardCellSizes so we can
80 // use them as a Key in a map.
81 inline bool
83 {
84  for (unsigned d=0; d<Dim; ++d) {
85  if ( left(d) != r.left(d) )
86  return ( left(d) < r.left(d) );
87  if ( right(d) != r.right(d) )
88  return ( right(d) < r.right(d) );
89  }
90  // If we get here they're equal.
91  return false;
92 }
93 
94 template<unsigned Dim>
95 inline bool
97 {
98  for (unsigned d=0; d<Dim; ++d) {
99  if ( left(d) != r.left(d) )
100  return false;
101  if ( right(d) != r.right(d) )
102  return false;
103  }
104  // If we get here they're equal.
105  return true;
106 }
107 
109 
110 template<unsigned Dim>
111 std::ostream& operator<<(std::ostream&,const GuardCellSizes<Dim>&);
112 
114 
115 #include "Field/GuardCellSizes.hpp"
116 
117 #endif // GUARD_CELL_SIZES_H
118 
119 /***************************************************************************
120  * $RCSfile: GuardCellSizes.h,v $ $Author: adelmann $
121  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:26 $
122  * IPPL_VERSION_ID: $Id: GuardCellSizes.h,v 1.1.1.1 2003/01/23 07:40:26 adelmann Exp $
123  ***************************************************************************/
void set_Right(unsigned s)
unsigned left(unsigned d) const
NDIndex< Dim > AddGuardCells(const NDIndex< Dim > &idx, const GuardCellSizes< Dim > &g)
void set_Left(unsigned s)
unsigned Right[Dim]
bool operator==(const GuardCellSizes< Dim > &r) const
bool operator<(const GuardCellSizes< Dim > &r) const
Definition: Index.h:236
GuardCellSizes< Dim > & operator=(const GuardCellSizes< Dim > &gc)
unsigned right(unsigned d) const
const unsigned Dim
unsigned Left[Dim]
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:95