1 |
//$Id$ |
//$Id$ |
2 |
/*============================================================================= |
/* |
3 |
|
************************************************************ |
4 |
****************************************************************************** |
* Copyright 2006 by ACcESS MNRF * |
5 |
* * |
* * |
6 |
* COPYRIGHT ACcESS 2004 - All Rights Reserved * |
* http://www.access.edu.au * |
7 |
* * |
* Primary Business: Queensland, Australia * |
8 |
* This software is the property of ACcESS. No part of this code * |
* Licensed under the Open Software License version 3.0 * |
9 |
* may be copied in any form or by any means without the expressed written * |
* http://www.opensource.org/licenses/osl-3.0.php * |
10 |
* consent of ACcESS. Copying, use or modification of this software * |
* * |
11 |
* by any unauthorised person is illegal unless that * |
************************************************************ |
12 |
* person has a software license agreement with ACcESS. * |
*/ |
13 |
* * |
|
14 |
****************************************************************************** |
#include "Data.h" |
15 |
|
#include "FunctionSpace.h" |
16 |
******************************************************************************/ |
#include "FunctionSpaceFactory.h" |
17 |
|
#include "DataFactory.h" |
18 |
#include "escript/Data/Data.h" |
#include "AbstractContinuousDomain.h" |
19 |
#include "escript/Data/DataVariable.h" |
#include "AbstractDomain.h" |
20 |
#include "escript/Data/FunctionSpace.h" |
#include "Utils.h" |
21 |
#include "escript/Data/FunctionSpaceFactory.h" |
#include "AbstractSystemMatrix.h" |
22 |
#include "escript/Data/DataFactory.h" |
#include "DataVector.h" |
23 |
#include "escript/Data/AbstractContinuousDomain.h" |
|
|
#include "escript/Data/AbstractDomain.h" |
|
|
#include "escript/Data/Utils.h" |
|
24 |
#include "esysUtils/esysExceptionTranslator.h" |
#include "esysUtils/esysExceptionTranslator.h" |
25 |
|
|
26 |
#include <boost/python.hpp> |
#include <boost/python.hpp> |
70 |
{ |
{ |
71 |
def("setNumberOfThreads",escript::setNumberOfThreads); |
def("setNumberOfThreads",escript::setNumberOfThreads); |
72 |
def("getNumberOfThreads",escript::getNumberOfThreads); |
def("getNumberOfThreads",escript::getNumberOfThreads); |
73 |
|
def("releaseUnusedMemory",escript::releaseUnusedMemory); |
74 |
|
|
75 |
|
|
76 |
// |
// |
77 |
// Interface for AbstractDomain |
// Interface for AbstractDomain |
78 |
// |
// |
79 |
class_<escript::AbstractDomain>("Domain",no_init) |
class_<escript::AbstractDomain>("Domain",no_init) |
80 |
|
.def("setTagMap",&escript::AbstractDomain::setTagMap) |
81 |
|
.def("getTag",&escript::AbstractDomain::getTag) |
82 |
|
.def("isValidTagName",&escript::AbstractDomain::isValidTagName) |
83 |
|
.def("showTagNames",&escript::AbstractDomain::showTagNames) |
84 |
.def("getX",&escript::AbstractDomain::getX) |
.def("getX",&escript::AbstractDomain::getX) |
85 |
.def("getNormal",&escript::AbstractDomain::getNormal) |
.def("getNormal",&escript::AbstractDomain::getNormal) |
86 |
.def("getSize",&escript::AbstractDomain::getSize) |
.def("getSize",&escript::AbstractDomain::getSize) |
104 |
.def("getX",&escript::FunctionSpace::getX) |
.def("getX",&escript::FunctionSpace::getX) |
105 |
.def("getNormal",&escript::FunctionSpace::getNormal) |
.def("getNormal",&escript::FunctionSpace::getNormal) |
106 |
.def("getSize",&escript::FunctionSpace::getSize) |
.def("getSize",&escript::FunctionSpace::getSize) |
107 |
|
.def("setTags",&escript::FunctionSpace::setTags) |
108 |
.def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo) |
.def("getTagFromDataPointNo",&escript::FunctionSpace::getTagFromDataPointNo) |
109 |
.def("__str__",&escript::FunctionSpace::toString) |
.def("__str__",&escript::FunctionSpace::toString) |
110 |
.def(self == self) |
.def(self == self) |
111 |
.def(self != self); |
.def(self != self); |
|
|
|
|
// |
|
|
// Interface for DataVariable |
|
|
// |
|
|
class_<escript::DataVariable>("DataVariable",init<>()) |
|
|
.def(init<escript::Data*>()) |
|
|
.def("evaluate",&escript::DataVariable::evaluate) |
|
|
.def("sum",&escript::DataVariable::sum) |
|
|
.def("diff",&escript::DataVariable::diff); |
|
|
|
|
112 |
// |
// |
113 |
// Interface for Data |
// Interface for Data |
114 |
// |
// |
125 |
.def("getDomain",&escript::Data::getDomain,return_internal_reference<>()) |
.def("getDomain",&escript::Data::getDomain,return_internal_reference<>()) |
126 |
.def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>()) |
.def("getFunctionSpace",&escript::Data::getFunctionSpace,return_internal_reference<>()) |
127 |
.def("isEmpty",&escript::Data::isEmpty) |
.def("isEmpty",&escript::Data::isEmpty) |
128 |
|
.def("isProtected",&escript::Data::isProtected) |
129 |
|
.def("setProtection",&escript::Data::setProtection) |
130 |
.def("getShape",&escript::Data::getShapeTuple) |
.def("getShape",&escript::Data::getShapeTuple) |
131 |
.def("getRank",&escript::Data::getDataPointRank) |
.def("getRank",&escript::Data::getDataPointRank) |
132 |
|
.def("dump",&escript::Data::dump) |
133 |
.def("copyWithMask",&escript::Data::copyWithMask) |
.def("copyWithMask",&escript::Data::copyWithMask) |
134 |
.def("setTaggedValue",&escript::Data::setTaggedValue) |
.def("setTaggedValue",&escript::Data::setTaggedValue) |
135 |
.def("setRefValue",&escript::Data::setRefValue) |
.def("setTaggedValue",&escript::Data::setTaggedValueByName) |
136 |
.def("getRefValue",&escript::Data::getRefValue) |
.def("getNumberOfDataPoints",&escript::Data::getNumDataPoints) |
137 |
.def("expand",&escript::Data::expand) |
.def("expand",&escript::Data::expand) |
138 |
.def("tag",&escript::Data::tag) |
.def("tag",&escript::Data::tag) |
139 |
.def("copy",&escript::Data::copy) |
.def("copy",&escript::Data::copy) |
140 |
.def("convertToNumArray",&escript::Data::convertToNumArray) |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToPyObject) |
141 |
.def("convertToNumArrayFromSampleNo",&escript::Data::convertToNumArrayFromSampleNo) |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPointToArray) |
142 |
.def("convertToNumArrayFromDPNo",&escript::Data::convertToNumArrayFromDPNo) |
.def("setValueOfDataPoint",&escript::Data::setValueOfDataPoint) |
143 |
.def("fillFromNumArray",&escript::Data::fillFromNumArray) |
.def("getValueOfDataPoint",&escript::Data::getValueOfDataPoint) |
144 |
|
.def("getValueOfGlobalDataPoint",&escript::Data::getValueOfGlobalDataPoint) |
145 |
.def("interpolate",&escript::Data::interpolate) |
.def("interpolate",&escript::Data::interpolate) |
146 |
.def("mindp",&escript::Data::mindp) |
.def("minGlobalDataPoint",&escript::Data::minGlobalDataPoint) |
|
|
|
147 |
.def("saveDX",&escript::Data::saveDX) |
.def("saveDX",&escript::Data::saveDX) |
148 |
.def("saveVTK",&escript::Data::saveVTK) |
.def("saveVTK",&escript::Data::saveVTK) |
149 |
.def("getTagNumber",&escript::Data::getTagNumber) |
.def("getTagNumber",&escript::Data::getTagNumber) |
161 |
.def("_whereNegative",&escript::Data::whereNegative) |
.def("_whereNegative",&escript::Data::whereNegative) |
162 |
.def("_whereNonNegative",&escript::Data::whereNonNegative) |
.def("_whereNonNegative",&escript::Data::whereNonNegative) |
163 |
.def("_whereNonPositive",&escript::Data::whereNonPositive) |
.def("_whereNonPositive",&escript::Data::whereNonPositive) |
164 |
.def("_whereZero",&escript::Data::whereZero) |
.def("_whereZero",&escript::Data::whereZero,(arg("tol")=0.0)) |
165 |
.def("_whereNonZero",&escript::Data::whereNonZero) |
.def("_whereNonZero",&escript::Data::whereNonZero,(arg("tol")=0.0)) |
166 |
|
.def("_erf",&escript::Data::erf) |
167 |
.def("_sin",&escript::Data::sin) |
.def("_sin",&escript::Data::sin) |
168 |
.def("_cos",&escript::Data::cos) |
.def("_cos",&escript::Data::cos) |
169 |
.def("_tan",&escript::Data::tan) |
.def("_tan",&escript::Data::tan) |
181 |
.def("_log10",&escript::Data::log10) |
.def("_log10",&escript::Data::log10) |
182 |
.def("_log",&escript::Data::log) |
.def("_log",&escript::Data::log) |
183 |
.def("_sign",&escript::Data::sign) |
.def("_sign",&escript::Data::sign) |
184 |
|
.def("_symmetric",&escript::Data::symmetric) |
185 |
|
.def("_nonsymmetric",&escript::Data::nonsymmetric) |
186 |
|
.def("_trace",&escript::Data::trace) |
187 |
|
.def("_swap_axes",&escript::Data::swapaxes) |
188 |
|
.def("_eigenvalues",&escript::Data::eigenvalues) |
189 |
|
.def("_eigenvalues_and_eigenvectors",&escript::Data::eigenvalues_and_eigenvectors,(arg("tol")=1.e-13)) |
190 |
// functions returning a single real number: |
// functions returning a single real number: |
191 |
.def("_Lsup",&escript::Data::Lsup) |
.def("_Lsup",&escript::Data::Lsup) |
192 |
.def("_sup",&escript::Data::sup) |
.def("_sup",&escript::Data::sup) |
206 |
// following two functions implement the python ** operator |
// following two functions implement the python ** operator |
207 |
.def("__pow__",&escript::Data::powO) |
.def("__pow__",&escript::Data::powO) |
208 |
.def("__pow__",&escript::Data::powD) |
.def("__pow__",&escript::Data::powD) |
209 |
|
.def("__rpow__",&escript::Data::rpowO) |
210 |
// NOTE:: The order of these declarations is important. Anything |
// NOTE:: The order of these declarations is important. Anything |
211 |
// declared before the generic declaration isn't found so the generic |
// declared before the generic declaration isn't found so the generic |
212 |
// version will be called. |
// version will be called. |
241 |
// Factory methods for function space |
// Factory methods for function space |
242 |
// |
// |
243 |
def("ContinuousFunction",escript::continuousFunction); |
def("ContinuousFunction",escript::continuousFunction); |
244 |
|
def("ReducedContinuousFunction",escript::reducedContinuousFunction); |
245 |
def("Function",escript::function); |
def("Function",escript::function); |
246 |
|
def("ReducedFunction",escript::reducedFunction); |
247 |
def("FunctionOnBoundary",escript::functionOnBoundary); |
def("FunctionOnBoundary",escript::functionOnBoundary); |
248 |
|
def("ReducedFunctionOnBoundary",escript::reducedFunctionOnBoundary); |
249 |
def("FunctionOnContactZero",escript::functionOnContactZero); |
def("FunctionOnContactZero",escript::functionOnContactZero); |
250 |
|
def("ReducedFunctionOnContactZero",escript::reducedFunctionOnContactZero); |
251 |
def("FunctionOnContactOne",escript::functionOnContactOne); |
def("FunctionOnContactOne",escript::functionOnContactOne); |
252 |
|
def("ReducedFunctionOnContactOne",escript::reducedFunctionOnContactOne); |
253 |
def("Solution",escript::solution); |
def("Solution",escript::solution); |
254 |
def("ReducedSolution",escript::reducedSolution); |
def("ReducedSolution",escript::reducedSolution); |
255 |
def("DiracDeltaFunction",escript::diracDeltaFunction); |
def("DiracDeltaFunction",escript::diracDeltaFunction); |
257 |
// |
// |
258 |
// Factory methods for Data |
// Factory methods for Data |
259 |
// |
// |
260 |
|
def("load",escript::load); |
261 |
|
def("loadIsConfigured",escript::loadConfigured); |
262 |
def("Scalar",escript::Scalar, |
def("Scalar",escript::Scalar, |
263 |
(arg("value")=0.0, |
(arg("value")=0.0, |
264 |
arg("what")=escript::FunctionSpace(), |
arg("what")=escript::FunctionSpace(), |
281 |
arg("expanded")=false)); |
arg("expanded")=false)); |
282 |
|
|
283 |
// |
// |
284 |
|
// Binary operators |
285 |
|
// |
286 |
|
def("C_GeneralTensorProduct",escript::C_GeneralTensorProduct, |
287 |
|
(arg("arg0")=escript::Data(), |
288 |
|
arg("arg1")=escript::Data(), |
289 |
|
arg("axis_offset")=0, |
290 |
|
arg("transpose")=0)); |
291 |
|
|
292 |
|
// |
293 |
// Interface for AbstractSystemMatrix |
// Interface for AbstractSystemMatrix |
294 |
// |
// |
295 |
class_<escript::AbstractSystemMatrix>("Operator",init<>()) |
class_<escript::AbstractSystemMatrix>("Operator",init<>()) |