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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1811 - (show annotations)
Thu Sep 25 23:11:13 2008 UTC (10 years, 6 months ago) by ksteube
Original Path: trunk/finley/src/CPPAdapter/finleycpp.cpp
File size: 6864 byte(s)
Copyright updated in all files

1
2 /*******************************************************
3 *
4 * Copyright (c) 2003-2008 by University of Queensland
5 * Earth Systems Science Computational Center (ESSCC)
6 * http://www.uq.edu.au/esscc
7 *
8 * Primary Business: Queensland, Australia
9 * Licensed under the Open Software License version 3.0
10 * http://www.opensource.org/licenses/osl-3.0.php
11 *
12 *******************************************************/
13
14
15 #ifdef PASO_MPI
16 #include <mpi.h>
17 #include "paso/Paso_MPI.h"
18 #endif
19 extern "C" {
20 #include "../Finley.h"
21 }
22
23 #include "MeshAdapter.h"
24 #include "MeshAdapterFactory.h"
25 #include "SystemMatrixAdapter.h"
26 #include "TransportProblemAdapter.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 //
83 // NOTE: The return_value_policy is necessary for functions that
84 // return pointers.
85 //
86 register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));
87
88 def("LoadMesh",finley::loadMesh,
89 (arg("fileName")="file.nc"),
90 return_value_policy<manage_new_object>());
91 def("ReadMesh",finley::readMesh,
92 (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true),
93 return_value_policy<manage_new_object>());
94
95 def("ReadGmsh",finley::readGmsh,
96 (arg("fileName")="file.msh",arg("numDim"), arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true),
97 return_value_policy<manage_new_object>());
98
99 def ("Brick",finley::brick,
100 (arg("n0")=1,arg("n1")=1,arg("n2")=1,
101 arg("order")=1,
102 arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
103 arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false,
104 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
105 arg("useElementsOnFace")=false,
106 arg("useFullElementOrder")=false,
107 arg("optimize")=false),
108 return_value_policy<manage_new_object>());
109
110 def ("Rectangle",finley::rectangle,
111 (arg("n0")=1,arg("n1")=1,arg("order")=1,
112 arg("l0")=1.0,arg("l1")=1.0,
113 arg("periodic0")=false,arg("periodic1")=false,
114 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
115 arg("useElementsOnFace")=false,
116 arg("useFullElementOrder")=false,
117 arg("optimize")=false),
118 return_value_policy<manage_new_object>());
119
120 def("Merge",finley::meshMerge,
121 return_value_policy<manage_new_object>());
122
123 def("GlueFaces",finley::glueFaces,
124 (arg("safetyFactor")=0.2,
125 arg("tolerance")=1.e-8,
126 arg("optimize")=true),
127 return_value_policy<manage_new_object>());
128
129 def("JoinFaces",finley::joinFaces,
130 (arg("safetyFactor")=0.2,
131 arg("tolerance")=1.e-8,
132 arg("optimize")=true),
133 return_value_policy<manage_new_object>());
134
135
136
137 class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
138 ("MeshAdapter",init<optional <Finley_Mesh*> >())
139 .def(init<const finley::MeshAdapter&>())
140 .def("write",&finley::MeshAdapter::write)
141 .def("print_mesh_info",&finley::MeshAdapter::Print_Mesh_Info,(arg("full")=false))
142 .def("dump",&finley::MeshAdapter::dump)
143 .def("getDescription",&finley::MeshAdapter::getDescription)
144 .def("getDim",&finley::MeshAdapter::getDim)
145 .def("getDataShape",&finley::MeshAdapter::getDataShape)
146 .def("getNumDataPointsGlobal",&finley::MeshAdapter::getNumDataPointsGlobal)
147 .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
148 .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem)
149 .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
150 .def("addPDEToTransportProblem",&finley::MeshAdapter::addPDEToTransportProblem)
151 .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
152 .def("newTransportProblem",&finley::MeshAdapter::newTransportProblem)
153 .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
154 .def("setX",&finley::MeshAdapter::setNewX)
155 .def("getX",&finley::MeshAdapter::getX)
156 .def("getNormal",&finley::MeshAdapter::getNormal)
157 .def("getSize",&finley::MeshAdapter::getSize)
158 .def("saveDX",&finley::MeshAdapter::saveDX)
159 .def("saveVTK",&finley::MeshAdapter::saveVTK)
160 .def("setTagMap",&finley::MeshAdapter::setTagMap)
161 .def("getTag",&finley::MeshAdapter::getTag)
162 .def("isValidTagName",&finley::MeshAdapter::isValidTagName)
163 .def("showTagNames",&finley::MeshAdapter::showTagNames)
164 .def("getMPISize",&finley::MeshAdapter::getMPISize)
165 .def("getMPIRank",&finley::MeshAdapter::getMPIRank);
166
167 class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
168 ("OperatorAdapter",no_init)
169 .def("print_matrix_info",&finley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false))
170 .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
171 .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
172 .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
173 .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
174
175 class_<finley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >
176 ("TransportProblemAdapter",no_init)
177 .def("getSafeTimeStepSize",&finley::TransportProblemAdapter::getSafeTimeStepSize)
178 .def("resetTransport",&finley::TransportProblemAdapter::resetTransport);
179 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26