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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 471 - (hide annotations)
Fri Jan 27 01:33:02 2006 UTC (13 years, 4 months ago) by jgs
Original Path: trunk/finley/src/CPPAdapter/finleycpp.cpp
File size: 6046 byte(s)
reorganise finley src tree to remove inc dir and src/finley directory

1 jgs 102 // $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 jgs 203 #include "Finley.h"
19 jgs 102 }
20 jgs 203 #include "MeshAdapter.h"
21     #include "MeshAdapterFactory.h"
22     #include "SystemMatrixAdapter.h"
23 jgs 102
24 jgs 468 #include "EsysException.h"
25     #include "esysExceptionTranslator.h"
26 jgs 102
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 jgs 121 \page finley Finley
38     Finley is the python module name that contains the interfaces
39 jgs 102 to the C++ wrapper to finley.
40    
41 jgs 121 \version 1.0.0
42 jgs 102
43 jgs 121 \section class_desc Class Description:
44 jgs 102 Data
45    
46 jgs 121 \section class_limits Class Limitations:
47 jgs 102 None
48    
49 jgs 121 \section class_conds Class Conditions of Use:
50 jgs 102 None
51    
52 jgs 121 \section throws Throws:
53 jgs 102 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 jgs 110 def("Merge",finley::meshMerge,
116     return_value_policy<manage_new_object>());
117    
118 jgs 102 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 jgs 110 .def("setX",&finley::MeshAdapter::setNewX)
142 jgs 102 .def("getX",&finley::MeshAdapter::getX)
143     .def("getNormal",&finley::MeshAdapter::getNormal)
144 jgs 153 .def("getSize",&finley::MeshAdapter::getSize)
145     .def("saveDX",&finley::MeshAdapter::saveDX)
146     .def("saveVTK",&finley::MeshAdapter::saveVTK);
147 jgs 102
148 jgs 153
149 jgs 102 class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
150     ("OperatorAdapter",no_init)
151     .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
152 jgs 149 .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
153 jgs 123 .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
154     .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
155 jgs 102
156     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26