/[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 888 - (hide annotations)
Tue Nov 7 08:31:26 2006 UTC (12 years, 5 months ago) by gross
Original Path: trunk/finley/src/CPPAdapter/finleycpp.cpp
File size: 6086 byte(s)
Problem in Mesh_findMatchingFaces.c fixed:
default tolerance in python interface was set too tight.



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 ksteube 817 #ifdef PASO_MPI
18     #include <mpi.h>
19     #endif
20 jgs 102 extern "C" {
21 robwdcock 682 #include "../Finley.h"
22 jgs 102 }
23 jgs 472
24 jgs 203 #include "MeshAdapter.h"
25     #include "MeshAdapterFactory.h"
26     #include "SystemMatrixAdapter.h"
27 jgs 102
28 gross 727 #include "FinleyAdapterException.h"
29     // #include "esysUtils/EsysException.h"
30 robwdcock 682 #include "esysUtils/esysExceptionTranslator.h"
31 jgs 102
32 robwdcock 682 #include "escript/AbstractContinuousDomain.h"
33 jgs 102
34     #include <boost/python.hpp>
35     #include <boost/python/module.hpp>
36     #include <boost/python/def.hpp>
37     #include <boost/python/detail/defaults_gen.hpp>
38    
39     using namespace boost::python;
40    
41     /**
42 jgs 121 \page finley Finley
43     Finley is the python module name that contains the interfaces
44 jgs 102 to the C++ wrapper to finley.
45    
46 jgs 121 \version 1.0.0
47 jgs 102
48 jgs 121 \section class_desc Class Description:
49 jgs 102 Data
50    
51 jgs 121 \section class_limits Class Limitations:
52 jgs 102 None
53    
54 jgs 121 \section class_conds Class Conditions of Use:
55 jgs 102 None
56    
57 jgs 121 \section throws Throws:
58 jgs 102 None
59    
60     */
61    
62     //
63     // The BOOST_PYTHON_FUNCTION_OVERLOADS macro generates function overloads for optional
64     // arguments to the respective finley functions.
65     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
66     //
67     // NOTE: If the number of arguments to the finley functions change
68     // the magic numbers in the BOOST_PYTHON_FUNCTION_OVERLOADS call
69     // must change.
70     //
71     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
72     // BOOST_PYTHON_FUNCTION_OVERLOADS(readMesh_overloads,finley::readMesh,1,2)
73     // BOOST_PYTHON_FUNCTION_OVERLOADS(brick_overloads,finley::brick,0,12)
74     // BOOST_PYTHON_FUNCTION_OVERLOADS(rectangle_overloads,finley::rectangle,0,9)
75     // BOOST_PYTHON_FUNCTION_OVERLOADS(interval_overloads,finley::interval,0,6)
76     // BOOST_PYTHON_FUNCTION_OVERLOADS(glueFaces_overloads,finley::glueFaces,1,3)
77     // BOOST_PYTHON_FUNCTION_OVERLOADS(joinFaces_overloads,finley::joinFaces,1,3)
78    
79     BOOST_PYTHON_MODULE(finleycpp)
80     {
81    
82     // def("ReadMesh",finley::readMesh,readMesh_overloads());
83     // def("Brick",finley::brick,brick_overloads());
84     // def("Rectangle",finley::rectangle,rectangle_overloads());
85     // def("Interval",finley::interval,interval_overloads());
86     // def("GlueFaces",finley::glueFaces,glueFaces_overloads());
87     // def("JoinFaces",finley::joinFaces,joinFaces_overloads());
88     //
89     // NOTE: The return_value_policy is necessary for functions that
90     // return pointers.
91    
92     def("ReadMesh",finley::readMesh,
93     (arg("fileName"),arg("integrationOrder")=-1),
94     return_value_policy<manage_new_object>());
95    
96     def ("Brick",finley::brick,
97     (arg("n0")=1,arg("n1")=1,arg("n2")=1,
98     arg("order")=1,
99     arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
100     arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false,
101     arg("integrationOrder")=-1,
102     arg("useElementsOnFace")=false),
103     return_value_policy<manage_new_object>());
104    
105     def ("Rectangle",finley::rectangle,
106     (arg("n0")=1,arg("n1")=1,arg("order")=1,
107     arg("l0")=1.0,arg("l1")=1.0,
108     arg("periodic0")=false,arg("periodic1")=false,
109     arg("integrationOrder")=-1,
110     arg("useElementsOnFace")=false),
111     return_value_policy<manage_new_object>());
112    
113     def("Interval",finley::interval,
114     (arg("n1")=1,arg("order")=1,
115     arg("l1")=1.0,arg("periodic0")=false,
116     arg("integrationOrder")=-1,
117     arg("useElementsOnFace")=false),
118     return_value_policy<manage_new_object>());
119    
120 jgs 110 def("Merge",finley::meshMerge,
121     return_value_policy<manage_new_object>());
122    
123 jgs 102 def("GlueFaces",finley::glueFaces,
124     (arg("safetyFactor")=0.2,
125 gross 888 arg("tolerance")=1.e-8),
126 jgs 102 return_value_policy<manage_new_object>());
127    
128     def("JoinFaces",finley::joinFaces,
129     (arg("safetyFactor")=0.2,
130 gross 888 arg("tolerance")=1.e-8),
131 jgs 102 return_value_policy<manage_new_object>());
132    
133 gross 727 register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));
134 jgs 102
135     class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
136     ("MeshAdapter",init<optional <Finley_Mesh*> >())
137     .def(init<const finley::MeshAdapter&>())
138     .def("write",&finley::MeshAdapter::write)
139     .def("getDescription",&finley::MeshAdapter::getDescription)
140     .def("getDim",&finley::MeshAdapter::getDim)
141     .def("getDataShape",&finley::MeshAdapter::getDataShape)
142     .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
143     .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
144     .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
145     .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
146 jgs 110 .def("setX",&finley::MeshAdapter::setNewX)
147 jgs 102 .def("getX",&finley::MeshAdapter::getX)
148     .def("getNormal",&finley::MeshAdapter::getNormal)
149 jgs 153 .def("getSize",&finley::MeshAdapter::getSize)
150     .def("saveDX",&finley::MeshAdapter::saveDX)
151     .def("saveVTK",&finley::MeshAdapter::saveVTK);
152 jgs 102
153 jgs 153
154 jgs 102 class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
155     ("OperatorAdapter",no_init)
156     .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
157 jgs 149 .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
158 jgs 123 .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
159     .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
160 jgs 102
161     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26