1
/* ----------------------------------------------------------------------------
2
* This file was automatically generated by SWIG (http://www.swig.org).
5
* This file is not intended to be easily readable and contains a number of
6
* coding conventions designed to improve portability and efficiency. Do not make
7
* changes to this file unless you know what you are doing--modify the SWIG
8
* interface file instead.
9
* ----------------------------------------------------------------------------- */
11
#ifndef SWIG_dolfin_WRAP_H_
12
#define SWIG_dolfin_WRAP_H_
17
#ifndef SWIG_DIRECTOR_PYTHON_HEADER_
18
#define SWIG_DIRECTOR_PYTHON_HEADER_
19
/***********************************************************************
22
* This file contains support for director classes that proxy
23
* method calls from C++ to Python extensions.
25
* Author : Mark Rose (mrose@stm.lbl.gov)
26
************************************************************************/
36
Use -DSWIG_DIRECTOR_NOUEH if you prefer to avoid the use of the
37
Undefined Exception Handler provided by swift
39
#ifndef SWIG_DIRECTOR_NOUEH
40
#ifndef SWIG_DIRECTOR_UEH
41
#define SWIG_DIRECTOR_UEH
47
Use -DSWIG_DIRECTOR_STATIC if you prefer to avoid the use of the
48
'Swig' namespace. This could be usefull for multi-modules projects.
50
#ifdef SWIG_DIRECTOR_STATIC
51
/* Force anonymous (static) namespace */
57
Use -DSWIG_DIRECTOR_NORTTI if you prefer to avoid the use of the
58
native C++ RTTI and dynamic_cast<>. But be aware that directors
59
could stop working when using this option.
61
#ifdef SWIG_DIRECTOR_NORTTI
63
When we don't use the native C++ RTTI, we implement a minimal one
66
# ifndef SWIG_DIRECTOR_RTDIR
67
# define SWIG_DIRECTOR_RTDIR
71
SWIGINTERN std::map<void*,Director*>& get_rtdir_map() {
72
static std::map<void*,Director*> rtdir_map;
76
SWIGINTERNINLINE void set_rtdir(void *vptr, Director *rtdir) {
77
get_rtdir_map()[vptr] = rtdir;
80
SWIGINTERNINLINE Director *get_rtdir(void *vptr) {
81
std::map<void*,Director*>::const_iterator pos = get_rtdir_map().find(vptr);
82
Director *rtdir = (pos != get_rtdir_map().end()) ? pos->second : 0;
86
# endif /* SWIG_DIRECTOR_RTDIR */
88
# define SWIG_DIRECTOR_CAST(Arg) Swig::get_rtdir(static_cast<void*>(Arg))
89
# define SWIG_DIRECTOR_RGTR(Arg1, Arg2) Swig::set_rtdir(static_cast<void*>(Arg1), Arg2)
93
# define SWIG_DIRECTOR_CAST(Arg) dynamic_cast<Swig::Director*>(Arg)
94
# define SWIG_DIRECTOR_RGTR(Arg1, Arg2)
96
#endif /* SWIG_DIRECTOR_NORTTI */
99
struct swig_type_info;
104
/* base class for director exceptions */
105
class DirectorException {
107
std::string swig_msg;
109
DirectorException(const char* hdr ="", const char* msg ="")
112
if (!PyErr_Occurred()) {
113
PyErr_SetString(PyExc_TypeError, getMessage());
115
SWIG_Python_AddErrMesg(getMessage(), 1);
119
const char *getMessage() const {
120
return swig_msg.c_str();
123
static void raise(const char* msg = "")
125
throw DirectorException(msg);
129
class UnknownExceptionHandler
131
static void handler();
135
#ifdef SWIG_DIRECTOR_UEH
136
std::unexpected_handler old;
137
UnknownExceptionHandler(std::unexpected_handler nh = handler)
139
old = std::set_unexpected(nh);
142
~UnknownExceptionHandler()
144
std::set_unexpected(old);
149
/* type mismatch in the return value from a python method call */
150
class DirectorTypeMismatchException : public Swig::DirectorException {
152
DirectorTypeMismatchException(const char* msg="")
153
: Swig::DirectorException("Swig director type mismatch: ", msg) {
156
static void raise(const char* msg = "")
158
throw DirectorTypeMismatchException(msg);
162
/* any python exception that occurs during a director method call */
163
class DirectorMethodException : public Swig::DirectorException {
165
DirectorMethodException(const char* msg = "")
166
: DirectorException("Swig director python method error: ", msg)
170
static void raise(const char* msg = "")
172
throw DirectorMethodException(msg);
176
/* attempt to call a pure virtual method via a director method */
177
class DirectorPureVirtualException : public Swig::DirectorException
180
DirectorPureVirtualException(const char* msg = "")
181
: DirectorException("Swig director pure virtal method called: ", msg)
185
static void raise(const char* msg = "")
187
throw DirectorPureVirtualException(msg);
192
/* simple thread abstraction for pthreads on win32 */
195
#if defined(_WIN32) || defined(__WIN32__)
196
#define pthread_mutex_lock EnterCriticalSection
197
#define pthread_mutex_unlock LeaveCriticalSection
198
#define pthread_mutex_t CRITICAL_SECTION
199
#define MUTEX_INIT(var) CRITICAL_SECTION var
202
#define MUTEX_INIT(var) pthread_mutex_t var = PTHREAD_MUTEX_INITIALIZER
207
/* director base class */
210
/* pointer to the wrapped python object */
212
/* flag indicating whether the object is owned by python or c++ */
213
mutable bool swig_disown_flag;
214
/* shared flag for breaking recursive director calls */
218
/* locks for sharing the swig_up flag in a threaded environment */
219
static pthread_mutex_t swig_mutex_up;
220
static bool swig_mutex_active;
221
static pthread_t swig_mutex_thread;
224
/* decrement the reference count of the wrapped python object */
225
void swig_decref() const {
226
if (swig_disown_flag) {
227
Py_DECREF(swig_self);
231
/* reset the swig_up flag once the routing direction has been determined */
233
void swig_clear_up() const {
234
Swig::Director::swig_up = false;
235
Swig::Director::swig_mutex_active = false;
236
pthread_mutex_unlock(&swig_mutex_up);
239
void swig_clear_up() const {
240
Swig::Director::swig_up = false;
245
/* wrap a python object, optionally taking ownership */
246
Director(PyObject* self) : swig_self(self), swig_disown_flag(false) {
250
/* discard our reference at destruction */
253
/* return a pointer to the wrapped python object */
254
PyObject *swig_get_self() const {
258
/* get the swig_up flag to determine if the method call should be routed
259
* to the c++ base class or through the wrapped python object
262
bool swig_get_up() const {
263
if (Swig::Director::swig_mutex_active) {
264
if (pthread_equal(Swig::Director::swig_mutex_thread, pthread_self())) {
273
bool swig_get_up() const {
280
/* set the swig_up flag if the next method call should be directed to
281
* the c++ base class rather than the wrapped python object
284
void swig_set_up() const {
285
pthread_mutex_lock(&Swig::Director::swig_mutex_up);
286
Swig::Director::swig_mutex_thread = pthread_self();
287
Swig::Director::swig_mutex_active = true;
288
Swig::Director::swig_up = true;
291
void swig_set_up() const {
292
Swig::Director::swig_up = true;
296
/* acquire ownership of the wrapped python object (the sense of "disown"
298
void swig_disown() const {
299
if (!swig_disown_flag) {
300
swig_disown_flag=true;
305
/* increase the reference count of the wrapped python object */
306
void swig_incref() const {
307
if (swig_disown_flag) {
308
Py_INCREF(swig_self);
312
/* methods to implement pseudo protected director members */
313
virtual bool swig_get_inner(const char* /* name */) const {
317
virtual void swig_set_inner(const char* /* name */, bool /* val */) const {
323
#endif /* __cplusplus */
328
class SwigDirector_Function : public dolfin::Function, public Swig::Director {
331
SwigDirector_Function(PyObject *self, dolfin::real value);
332
SwigDirector_Function(PyObject *self, dolfin::uint vectordim = 1);
333
SwigDirector_Function(PyObject *self, FunctionPointer fp, dolfin::uint vectordim = 1);
334
SwigDirector_Function(PyObject *self, dolfin::Vector &x);
335
SwigDirector_Function(PyObject *self, dolfin::Vector &x, dolfin::Mesh &mesh);
336
SwigDirector_Function(PyObject *self, dolfin::Vector &x, dolfin::Mesh &mesh, dolfin::FiniteElement &element);
337
SwigDirector_Function(PyObject *self, dolfin::Mesh &mesh, dolfin::FiniteElement &element);
338
SwigDirector_Function(PyObject *self, dolfin::Function const &f);
339
virtual dolfin::real eval(dolfin::Point const &p, dolfin::uint i = 0);
340
virtual ~SwigDirector_Function();
343
/* Internal Director utilities */
345
bool swig_get_inner(const char* name) const {
346
std::map<std::string, bool>::const_iterator iv = inner.find(name);
347
return (iv != inner.end() ? iv->second : false);
350
void swig_set_inner(const char* name, bool val) const
351
{ inner[name] = val;}
354
mutable std::map<std::string, bool> inner;
358
class SwigDirector_BoundaryCondition : public dolfin::BoundaryCondition, public Swig::Director {
361
SwigDirector_BoundaryCondition(PyObject *self);
362
virtual ~SwigDirector_BoundaryCondition();
363
virtual void eval(dolfin::BoundaryValue &value, dolfin::Point const &p, dolfin::uint i);
366
/* Internal Director utilities */
368
bool swig_get_inner(const char* name) const {
369
std::map<std::string, bool>::const_iterator iv = inner.find(name);
370
return (iv != inner.end() ? iv->second : false);
373
void swig_set_inner(const char* name, bool val) const
374
{ inner[name] = val;}
377
mutable std::map<std::string, bool> inner;
381
class SwigDirector_ODE : public dolfin::ODE, public Swig::Director {
384
SwigDirector_ODE(PyObject *self, dolfin::uint N, dolfin::real T);
385
virtual dolfin::real u0(dolfin::uint i);
386
virtual dolfin::real f(dolfin::real const u[], dolfin::real t, dolfin::uint i);
387
virtual void save(dolfin::Sample &sample);
388
virtual ~SwigDirector_ODE();
389
virtual void f(dolfin::real const u[], dolfin::real t, dolfin::real y[]);
390
virtual dolfin::real dfdu(dolfin::real const u[], dolfin::real t, dolfin::uint i, dolfin::uint j);
391
virtual dolfin::real timestep(dolfin::real t, dolfin::real k0) const;
392
virtual dolfin::real timestep(dolfin::real t, dolfin::uint i, dolfin::real k0) const;
393
virtual void M(dolfin::real const x[], dolfin::real y[], dolfin::real const u[], dolfin::real t);
394
virtual void J(dolfin::real const x[], dolfin::real y[], dolfin::real const u[], dolfin::real t);
395
virtual bool update(dolfin::real const u[], dolfin::real t, bool end);
398
/* Internal Director utilities */
400
bool swig_get_inner(const char* name) const {
401
std::map<std::string, bool>::const_iterator iv = inner.find(name);
402
return (iv != inner.end() ? iv->second : false);
405
void swig_set_inner(const char* name, bool val) const
406
{ inner[name] = val;}
409
mutable std::map<std::string, bool> inner;