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

Contents of /branches/intelc_win32/finley/src/CPPAdapter/MeshAdapterFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 742 - (show annotations)
Sat Jun 24 11:27:16 2006 UTC (13 years, 2 months ago) by woo409
File size: 6879 byte(s)
+ Initial commit of win32 port using intel c++ compiler 9.1.x for Windows
+ This version is failing some file handling tests in python
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 #include "MeshAdapterFactory.h"
17 #include "FinleyError.h"
18
19 #include <boost/python/extract.hpp>
20
21 #include <sstream>
22
23 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 // Win32 refactor
35 char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;
36 strcpy(fName,fileName.c_str());
37 Finley_Mesh* fMesh=Finley_Mesh_read(fName,integrationOrder);
38 checkFinleyError();
39 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
40
41 /* win32 refactor */
42 TMPMEMFREE(fName);
43
44 return temp;
45 }
46
47 AbstractContinuousDomain* brick(int n0,int n1,int n2,int order,
48 double l0,double l1,double l2,
49 int periodic0,int periodic1,
50 int periodic2,
51 int integrationOrder,
52 int useElementsOnFace)
53 {
54 // cout << "n0=" << n0 << " n1=" << n1 << " n2=" << n2
55 // << " order=" << order
56 // << " l0=" << l0 << " l1=" << l1 << " l2=" << l2
57 // << " periodic0=" << periodic0
58 // << " periodic1=" << periodic1
59 // << " periodic2=" << periodic2
60 // << " integerationOrder=" << integrationOrder
61 // << " useElementsOnFace=" << useElementsOnFace << endl;
62
63 int numElements[]={n0,n1,n2};
64 double length[]={l0,l1,l2};
65 int periodic[]={periodic0, periodic1, periodic2};
66
67 //
68 // linearInterpolation
69 Finley_Mesh* fMesh;
70 if (order==1) {
71 fMesh=Finley_RectangularMesh_Hex8(numElements,length,periodic,integrationOrder,
72 useElementsOnFace) ;
73 } else if (order==2) {
74 fMesh=Finley_RectangularMesh_Hex20(numElements,length,periodic,integrationOrder,
75 useElementsOnFace) ;
76 } else {
77 stringstream temp;
78 temp << "Illegal interpolation order: " << order;
79 setFinleyError(VALUE_ERROR,temp.str().c_str());
80 }
81 //
82 // Convert any finley errors into a C++ exception
83 checkFinleyError();
84 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
85 return temp;
86 }
87 AbstractContinuousDomain* rectangle(int n0,int n1,int order,
88 double l0, double l1,
89 int periodic0,int periodic1,
90 int integrationOrder,
91 int useElementsOnFace)
92 {
93 int numElements[]={n0,n1};
94 double length[]={l0,l1};
95 int periodic[]={periodic0, periodic1};
96
97 Finley_Mesh* fMesh;
98 if (order==1) {
99 fMesh=Finley_RectangularMesh_Rec4(numElements, length,periodic,integrationOrder,
100 useElementsOnFace);
101 } else if (order==2) {
102 fMesh=Finley_RectangularMesh_Rec8(numElements,length,periodic,integrationOrder,
103 useElementsOnFace);
104 } else {
105 stringstream temp;
106 temp << "Illegal interpolation order: " << order;
107 setFinleyError(VALUE_ERROR,temp.str().c_str());
108 }
109 //
110 // Convert any finley errors into a C++ exception
111 checkFinleyError();
112 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
113 return temp;
114 }
115 AbstractContinuousDomain* interval(int n0,int order,double l0,int periodic0,
116 int integrationOrder,
117 int useElementsOnFace)
118 {
119 int numElements[]={n0};
120 double length[]={l0};
121 int periodic[]={periodic0};
122 Finley_Mesh* fMesh;
123 if (order==1) {
124 fMesh=Finley_RectangularMesh_Line2(numElements, length,periodic,integrationOrder,
125 useElementsOnFace);
126 } else if (order==2) {
127 fMesh=Finley_RectangularMesh_Line3(numElements,length,periodic,integrationOrder,
128 useElementsOnFace);
129 } else {
130 stringstream temp;
131 temp << "Illegal interpolation order: " << order;
132 setFinleyError(VALUE_ERROR,temp.str().c_str());
133 }
134 //
135 // Convert any finley errors into a C++ exception
136 checkFinleyError();
137 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
138 return temp;
139 }
140 AbstractContinuousDomain* meshMerge(const boost::python::list& meshList)
141 {
142 Finley_Mesh* fMesh=0;
143 //
144 // extract the meshes from meshList
145 int numMsh=boost::python::extract<int>(meshList.attr("__len__")());
146 Finley_Mesh **mshes = (numMsh) ? TMPMEMALLOC(numMsh,Finley_Mesh*) : (Finley_Mesh**)NULL;
147 for (int i=0;i<numMsh;++i) {
148 AbstractContinuousDomain& meshListMember=boost::python::extract<AbstractContinuousDomain&>(meshList[i]);
149 const MeshAdapter* finley_meshListMember=static_cast<const MeshAdapter*>(&meshListMember);
150 mshes[i]=finley_meshListMember->getFinley_Mesh();
151 }
152 //
153 // merge the meshes:
154 fMesh=Finley_Mesh_merge(numMsh,mshes);
155 //
156 // Convert any finley errors into a C++ exception
157 checkFinleyError();
158 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
159 TMPMEMFREE(mshes);
160
161 return temp;
162 }
163 AbstractContinuousDomain* glueFaces(const boost::python::list& meshList,
164 double safety_factor,
165 double tolerance)
166 {
167 Finley_Mesh* fMesh=0;
168 //
169 // merge the meshes:
170 AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
171 //
172 // glue the faces:
173 const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
174 fMesh=merged_finley_meshes->getFinley_Mesh();
175 Finley_Mesh_glueFaces(fMesh,safety_factor,tolerance);
176 //
177 // Convert any finley errors into a C++ exception
178 checkFinleyError();
179 return merged_meshes;
180 }
181 AbstractContinuousDomain* joinFaces(const boost::python::list& meshList,
182 double safety_factor,
183 double tolerance)
184 {
185 Finley_Mesh* fMesh=0;
186 //
187 // merge the meshes:
188 AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
189 //
190 // join the faces:
191 const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
192 fMesh=merged_finley_meshes->getFinley_Mesh();
193 Finley_Mesh_joinFaces(fMesh,safety_factor,tolerance);
194 //
195 // Convert any finley errors into a C++ exception
196 checkFinleyError();
197 return merged_meshes;
198 }
199
200 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26