/[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 1339 - (show annotations)
Wed Nov 7 01:53:12 2007 UTC (11 years, 5 months ago) by ksteube
Original Path: trunk/finley/src/CPPAdapter/finleycpp.cpp
File size: 6648 byte(s)
Modified scons target release_src to include lib/ and include/ since
their presence is required for a build.  Modified
mydomain.print_mesh_info(True) to include more useful info about a
distributed domain.  Added mypde.getOperator().print_matrix_info(True)
to tell about a distributed matrix.


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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26