tPISM.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.i (10994B)
---
1 // Copyright (C) 2011--2020 David Maxwell and Constantine Khroulev
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 %module(directors="1") cpp
20 %feature("autodoc", "2");
21
22 /* Don't warn about
23 * - 312,325 Nested classes not currently supported (ignored).
24 * - 503. Can't wrap 'identifier' unless renamed to a valid identifier.
25 * - 512. Overloaded declaration const ignored. Non-const method at file:line used.
26 */
27 #pragma SWIG nowarn=312,325,503,512
28
29 %{
30 // The material in this section is included verbatim in the C++ source code generated by SWIG.
31 // The necessary header files required to compile must be included.
32 // This list is NOT the whole set of headers being wrapped; it is just the list of includes that
33 // draws in all the other needed includes as well. See the end of this file for the list
34 // of PISM headers being wrapped.
35
36 #include "util/interpolation.hh"
37
38 #include "util/pism_utilities.hh"
39
40 #include "util/Units.hh"
41 #include "pism_python.hh"
42
43 #include "geometry/grounded_cell_fraction.hh"
44 #include "util/Mask.hh"
45 #include "basalstrength/basal_resistance.hh"
46 #include "util/EnthalpyConverter.hh"
47 #include "basalstrength/MohrCoulombYieldStress.hh"
48 #include "util/error_handling.hh"
49 #include "util/Diagnostic.hh"
50 #include "util/Config.hh"
51
52 #if (Pism_USE_JANSSON==1)
53 #include "util/ConfigJSON.hh"
54 #endif
55
56 #include "util/MaxTimestep.hh"
57 #include "stressbalance/timestepping.hh"
58 #include "util/Context.hh"
59 #include "util/Logger.hh"
60 #include "util/Profiling.hh"
61
62 #include "util/projection.hh"
63 #include "energy/bootstrapping.hh"
64 #include "util/node_types.hh"
65
66 #include "util/Time.hh"
67 #include "util/Time_Calendar.hh"
68 #include "util/Poisson.hh"
69 #include "util/label_components.hh"
70 %}
71
72 // Tell SWIG that the following variables are truly constant
73 %immutable pism::revision;
74 %immutable pism::config_file;
75 %immutable pism::petsc_configure_flags;
76 %immutable pism::petsc4py_version;
77 %immutable pism::swig_version;
78 %immutable pism::cmake_version;
79 %include "pism/pism_config.hh"
80
81 // Include petsc4py.i so that we get support for automatic handling of PetscErrorCode return values
82 %include "petsc4py/petsc4py.i"
83
84 %include "pism_exception.i"
85
86 // Automatic conversions between std::string and python string arguments and return values
87 %include std_string.i
88 // Conversions between python lists and certain STL vectors
89 %include std_vector.i
90 %include std_set.i
91 %include std_map.i
92
93 %include <std_shared_ptr.i>
94
95 // Add a PISM class
96 %define pism_class(name, header)
97 %{
98 #include header
99 %}
100 %shared_ptr(name)
101 %include header
102 %enddef
103
104 %template(SizetVector) std::vector<size_t>;
105 %template(IntVector) std::vector<int>;
106 %template(UnsignedIntVector) std::vector<unsigned int>;
107 %template(DoubleVector) std::vector<double>;
108 %template(StringVector) std::vector<std::string>;
109 %template(StringSet) std::set<std::string>;
110 %template(DoubleVectorMap) std::map<std::string, std::vector<double> >;
111 %template(BoolMap) std::map<std::string, bool >;
112 %template(StringMap) std::map<std::string, std::string>;
113 %template(DiagnosticMap) std::map<std::string, std::shared_ptr<pism::Diagnostic> >;
114
115 // Why did I include this?
116 %include "cstring.i"
117
118 /* Type map for treating reference arguments as output. */
119 %define %Pism_reference_output_typemaps(TYPE)
120 %typemap(in, numinputs=0,noblock=1) TYPE & OUTPUT (TYPE temp) {
121 $1 = &temp;
122 }
123 %typemap(argout,noblock=1) TYPE & OUTPUT
124 {
125 %append_output(SWIG_NewPointerObj(%as_voidptr($1), $descriptor, 0 | %newpointer_flags));
126 };
127 %enddef
128
129 /* Tell SWIG that reference arguments are always output. */
130 %define %Pism_reference_is_always_output(TYPE)
131 %Pism_reference_output_typemaps(TYPE);
132 %apply TYPE & OUTPUT { TYPE &}
133 %enddef
134
135 %typemap(in, numinputs=0,noblock=1) bool & OUTPUT (bool temp = false) {
136 $1 = &temp;
137 }
138
139 %typemap(argout,noblock=1) bool & OUTPUT
140 {
141 %append_output(SWIG_From(bool)(*$1));
142 };
143
144 %typemap(in, numinputs=0,noblock=1) std::string& result (std::string temp) {
145 $1 = &temp;
146 }
147
148 %typemap(in, numinputs=0,noblock=1) std::string& OUTPUT (std::string temp) {
149 $1 = &temp;
150 }
151
152 %typemap(argout,noblock=1) std::string & OUTPUT
153 {
154 %append_output(SWIG_FromCharPtr((*$1).c_str()));
155 }
156
157 %apply std::string &OUTPUT { std::string &result}
158
159 %typemap(in, numinputs=0,noblock=1) std::vector<double> & OUTPUT (std::vector<double> temp) {
160 $1 = &temp;
161 }
162
163 %typemap(argout,noblock=1) std::vector<double> & OUTPUT
164 {
165 int len;
166 len = $1->size();
167 $result = PyList_New(len);
168 int i;
169 for (i=0; i<len; i++) {
170 PyList_SetItem($result, i, PyFloat_FromDouble((*$1)[i]));
171 }
172 }
173
174 %apply std::vector<double> & OUTPUT {std::vector<double> &result};
175 %apply std::vector<std::string> & OUTPUT {std::vector<std::string> & result};
176
177 %apply int &OUTPUT {int &result};
178 %apply int *OUTPUT {int *out_mask};
179
180 %apply double & OUTPUT {double & result};
181 %apply double & OUTPUT {double & out};
182 %apply double * OUTPUT {double * result};
183 %apply bool & OUTPUT {bool & is_set, bool & result, bool & flag, bool & success};
184
185 // The SWIG built-in typecheck for a const char [] (used, e.g., with overloaded methods) checks that
186 // the string is zero length. So we have this bug fix from SWIG developer William Fulton here.
187 %typemap(typecheck,noblock=1,precedence=SWIG_TYPECHECK_STRING, fragment="SWIG_AsCharPtrAndSize") const char[] {
188 int res = SWIG_AsCharPtrAndSize($input, 0, NULL, 0);
189 $1 = SWIG_CheckState(res);
190 }
191
192
193 /* PISM header with no dependence on other PISM headers. */
194 %include "util/pism_utilities.hh"
195 %include "util/interpolation.hh"
196
197 %shared_ptr(pism::Logger);
198 %shared_ptr(pism::StringLogger);
199 %include "util/Logger.hh"
200
201 %include pism_options.i
202
203 %ignore pism::Vector2::operator=;
204 %include "util/Vector2.hh"
205
206 %ignore pism::units::Unit::operator=;
207 %rename(UnitSystem) pism::units::System;
208 %rename(UnitConverter) pism::units::Converter;
209 %shared_ptr(pism::units::System);
210 %feature("valuewrapper") pism::units::System;
211 %feature("valuewrapper") pism::units::Unit;
212 %include "util/Units.hh"
213
214 %shared_ptr(pism::MaxTimestep)
215 %include "util/MaxTimestep.hh"
216
217 %include pism_DM.i
218 %include pism_Vec.i
219 /* End of independent PISM classes. */
220
221 %shared_ptr(pism::Config);
222 %shared_ptr(pism::NetCDFConfig);
223 %shared_ptr(pism::DefaultConfig);
224 %include "util/ConfigInterface.hh"
225 %include "util/Config.hh"
226
227 #if (Pism_USE_JANSSON==1)
228 %shared_ptr(pism::ConfigJSON);
229 %include "util/ConfigJSON.hh"
230 #endif
231
232 /* EnthalpyConverter uses Config, so we need to wrap Config first (see above). */
233 %shared_ptr(pism::EnthalpyConverter);
234 %shared_ptr(pism::ColdEnthalpyConverter);
235 %include "util/EnthalpyConverter.hh"
236
237 %shared_ptr(pism::Time);
238 %include "util/Time.hh"
239 %shared_ptr(pism::Time_Calendar);
240 %include "util/Time_Calendar.hh"
241
242 %include "util/Profiling.hh"
243 %shared_ptr(pism::Context);
244 %include "util/Context.hh"
245
246 %include pism_IceGrid.i
247
248 /* File uses IceGrid, so IceGrid has to be wrapped first. */
249 %include pism_File.i
250
251 /* make sure pism_File.i is included before VariableMetadata.hh */
252 %include pism_VariableMetadata.i
253
254 /* Timeseries uses IceGrid and VariableMetadata so they have to be wrapped first. */
255 %include pism_Timeseries.i
256
257 /* IceModelVec uses IceGrid and VariableMetadata so they have to be wrapped first. */
258 %include pism_IceModelVec.i
259
260 /* pism::Vars uses IceModelVec, so IceModelVec has to be wrapped first. */
261 %include pism_Vars.i
262
263
264 %shared_ptr(pism::Diagnostic)
265 %include "util/Diagnostic.hh"
266 %include "stressbalance/timestepping.hh"
267
268 %shared_ptr(pism::Component)
269 %include "util/Component.hh"
270
271 /* GeometryEvolution is a Component, so this has to go after Component.hh */
272 %include geometry.i
273
274 %include "basalstrength/basal_resistance.hh"
275
276 %include pism_FlowLaw.i
277
278 %include pism_ColumnSystem.i
279
280 %include pism_energy.i
281
282 /* SSAForwardRunFromInputFile sets up a yield stress model, which
283 * requires a hydrology model.
284 */
285 %include pism_Hydrology.i
286
287 %include "geometry/grounded_cell_fraction.hh"
288 %include "util/Mask.hh"
289 %include "pism_python.hh"
290
291 pism_class(pism::MohrCoulombPointwise, "pism/basalstrength/MohrCoulombPointwise.hh")
292 pism_class(pism::YieldStress, "pism/basalstrength/YieldStress.hh")
293 pism_class(pism::ConstantYieldStress, "pism/basalstrength/ConstantYieldStress.hh")
294 pism_class(pism::MohrCoulombYieldStress, "pism/basalstrength/MohrCoulombYieldStress.hh")
295 pism_class(pism::RegionalYieldStress, "pism/regional/RegionalYieldStress.hh")
296
297 %rename(StressBalanceInputs) pism::stressbalance::Inputs;
298
299 %include pism_SSA.i
300
301 %include pism_SIA.i
302
303 %include pism_BedDef.i
304
305 %include AgeModel.i
306
307 /* The regional model implements some classes derived from SSAFD and
308 * SIAFD, so this %include has to appear after %including the rest of
309 * PISM's stress balance headers.
310 */
311 %{
312 #include "regional/SSAFD_Regional.hh"
313 #include "regional/SIAFD_Regional.hh"
314 %}
315 %shared_ptr(pism::stressbalance::SSAFD_Regional)
316 %include "regional/SSAFD_Regional.hh"
317 %shared_ptr(pism::stressbalance::SIAFD_Regional)
318 %include "regional/SIAFD_Regional.hh"
319
320 %include "util/projection.hh"
321
322
323 %ignore pism::fem::q1::chi;
324 %ignore pism::fem::q1::n_chi;
325 %ignore pism::fem::q1::n_sides;
326 %ignore pism::fem::q1::incident_nodes;
327 %ignore pism::fem::p1::chi;
328 %ignore pism::fem::p1::n_sides;
329 %ignore pism::fem::p1::incident_nodes;
330 %include "util/FETools.hh"
331 %include "util/node_types.hh"
332
333 %include pism_inverse.i
334
335 %include "coupler/util/PCFactory.hh"
336 %{
337 #include "coupler/util/options.hh"
338 %}
339 %include "coupler/util/options.hh"
340
341 %shared_ptr(pism::PCFactory< pism::surface::SurfaceModel >)
342 %template(_SurfaceFactoryBase) pism::PCFactory<pism::surface::SurfaceModel>;
343
344 %shared_ptr(pism::PCFactory<pism::ocean::OceanModel>)
345 %template(_OceanFactoryBase) pism::PCFactory<pism::ocean::OceanModel>;
346
347 %shared_ptr(pism::PCFactory<pism::ocean::sea_level::SeaLevel>)
348 %template(_SeaLevelFactoryBase) pism::PCFactory<pism::ocean::sea_level::SeaLevel>;
349
350 %shared_ptr(pism::PCFactory<pism::atmosphere::AtmosphereModel>)
351 %template(_AtmosphereFactoryBase) pism::PCFactory<pism::atmosphere::AtmosphereModel>;
352
353 %include pism_ocean.i
354
355 %include pism_frontalmelt.i
356
357 /* surface models use atmosphere models as inputs so we need to define atmosphere models first */
358 %include pism_atmosphere.i
359
360 %include pism_surface.i
361
362 %include pism_calving.i
363
364 %include pism_verification.i
365
366 %include "energy/bootstrapping.hh"
367
368 %shared_ptr(pism::Poisson)
369 %include "util/Poisson.hh"
370
371 pism_class(pism::FractureDensity, "pism/fracturedensity/FractureDensity.hh")
372 %include "util/label_components.hh"