OPAL (Object Oriented Parallel Accelerator Library) 2022.1
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
19template<unsigned Dim>
21{
22
23public:
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 constexpr GuardCellSizes<Dim>(const GuardCellSizes<Dim>&) = default;
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
60private:
61
62 unsigned Left[Dim];
63 unsigned Right[Dim];
64
65};
66
67template<unsigned Dim>
68inline 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
78template<unsigned Dim>
79// Lexigraphic compare of two GuardCellSizes so we can
80// use them as a Key in a map.
81inline 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
94template<unsigned Dim>
95inline 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
110template<unsigned Dim>
111std::ostream& operator<<(std::ostream&,const GuardCellSizes<Dim>&);
112
114
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 ***************************************************************************/
const unsigned Dim
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
Definition: ReductionLoc.h:76
std::ostream & operator<<(std::ostream &, const GuardCellSizes< Dim > &)
NDIndex< Dim > AddGuardCells(const NDIndex< Dim > &idx, const GuardCellSizes< Dim > &g)
unsigned Right[Dim]
unsigned Left[Dim]
unsigned left(unsigned d) const
GuardCellSizes< Dim > & operator=(const GuardCellSizes< Dim > &gc)
bool operator==(const GuardCellSizes< Dim > &r) const
void set_Right(unsigned s)
void set_Left(unsigned s)
bool operator<(const GuardCellSizes< Dim > &r) const
unsigned right(unsigned d) const
Definition: Index.h:237