cantera/src/python/pycantera.cpp
Ray Speth 2528df0f75 Reorganized source tree structure
These changes make it unnecessary to copy header files around during
the build process, which tends to confuse IDEs and debuggers. The
headers which comprise Cantera's external C++ interface are now in
the 'include' directory.

All of the samples and demos are now in the 'samples' subdirectory.
2012-02-12 02:27:14 +00:00

104 lines
2.4 KiB
C++

/**
* @file pycantera.cpp
*
* This is the main file for the Python interface module.
*
*/
#include "cantera/kernel/config.h"
#include "Python.h"
#ifdef HAS_NUMERIC
#include "Numeric/arrayobject.h"
#endif
#ifdef HAS_NUMARRAY
#include "numarray/arrayobject.h"
#endif
#ifdef HAS_NUMPY
#include "numpy/arrayobject.h"
#endif
#include "clib/ct.h"
#include "clib/ctxml.h"
#include "clib/ctsurf.h"
#include "clib/ctbdry.h"
#include "clib/ctrpath.h"
#include "clib/ctreactor.h"
#include "clib/ctfunc.h"
#include "clib/ctonedim.h"
#include "clib/ctmultiphase.h"
#include <iostream>
using namespace std;
// constants defined in the module
static PyObject* ErrorObject;
// local includes
#include "pyutils.h"
#include "ctphase_methods.cpp"
#include "ctthermo_methods.cpp"
#include "ctkinetics_methods.cpp"
#include "cttransport_methods.cpp"
#include "ctxml_methods.cpp"
#include "ctfuncs.cpp"
#include "ctsurf_methods.cpp"
//#include "ctbndry_methods.cpp"
#include "ctrpath_methods.cpp"
#include "ctreactor_methods.cpp"
#include "ctfunc_methods.cpp"
#include "ctonedim_methods.cpp"
#include "ctmultiphase_methods.cpp"
#ifdef INCL_USER_PYTHON
#include "ctuser.h"
#include "ctuser_methods.cpp"
#endif
static PyObject*
pyct_appdelete(PyObject* self, PyObject* args)
{
return Py_BuildValue("i",ct_appdelete());
}
#include "methods.h"
#include "pylogger.h"
//#include "../../src/global.h"
extern "C" {
/* Initialization function for the module */
DL_EXPORT(void) init_cantera(void)
{
PyObject* m, *d;
/* Initialize the type of the new type object here; doing it here
* is required for portability to Windows without requiring C++. */
/* Create the module and add the functions */
m = Py_InitModule("_cantera", ct_methods);
import_array();
Cantera::Logger* pylog = new Cantera::Py_Logger;
setLogWriter(pylog);
/* Add some symbolic constants to the module */
d = PyModule_GetDict(m);
ErrorObject = PyErr_NewException((char*)"cantera.error", NULL, NULL);
PyDict_SetItemString(d, "error", ErrorObject);
#ifdef HAS_NUMERIC
PyDict_SetItemString(d, "nummod",PyString_FromString("Numeric"));
#else
#ifdef HAS_NUMARRAY
PyDict_SetItemString(d, "nummod",PyString_FromString("numarray"));
#else
PyDict_SetItemString(d, "nummod",PyString_FromString("numpy"));
#endif
#endif
}
}