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

Contents of /trunk/finley/src/CPPAdapter/finleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1807 - (show annotations)
Thu Sep 25 01:04:51 2008 UTC (10 years, 9 months ago) by ksteube
File size: 6899 byte(s)
The new MPI parallel ReadMesh is now the default after having passed
all tests both with and without MPI.
If you have been using ReadMesh you should notice no difference.
If you were using ReadMeshMPI then change to ReadMesh.

1
2 /* $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 #ifdef PASO_MPI
17 #include <mpi.h>
18 #include "paso/Paso_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 #include "TransportProblemAdapter.h"
28
29 #include "FinleyAdapterException.h"
30 // #include "esysUtils/EsysException.h"
31 #include "esysUtils/esysExceptionTranslator.h"
32
33 #include "escript/AbstractContinuousDomain.h"
34
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 \page finley Finley
44 Finley is the python module name that contains the interfaces
45 to the C++ wrapper to finley.
46
47 \version 1.0.0
48
49 \section class_desc Class Description:
50 Data
51
52 \section class_limits Class Limitations:
53 None
54
55 \section class_conds Class Conditions of Use:
56 None
57
58 \section throws Throws:
59 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 //
87 register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));
88
89 def("LoadMesh",finley::loadMesh,
90 (arg("fileName")="file.nc"),
91 return_value_policy<manage_new_object>());
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
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("print_mesh_info",&finley::MeshAdapter::Print_Mesh_Info,(arg("full")=false))
143 .def("dump",&finley::MeshAdapter::dump)
144 .def("getDescription",&finley::MeshAdapter::getDescription)
145 .def("getDim",&finley::MeshAdapter::getDim)
146 .def("getDataShape",&finley::MeshAdapter::getDataShape)
147 .def("getNumDataPointsGlobal",&finley::MeshAdapter::getNumDataPointsGlobal)
148 .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
149 .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem)
150 .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
151 .def("addPDEToTransportProblem",&finley::MeshAdapter::addPDEToTransportProblem)
152 .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
153 .def("newTransportProblem",&finley::MeshAdapter::newTransportProblem)
154 .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
155 .def("setX",&finley::MeshAdapter::setNewX)
156 .def("getX",&finley::MeshAdapter::getX)
157 .def("getNormal",&finley::MeshAdapter::getNormal)
158 .def("getSize",&finley::MeshAdapter::getSize)
159 .def("saveDX",&finley::MeshAdapter::saveDX)
160 .def("saveVTK",&finley::MeshAdapter::saveVTK)
161 .def("setTagMap",&finley::MeshAdapter::setTagMap)
162 .def("getTag",&finley::MeshAdapter::getTag)
163 .def("isValidTagName",&finley::MeshAdapter::isValidTagName)
164 .def("showTagNames",&finley::MeshAdapter::showTagNames)
165 .def("getMPISize",&finley::MeshAdapter::getMPISize)
166 .def("getMPIRank",&finley::MeshAdapter::getMPIRank);
167
168 class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
169 ("OperatorAdapter",no_init)
170 .def("print_matrix_info",&finley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false))
171 .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
172 .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
173 .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
174 .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
175
176 class_<finley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >
177 ("TransportProblemAdapter",no_init)
178 .def("getSafeTimeStepSize",&finley::TransportProblemAdapter::getSafeTimeStepSize)
179 .def("resetTransport",&finley::TransportProblemAdapter::resetTransport);
180 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26