1 |
// $Id$ |
2 |
/* |
3 |
****************************************************************************** |
4 |
* * |
5 |
* COPYRIGHT ACcESS 2004 - All Rights Reserved * |
6 |
* * |
7 |
* This software is the property of ACcESS. No part of this code * |
8 |
* may be copied in any form or by any means without the expressed written * |
9 |
* consent of ACcESS. Copying, use or modification of this software * |
10 |
* by any unauthorised person is illegal unless that * |
11 |
* person has a software license agreement with ACcESS. * |
12 |
* * |
13 |
****************************************************************************** |
14 |
|
15 |
******************************************************************************/ |
16 |
|
17 |
extern "C" { |
18 |
#include "finley/finleyC/Finley.h" |
19 |
} |
20 |
#include "finley/CPPAdapter/MeshAdapter.h" |
21 |
#include "finley/CPPAdapter/MeshAdapterFactory.h" |
22 |
#include "finley/CPPAdapter/SystemMatrixAdapter.h" |
23 |
|
24 |
#include "esysUtils/EsysException.h" |
25 |
#include "esysUtils/esysExceptionTranslator.h" |
26 |
|
27 |
#include "escript/Data/AbstractContinuousDomain.h" |
28 |
|
29 |
#include <boost/python.hpp> |
30 |
#include <boost/python/module.hpp> |
31 |
#include <boost/python/def.hpp> |
32 |
#include <boost/python/detail/defaults_gen.hpp> |
33 |
|
34 |
using namespace boost::python; |
35 |
|
36 |
/** |
37 |
\page finley Finley |
38 |
Finley is the python module name that contains the interfaces |
39 |
to the C++ wrapper to finley. |
40 |
|
41 |
\version 1.0.0 |
42 |
|
43 |
\section class_desc Class Description: |
44 |
Data |
45 |
|
46 |
\section class_limits Class Limitations: |
47 |
None |
48 |
|
49 |
\section class_conds Class Conditions of Use: |
50 |
None |
51 |
|
52 |
\section throws Throws: |
53 |
None |
54 |
|
55 |
*/ |
56 |
|
57 |
// |
58 |
// The BOOST_PYTHON_FUNCTION_OVERLOADS macro generates function overloads for optional |
59 |
// arguments to the respective finley functions. |
60 |
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
61 |
// |
62 |
// NOTE: If the number of arguments to the finley functions change |
63 |
// the magic numbers in the BOOST_PYTHON_FUNCTION_OVERLOADS call |
64 |
// must change. |
65 |
// |
66 |
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
67 |
// BOOST_PYTHON_FUNCTION_OVERLOADS(readMesh_overloads,finley::readMesh,1,2) |
68 |
// BOOST_PYTHON_FUNCTION_OVERLOADS(brick_overloads,finley::brick,0,12) |
69 |
// BOOST_PYTHON_FUNCTION_OVERLOADS(rectangle_overloads,finley::rectangle,0,9) |
70 |
// BOOST_PYTHON_FUNCTION_OVERLOADS(interval_overloads,finley::interval,0,6) |
71 |
// BOOST_PYTHON_FUNCTION_OVERLOADS(glueFaces_overloads,finley::glueFaces,1,3) |
72 |
// BOOST_PYTHON_FUNCTION_OVERLOADS(joinFaces_overloads,finley::joinFaces,1,3) |
73 |
|
74 |
BOOST_PYTHON_MODULE(finleycpp) |
75 |
{ |
76 |
|
77 |
// def("ReadMesh",finley::readMesh,readMesh_overloads()); |
78 |
// def("Brick",finley::brick,brick_overloads()); |
79 |
// def("Rectangle",finley::rectangle,rectangle_overloads()); |
80 |
// def("Interval",finley::interval,interval_overloads()); |
81 |
// def("GlueFaces",finley::glueFaces,glueFaces_overloads()); |
82 |
// def("JoinFaces",finley::joinFaces,joinFaces_overloads()); |
83 |
// |
84 |
// NOTE: The return_value_policy is necessary for functions that |
85 |
// return pointers. |
86 |
|
87 |
def("ReadMesh",finley::readMesh, |
88 |
(arg("fileName"),arg("integrationOrder")=-1), |
89 |
return_value_policy<manage_new_object>()); |
90 |
|
91 |
def ("Brick",finley::brick, |
92 |
(arg("n0")=1,arg("n1")=1,arg("n2")=1, |
93 |
arg("order")=1, |
94 |
arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0, |
95 |
arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false, |
96 |
arg("integrationOrder")=-1, |
97 |
arg("useElementsOnFace")=false), |
98 |
return_value_policy<manage_new_object>()); |
99 |
|
100 |
def ("Rectangle",finley::rectangle, |
101 |
(arg("n0")=1,arg("n1")=1,arg("order")=1, |
102 |
arg("l0")=1.0,arg("l1")=1.0, |
103 |
arg("periodic0")=false,arg("periodic1")=false, |
104 |
arg("integrationOrder")=-1, |
105 |
arg("useElementsOnFace")=false), |
106 |
return_value_policy<manage_new_object>()); |
107 |
|
108 |
def("Interval",finley::interval, |
109 |
(arg("n1")=1,arg("order")=1, |
110 |
arg("l1")=1.0,arg("periodic0")=false, |
111 |
arg("integrationOrder")=-1, |
112 |
arg("useElementsOnFace")=false), |
113 |
return_value_policy<manage_new_object>()); |
114 |
|
115 |
def("Merge",finley::meshMerge, |
116 |
return_value_policy<manage_new_object>()); |
117 |
|
118 |
def("GlueFaces",finley::glueFaces, |
119 |
(arg("safetyFactor")=0.2, |
120 |
arg("tolerance")=std::numeric_limits<double>::epsilon()), |
121 |
return_value_policy<manage_new_object>()); |
122 |
|
123 |
def("JoinFaces",finley::joinFaces, |
124 |
(arg("safetyFactor")=0.2, |
125 |
arg("tolerance")=std::numeric_limits<double>::epsilon()), |
126 |
return_value_policy<manage_new_object>()); |
127 |
|
128 |
register_exception_translator<esysUtils::EsysException>(&esysUtils::esysExceptionTranslator); |
129 |
|
130 |
class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> > |
131 |
("MeshAdapter",init<optional <Finley_Mesh*> >()) |
132 |
.def(init<const finley::MeshAdapter&>()) |
133 |
.def("write",&finley::MeshAdapter::write) |
134 |
.def("getDescription",&finley::MeshAdapter::getDescription) |
135 |
.def("getDim",&finley::MeshAdapter::getDim) |
136 |
.def("getDataShape",&finley::MeshAdapter::getDataShape) |
137 |
.def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem) |
138 |
.def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS) |
139 |
.def("newOperator",&finley::MeshAdapter::newSystemMatrix) |
140 |
.def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId) |
141 |
.def("setX",&finley::MeshAdapter::setNewX) |
142 |
.def("getX",&finley::MeshAdapter::getX) |
143 |
.def("getNormal",&finley::MeshAdapter::getNormal) |
144 |
.def("getSize",&finley::MeshAdapter::getSize); |
145 |
|
146 |
class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> > |
147 |
("OperatorAdapter",no_init) |
148 |
.def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols) |
149 |
.def("setValue",&finley::SystemMatrixAdapter::setValue) |
150 |
.def("resetSolver",&finley::SystemMatrixAdapter::resetSolver) |
151 |
.def("saveMM",&finley::SystemMatrixAdapter::saveMM) |
152 |
.def("saveHB",&finley::SystemMatrixAdapter::saveHB); |
153 |
|
154 |
} |