/[escript]/branches/ROBW_XPLATFORM/finley/src/CPPAdapter/finleycpp.cpp
ViewVC logotype

Contents of /branches/ROBW_XPLATFORM/finley/src/CPPAdapter/finleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 667 - (show annotations)
Fri Mar 24 13:25:00 2006 UTC (15 years ago) by robwdcock
File size: 6071 byte(s)
+ OUCH ARGHH
+ Okay the wizzy linkHack doesn't work. Not sure why but py_tests fail
when the shared library is on the link line directly (without a -l)

+ Unfortunately we can't figure out how to use -l without it prepending
a lib prefix. Hence all the shareable objects in python now need to be
called libblah.so (and lib will need to be prepended on windows!!!!).
This is not the python way and its very annoying. Why do we have this
problem? Because the C++ shared libraries link with each other.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26