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

Annotation of /branches/domexper/dudley/src/CPPAdapter/finleycpp.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1360 - (hide annotations)
Thu Dec 13 05:05:00 2007 UTC (11 years, 4 months ago) by ksteube
Original Path: trunk/finley/src/CPPAdapter/finleycpp.cpp
File size: 6863 byte(s)
Partial implementation of ReadMeshMPI.
Will eventually replace ReadMesh but for now has a different name.

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     #endif
19 jgs 102 extern "C" {
20 robwdcock 682 #include "../Finley.h"
21 jgs 102 }
22 jgs 472
23 jgs 203 #include "MeshAdapter.h"
24     #include "MeshAdapterFactory.h"
25     #include "SystemMatrixAdapter.h"
26 jgs 102
27 gross 727 #include "FinleyAdapterException.h"
28     // #include "esysUtils/EsysException.h"
29 robwdcock 682 #include "esysUtils/esysExceptionTranslator.h"
30 jgs 102
31 robwdcock 682 #include "escript/AbstractContinuousDomain.h"
32 jgs 102
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 jgs 121 \page finley Finley
42     Finley is the python module name that contains the interfaces
43 jgs 102 to the C++ wrapper to finley.
44    
45 jgs 121 \version 1.0.0
46 jgs 102
47 jgs 121 \section class_desc Class Description:
48 jgs 102 Data
49    
50 jgs 121 \section class_limits Class Limitations:
51 jgs 102 None
52    
53 jgs 121 \section class_conds Class Conditions of Use:
54 jgs 102 None
55    
56 jgs 121 \section throws Throws:
57 jgs 102 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 ksteube 1345 def("LoadMesh",finley::loadMesh,
92 ksteube 1312 (arg("fileName")="file.nc"),
93     return_value_policy<manage_new_object>());
94 jgs 102 def("ReadMesh",finley::readMesh,
95 ksteube 1312 (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true),
96 jgs 102 return_value_policy<manage_new_object>());
97 ksteube 1360 def("ReadMeshMPI",finley::readMeshMPI,
98     (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true),
99     return_value_policy<manage_new_object>());
100 jgs 102
101 gross 934 def("ReadGmsh",finley::readGmsh,
102 ksteube 1312 (arg("fileName")="file.msh",arg("numDim"), arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true),
103 gross 934 return_value_policy<manage_new_object>());
104    
105 jgs 102 def ("Brick",finley::brick,
106     (arg("n0")=1,arg("n1")=1,arg("n2")=1,
107     arg("order")=1,
108     arg("l0")=1.0,arg("l1")=1.0,arg("l2")=1.0,
109     arg("periodic0")=false,arg("periodic1")=false,arg("periodic2")=false,
110 gross 1059 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
111 ksteube 1312 arg("useElementsOnFace")=false,
112     arg("useFullElementOrder")=false,
113     arg("optimize")=false),
114 jgs 102 return_value_policy<manage_new_object>());
115    
116     def ("Rectangle",finley::rectangle,
117     (arg("n0")=1,arg("n1")=1,arg("order")=1,
118     arg("l0")=1.0,arg("l1")=1.0,
119     arg("periodic0")=false,arg("periodic1")=false,
120 gross 1059 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
121 ksteube 1312 arg("useElementsOnFace")=false,
122     arg("useFullElementOrder")=false,
123     arg("optimize")=false),
124 jgs 102 return_value_policy<manage_new_object>());
125    
126 jgs 110 def("Merge",finley::meshMerge,
127     return_value_policy<manage_new_object>());
128    
129 jgs 102 def("GlueFaces",finley::glueFaces,
130     (arg("safetyFactor")=0.2,
131 gross 1062 arg("tolerance")=1.e-8,
132 ksteube 1312 arg("optimize")=true),
133 jgs 102 return_value_policy<manage_new_object>());
134    
135     def("JoinFaces",finley::joinFaces,
136     (arg("safetyFactor")=0.2,
137 gross 1062 arg("tolerance")=1.e-8,
138 ksteube 1312 arg("optimize")=true),
139 jgs 102 return_value_policy<manage_new_object>());
140    
141 gross 727 register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));
142 jgs 102
143     class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
144     ("MeshAdapter",init<optional <Finley_Mesh*> >())
145     .def(init<const finley::MeshAdapter&>())
146     .def("write",&finley::MeshAdapter::write)
147 ksteube 1339 .def("print_mesh_info",&finley::MeshAdapter::Print_Mesh_Info,(arg("full")=false))
148 ksteube 1343 .def("dump",&finley::MeshAdapter::dump)
149 jgs 102 .def("getDescription",&finley::MeshAdapter::getDescription)
150     .def("getDim",&finley::MeshAdapter::getDim)
151     .def("getDataShape",&finley::MeshAdapter::getDataShape)
152     .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
153 gross 1204 .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem)
154 jgs 102 .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
155     .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
156     .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
157 jgs 110 .def("setX",&finley::MeshAdapter::setNewX)
158 jgs 102 .def("getX",&finley::MeshAdapter::getX)
159     .def("getNormal",&finley::MeshAdapter::getNormal)
160 jgs 153 .def("getSize",&finley::MeshAdapter::getSize)
161     .def("saveDX",&finley::MeshAdapter::saveDX)
162 gross 1044 .def("saveVTK",&finley::MeshAdapter::saveVTK)
163     .def("setTagMap",&finley::MeshAdapter::setTagMap)
164     .def("getTag",&finley::MeshAdapter::getTag)
165     .def("isValidTagName",&finley::MeshAdapter::isValidTagName)
166 ksteube 1312 .def("showTagNames",&finley::MeshAdapter::showTagNames)
167     .def("getMPISize",&finley::MeshAdapter::getMPISize)
168     .def("getMPIRank",&finley::MeshAdapter::getMPIRank);
169 jgs 102
170     class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
171     ("OperatorAdapter",no_init)
172 ksteube 1339 .def("print_matrix_info",&finley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false))
173 jgs 102 .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
174 jgs 149 .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
175 jgs 123 .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
176     .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
177 jgs 102
178     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26