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

Contents of /trunk-mpi-branch/finley/src/CPPAdapter/MeshAdapterFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1226 - (show annotations)
Fri Aug 3 08:00:07 2007 UTC (11 years, 8 months ago) by gross
File size: 7486 byte(s)
hook for ParaMetis added. still needs some work
1 /* $Id$ */
2 /*
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 #ifdef PASO_MPI
17 #include <mpi.h>
18 #endif
19 #include "MeshAdapterFactory.h"
20 #include "FinleyError.h"
21
22 #include <boost/python/extract.hpp>
23
24 #include <sstream>
25
26 using namespace std;
27 using namespace escript;
28
29 namespace finley {
30
31 AbstractContinuousDomain* readMesh(const std::string& fileName,
32 int integrationOrder,
33 int reducedIntegrationOrder,
34 int optimize)
35 {
36 //
37 // create a copy of the filename to overcome the non-constness of call
38 // to Finley_Mesh_read
39 Finley_Mesh* fMesh=0;
40 // Win32 refactor
41 char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;
42 strcpy(fName,fileName.c_str());
43
44 fMesh=Finley_Mesh_read(fName,integrationOrder, reducedIntegrationOrder, (optimize ? TRUE : FALSE));
45 checkFinleyError();
46 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
47
48 /* win32 refactor */
49 TMPMEMFREE(fName);
50
51 return temp;
52 }
53
54 AbstractContinuousDomain* readGmsh(const std::string& fileName,
55 int numDim,
56 int integrationOrder,
57 int reducedIntegrationOrder,
58 int optimize)
59 {
60 //
61 // create a copy of the filename to overcome the non-constness of call
62 // to Finley_Mesh_read
63 Finley_Mesh* fMesh=0;
64 // Win32 refactor
65 char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;
66 strcpy(fName,fileName.c_str());
67
68 fMesh=Finley_Mesh_readGmsh(fName, numDim, integrationOrder, reducedIntegrationOrder, (optimize ? TRUE : FALSE));
69 checkFinleyError();
70 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
71
72 /* win32 refactor */
73 TMPMEMFREE(fName);
74
75 return temp;
76 }
77
78 AbstractContinuousDomain* brick(int n0,int n1,int n2,int order,
79 double l0,double l1,double l2,
80 int periodic0,int periodic1,
81 int periodic2,
82 int integrationOrder,
83 int reducedIntegrationOrder,
84 int useElementsOnFace,
85 int useFullElementOrder,
86 int optimize)
87 {
88 int numElements[]={n0,n1,n2};
89 double length[]={l0,l1,l2};
90 int periodic[]={periodic0, periodic1, periodic2};
91
92 //
93 // linearInterpolation
94 Finley_Mesh* fMesh=NULL;
95
96 if (order==1) {
97 fMesh=Finley_RectangularMesh_Hex8(numElements,length,periodic,integrationOrder,reducedIntegrationOrder,
98 useElementsOnFace,useFullElementOrder,(optimize ? TRUE : FALSE)) ;
99 }
100 else if (order==2) {
101 fMesh=Finley_RectangularMesh_Hex20(numElements,length,periodic,integrationOrder,reducedIntegrationOrder,
102 useElementsOnFace,useFullElementOrder,(optimize ? TRUE : FALSE)) ;
103 } else {
104 stringstream temp;
105 temp << "Illegal interpolation order: " << order;
106 setFinleyError(VALUE_ERROR,temp.str().c_str());
107 }
108 //
109 // Convert any finley errors into a C++ exception
110 checkFinleyError();
111 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
112 return temp;
113 }
114 AbstractContinuousDomain* rectangle(int n0,int n1,int order,
115 double l0, double l1,
116 int periodic0,int periodic1,
117 int integrationOrder,
118 int reducedIntegrationOrder,
119 int useElementsOnFace,
120 int useFullElementOrder,
121 int optimize)
122 {
123 int numElements[]={n0,n1};
124 double length[]={l0,l1};
125 int periodic[]={periodic0, periodic1};
126
127 Finley_Mesh* fMesh=0;
128 if (order==1) {
129 fMesh=Finley_RectangularMesh_Rec4(numElements, length,periodic,integrationOrder,reducedIntegrationOrder,
130 useElementsOnFace,useFullElementOrder,(optimize ? TRUE : FALSE));
131 }
132 else if (order==2) {
133 fMesh=Finley_RectangularMesh_Rec8(numElements,length,periodic,integrationOrder,reducedIntegrationOrder,
134 useElementsOnFace,useFullElementOrder,(optimize ? TRUE : FALSE));
135 }
136 else {
137 stringstream temp;
138 temp << "Illegal interpolation order: " << order;
139 setFinleyError(VALUE_ERROR,temp.str().c_str());
140 }
141 //
142 // Convert any finley errors into a C++ exception
143 checkFinleyError();
144 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
145 return temp;
146 }
147
148 AbstractContinuousDomain* meshMerge(const boost::python::list& meshList)
149 {
150 Finley_Mesh* fMesh=0;
151 //
152 // extract the meshes from meshList
153 int numMsh=boost::python::extract<int>(meshList.attr("__len__")());
154 Finley_Mesh **mshes = (numMsh) ? TMPMEMALLOC(numMsh,Finley_Mesh*) : (Finley_Mesh**)NULL;
155 for (int i=0;i<numMsh;++i) {
156 AbstractContinuousDomain& meshListMember=boost::python::extract<AbstractContinuousDomain&>(meshList[i]);
157 const MeshAdapter* finley_meshListMember=static_cast<const MeshAdapter*>(&meshListMember);
158 mshes[i]=finley_meshListMember->getFinley_Mesh();
159 }
160 //
161 // merge the meshes:
162 fMesh=Finley_Mesh_merge(numMsh,mshes);
163 TMPMEMFREE(mshes);
164 //
165 // Convert any finley errors into a C++ exception
166 checkFinleyError();
167 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
168
169 return temp;
170 }
171 AbstractContinuousDomain* glueFaces(const boost::python::list& meshList,
172 double safety_factor,
173 double tolerance,
174 int optimize)
175 {
176 Finley_Mesh* fMesh=0;
177 //
178 // merge the meshes:
179 AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
180 //
181 // glue the faces:
182 const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
183 fMesh=merged_finley_meshes->getFinley_Mesh();
184 Finley_Mesh_glueFaces(fMesh,safety_factor,tolerance,(optimize ? TRUE : FALSE));
185
186 //
187 // Convert any finley errors into a C++ exception
188 checkFinleyError();
189 return merged_meshes;
190 }
191 AbstractContinuousDomain* joinFaces(const boost::python::list& meshList,
192 double safety_factor,
193 double tolerance,
194 int optimize)
195 {
196 Finley_Mesh* fMesh=0;
197 //
198 // merge the meshes:
199 AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
200 //
201 // join the faces:
202 const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
203 fMesh=merged_finley_meshes->getFinley_Mesh();
204 Finley_Mesh_joinFaces(fMesh,safety_factor,tolerance, (optimize ? TRUE : FALSE));
205 //
206 // Convert any finley errors into a C++ exception
207 checkFinleyError();
208 return merged_meshes;
209 }
210
211 // end of namespace
212
213 }

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26