/[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 1312 - (hide annotations)
Mon Sep 24 06:18:44 2007 UTC (12 years, 8 months ago) by ksteube
File size: 7588 byte(s)
The MPI branch is hereby closed. All future work should be in trunk.

Previously in revision 1295 I merged the latest changes to trunk into trunk-mpi-branch.
In this revision I copied all files from trunk-mpi-branch over the corresponding
trunk files. I did not use 'svn merge', it was a copy.

1 ksteube 1312
2 jgs 102 /* $Id$ */
3 jgs 82
4 ksteube 1312 /*******************************************************
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 203 #include "MeshAdapterFactory.h"
20 jgs 480 #include "FinleyError.h"
21 jgs 82
22 jgs 480 #include <boost/python/extract.hpp>
23    
24     #include <sstream>
25    
26 jgs 82 using namespace std;
27     using namespace escript;
28    
29     namespace finley {
30    
31 ksteube 1312 AbstractContinuousDomain* loadMesh(const std::string& fileName)
32     {
33     //
34     // create a copy of the filename to overcome the non-constness of call
35     // to Finley_Mesh_read
36     Finley_Mesh* fMesh=0;
37     // Win32 refactor
38     char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;
39     strcpy(fName,fileName.c_str());
40    
41     fMesh=Finley_Mesh_load(fName);
42     checkFinleyError();
43     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
44    
45     /* win32 refactor */
46     TMPMEMFREE(fName);
47    
48     return temp;
49     }
50    
51 jgs 82 AbstractContinuousDomain* readMesh(const std::string& fileName,
52 gross 1059 int integrationOrder,
53     int reducedIntegrationOrder,
54 ksteube 1312 int optimize)
55 jgs 82 {
56     //
57     // create a copy of the filename to overcome the non-constness of call
58     // to Finley_Mesh_read
59 bcumming 751 Finley_Mesh* fMesh=0;
60 woo409 757 // Win32 refactor
61     char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;
62 jgs 82 strcpy(fName,fileName.c_str());
63 bcumming 751
64 ksteube 1312 fMesh=Finley_Mesh_read(fName,integrationOrder, reducedIntegrationOrder, (optimize ? TRUE : FALSE));
65 jgs 82 checkFinleyError();
66     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
67 woo409 757
68     /* win32 refactor */
69     TMPMEMFREE(fName);
70    
71 jgs 82 return temp;
72     }
73    
74 gross 934 AbstractContinuousDomain* readGmsh(const std::string& fileName,
75     int numDim,
76     int integrationOrder,
77     int reducedIntegrationOrder,
78 ksteube 1312 int optimize)
79 gross 934 {
80     //
81     // create a copy of the filename to overcome the non-constness of call
82     // to Finley_Mesh_read
83     Finley_Mesh* fMesh=0;
84     // Win32 refactor
85     char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;
86     strcpy(fName,fileName.c_str());
87    
88 ksteube 1312 fMesh=Finley_Mesh_readGmsh(fName, numDim, integrationOrder, reducedIntegrationOrder, (optimize ? TRUE : FALSE));
89 gross 934 checkFinleyError();
90     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
91    
92     /* win32 refactor */
93     TMPMEMFREE(fName);
94    
95     return temp;
96     }
97    
98 jgs 82 AbstractContinuousDomain* brick(int n0,int n1,int n2,int order,
99     double l0,double l1,double l2,
100     int periodic0,int periodic1,
101     int periodic2,
102     int integrationOrder,
103 gross 1059 int reducedIntegrationOrder,
104 ksteube 1312 int useElementsOnFace,
105     int useFullElementOrder,
106     int optimize)
107 jgs 82 {
108     int numElements[]={n0,n1,n2};
109     double length[]={l0,l1,l2};
110     int periodic[]={periodic0, periodic1, periodic2};
111    
112     //
113     // linearInterpolation
114 bcumming 751 Finley_Mesh* fMesh=NULL;
115    
116 jgs 82 if (order==1) {
117 gross 1062 fMesh=Finley_RectangularMesh_Hex8(numElements,length,periodic,integrationOrder,reducedIntegrationOrder,
118 ksteube 1312 useElementsOnFace,useFullElementOrder,(optimize ? TRUE : FALSE)) ;
119 bcumming 751 }
120     else if (order==2) {
121 gross 1062 fMesh=Finley_RectangularMesh_Hex20(numElements,length,periodic,integrationOrder,reducedIntegrationOrder,
122 ksteube 1312 useElementsOnFace,useFullElementOrder,(optimize ? TRUE : FALSE)) ;
123 jgs 82 } else {
124     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* rectangle(int n0,int n1,int order,
135     double l0, double l1,
136     int periodic0,int periodic1,
137     int integrationOrder,
138 gross 1059 int reducedIntegrationOrder,
139 ksteube 1312 int useElementsOnFace,
140     int useFullElementOrder,
141     int optimize)
142 jgs 82 {
143     int numElements[]={n0,n1};
144     double length[]={l0,l1};
145     int periodic[]={periodic0, periodic1};
146    
147 bcumming 751 Finley_Mesh* fMesh=0;
148 jgs 82 if (order==1) {
149 gross 1062 fMesh=Finley_RectangularMesh_Rec4(numElements, length,periodic,integrationOrder,reducedIntegrationOrder,
150 ksteube 1312 useElementsOnFace,useFullElementOrder,(optimize ? TRUE : FALSE));
151 bcumming 751 }
152     else if (order==2) {
153 gross 1062 fMesh=Finley_RectangularMesh_Rec8(numElements,length,periodic,integrationOrder,reducedIntegrationOrder,
154 ksteube 1312 useElementsOnFace,useFullElementOrder,(optimize ? TRUE : FALSE));
155 bcumming 751 }
156     else {
157 jgs 82 stringstream temp;
158     temp << "Illegal interpolation order: " << order;
159     setFinleyError(VALUE_ERROR,temp.str().c_str());
160     }
161     //
162     // Convert any finley errors into a C++ exception
163     checkFinleyError();
164     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
165     return temp;
166     }
167 gross 1062
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     int numMsh=boost::python::extract<int>(meshList.attr("__len__")());
174 woo409 757 Finley_Mesh **mshes = (numMsh) ? TMPMEMALLOC(numMsh,Finley_Mesh*) : (Finley_Mesh**)NULL;
175 jgs 110 for (int i=0;i<numMsh;++i) {
176     AbstractContinuousDomain& meshListMember=boost::python::extract<AbstractContinuousDomain&>(meshList[i]);
177     const MeshAdapter* finley_meshListMember=static_cast<const MeshAdapter*>(&meshListMember);
178     mshes[i]=finley_meshListMember->getFinley_Mesh();
179     }
180     //
181     // merge the meshes:
182     fMesh=Finley_Mesh_merge(numMsh,mshes);
183 bcumming 759 TMPMEMFREE(mshes);
184 jgs 110 //
185     // Convert any finley errors into a C++ exception
186     checkFinleyError();
187     AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
188 woo409 757
189 jgs 82 return temp;
190     }
191     AbstractContinuousDomain* glueFaces(const boost::python::list& meshList,
192 ksteube 1312 double safety_factor,
193     double tolerance,
194     int optimize)
195 jgs 82 {
196 jgs 110 Finley_Mesh* fMesh=0;
197     //
198     // merge the meshes:
199     AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
200     //
201     // glue the faces:
202     const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
203     fMesh=merged_finley_meshes->getFinley_Mesh();
204 ksteube 1312 Finley_Mesh_glueFaces(fMesh,safety_factor,tolerance,(optimize ? TRUE : FALSE));
205 bcumming 751
206 jgs 110 //
207     // Convert any finley errors into a C++ exception
208     checkFinleyError();
209     return merged_meshes;
210 jgs 82 }
211     AbstractContinuousDomain* joinFaces(const boost::python::list& meshList,
212     double safety_factor,
213 gross 1059 double tolerance,
214 ksteube 1312 int optimize)
215 jgs 82 {
216 jgs 110 Finley_Mesh* fMesh=0;
217     //
218     // merge the meshes:
219     AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
220     //
221     // join the faces:
222     const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
223     fMesh=merged_finley_meshes->getFinley_Mesh();
224 ksteube 1312 Finley_Mesh_joinFaces(fMesh,safety_factor,tolerance, (optimize ? TRUE : FALSE));
225 jgs 110 //
226     // Convert any finley errors into a C++ exception
227     checkFinleyError();
228     return merged_meshes;
229 jgs 82 }
230    
231 gross 1062 // end of namespace
232    
233     }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26