1 |
//$Id$ |
|
2 |
/* |
/******************************************************* |
3 |
************************************************************ |
* |
4 |
* Copyright 2006 by ACcESS MNRF * |
* Copyright (c) 2003-2008 by University of Queensland |
5 |
* * |
* Earth Systems Science Computational Center (ESSCC) |
6 |
* http://www.access.edu.au * |
* http://www.uq.edu.au/esscc |
7 |
* Primary Business: Queensland, Australia * |
* |
8 |
* Licensed under the Open Software License version 3.0 * |
* Primary Business: Queensland, Australia |
9 |
* http://www.opensource.org/licenses/osl-3.0.php * |
* Licensed under the Open Software License version 3.0 |
10 |
* * |
* http://www.opensource.org/licenses/osl-3.0.php |
11 |
************************************************************ |
* |
12 |
*/ |
*******************************************************/ |
13 |
|
|
14 |
|
|
15 |
#include "Data.h" |
#include "Data.h" |
16 |
#include "FunctionSpace.h" |
#include "FunctionSpace.h" |
20 |
#include "AbstractDomain.h" |
#include "AbstractDomain.h" |
21 |
#include "Utils.h" |
#include "Utils.h" |
22 |
#include "AbstractSystemMatrix.h" |
#include "AbstractSystemMatrix.h" |
23 |
|
#include "AbstractTransportProblem.h" |
24 |
#include "DataVector.h" |
#include "DataVector.h" |
25 |
|
#include "paso/Paso_MPI.h" |
26 |
|
#include "EscriptParams.h" |
27 |
|
|
28 |
|
|
29 |
|
extern "C" { |
30 |
|
#include "escript/blocktimer.h" |
31 |
|
} |
32 |
|
|
33 |
#include "esysUtils/esysExceptionTranslator.h" |
#include "esysUtils/esysExceptionTranslator.h" |
34 |
|
|
38 |
#include <boost/python/object.hpp> |
#include <boost/python/object.hpp> |
39 |
#include <boost/python/tuple.hpp> |
#include <boost/python/tuple.hpp> |
40 |
#include <boost/python/numeric.hpp> |
#include <boost/python/numeric.hpp> |
41 |
|
#include <boost/smart_ptr.hpp> |
42 |
|
#include <boost/version.hpp> |
43 |
|
|
44 |
using namespace boost::python; |
using namespace boost::python; |
45 |
|
|
79 |
|
|
80 |
BOOST_PYTHON_MODULE(escriptcpp) |
BOOST_PYTHON_MODULE(escriptcpp) |
81 |
{ |
{ |
82 |
|
// This feature was added in boost v1.34 |
83 |
|
#if ((BOOST_VERSION/100)%1000 > 33) || (BOOST_VERSION/100000 >1) |
84 |
|
//#if ((BOOST_VERSION/100)%1000) > 33 |
85 |
|
// params are: bool show_user_defined, bool show_py_signatures, bool show_cpp_signatures |
86 |
|
docstring_options docopt(true, true, false); |
87 |
|
#endif |
88 |
|
|
89 |
def("setNumberOfThreads",escript::setNumberOfThreads); |
def("setNumberOfThreads",escript::setNumberOfThreads); |
90 |
def("getNumberOfThreads",escript::getNumberOfThreads); |
def("getNumberOfThreads",escript::getNumberOfThreads); |
91 |
def("releaseUnusedMemory",escript::releaseUnusedMemory); |
def("releaseUnusedMemory",escript::releaseUnusedMemory); |
92 |
|
def("blocktimer_initialize",blocktimer_initialize); |
93 |
|
def("blocktimer_reportSortByName",blocktimer_reportSortByName); |
94 |
|
def("blocktimer_reportSortByTime",blocktimer_reportSortByTime); |
95 |
|
def("blocktimer_increment",blocktimer_increment); |
96 |
|
def("blocktimer_time",blocktimer_time); |
97 |
|
def("getVersion",escript::getSvnVersion); |
98 |
|
def("printParallelThreadCounts",escript::printParallelThreadCnt); |
99 |
|
def("getMPISizeWorld",escript::getMPISizeWorld); |
100 |
|
def("getMPIRankWorld",escript::getMPIRankWorld); |
101 |
|
|
102 |
|
|
103 |
// |
// |
104 |
// Interface for AbstractDomain |
// Interface for AbstractDomain |
105 |
// |
// |
106 |
class_<escript::AbstractDomain>("Domain",no_init) |
class_<escript::AbstractDomain, escript::Domain_ptr>("Domain","Base class for all domains.",no_init) |
107 |
.def("setTagMap",&escript::AbstractDomain::setTagMap) |
.def("setTagMap",&escript::AbstractDomain::setTagMap) |
108 |
.def("getTag",&escript::AbstractDomain::getTag) |
.def("getTag",&escript::AbstractDomain::getTag) |
109 |
.def("isValidTagName",&escript::AbstractDomain::isValidTagName) |
.def("isValidTagName",&escript::AbstractDomain::isValidTagName) |
110 |
.def("showTagNames",&escript::AbstractDomain::showTagNames) |
.def("showTagNames",&escript::AbstractDomain::showTagNames) |
111 |
.def("getX",&escript::AbstractDomain::getX) |
.def("getX",&escript::AbstractDomain::getX) |
112 |
|
.def("getDim",&escript::AbstractDomain::getDim) |
113 |
.def("getNormal",&escript::AbstractDomain::getNormal) |
.def("getNormal",&escript::AbstractDomain::getNormal) |
114 |
.def("getSize",&escript::AbstractDomain::getSize) |
.def("getSize",&escript::AbstractDomain::getSize) |
115 |
.def("saveVTK",&escript::AbstractDomain::saveVTK) |
.def("saveVTK",&escript::AbstractDomain::saveVTK) |
116 |
.def("saveDX",&escript::AbstractDomain::saveDX) |
.def("saveDX",&escript::AbstractDomain::saveDX) |
117 |
|
.def("getMPISize",&escript::AbstractDomain::getMPISize) |
118 |
|
.def("getMPIRank",&escript::AbstractDomain::getMPIRank) |
119 |
|
.def("MPIBarrier",&escript::AbstractDomain::MPIBarrier) |
120 |
|
.def("onMasterProcessor",&escript::AbstractDomain::onMasterProcessor) |
121 |
|
|
122 |
.def(self == self) |
.def(self == self) |
123 |
.def(self != self); |
.def(self != self); |
124 |
|
|
125 |
// |
// |
126 |
// Interface for AbstractContinuousDomain |
// Interface for AbstractContinuousDomain |
127 |
// |
// |
128 |
class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain",no_init) |
class_<escript::AbstractContinuousDomain, bases<escript::AbstractDomain> >("ContinuousDomain","Class representing continuous domains",no_init) |
129 |
.def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId); |
.def("getSystemMatrixTypeId",&escript::AbstractContinuousDomain::getSystemMatrixTypeId) |
130 |
|
.def("getTransportTypeId",&escript::AbstractContinuousDomain::getTransportTypeId); |
131 |
|
|
132 |
// |
// |
133 |
// Interface for FunctionSpace |
// Interface for FunctionSpace |
134 |
// |
// |
135 |
class_<escript::FunctionSpace>("FunctionSpace",init<>()) |
class_<escript::FunctionSpace> fs_definer("FunctionSpace","",init<>()); // Doco goes in the empty string param |
136 |
.def("getDim",&escript::FunctionSpace::getDim) |
fs_definer.def("getDim",&escript::FunctionSpace::getDim); |
137 |
.def("getDomain",&escript::FunctionSpace::getDomain,return_internal_reference<>()) |
// fs_definer.def("getDomain",&escript::FunctionSpace::getDomain, |
138 |
.def("getX",&escript::FunctionSpace::getX) |
// return_internal_reference<>()); |
139 |
.def("getNormal",&escript::FunctionSpace::getNormal) |
fs_definer.def("getDomain",&escript::FunctionSpace::getDomainPython); |
140 |
.def("getSize",&escript::FunctionSpace::getSize) |
fs_definer.def("getX",&escript::FunctionSpace::getX); |
141 |
.def("setTags",&escript::FunctionSpace::setTags) |
fs_definer.def("getNormal",&escript::FunctionSpace::getNormal); |
142 |
.def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo) |
fs_definer.def("getSize",&escript::FunctionSpace::getSize); |
143 |
.def("__str__",&escript::FunctionSpace::toString) |
fs_definer.def("setTags",&escript::FunctionSpace::setTags); |
144 |
.def(self == self) |
fs_definer.def("getTagFromDataPointNo", |
145 |
.def(self != self); |
&escript::FunctionSpace::getTagFromDataPointNo); |
146 |
|
fs_definer.def("getReferenceIDFromDataPointNo", &escript::FunctionSpace::getReferenceIDFromDataPointNo); |
147 |
|
fs_definer.def("getListOfTags",&escript::FunctionSpace::getListOfTags); |
148 |
|
fs_definer.def("__str__", &escript::FunctionSpace::toString); |
149 |
|
fs_definer.def(self == self); |
150 |
|
fs_definer.def(self != self); |
151 |
// |
// |
152 |
// Interface for Data |
// Interface for Data |
153 |
// |
// |
154 |
class_<escript::Data>("Data","TEST DOCUMENTATION",init<>()) |
class_<escript::Data>("Data","Represents a collection of datapoints. It is used to store the values of a function. For more details please consult the c++ class documentation.",init<>() ) |
155 |
// various constructors for Data objects |
// various constructors for Data objects |
156 |
.def(init<const numeric::array&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand"))) |
.def(init<const numeric::array&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand"))) |
157 |
.def(init<const object&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand"))) |
.def(init<const object&, optional<const escript::FunctionSpace&, bool> >(args("value","what","expand"))) |
161 |
// Note for Lutz, Need to specify the call policy in order to return a |
// Note for Lutz, Need to specify the call policy in order to return a |
162 |
// reference. In this case return_internal_reference. |
// reference. In this case return_internal_reference. |
163 |
.def("__str__",&escript::Data::toString) |
.def("__str__",&escript::Data::toString) |
164 |
.def("getDomain",&escript::Data::getDomain,return_internal_reference<>()) |
// .def("getDomain",&escript::Data::getDomain,return_internal_reference<>()) |
165 |
.def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>()) |
.def("getDomain",&escript::Data::getDomainPython) |
166 |
|
.def("getFunctionSpace",&escript::Data::getFunctionSpace,return_value_policy<copy_const_reference>()) |
167 |
.def("isEmpty",&escript::Data::isEmpty) |
.def("isEmpty",&escript::Data::isEmpty) |
168 |
.def("isProtected",&escript::Data::isProtected) |
.def("isProtected",&escript::Data::isProtected) |
169 |
.def("setProtection",&escript::Data::setProtection) |
.def("setProtection",&escript::Data::setProtection) |
174 |
.def("setTaggedValue",&escript::Data::setTaggedValue) |
.def("setTaggedValue",&escript::Data::setTaggedValue) |
175 |
.def("setTaggedValue",&escript::Data::setTaggedValueByName) |
.def("setTaggedValue",&escript::Data::setTaggedValueByName) |
176 |
.def("getNumberOfDataPoints",&escript::Data::getNumDataPoints) |
.def("getNumberOfDataPoints",&escript::Data::getNumDataPoints) |
177 |
|
.def("isExpanded",&escript::Data::isExpanded) |
178 |
|
.def("isTagged",&escript::Data::isTagged) |
179 |
|
.def("isConstant",&escript::Data::isConstant) |
180 |
|
.def("isLazy",&escript::Data::isLazy) |
181 |
|
.def("isReady",&escript::Data::isReady) |
182 |
.def("expand",&escript::Data::expand) |
.def("expand",&escript::Data::expand) |
183 |
.def("tag",&escript::Data::tag) |
.def("tag",&escript::Data::tag) |
184 |
|
.def("resolve",&escript::Data::resolve) |
185 |
.def("copy",&escript::Data::copy) |
.def("copy",&escript::Data::copy) |
186 |
|
.def("copy",&escript::Data::copySelf,return_value_policy<manage_new_object>()) |
187 |
|
.def("delay",&escript::Data::delay) |
188 |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject) |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject) |
189 |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray) |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray) |
190 |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint) |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint) |
191 |
.def("getValueOfDataPoint",&escript::Data::getValueOfDataPoint) |
.def("getValueOfDataPoint",&escript::Data::getValueOfDataPoint) |
192 |
.def("getValueOfGlobalDataPoint",&escript::Data::getValueOfGlobalDataPoint) |
.def("getValueOfGlobalDataPoint",&escript::Data::getValueOfGlobalDataPoint) |
193 |
|
.def("setToZero",&escript::Data::setToZero) |
194 |
.def("interpolate",&escript::Data::interpolate) |
.def("interpolate",&escript::Data::interpolate) |
195 |
.def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint) |
.def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint) |
196 |
.def("saveDX",&escript::Data::saveDX) |
.def("saveDX",&escript::Data::saveDX) |
197 |
.def("saveVTK",&escript::Data::saveVTK) |
.def("saveVTK",&escript::Data::saveVTK) |
198 |
.def("getTagNumber",&escript::Data::getTagNumber) |
.def("getTagNumber",&escript::Data::getTagNumber) |
|
.def("archiveData",&escript::Data::archiveData) |
|
|
.def("extractData",&escript::Data::extractData) |
|
199 |
// Unary functions for Data |
// Unary functions for Data |
200 |
.def("_interpolate",&escript::Data::interpolate) |
.def("_interpolate",&escript::Data::interpolate) |
201 |
.def("_grad",&escript::Data::gradOn) |
.def("_grad",&escript::Data::gradOn) |
288 |
// Factory methods for function space |
// Factory methods for function space |
289 |
// |
// |
290 |
def("ContinuousFunction",escript::continuousFunction); |
def("ContinuousFunction",escript::continuousFunction); |
291 |
|
def("ReducedContinuousFunction",escript::reducedContinuousFunction); |
292 |
def("Function",escript::function); |
def("Function",escript::function); |
293 |
|
def("ReducedFunction",escript::reducedFunction); |
294 |
def("FunctionOnBoundary",escript::functionOnBoundary); |
def("FunctionOnBoundary",escript::functionOnBoundary); |
295 |
|
def("ReducedFunctionOnBoundary",escript::reducedFunctionOnBoundary); |
296 |
def("FunctionOnContactZero",escript::functionOnContactZero); |
def("FunctionOnContactZero",escript::functionOnContactZero); |
297 |
|
def("ReducedFunctionOnContactZero",escript::reducedFunctionOnContactZero); |
298 |
def("FunctionOnContactOne",escript::functionOnContactOne); |
def("FunctionOnContactOne",escript::functionOnContactOne); |
299 |
|
def("ReducedFunctionOnContactOne",escript::reducedFunctionOnContactOne); |
300 |
def("Solution",escript::solution); |
def("Solution",escript::solution); |
301 |
def("ReducedSolution",escript::reducedSolution); |
def("ReducedSolution",escript::reducedSolution); |
302 |
def("DiracDeltaFunction",escript::diracDeltaFunction); |
def("DiracDeltaFunction",escript::diracDeltaFunction); |
339 |
// |
// |
340 |
// Interface for AbstractSystemMatrix |
// Interface for AbstractSystemMatrix |
341 |
// |
// |
342 |
class_<escript::AbstractSystemMatrix>("Operator",init<>()) |
class_<escript::AbstractSystemMatrix>("Operator","",init<>()) // Doco goes in the empty string param |
343 |
.def("isEmpty",&escript::AbstractSystemMatrix::isEmpty) |
.def("isEmpty",&escript::AbstractSystemMatrix::isEmpty) |
344 |
.def("solve",&escript::AbstractSystemMatrix::solve) |
.def("solve",&escript::AbstractSystemMatrix::solve) |
345 |
.def("of",&escript::AbstractSystemMatrix::vectorMultiply) |
.def("of",&escript::AbstractSystemMatrix::vectorMultiply) |
347 |
.def("saveHB",&escript::AbstractSystemMatrix::saveHB) |
.def("saveHB",&escript::AbstractSystemMatrix::saveHB) |
348 |
.def("resetValues",&escript::AbstractSystemMatrix::resetValues) |
.def("resetValues",&escript::AbstractSystemMatrix::resetValues) |
349 |
.def(self*other<escript::Data>()); |
.def(self*other<escript::Data>()); |
350 |
|
// |
351 |
|
// Interface for AbstractTransportProblem |
352 |
|
// |
353 |
|
class_<escript::AbstractTransportProblem>("TransportProblem","",init<>()) // Doco goes in the empty string param |
354 |
|
.def("isEmpty",&escript::AbstractTransportProblem::isEmpty) |
355 |
|
.def("solve",&escript::AbstractTransportProblem::solve) |
356 |
|
.def("setInitialValue",&escript::AbstractTransportProblem::setInitialValue) |
357 |
|
.def("insertConstraint",&escript::AbstractTransportProblem::insertConstraint) |
358 |
|
.def("reset",&escript::AbstractTransportProblem::resetTransport) |
359 |
|
.def("resetValues",&escript::AbstractTransportProblem::resetTransport) |
360 |
|
.def("getSafeTimeStepSize",&escript::AbstractTransportProblem::getSafeTimeStepSize) |
361 |
|
.def("getUnlimitedTimeStepSize",&escript::AbstractTransportProblem::getUnlimitedTimeStepSize); |
362 |
|
|
363 |
|
// Functions to modify global parameters |
364 |
|
def("setEscriptParamInt",escript::setEscriptParamInt, |
365 |
|
(arg("value")=0)); |
366 |
|
def("getEscriptParamInt",escript::getEscriptParamInt, |
367 |
|
(arg("sentinel")=0)); |
368 |
|
|
369 |
|
|
370 |
// |
// |
371 |
// Register esysExceptionTranslator |
// Register esysExceptionTranslator |