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

Annotation of /trunk/finley/src/CPPAdapter/MeshAdapterFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 759 - (hide annotations)
Thu Jun 29 01:53:23 2006 UTC (16 years, 9 months ago) by bcumming
File size: 8195 byte(s)
- added directory pythonMPI to the source tree. this directory contains
  the c++ wrapper that is used to run python scripts in parallel for the
  MPI version of escript/finley
- updated the SConstruct and ./scons/ess_options.py for conditional MPI
  compilation. To compile the MPI version on ESS uncomment the #define
  PASO_MPI in ./paso/src/Paso.h and add the command line option
  useMPI=yes when running scons.
- fixed a compile time error in the MPI build in  
  finley/src/CPPAdapter/MeshAdapterFactory.cpp 
     

1 jgs 102 /* $Id$ */
2 jgs 82 /*
3     ******************************************************************************
4     * *
5     * COPYRIGHT ACcESS 2004 - All Rights Reserved *
6     * *
7     * This software is the property of ACcESS. No part of this code *
8     * may be copied in any form or by any means without the expressed written *
9     * consent of ACcESS. Copying, use or modification of this software *
10     * by any unauthorised person is illegal unless that person has a software *
11     * license agreement with ACcESS. *
12     * *
13     ******************************************************************************
14     */
15    
16 jgs 203 #include "MeshAdapterFactory.h"
17 jgs 480 #include "FinleyError.h"
18 jgs 82
19 jgs 480 #include <boost/python/extract.hpp>
20    
21     #include <sstream>
22    
23 jgs 82 using namespace std;
24     using namespace escript;
25    
26     namespace finley {
27    
28     AbstractContinuousDomain* readMesh(const std::string& fileName,
29     int integrationOrder)
30     {
31     //
32     // create a copy of the filename to overcome the non-constness of call
33     // to Finley_Mesh_read
34 bcumming 751 Finley_Mesh* fMesh=0;
35 woo409 757 // Win32 refactor
36     char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;
37 jgs 82 strcpy(fName,fileName.c_str());
38 bcumming 751
39     #ifndef PASO_MPI
40     fMesh=Finley_Mesh_read(fName,integrationOrder);
41     #else
42     {
43     stringstream temp;
44     temp << "Unable to read meshes from file under MPI yet...";
45     setFinleyError(VALUE_ERROR,temp.str().c_str());
46     }
47     #endif
48 jgs 82 checkFinleyError();
49     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
50 woo409 757
51     /* win32 refactor */
52     TMPMEMFREE(fName);
53    
54 jgs 82 return temp;
55     }
56    
57     AbstractContinuousDomain* brick(int n0,int n1,int n2,int order,
58     double l0,double l1,double l2,
59     int periodic0,int periodic1,
60     int periodic2,
61     int integrationOrder,
62     int useElementsOnFace)
63     {
64     // cout << "n0=" << n0 << " n1=" << n1 << " n2=" << n2
65     // << " order=" << order
66     // << " l0=" << l0 << " l1=" << l1 << " l2=" << l2
67     // << " periodic0=" << periodic0
68     // << " periodic1=" << periodic1
69     // << " periodic2=" << periodic2
70     // << " integerationOrder=" << integrationOrder
71     // << " useElementsOnFace=" << useElementsOnFace << endl;
72    
73     int numElements[]={n0,n1,n2};
74     double length[]={l0,l1,l2};
75     int periodic[]={periodic0, periodic1, periodic2};
76    
77     //
78     // linearInterpolation
79 bcumming 751 Finley_Mesh* fMesh=NULL;
80    
81 jgs 82 if (order==1) {
82 jgs 102 fMesh=Finley_RectangularMesh_Hex8(numElements,length,periodic,integrationOrder,
83 jgs 82 useElementsOnFace) ;
84 bcumming 751 }
85     #ifndef PASO_MPI
86     else if (order==2) {
87 jgs 102 fMesh=Finley_RectangularMesh_Hex20(numElements,length,periodic,integrationOrder,
88 jgs 82 useElementsOnFace) ;
89     } else {
90     stringstream temp;
91     temp << "Illegal interpolation order: " << order;
92     setFinleyError(VALUE_ERROR,temp.str().c_str());
93     }
94 bcumming 751 #else
95     else {
96     stringstream temp;
97     temp << "type of 3D regular mesh requested is unavailable under MPI\nOR\nIllegal interpolation order: " << order;
98     setFinleyError(VALUE_ERROR,temp.str().c_str());
99     }
100     #endif
101 jgs 82 //
102     // Convert any finley errors into a C++ exception
103     checkFinleyError();
104     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
105     return temp;
106     }
107     AbstractContinuousDomain* rectangle(int n0,int n1,int order,
108     double l0, double l1,
109     int periodic0,int periodic1,
110     int integrationOrder,
111     int useElementsOnFace)
112     {
113     int numElements[]={n0,n1};
114     double length[]={l0,l1};
115     int periodic[]={periodic0, periodic1};
116    
117 bcumming 751 Finley_Mesh* fMesh=0;
118 jgs 82 if (order==1) {
119 jgs 102 fMesh=Finley_RectangularMesh_Rec4(numElements, length,periodic,integrationOrder,
120 jgs 82 useElementsOnFace);
121 bcumming 751 }
122     #ifndef PASO_MPI
123     else if (order==2) {
124 jgs 102 fMesh=Finley_RectangularMesh_Rec8(numElements,length,periodic,integrationOrder,
125 jgs 82 useElementsOnFace);
126 bcumming 751 }
127     #endif
128     else {
129 jgs 82 stringstream temp;
130     temp << "Illegal interpolation order: " << order;
131     setFinleyError(VALUE_ERROR,temp.str().c_str());
132     }
133     //
134     // Convert any finley errors into a C++ exception
135     checkFinleyError();
136     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
137     return temp;
138     }
139     AbstractContinuousDomain* interval(int n0,int order,double l0,int periodic0,
140     int integrationOrder,
141     int useElementsOnFace)
142     {
143     int numElements[]={n0};
144     double length[]={l0};
145     int periodic[]={periodic0};
146     Finley_Mesh* fMesh;
147     if (order==1) {
148 jgs 102 fMesh=Finley_RectangularMesh_Line2(numElements, length,periodic,integrationOrder,
149 jgs 82 useElementsOnFace);
150 bcumming 751 }
151     #ifndef PASO_MPI
152     else if (order==2) {
153 jgs 102 fMesh=Finley_RectangularMesh_Line3(numElements,length,periodic,integrationOrder,
154 jgs 82 useElementsOnFace);
155 bcumming 751 }
156     #endif
157     else {
158 jgs 82 stringstream temp;
159     temp << "Illegal interpolation order: " << order;
160     setFinleyError(VALUE_ERROR,temp.str().c_str());
161     }
162     //
163     // Convert any finley errors into a C++ exception
164     checkFinleyError();
165     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
166     return temp;
167     }
168 jgs 110 AbstractContinuousDomain* meshMerge(const boost::python::list& meshList)
169 jgs 82 {
170 jgs 110 Finley_Mesh* fMesh=0;
171     //
172     // extract the meshes from meshList
173 bcumming 751 #ifndef PASO_MPI
174 jgs 110 int numMsh=boost::python::extract<int>(meshList.attr("__len__")());
175 woo409 757 Finley_Mesh **mshes = (numMsh) ? TMPMEMALLOC(numMsh,Finley_Mesh*) : (Finley_Mesh**)NULL;
176 jgs 110 for (int i=0;i<numMsh;++i) {
177     AbstractContinuousDomain& meshListMember=boost::python::extract<AbstractContinuousDomain&>(meshList[i]);
178     const MeshAdapter* finley_meshListMember=static_cast<const MeshAdapter*>(&meshListMember);
179     mshes[i]=finley_meshListMember->getFinley_Mesh();
180     }
181     //
182     // merge the meshes:
183     fMesh=Finley_Mesh_merge(numMsh,mshes);
184 bcumming 759 TMPMEMFREE(mshes);
185 bcumming 751 #else
186     {
187     stringstream temp;
188     temp << "meshMerge() not available in MPI yet...";
189     setFinleyError(VALUE_ERROR,temp.str().c_str());
190     }
191     #endif
192 jgs 110 //
193     // Convert any finley errors into a C++ exception
194     checkFinleyError();
195     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
196 woo409 757
197 jgs 82 return temp;
198     }
199     AbstractContinuousDomain* glueFaces(const boost::python::list& meshList,
200 jgs 110 double safety_factor,
201 jgs 82 double tolerance)
202     {
203 jgs 110 Finley_Mesh* fMesh=0;
204 bcumming 751 #ifndef PASO_MPI
205 jgs 110 //
206     // merge the meshes:
207     AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
208     //
209     // glue the faces:
210     const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
211     fMesh=merged_finley_meshes->getFinley_Mesh();
212     Finley_Mesh_glueFaces(fMesh,safety_factor,tolerance);
213 bcumming 751
214 jgs 110 //
215     // Convert any finley errors into a C++ exception
216     checkFinleyError();
217     return merged_meshes;
218 bcumming 751 #else
219     {
220     stringstream temp;
221     temp << "glueFaces() not available in MPI yet...";
222     setFinleyError(VALUE_ERROR,temp.str().c_str());
223     }
224    
225     //
226     // Convert any finley errors into a C++ exception
227     checkFinleyError();
228     return (AbstractContinuousDomain*)0;
229     #endif
230    
231 jgs 82 }
232     AbstractContinuousDomain* joinFaces(const boost::python::list& meshList,
233     double safety_factor,
234     double tolerance)
235     {
236 jgs 110 Finley_Mesh* fMesh=0;
237     //
238     // merge the meshes:
239 bcumming 751 #ifndef PASO_MPI
240 jgs 110 AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
241     //
242     // join the faces:
243     const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
244     fMesh=merged_finley_meshes->getFinley_Mesh();
245     Finley_Mesh_joinFaces(fMesh,safety_factor,tolerance);
246     //
247     // Convert any finley errors into a C++ exception
248     checkFinleyError();
249     return merged_meshes;
250 bcumming 751 #else
251     {
252     stringstream temp;
253     temp << "joinFaces() not available in MPI yet...";
254     setFinleyError(VALUE_ERROR,temp.str().c_str());
255     }
256     //
257     // Convert any finley errors into a C++ exception
258     checkFinleyError();
259     return (AbstractContinuousDomain*)0;
260    
261     #endif
262 jgs 82 }
263    
264     } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26