/[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 1801 - (hide annotations)
Fri Sep 19 01:37:09 2008 UTC (10 years, 7 months ago) by ksteube
Original Path: trunk/finley/src/CPPAdapter/finleycpp.cpp
File size: 7111 byte(s)
Fixed serialization of I/O for MPI...code didn't compile without MPI

1 jgs 102
2 ksteube 1312 /* $Id$ */
3    
4     /*******************************************************
5     *
6     * Copyright 2003-2007 by ACceSS MNRF
7     * Copyright 2007 by University of Queensland
8     *
9     * http://esscc.uq.edu.au
10     * Primary Business: Queensland, Australia
11     * Licensed under the Open Software License version 3.0
12     * http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16 ksteube 817 #ifdef PASO_MPI
17     #include <mpi.h>
18 ksteube 1800 #include "paso/Paso_MPI.h"
19 ksteube 817 #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 gross 1364 #include "TransportProblemAdapter.h"
28 jgs 102
29 gross 727 #include "FinleyAdapterException.h"
30     // #include "esysUtils/EsysException.h"
31 robwdcock 682 #include "esysUtils/esysExceptionTranslator.h"
32 jgs 102
33 robwdcock 682 #include "escript/AbstractContinuousDomain.h"
34 jgs 102
35     #include <boost/python.hpp>
36     #include <boost/python/module.hpp>
37     #include <boost/python/def.hpp>
38     #include <boost/python/detail/defaults_gen.hpp>
39    
40     using namespace boost::python;
41    
42     /**
43 jgs 121 \page finley Finley
44     Finley is the python module name that contains the interfaces
45 jgs 102 to the C++ wrapper to finley.
46    
47 jgs 121 \version 1.0.0
48 jgs 102
49 jgs 121 \section class_desc Class Description:
50 jgs 102 Data
51    
52 jgs 121 \section class_limits Class Limitations:
53 jgs 102 None
54    
55 jgs 121 \section class_conds Class Conditions of Use:
56 jgs 102 None
57    
58 jgs 121 \section throws Throws:
59 jgs 102 None
60    
61     */
62    
63     //
64     // The BOOST_PYTHON_FUNCTION_OVERLOADS macro generates function overloads for optional
65     // arguments to the respective finley functions.
66     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
67     //
68     // NOTE: If the number of arguments to the finley functions change
69     // the magic numbers in the BOOST_PYTHON_FUNCTION_OVERLOADS call
70     // must change.
71     //
72     // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
73     // BOOST_PYTHON_FUNCTION_OVERLOADS(readMesh_overloads,finley::readMesh,1,2)
74     // BOOST_PYTHON_FUNCTION_OVERLOADS(brick_overloads,finley::brick,0,12)
75     // BOOST_PYTHON_FUNCTION_OVERLOADS(rectangle_overloads,finley::rectangle,0,9)
76     // BOOST_PYTHON_FUNCTION_OVERLOADS(interval_overloads,finley::interval,0,6)
77     // BOOST_PYTHON_FUNCTION_OVERLOADS(glueFaces_overloads,finley::glueFaces,1,3)
78     // BOOST_PYTHON_FUNCTION_OVERLOADS(joinFaces_overloads,finley::joinFaces,1,3)
79    
80     BOOST_PYTHON_MODULE(finleycpp)
81     {
82    
83     //
84     // NOTE: The return_value_policy is necessary for functions that
85     // return pointers.
86 gross 1382 //
87     register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));
88 jgs 102
89 ksteube 1345 def("LoadMesh",finley::loadMesh,
90 ksteube 1312 (arg("fileName")="file.nc"),
91     return_value_policy<manage_new_object>());
92 jgs 102 def("ReadMesh",finley::readMesh,
93 ksteube 1312 (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true),
94 jgs 102 return_value_policy<manage_new_object>());
95 ksteube 1360 def("ReadMeshMPI",finley::readMeshMPI,
96     (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true),
97     return_value_policy<manage_new_object>());
98 jgs 102
99 gross 934 def("ReadGmsh",finley::readGmsh,
100 ksteube 1312 (arg("fileName")="file.msh",arg("numDim"), arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true),
101 gross 934 return_value_policy<manage_new_object>());
102    
103 jgs 102 def ("Brick",finley::brick,
104     (arg("n0")=1,arg("n1")=1,arg("n2")=1,
105     arg("order")=1,
106     arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
107     arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false,
108 gross 1059 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
109 ksteube 1312 arg("useElementsOnFace")=false,
110     arg("useFullElementOrder")=false,
111     arg("optimize")=false),
112 jgs 102 return_value_policy<manage_new_object>());
113    
114     def ("Rectangle",finley::rectangle,
115     (arg("n0")=1,arg("n1")=1,arg("order")=1,
116     arg("l0")=1.0,arg("l1")=1.0,
117     arg("periodic0")=false,arg("periodic1")=false,
118 gross 1059 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
119 ksteube 1312 arg("useElementsOnFace")=false,
120     arg("useFullElementOrder")=false,
121     arg("optimize")=false),
122 jgs 102 return_value_policy<manage_new_object>());
123    
124 jgs 110 def("Merge",finley::meshMerge,
125     return_value_policy<manage_new_object>());
126    
127 jgs 102 def("GlueFaces",finley::glueFaces,
128     (arg("safetyFactor")=0.2,
129 gross 1062 arg("tolerance")=1.e-8,
130 ksteube 1312 arg("optimize")=true),
131 jgs 102 return_value_policy<manage_new_object>());
132    
133     def("JoinFaces",finley::joinFaces,
134     (arg("safetyFactor")=0.2,
135 gross 1062 arg("tolerance")=1.e-8,
136 ksteube 1312 arg("optimize")=true),
137 jgs 102 return_value_policy<manage_new_object>());
138    
139    
140 gross 1361
141 jgs 102 class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
142     ("MeshAdapter",init<optional <Finley_Mesh*> >())
143     .def(init<const finley::MeshAdapter&>())
144     .def("write",&finley::MeshAdapter::write)
145 ksteube 1339 .def("print_mesh_info",&finley::MeshAdapter::Print_Mesh_Info,(arg("full")=false))
146 ksteube 1343 .def("dump",&finley::MeshAdapter::dump)
147 jgs 102 .def("getDescription",&finley::MeshAdapter::getDescription)
148     .def("getDim",&finley::MeshAdapter::getDim)
149     .def("getDataShape",&finley::MeshAdapter::getDataShape)
150 ksteube 1754 .def("getNumDataPointsGlobal",&finley::MeshAdapter::getNumDataPointsGlobal)
151 jgs 102 .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
152 gross 1204 .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem)
153 jgs 102 .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
154 gross 1370 .def("addPDEToTransportProblem",&finley::MeshAdapter::addPDEToTransportProblem)
155 jgs 102 .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
156 gross 1370 .def("newTransportProblem",&finley::MeshAdapter::newTransportProblem)
157 jgs 102 .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
158 jgs 110 .def("setX",&finley::MeshAdapter::setNewX)
159 jgs 102 .def("getX",&finley::MeshAdapter::getX)
160     .def("getNormal",&finley::MeshAdapter::getNormal)
161 jgs 153 .def("getSize",&finley::MeshAdapter::getSize)
162     .def("saveDX",&finley::MeshAdapter::saveDX)
163 gross 1044 .def("saveVTK",&finley::MeshAdapter::saveVTK)
164     .def("setTagMap",&finley::MeshAdapter::setTagMap)
165     .def("getTag",&finley::MeshAdapter::getTag)
166     .def("isValidTagName",&finley::MeshAdapter::isValidTagName)
167 ksteube 1312 .def("showTagNames",&finley::MeshAdapter::showTagNames)
168     .def("getMPISize",&finley::MeshAdapter::getMPISize)
169 ksteube 1801 .def("getMPIRank",&finley::MeshAdapter::getMPIRank);
170 jgs 102
171     class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
172     ("OperatorAdapter",no_init)
173 ksteube 1339 .def("print_matrix_info",&finley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false))
174 jgs 102 .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
175 jgs 149 .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
176 jgs 123 .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
177     .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
178 jgs 102
179 gross 1364 class_<finley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >
180 gross 1417 ("TransportProblemAdapter",no_init)
181 gross 1407 .def("getSafeTimeStepSize",&finley::TransportProblemAdapter::getSafeTimeStepSize)
182 gross 1364 .def("resetTransport",&finley::TransportProblemAdapter::resetTransport);
183 jgs 102 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26