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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 110 - (hide annotations)
Mon Feb 14 04:14:42 2005 UTC (14 years, 3 months ago) by jgs
Original Path: trunk/esys2/finley/src/CPPAdapter/finleycpp.cpp
File size: 5953 byte(s)
*** empty log message ***

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     #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 jgs 110 def("Merge",finley::meshMerge,
118     return_value_policy<manage_new_object>());
119    
120 jgs 102 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<esysUtils::EsysException>(&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 jgs 110 .def("setX",&finley::MeshAdapter::setNewX)
144 jgs 102 .def("getX",&finley::MeshAdapter::getX)
145     .def("getNormal",&finley::MeshAdapter::getNormal)
146     .def("getSize",&finley::MeshAdapter::getSize);
147    
148    
149     class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
150     ("OperatorAdapter",no_init)
151     .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
152     .def("setValue",&finley::SystemMatrixAdapter::setValue)
153 jgs 108 .def("resetSolver",&finley::SystemMatrixAdapter::resetSolver)
154 jgs 102 .def("saveMM",&finley::SystemMatrixAdapter::saveMM);
155    
156     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26