tStarStencil.hh - pism - [fork] customized build of PISM, the parallel ice sheet model (tillflux branch)
HTML git clone git://src.adamsgaard.dk/pism
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
tStarStencil.hh (1852B)
---
1 /* Copyright (C) 2015, 2016 PISM Authors
2 *
3 * This file is part of PISM.
4 *
5 * PISM is free software; you can redistribute it and/or modify it under the
6 * terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * PISM is distributed in the hope that it will be useful, but WITHOUT ANY
11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with PISM; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20 #ifndef _STARSTENCIL_H_
21 #define _STARSTENCIL_H_
22
23 namespace pism {
24 enum Direction {North = 0, East, South, West};
25
26 //! \brief Star stencil points (in the map-plane).
27 template <typename T>
28 struct StarStencil {
29 T ij, e, w, n, s;
30
31 StarStencil() {
32 // empty
33 }
34
35 StarStencil(T value) {
36 set(value);
37 }
38
39 void set(T input) {
40 ij = e = w = n = s = input;
41 }
42
43 //! Get the element corresponding to a given direction.
44 //! Use foo.ij to get the value at i,j (center of the star).
45 inline T& operator[](Direction direction) {
46 switch (direction) {
47 default: // just to silence the warning
48 case North:
49 return n;
50 case East:
51 return e;
52 case South:
53 return s;
54 case West:
55 return w;
56 }
57 }
58
59 inline const T& operator[](Direction direction) const {
60 switch (direction) {
61 default: // just to silence the warning
62 case North:
63 return n;
64 case East:
65 return e;
66 case South:
67 return s;
68 case West:
69 return w;
70 }
71 }
72 };
73
74 }
75
76 #endif /* _STARSTENCIL_H_ */