/[escript]/branches/domexper/dudley/src/CPPAdapter/dudleycpp.cpp
ViewVC logotype

Annotation of /branches/domexper/dudley/src/CPPAdapter/dudleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2076 - (hide annotations)
Thu Nov 20 12:34:17 2008 UTC (10 years, 6 months ago) by phornby
Original Path: trunk/finley/src/CPPAdapter/finleycpp.cpp
File size: 7709 byte(s)

I may get into trouble for this.
boost-python 1.34 does have a docstring_options class,
but does not have a 3 argument constructor for
it. So the test has been modified to 


#if ((BOOST_VERSION/100)%1000 > 34) || (BOOST_VERSION/100000 >1)

If you wish to make things more delicate, one can define a 2 argument construction
of docopt just for 1.34 (with an #elif). Probably not worth the effort frankly.

Hope that this has not broken anything for anyone else. The SVN logs suggest this is a
little fragile.....

Also, please be aware that much of our chemistry interface code, that we wish to use with
escript, makes extensive use of boost python.
Having two different boost versions mucking with the python interpreter sounds
like a really bad idea, I'm sure you'll agree.
The problem is that it is not a simple task for us to build new versions of boost-python
on all our platforms. Consequently, it would be nice to be informed when you guys
intend to upgrade a support library of this nature so that we can plan and allocate
resources to keep up.

Cheers.


1 jgs 102
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 ksteube 1312
14 ksteube 1811
15 ksteube 817 #ifdef PASO_MPI
16     #include <mpi.h>
17 ksteube 1800 #include "paso/Paso_MPI.h"
18 ksteube 817 #endif
19 jgs 102 extern "C" {
20 robwdcock 682 #include "../Finley.h"
21 jgs 102 }
22 jgs 472
23 jgs 203 #include "MeshAdapter.h"
24     #include "MeshAdapterFactory.h"
25     #include "SystemMatrixAdapter.h"
26 gross 1364 #include "TransportProblemAdapter.h"
27 jgs 102
28 gross 727 #include "FinleyAdapterException.h"
29     // #include "esysUtils/EsysException.h"
30 robwdcock 682 #include "esysUtils/esysExceptionTranslator.h"
31 jgs 102
32 robwdcock 682 #include "escript/AbstractContinuousDomain.h"
33 jgs 102
34     #include <boost/python.hpp>
35     #include <boost/python/module.hpp>
36     #include <boost/python/def.hpp>
37     #include <boost/python/detail/defaults_gen.hpp>
38 jfenwick 2064 #include <boost/version.hpp>
39 jgs 102
40     using namespace boost::python;
41    
42     /**
43 jgs 121 \page finley Finley
44     Finley is the python module name that contains the interfaces
45 jgs 102 to the C++ wrapper to finley.
46    
47 jgs 121 \version 1.0.0
48 jgs 102
49 jgs 121 \section class_desc Class Description:
50 jgs 102 Data
51    
52 jgs 121 \section class_limits Class Limitations:
53 jgs 102 None
54    
55 jgs 121 \section class_conds Class Conditions of Use:
56 jgs 102 None
57    
58 jgs 121 \section throws Throws:
59 jgs 102 None
60    
61     */
62    
63     //
64     // The BOOST_PYTHON_FUNCTION_OVERLOADS macro generates function overloads for optional
65     // arguments to the respective finley functions.
66     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
67     //
68     // NOTE: If the number of arguments to the finley functions change
69     // the magic numbers in the BOOST_PYTHON_FUNCTION_OVERLOADS call
70     // must change.
71     //
72     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
73     // BOOST_PYTHON_FUNCTION_OVERLOADS(readMesh_overloads,finley::readMesh,1,2)
74     // BOOST_PYTHON_FUNCTION_OVERLOADS(brick_overloads,finley::brick,0,12)
75     // BOOST_PYTHON_FUNCTION_OVERLOADS(rectangle_overloads,finley::rectangle,0,9)
76     // BOOST_PYTHON_FUNCTION_OVERLOADS(interval_overloads,finley::interval,0,6)
77     // BOOST_PYTHON_FUNCTION_OVERLOADS(glueFaces_overloads,finley::glueFaces,1,3)
78     // BOOST_PYTHON_FUNCTION_OVERLOADS(joinFaces_overloads,finley::joinFaces,1,3)
79    
80     BOOST_PYTHON_MODULE(finleycpp)
81     {
82 jfenwick 2064 // This feature was added in boost v1.34
83 phornby 2076 #if ((BOOST_VERSION/100)%1000 > 34) || (BOOST_VERSION/100000 >1)
84 jfenwick 2061 // params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures
85     docstring_options docopt(true, true, false);
86 jfenwick 2064 #endif
87 jgs 102
88     //
89     // NOTE: The return_value_policy is necessary for functions that
90     // return pointers.
91 gross 1382 //
92     register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));
93 jgs 102
94 ksteube 1345 def("LoadMesh",finley::loadMesh,
95 jfenwick 1872 (arg("fileName")="file.nc")
96     /* ,return_value_policy<manage_new_object>());*/
97     );
98    
99 jgs 102 def("ReadMesh",finley::readMesh,
100 jfenwick 1872 (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true)
101     /* ,return_value_policy<manage_new_object>());*/
102     );
103 jgs 102
104 gross 934 def("ReadGmsh",finley::readGmsh,
105 jfenwick 1872 (arg("fileName")="file.msh",arg("numDim"), arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true)
106     // ,return_value_policy<manage_new_object>());
107     );
108 gross 934
109 jgs 102 def ("Brick",finley::brick,
110     (arg("n0")=1,arg("n1")=1,arg("n2")=1,
111     arg("order")=1,
112     arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
113     arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false,
114 gross 1059 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
115 ksteube 1312 arg("useElementsOnFace")=false,
116     arg("useFullElementOrder")=false,
117 jfenwick 1872 arg("optimize")=false)
118     // ,return_value_policy<manage_new_object>());
119     );
120 jgs 102
121     def ("Rectangle",finley::rectangle,
122     (arg("n0")=1,arg("n1")=1,arg("order")=1,
123     arg("l0")=1.0,arg("l1")=1.0,
124     arg("periodic0")=false,arg("periodic1")=false,
125 gross 1059 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
126 ksteube 1312 arg("useElementsOnFace")=false,
127     arg("useFullElementOrder")=false,
128 jfenwick 1872 arg("optimize")=false)
129     // ,return_value_policy<manage_new_object>());
130     );
131 jgs 102
132 jfenwick 1872 def("Merge",finley::meshMerge
133     // ,return_value_policy<manage_new_object>());
134     );
135 jgs 110
136 jgs 102 def("GlueFaces",finley::glueFaces,
137     (arg("safetyFactor")=0.2,
138 gross 1062 arg("tolerance")=1.e-8,
139 jfenwick 1872 arg("optimize")=true)
140     // ,return_value_policy<manage_new_object>());
141     );
142 jgs 102
143     def("JoinFaces",finley::joinFaces,
144     (arg("safetyFactor")=0.2,
145 gross 1062 arg("tolerance")=1.e-8,
146 jfenwick 1872 arg("optimize")=true)
147     // ,return_value_policy<manage_new_object>());
148     );
149 jgs 102
150    
151     class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
152 jfenwick 2061 ("MeshAdapter","A concrete class representing a domain. For more details, please consult the c++ documentation.",init<optional <Finley_Mesh*> >())
153 jgs 102 .def(init<const finley::MeshAdapter&>())
154     .def("write",&finley::MeshAdapter::write)
155 ksteube 1339 .def("print_mesh_info",&finley::MeshAdapter::Print_Mesh_Info,(arg("full")=false))
156 ksteube 1343 .def("dump",&finley::MeshAdapter::dump)
157 jgs 102 .def("getDescription",&finley::MeshAdapter::getDescription)
158     .def("getDim",&finley::MeshAdapter::getDim)
159     .def("getDataShape",&finley::MeshAdapter::getDataShape)
160 ksteube 1754 .def("getNumDataPointsGlobal",&finley::MeshAdapter::getNumDataPointsGlobal)
161 jgs 102 .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
162 gross 1204 .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem)
163 jgs 102 .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
164 gross 1370 .def("addPDEToTransportProblem",&finley::MeshAdapter::addPDEToTransportProblem)
165 jgs 102 .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
166 gross 1370 .def("newTransportProblem",&finley::MeshAdapter::newTransportProblem)
167 jgs 102 .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
168 gross 1859 .def("getTransportTypeId",&finley::MeshAdapter::getTransportTypeId)
169 jgs 110 .def("setX",&finley::MeshAdapter::setNewX)
170 jgs 102 .def("getX",&finley::MeshAdapter::getX)
171     .def("getNormal",&finley::MeshAdapter::getNormal)
172 jgs 153 .def("getSize",&finley::MeshAdapter::getSize)
173     .def("saveDX",&finley::MeshAdapter::saveDX)
174 gross 1044 .def("saveVTK",&finley::MeshAdapter::saveVTK)
175     .def("setTagMap",&finley::MeshAdapter::setTagMap)
176     .def("getTag",&finley::MeshAdapter::getTag)
177     .def("isValidTagName",&finley::MeshAdapter::isValidTagName)
178 ksteube 1312 .def("showTagNames",&finley::MeshAdapter::showTagNames)
179     .def("getMPISize",&finley::MeshAdapter::getMPISize)
180 ksteube 1877 .def("getMPIRank",&finley::MeshAdapter::getMPIRank)
181     .def("MPIBarrier",&finley::MeshAdapter::MPIBarrier)
182     .def("onMasterProcessor",&finley::MeshAdapter::onMasterProcessor);
183 jgs 102
184     class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
185 jfenwick 2061 ("OperatorAdapter","A concrete class representing an operator. For more details, please see the c++ documentation.", no_init)
186 ksteube 1339 .def("print_matrix_info",&finley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false))
187 jgs 102 .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
188 jgs 149 .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
189 jgs 123 .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
190     .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
191 jgs 102
192 gross 1364 class_<finley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >
193 jfenwick 2061 ("TransportProblemAdapter","",no_init)
194 gross 1407 .def("getSafeTimeStepSize",&finley::TransportProblemAdapter::getSafeTimeStepSize)
195 gross 1859 .def("getUnlimitedTimeStepSize",&finley::TransportProblemAdapter::getUnlimitedTimeStepSize)
196 gross 1364 .def("resetTransport",&finley::TransportProblemAdapter::resetTransport);
197 jgs 102 }

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26