/[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 474 - (hide annotations)
Mon Jan 30 04:23:44 2006 UTC (13 years, 2 months ago) by jgs
Original Path: trunk/finley/src/CPPAdapter/finleycpp.cpp
File size: 6034 byte(s)
restructure escript source tree
move src/Data/* -> src
remove inc
modify #includes and cpppath settings accordingly

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26