tpism_IceModelVec.i - 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
---
tpism_IceModelVec.i (3370B)
---
1 %{
2 /* Using directives needed to compile IceModelVec wrappers. */
3 #include "util/IceModelVec2CellType.hh"
4 #include "util/iceModelVec2T.hh"
5 #include "util/iceModelVec3Custom.hh"
6
7 using namespace pism;
8 %}
9
10 %shared_ptr(pism::PetscAccessible)
11 %shared_ptr(pism::IceModelVec)
12 %shared_ptr(pism::IceModelVec2)
13 %shared_ptr(pism::IceModelVec2S)
14 %shared_ptr(pism::IceModelVec2T)
15 %shared_ptr(pism::IceModelVec2V)
16 %shared_ptr(pism::IceModelVec2Int)
17 %shared_ptr(pism::IceModelVec2CellType)
18 %shared_ptr(pism::IceModelVec2Stag)
19 %shared_ptr(pism::IceModelVec3D)
20 %shared_ptr(pism::IceModelVec3)
21 %shared_ptr(pism::IceModelVec3Custom)
22
23 %ignore pism::AccessList::AccessList(std::initializer_list<const PetscAccessible *>);
24
25 %ignore pism::IceModelVec2S::get_array;
26 %ignore pism::IceModelVec2V::get_array;
27
28 %rename(_regrid) pism::IceModelVec::regrid;
29 %extend pism::IceModelVec
30 {
31 %pythoncode "IceModelVec.py"
32 }
33
34 // We also make the same fix for IceModelVec2's.
35 %rename(_regrid) pism::IceModelVec2::regrid;
36 %extend pism::IceModelVec2
37 {
38 %pythoncode {
39 def regrid(self,filename,critical=False,default_value=0.0):
40 if critical == True:
41 flag = CRITICAL
42 else:
43 flag = OPTIONAL
44 self._regrid(filename, flag, default_value)
45 }
46 }
47
48 // Shenanigans to allow python indexing to get at IceModelVec entries. I couldn't figure out a more
49 // elegant solution.
50 %extend pism::IceModelVec2S
51 {
52 double getitem(int i, int j)
53 {
54 return (*($self))(i,j);
55 }
56
57 void setitem(int i, int j, double val)
58 {
59 (*($self))(i,j) = val;
60 }
61
62 %pythoncode "IceModelVec2S.py"
63 };
64
65 %rename(__mult__) pism::Vector2::operator*;
66 %rename(__add__) pism::Vector2::operator+;
67 %ignore operator*(const double &a, const pism::Vector2 &v1);
68 %extend pism::Vector2
69 {
70 %pythoncode
71 {
72 def __lmul__(self,a):
73 return self.__mul__(self,a)
74 }
75 }
76
77 %extend pism::IceModelVec2V
78 {
79 Vector2 &getitem(int i, int j)
80 {
81 return (*($self))(i,j);
82 }
83
84 void setitem(int i, int j, Vector2 val)
85 {
86 (*($self))(i,j) = val;
87 }
88
89 void setitem(int i, int j, double u, double v)
90 {
91 (*($self))(i,j).u = u;
92 (*($self))(i,j).v = v;
93 }
94
95 %pythoncode "IceModelVec2V.py"
96 };
97
98 %ignore pism::IceModelVec3D::getInternalColumn(int,int) const;
99 %ignore pism::IceModelVec3D::operator();
100 %extend pism::IceModelVec3D
101 {
102
103 double getitem(int i, int j, int k)
104 {
105 return (*($self))(i,j,k);
106 }
107
108 void setitem(int i, int j, int k, double val)
109 {
110 (*($self))(i,j,k) = val;
111 }
112
113
114 %pythoncode {
115 def __getitem__(self,*args):
116 return self.getitem(args[0][0],args[0][1],args[0][2])
117
118 def __setitem__(self,*args):
119 if(len(args)==2):
120 self.setitem(args[0][0],args[0][1],args[0][2],args[1])
121 else:
122 raise ValueError("__setitem__ requires 2 arguments; received %d" % len(args));
123 }
124 };
125
126 %ignore pism::IceModelVec2T::interp(int, int, double*);
127 %extend pism::IceModelVec2T
128 {
129 std::vector<double> interp(int i, int j) {
130 std::vector<double> result;
131 $self->interp(i, j, result);
132 return result;
133 }
134 };
135
136 %ignore pism::StarStencil::operator[];
137 %include "util/StarStencil.hh"
138 %template(DoubleStar) pism::StarStencil<double>;
139
140 %include "util/iceModelVec.hh"
141 %include "util/IceModelVec2CellType.hh"
142 %include "util/iceModelVec2T.hh"
143 %include "util/Vector2.hh"
144
145 %include "util/iceModelVec3Custom.hh"