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

Contents of /branches/domexper/dudley/src/CPPAdapter/dudleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 727 - (show annotations)
Fri May 12 06:31:06 2006 UTC (13 years, 1 month ago) by gross
Original Path: trunk/finley/src/CPPAdapter/finleycpp.cpp
File size: 6112 byte(s)
In case of an error in paso a seg fault occured. this was caused by
inproper deallocation of memory in this case. this problem is fixed now.


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 "FinleyAdapterException.h"
26 // #include "esysUtils/EsysException.h"
27 #include "esysUtils/esysExceptionTranslator.h"
28
29 #include "escript/AbstractContinuousDomain.h"
30
31 #include <boost/python.hpp>
32 #include <boost/python/module.hpp>
33 #include <boost/python/def.hpp>
34 #include <boost/python/detail/defaults_gen.hpp>
35
36 using namespace boost::python;
37
38 /**
39 \page finley Finley
40 Finley is the python module name that contains the interfaces
41 to the C++ wrapper to finley.
42
43 \version 1.0.0
44
45 \section class_desc Class Description:
46 Data
47
48 \section class_limits Class Limitations:
49 None
50
51 \section class_conds Class Conditions of Use:
52 None
53
54 \section throws 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("Merge",finley::meshMerge,
118 return_value_policy<manage_new_object>());
119
120 def("GlueFaces",finley::glueFaces,
121 (arg("safetyFactor")=0.2,
122 arg("tolerance")=std::numeric_limits<double>::epsilon()),
123 return_value_policy<manage_new_object>());
124
125 def("JoinFaces",finley::joinFaces,
126 (arg("safetyFactor")=0.2,
127 arg("tolerance")=std::numeric_limits<double>::epsilon()),
128 return_value_policy<manage_new_object>());
129
130 register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));
131
132 class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
133 ("MeshAdapter",init<optional <Finley_Mesh*> >())
134 .def(init<const finley::MeshAdapter&>())
135 .def("write",&finley::MeshAdapter::write)
136 .def("getDescription",&finley::MeshAdapter::getDescription)
137 .def("getDim",&finley::MeshAdapter::getDim)
138 .def("getDataShape",&finley::MeshAdapter::getDataShape)
139 .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
140 .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
141 .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
142 .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
143 .def("setX",&finley::MeshAdapter::setNewX)
144 .def("getX",&finley::MeshAdapter::getX)
145 .def("getNormal",&finley::MeshAdapter::getNormal)
146 .def("getSize",&finley::MeshAdapter::getSize)
147 .def("saveDX",&finley::MeshAdapter::saveDX)
148 .def("saveVTK",&finley::MeshAdapter::saveVTK);
149
150
151 class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
152 ("OperatorAdapter",no_init)
153 .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
154 .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
155 .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
156 .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
157
158 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26