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

Contents of /trunk/dudley/src/CPPAdapter/dudleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 102 - (show annotations)
Wed Dec 15 07:08:39 2004 UTC (14 years, 6 months ago) by jgs
Original Path: trunk/esys2/finley/src/CPPAdapter/finleycpp.cpp
File size: 5753 byte(s)
*** empty log message ***

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 @memo
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 @doc
44
45 Class Description:
46 Data
47
48 Class Limitations:
49 None
50
51 Class Conditions of Use:
52 None
53
54 Throws:
55 None
56
57 */
58
59 //
60 // The BOOST_PYTHON_FUNCTION_OVERLOADS macro generates function overloads for optional
61 // arguments to the respective finley functions.
62 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
63 //
64 // NOTE: If the number of arguments to the finley functions change
65 // the magic numbers in the BOOST_PYTHON_FUNCTION_OVERLOADS call
66 // must change.
67 //
68 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
69 // BOOST_PYTHON_FUNCTION_OVERLOADS(readMesh_overloads,finley::readMesh,1,2)
70 // BOOST_PYTHON_FUNCTION_OVERLOADS(brick_overloads,finley::brick,0,12)
71 // BOOST_PYTHON_FUNCTION_OVERLOADS(rectangle_overloads,finley::rectangle,0,9)
72 // BOOST_PYTHON_FUNCTION_OVERLOADS(interval_overloads,finley::interval,0,6)
73 // BOOST_PYTHON_FUNCTION_OVERLOADS(glueFaces_overloads,finley::glueFaces,1,3)
74 // BOOST_PYTHON_FUNCTION_OVERLOADS(joinFaces_overloads,finley::joinFaces,1,3)
75
76 BOOST_PYTHON_MODULE(finleycpp)
77 {
78
79 // def("ReadMesh",finley::readMesh,readMesh_overloads());
80 // def("Brick",finley::brick,brick_overloads());
81 // def("Rectangle",finley::rectangle,rectangle_overloads());
82 // def("Interval",finley::interval,interval_overloads());
83 // def("GlueFaces",finley::glueFaces,glueFaces_overloads());
84 // def("JoinFaces",finley::joinFaces,joinFaces_overloads());
85 //
86 // NOTE: The return_value_policy is necessary for functions that
87 // return pointers.
88
89 def("ReadMesh",finley::readMesh,
90 (arg("fileName"),arg("integrationOrder")=-1),
91 return_value_policy<manage_new_object>());
92
93 def ("Brick",finley::brick,
94 (arg("n0")=1,arg("n1")=1,arg("n2")=1,
95 arg("order")=1,
96 arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
97 arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false,
98 arg("integrationOrder")=-1,
99 arg("useElementsOnFace")=false),
100 return_value_policy<manage_new_object>());
101
102 def ("Rectangle",finley::rectangle,
103 (arg("n0")=1,arg("n1")=1,arg("order")=1,
104 arg("l0")=1.0,arg("l1")=1.0,
105 arg("periodic0")=false,arg("periodic1")=false,
106 arg("integrationOrder")=-1,
107 arg("useElementsOnFace")=false),
108 return_value_policy<manage_new_object>());
109
110 def("Interval",finley::interval,
111 (arg("n1")=1,arg("order")=1,
112 arg("l1")=1.0,arg("periodic0")=false,
113 arg("integrationOrder")=-1,
114 arg("useElementsOnFace")=false),
115 return_value_policy<manage_new_object>());
116
117 def("GlueFaces",finley::glueFaces,
118 (arg("safetyFactor")=0.2,
119 arg("tolerance")=std::numeric_limits<double>::epsilon()),
120 return_value_policy<manage_new_object>());
121
122 def("JoinFaces",finley::joinFaces,
123 (arg("safetyFactor")=0.2,
124 arg("tolerance")=std::numeric_limits<double>::epsilon()),
125 return_value_policy<manage_new_object>());
126
127 register_exception_translator<esysUtils::EsysException>(&esysUtils::esysExceptionTranslator);
128
129 class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
130 ("MeshAdapter",init<optional <Finley_Mesh*> >())
131 .def(init<const finley::MeshAdapter&>())
132 .def("write",&finley::MeshAdapter::write)
133 .def("getDescription",&finley::MeshAdapter::getDescription)
134 .def("getDim",&finley::MeshAdapter::getDim)
135 .def("getDataShape",&finley::MeshAdapter::getDataShape)
136 .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
137 .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
138 .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
139 .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
140 .def("getX",&finley::MeshAdapter::getX)
141 .def("getNormal",&finley::MeshAdapter::getNormal)
142 .def("getSize",&finley::MeshAdapter::getSize);
143
144
145 class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
146 ("OperatorAdapter",no_init)
147 .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
148 .def("setValue",&finley::SystemMatrixAdapter::setValue)
149 .def("saveMM",&finley::SystemMatrixAdapter::saveMM);
150
151 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26