/[escript]/trunk-mpi-branch/finley/src/CPPAdapter/finleycpp.cpp
ViewVC logotype

Contents of /trunk-mpi-branch/finley/src/CPPAdapter/finleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1226 - (show annotations)
Fri Aug 3 08:00:07 2007 UTC (11 years, 8 months ago) by gross
File size: 6832 byte(s)
hook for ParaMetis added. still needs some work
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 #ifdef PASO_MPI
18 #include <mpi.h>
19 #endif
20 extern "C" {
21 #include "../Finley.h"
22 }
23
24 #include "MeshAdapter.h"
25 #include "MeshAdapterFactory.h"
26 #include "SystemMatrixAdapter.h"
27
28 #include "FinleyAdapterException.h"
29 // #include "esysUtils/EsysException.h"
30 #include "esysUtils/esysExceptionTranslator.h"
31
32 #include "escript/AbstractContinuousDomain.h"
33
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 \page finley Finley
43 Finley is the python module name that contains the interfaces
44 to the C++ wrapper to finley.
45
46 \version 1.0.0
47
48 \section class_desc Class Description:
49 Data
50
51 \section class_limits Class Limitations:
52 None
53
54 \section class_conds Class Conditions of Use:
55 None
56
57 \section throws Throws:
58 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")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true),
94 return_value_policy<manage_new_object>());
95
96 def("ReadGmsh",finley::readGmsh,
97 (arg("fileName")="file.msh",arg("numDim"), arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true),
98 return_value_policy<manage_new_object>());
99
100 def ("Brick",finley::brick,
101 (arg("n0")=1,arg("n1")=1,arg("n2")=1,
102 arg("order")=1,
103 arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
104 arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false,
105 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
106 arg("useElementsOnFace")=false,
107 arg("useFullElementOrder")=false,
108 arg("optimize")=false),
109 return_value_policy<manage_new_object>());
110
111 def ("Rectangle",finley::rectangle,
112 (arg("n0")=1,arg("n1")=1,arg("order")=1,
113 arg("l0")=1.0,arg("l1")=1.0,
114 arg("periodic0")=false,arg("periodic1")=false,
115 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
116 arg("useElementsOnFace")=false,
117 arg("useFullElementOrder")=false,
118 arg("optimize")=false),
119 return_value_policy<manage_new_object>());
120
121 def("Merge",finley::meshMerge,
122 return_value_policy<manage_new_object>());
123
124 def("GlueFaces",finley::glueFaces,
125 (arg("safetyFactor")=0.2,
126 arg("tolerance")=1.e-8,
127 arg("optimize")=true),
128 return_value_policy<manage_new_object>());
129
130 def("JoinFaces",finley::joinFaces,
131 (arg("safetyFactor")=0.2,
132 arg("tolerance")=1.e-8,
133 arg("optimize")=true),
134 return_value_policy<manage_new_object>());
135
136 register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));
137
138 class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
139 ("MeshAdapter",init<optional <Finley_Mesh*> >())
140 .def(init<const finley::MeshAdapter&>())
141 .def("write",&finley::MeshAdapter::write)
142 .def("getDescription",&finley::MeshAdapter::getDescription)
143 .def("getDim",&finley::MeshAdapter::getDim)
144 .def("getDataShape",&finley::MeshAdapter::getDataShape)
145 .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
146 .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem)
147 .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
148 .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
149 .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
150 .def("setX",&finley::MeshAdapter::setNewX)
151 .def("getX",&finley::MeshAdapter::getX)
152 .def("getNormal",&finley::MeshAdapter::getNormal)
153 .def("getSize",&finley::MeshAdapter::getSize)
154 .def("saveDX",&finley::MeshAdapter::saveDX)
155 .def("saveVTK",&finley::MeshAdapter::saveVTK)
156 .def("setTagMap",&finley::MeshAdapter::setTagMap)
157 .def("getTag",&finley::MeshAdapter::getTag)
158 .def("isValidTagName",&finley::MeshAdapter::isValidTagName)
159 .def("showTagNames",&finley::MeshAdapter::showTagNames)
160 .def("getMPISize",&finley::MeshAdapter::getMPISize)
161 .def("getMPIRank",&finley::MeshAdapter::getMPIRank);
162
163 class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
164 ("OperatorAdapter",no_init)
165 .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
166 .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
167 .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
168 .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
169
170 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26