/[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 1877 - (hide annotations)
Tue Oct 14 02:58:39 2008 UTC (10 years, 6 months ago) by ksteube
Original Path: trunk/finley/src/CPPAdapter/finleycpp.cpp
File size: 7230 byte(s)
convection.py checkpointing uses mkdir/rmdir, and under MPI there
was a race condition.

mkdir needs to be run on only one CPU and then a barrier to prevent
working processors from using the directory before it exists.

Added methods domain.MPIBarrier and domain.onMasterProcessor() to
implement this technique.

A more general solution might be possible in the future.

1 jgs 102
2 ksteube 1312 /*******************************************************
3 ksteube 1811 *
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 ksteube 1312
14 ksteube 1811
15 ksteube 817 #ifdef PASO_MPI
16     #include <mpi.h>
17 ksteube 1800 #include "paso/Paso_MPI.h"
18 ksteube 817 #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 gross 1364 #include "TransportProblemAdapter.h"
27 jgs 102
28 gross 727 #include "FinleyAdapterException.h"
29     // #include "esysUtils/EsysException.h"
30 robwdcock 682 #include "esysUtils/esysExceptionTranslator.h"
31 jgs 102
32 robwdcock 682 #include "escript/AbstractContinuousDomain.h"
33 jgs 102
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 jgs 121 \page finley Finley
43     Finley is the python module name that contains the interfaces
44 jgs 102 to the C++ wrapper to finley.
45    
46 jgs 121 \version 1.0.0
47 jgs 102
48 jgs 121 \section class_desc Class Description:
49 jgs 102 Data
50    
51 jgs 121 \section class_limits Class Limitations:
52 jgs 102 None
53    
54 jgs 121 \section class_conds Class Conditions of Use:
55 jgs 102 None
56    
57 jgs 121 \section throws Throws:
58 jgs 102 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 gross 1382 //
86     register_exception_translator<finley::FinleyAdapterException>(&(esysUtils::esysExceptionTranslator));
87 jgs 102
88 ksteube 1345 def("LoadMesh",finley::loadMesh,
89 jfenwick 1872 (arg("fileName")="file.nc")
90     /* ,return_value_policy<manage_new_object>());*/
91     );
92    
93 jgs 102 def("ReadMesh",finley::readMesh,
94 jfenwick 1872 (arg("fileName")="file.fly",arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true)
95     /* ,return_value_policy<manage_new_object>());*/
96     );
97 jgs 102
98 gross 934 def("ReadGmsh",finley::readGmsh,
99 jfenwick 1872 (arg("fileName")="file.msh",arg("numDim"), arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1, arg("optimize")=true)
100     // ,return_value_policy<manage_new_object>());
101     );
102 gross 934
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 jfenwick 1872 arg("optimize")=false)
112     // ,return_value_policy<manage_new_object>());
113     );
114 jgs 102
115     def ("Rectangle",finley::rectangle,
116     (arg("n0")=1,arg("n1")=1,arg("order")=1,
117     arg("l0")=1.0,arg("l1")=1.0,
118     arg("periodic0")=false,arg("periodic1")=false,
119 gross 1059 arg("integrationOrder")=-1, arg("reducedIntegrationOrder")=-1,
120 ksteube 1312 arg("useElementsOnFace")=false,
121     arg("useFullElementOrder")=false,
122 jfenwick 1872 arg("optimize")=false)
123     // ,return_value_policy<manage_new_object>());
124     );
125 jgs 102
126 jfenwick 1872 def("Merge",finley::meshMerge
127     // ,return_value_policy<manage_new_object>());
128     );
129 jgs 110
130 jgs 102 def("GlueFaces",finley::glueFaces,
131     (arg("safetyFactor")=0.2,
132 gross 1062 arg("tolerance")=1.e-8,
133 jfenwick 1872 arg("optimize")=true)
134     // ,return_value_policy<manage_new_object>());
135     );
136 jgs 102
137     def("JoinFaces",finley::joinFaces,
138     (arg("safetyFactor")=0.2,
139 gross 1062 arg("tolerance")=1.e-8,
140 jfenwick 1872 arg("optimize")=true)
141     // ,return_value_policy<manage_new_object>());
142     );
143 jgs 102
144    
145     class_<finley::MeshAdapter, bases<escript::AbstractContinuousDomain> >
146     ("MeshAdapter",init<optional <Finley_Mesh*> >())
147     .def(init<const finley::MeshAdapter&>())
148     .def("write",&finley::MeshAdapter::write)
149 ksteube 1339 .def("print_mesh_info",&finley::MeshAdapter::Print_Mesh_Info,(arg("full")=false))
150 ksteube 1343 .def("dump",&finley::MeshAdapter::dump)
151 jgs 102 .def("getDescription",&finley::MeshAdapter::getDescription)
152     .def("getDim",&finley::MeshAdapter::getDim)
153     .def("getDataShape",&finley::MeshAdapter::getDataShape)
154 ksteube 1754 .def("getNumDataPointsGlobal",&finley::MeshAdapter::getNumDataPointsGlobal)
155 jgs 102 .def("addPDEToSystem",&finley::MeshAdapter::addPDEToSystem)
156 gross 1204 .def("addPDEToLumpedSystem",&finley::MeshAdapter::addPDEToLumpedSystem)
157 jgs 102 .def("addPDEToRHS",&finley::MeshAdapter::addPDEToRHS)
158 gross 1370 .def("addPDEToTransportProblem",&finley::MeshAdapter::addPDEToTransportProblem)
159 jgs 102 .def("newOperator",&finley::MeshAdapter::newSystemMatrix)
160 gross 1370 .def("newTransportProblem",&finley::MeshAdapter::newTransportProblem)
161 jgs 102 .def("getSystemMatrixTypeId",&finley::MeshAdapter::getSystemMatrixTypeId)
162 gross 1859 .def("getTransportTypeId",&finley::MeshAdapter::getTransportTypeId)
163 jgs 110 .def("setX",&finley::MeshAdapter::setNewX)
164 jgs 102 .def("getX",&finley::MeshAdapter::getX)
165     .def("getNormal",&finley::MeshAdapter::getNormal)
166 jgs 153 .def("getSize",&finley::MeshAdapter::getSize)
167     .def("saveDX",&finley::MeshAdapter::saveDX)
168 gross 1044 .def("saveVTK",&finley::MeshAdapter::saveVTK)
169     .def("setTagMap",&finley::MeshAdapter::setTagMap)
170     .def("getTag",&finley::MeshAdapter::getTag)
171     .def("isValidTagName",&finley::MeshAdapter::isValidTagName)
172 ksteube 1312 .def("showTagNames",&finley::MeshAdapter::showTagNames)
173     .def("getMPISize",&finley::MeshAdapter::getMPISize)
174 ksteube 1877 .def("getMPIRank",&finley::MeshAdapter::getMPIRank)
175     .def("MPIBarrier",&finley::MeshAdapter::MPIBarrier)
176     .def("onMasterProcessor",&finley::MeshAdapter::onMasterProcessor);
177 jgs 102
178     class_<finley::SystemMatrixAdapter, bases<escript::AbstractSystemMatrix> >
179     ("OperatorAdapter",no_init)
180 ksteube 1339 .def("print_matrix_info",&finley::SystemMatrixAdapter::Print_Matrix_Info,(arg("full")=false))
181 jgs 102 .def("nullifyRowsAndCols",&finley::SystemMatrixAdapter::nullifyRowsAndCols)
182 jgs 149 .def("resetValues",&finley::SystemMatrixAdapter::resetValues)
183 jgs 123 .def("saveMM",&finley::SystemMatrixAdapter::saveMM)
184     .def("saveHB",&finley::SystemMatrixAdapter::saveHB);
185 jgs 102
186 gross 1364 class_<finley::TransportProblemAdapter, bases<escript::AbstractTransportProblem> >
187 gross 1417 ("TransportProblemAdapter",no_init)
188 gross 1407 .def("getSafeTimeStepSize",&finley::TransportProblemAdapter::getSafeTimeStepSize)
189 gross 1859 .def("getUnlimitedTimeStepSize",&finley::TransportProblemAdapter::getUnlimitedTimeStepSize)
190 gross 1364 .def("resetTransport",&finley::TransportProblemAdapter::resetTransport);
191 jgs 102 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26