/[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 751 - (hide annotations)
Mon Jun 26 01:46:34 2006 UTC (13 years, 11 months ago) by bcumming
File size: 7969 byte(s)
Changes relating to the MPI version of escript
The standard OpenMP version of escript is unchanged

- updated data types (Finley_Mesh, Finley_NodeFile, etc) to store meshes
  over multiple MPI processes.
- added CommBuffer code in Paso for communication of Data associated
  with distributed meshes
- updates in Finley and Escript to support distributed data and operations
  on distributed data (such as interpolation).
- construction of RHS in MPI, so that simple explicit schemes (such as
  /docs/examples/wave.py without IO and the Locator) can run in MPI.
- updated mesh generation for first order line, rectangle and brick
  meshes and second order line meshes in MPI.        
- small changes to trunk/SConstruct and trunk/scons/ess_options.py to
  build the MPI version, these changes are turned off by default.

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 jgs 82 char fName[fileName.size()+1];
36     strcpy(fName,fileName.c_str());
37 bcumming 751
38     #ifndef PASO_MPI
39     fMesh=Finley_Mesh_read(fName,integrationOrder);
40     #else
41     {
42     stringstream temp;
43     temp << "Unable to read meshes from file under MPI yet...";
44     setFinleyError(VALUE_ERROR,temp.str().c_str());
45     }
46     #endif
47 jgs 82 checkFinleyError();
48     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
49     return temp;
50     }
51    
52     AbstractContinuousDomain* brick(int n0,int n1,int n2,int order,
53     double l0,double l1,double l2,
54     int periodic0,int periodic1,
55     int periodic2,
56     int integrationOrder,
57     int useElementsOnFace)
58     {
59     // cout << "n0=" << n0 << " n1=" << n1 << " n2=" << n2
60     // << " order=" << order
61     // << " l0=" << l0 << " l1=" << l1 << " l2=" << l2
62     // << " periodic0=" << periodic0
63     // << " periodic1=" << periodic1
64     // << " periodic2=" << periodic2
65     // << " integerationOrder=" << integrationOrder
66     // << " useElementsOnFace=" << useElementsOnFace << endl;
67    
68     int numElements[]={n0,n1,n2};
69     double length[]={l0,l1,l2};
70     int periodic[]={periodic0, periodic1, periodic2};
71    
72     //
73     // linearInterpolation
74 bcumming 751 Finley_Mesh* fMesh=NULL;
75    
76 jgs 82 if (order==1) {
77 jgs 102 fMesh=Finley_RectangularMesh_Hex8(numElements,length,periodic,integrationOrder,
78 jgs 82 useElementsOnFace) ;
79 bcumming 751 }
80     #ifndef PASO_MPI
81     else if (order==2) {
82 jgs 102 fMesh=Finley_RectangularMesh_Hex20(numElements,length,periodic,integrationOrder,
83 jgs 82 useElementsOnFace) ;
84     } else {
85     stringstream temp;
86     temp << "Illegal interpolation order: " << order;
87     setFinleyError(VALUE_ERROR,temp.str().c_str());
88     }
89 bcumming 751 #else
90     else {
91     stringstream temp;
92     temp << "type of 3D regular mesh requested is unavailable under MPI\nOR\nIllegal interpolation order: " << order;
93     setFinleyError(VALUE_ERROR,temp.str().c_str());
94     }
95     #endif
96 jgs 82 //
97     // Convert any finley errors into a C++ exception
98     checkFinleyError();
99     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
100     return temp;
101     }
102     AbstractContinuousDomain* rectangle(int n0,int n1,int order,
103     double l0, double l1,
104     int periodic0,int periodic1,
105     int integrationOrder,
106     int useElementsOnFace)
107     {
108     int numElements[]={n0,n1};
109     double length[]={l0,l1};
110     int periodic[]={periodic0, periodic1};
111    
112 bcumming 751 Finley_Mesh* fMesh=0;
113 jgs 82 if (order==1) {
114 jgs 102 fMesh=Finley_RectangularMesh_Rec4(numElements, length,periodic,integrationOrder,
115 jgs 82 useElementsOnFace);
116 bcumming 751 }
117     #ifndef PASO_MPI
118     else if (order==2) {
119 jgs 102 fMesh=Finley_RectangularMesh_Rec8(numElements,length,periodic,integrationOrder,
120 jgs 82 useElementsOnFace);
121 bcumming 751 }
122     #endif
123     else {
124 jgs 82 stringstream temp;
125     temp << "Illegal interpolation order: " << order;
126     setFinleyError(VALUE_ERROR,temp.str().c_str());
127     }
128     //
129     // Convert any finley errors into a C++ exception
130     checkFinleyError();
131     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
132     return temp;
133     }
134     AbstractContinuousDomain* interval(int n0,int order,double l0,int periodic0,
135     int integrationOrder,
136     int useElementsOnFace)
137     {
138     int numElements[]={n0};
139     double length[]={l0};
140     int periodic[]={periodic0};
141     Finley_Mesh* fMesh;
142     if (order==1) {
143 jgs 102 fMesh=Finley_RectangularMesh_Line2(numElements, length,periodic,integrationOrder,
144 jgs 82 useElementsOnFace);
145 bcumming 751 }
146     #ifndef PASO_MPI
147     else if (order==2) {
148 jgs 102 fMesh=Finley_RectangularMesh_Line3(numElements,length,periodic,integrationOrder,
149 jgs 82 useElementsOnFace);
150 bcumming 751 }
151     #endif
152     else {
153 jgs 82 stringstream temp;
154     temp << "Illegal interpolation order: " << order;
155     setFinleyError(VALUE_ERROR,temp.str().c_str());
156     }
157     //
158     // Convert any finley errors into a C++ exception
159     checkFinleyError();
160     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
161     return temp;
162     }
163 jgs 110 AbstractContinuousDomain* meshMerge(const boost::python::list& meshList)
164 jgs 82 {
165 jgs 110 Finley_Mesh* fMesh=0;
166     //
167     // extract the meshes from meshList
168 bcumming 751 #ifndef PASO_MPI
169 jgs 110 int numMsh=boost::python::extract<int>(meshList.attr("__len__")());
170     Finley_Mesh* mshes[numMsh];
171     for (int i=0;i<numMsh;++i) {
172     AbstractContinuousDomain& meshListMember=boost::python::extract<AbstractContinuousDomain&>(meshList[i]);
173     const MeshAdapter* finley_meshListMember=static_cast<const MeshAdapter*>(&meshListMember);
174     mshes[i]=finley_meshListMember->getFinley_Mesh();
175     }
176     //
177     // merge the meshes:
178     fMesh=Finley_Mesh_merge(numMsh,mshes);
179 bcumming 751 #else
180     {
181     stringstream temp;
182     temp << "meshMerge() not available in MPI yet...";
183     setFinleyError(VALUE_ERROR,temp.str().c_str());
184     }
185     #endif
186 jgs 110 //
187     // Convert any finley errors into a C++ exception
188     checkFinleyError();
189     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
190 jgs 82 return temp;
191     }
192     AbstractContinuousDomain* glueFaces(const boost::python::list& meshList,
193 jgs 110 double safety_factor,
194 jgs 82 double tolerance)
195     {
196 jgs 110 Finley_Mesh* fMesh=0;
197 bcumming 751 #ifndef PASO_MPI
198 jgs 110 //
199     // merge the meshes:
200     AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
201     //
202     // glue the faces:
203     const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
204     fMesh=merged_finley_meshes->getFinley_Mesh();
205     Finley_Mesh_glueFaces(fMesh,safety_factor,tolerance);
206 bcumming 751
207 jgs 110 //
208     // Convert any finley errors into a C++ exception
209     checkFinleyError();
210     return merged_meshes;
211 bcumming 751 #else
212     {
213     stringstream temp;
214     temp << "glueFaces() not available in MPI yet...";
215     setFinleyError(VALUE_ERROR,temp.str().c_str());
216     }
217    
218     //
219     // Convert any finley errors into a C++ exception
220     checkFinleyError();
221     return (AbstractContinuousDomain*)0;
222     #endif
223    
224 jgs 82 }
225     AbstractContinuousDomain* joinFaces(const boost::python::list& meshList,
226     double safety_factor,
227     double tolerance)
228     {
229 jgs 110 Finley_Mesh* fMesh=0;
230     //
231     // merge the meshes:
232 bcumming 751 #ifndef PASO_MPI
233 jgs 110 AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
234     //
235     // join the faces:
236     const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
237     fMesh=merged_finley_meshes->getFinley_Mesh();
238     Finley_Mesh_joinFaces(fMesh,safety_factor,tolerance);
239     //
240     // Convert any finley errors into a C++ exception
241     checkFinleyError();
242     return merged_meshes;
243 bcumming 751 #else
244     {
245     stringstream temp;
246     temp << "joinFaces() not available in MPI yet...";
247     setFinleyError(VALUE_ERROR,temp.str().c_str());
248     }
249     //
250     // Convert any finley errors into a C++ exception
251     checkFinleyError();
252     return (AbstractContinuousDomain*)0;
253    
254     #endif
255 jgs 82 }
256    
257     } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26