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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 472 - (show annotations)
Fri Jan 27 01:50:59 2006 UTC (12 years, 11 months ago) by jgs
File size: 6573 byte(s)
rationalise all #includes

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
18 using namespace std;
19 using namespace escript;
20
21 namespace finley {
22
23 AbstractContinuousDomain* readMesh(const std::string& fileName,
24 int integrationOrder)
25 {
26 //
27 // create a copy of the filename to overcome the non-constness of call
28 // to Finley_Mesh_read
29 char fName[fileName.size()+1];
30 strcpy(fName,fileName.c_str());
31 Finley_Mesh* fMesh=Finley_Mesh_read(fName,integrationOrder);
32 checkFinleyError();
33 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
34 return temp;
35 }
36
37 AbstractContinuousDomain* brick(int n0,int n1,int n2,int order,
38 double l0,double l1,double l2,
39 int periodic0,int periodic1,
40 int periodic2,
41 int integrationOrder,
42 int useElementsOnFace)
43 {
44 // cout << "n0=" << n0 << " n1=" << n1 << " n2=" << n2
45 // << " order=" << order
46 // << " l0=" << l0 << " l1=" << l1 << " l2=" << l2
47 // << " periodic0=" << periodic0
48 // << " periodic1=" << periodic1
49 // << " periodic2=" << periodic2
50 // << " integerationOrder=" << integrationOrder
51 // << " useElementsOnFace=" << useElementsOnFace << endl;
52
53 int numElements[]={n0,n1,n2};
54 double length[]={l0,l1,l2};
55 int periodic[]={periodic0, periodic1, periodic2};
56
57 //
58 // linearInterpolation
59 Finley_Mesh* fMesh;
60 if (order==1) {
61 fMesh=Finley_RectangularMesh_Hex8(numElements,length,periodic,integrationOrder,
62 useElementsOnFace) ;
63 } else if (order==2) {
64 fMesh=Finley_RectangularMesh_Hex20(numElements,length,periodic,integrationOrder,
65 useElementsOnFace) ;
66 } else {
67 stringstream temp;
68 temp << "Illegal interpolation order: " << order;
69 setFinleyError(VALUE_ERROR,temp.str().c_str());
70 }
71 //
72 // Convert any finley errors into a C++ exception
73 checkFinleyError();
74 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
75 return temp;
76 }
77 AbstractContinuousDomain* rectangle(int n0,int n1,int order,
78 double l0, double l1,
79 int periodic0,int periodic1,
80 int integrationOrder,
81 int useElementsOnFace)
82 {
83 int numElements[]={n0,n1};
84 double length[]={l0,l1};
85 int periodic[]={periodic0, periodic1};
86
87 Finley_Mesh* fMesh;
88 if (order==1) {
89 fMesh=Finley_RectangularMesh_Rec4(numElements, length,periodic,integrationOrder,
90 useElementsOnFace);
91 } else if (order==2) {
92 fMesh=Finley_RectangularMesh_Rec8(numElements,length,periodic,integrationOrder,
93 useElementsOnFace);
94 } else {
95 stringstream temp;
96 temp << "Illegal interpolation order: " << order;
97 setFinleyError(VALUE_ERROR,temp.str().c_str());
98 }
99 //
100 // Convert any finley errors into a C++ exception
101 checkFinleyError();
102 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
103 return temp;
104 }
105 AbstractContinuousDomain* interval(int n0,int order,double l0,int periodic0,
106 int integrationOrder,
107 int useElementsOnFace)
108 {
109 int numElements[]={n0};
110 double length[]={l0};
111 int periodic[]={periodic0};
112 Finley_Mesh* fMesh;
113 if (order==1) {
114 fMesh=Finley_RectangularMesh_Line2(numElements, length,periodic,integrationOrder,
115 useElementsOnFace);
116 } else if (order==2) {
117 fMesh=Finley_RectangularMesh_Line3(numElements,length,periodic,integrationOrder,
118 useElementsOnFace);
119 } else {
120 stringstream temp;
121 temp << "Illegal interpolation order: " << order;
122 setFinleyError(VALUE_ERROR,temp.str().c_str());
123 }
124 //
125 // Convert any finley errors into a C++ exception
126 checkFinleyError();
127 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
128 return temp;
129 }
130 AbstractContinuousDomain* meshMerge(const boost::python::list& meshList)
131 {
132 Finley_Mesh* fMesh=0;
133 //
134 // extract the meshes from meshList
135 int numMsh=boost::python::extract<int>(meshList.attr("__len__")());
136 Finley_Mesh* mshes[numMsh];
137 for (int i=0;i<numMsh;++i) {
138 AbstractContinuousDomain& meshListMember=boost::python::extract<AbstractContinuousDomain&>(meshList[i]);
139 const MeshAdapter* finley_meshListMember=static_cast<const MeshAdapter*>(&meshListMember);
140 mshes[i]=finley_meshListMember->getFinley_Mesh();
141 }
142 //
143 // merge the meshes:
144 fMesh=Finley_Mesh_merge(numMsh,mshes);
145 //
146 // Convert any finley errors into a C++ exception
147 checkFinleyError();
148 AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
149 return temp;
150 }
151 AbstractContinuousDomain* glueFaces(const boost::python::list& meshList,
152 double safety_factor,
153 double tolerance)
154 {
155 Finley_Mesh* fMesh=0;
156 //
157 // merge the meshes:
158 AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
159 //
160 // glue the faces:
161 const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
162 fMesh=merged_finley_meshes->getFinley_Mesh();
163 Finley_Mesh_glueFaces(fMesh,safety_factor,tolerance);
164 //
165 // Convert any finley errors into a C++ exception
166 checkFinleyError();
167 return merged_meshes;
168 }
169 AbstractContinuousDomain* joinFaces(const boost::python::list& meshList,
170 double safety_factor,
171 double tolerance)
172 {
173 Finley_Mesh* fMesh=0;
174 //
175 // merge the meshes:
176 AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
177 //
178 // join the faces:
179 const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
180 fMesh=merged_finley_meshes->getFinley_Mesh();
181 Finley_Mesh_joinFaces(fMesh,safety_factor,tolerance);
182 //
183 // Convert any finley errors into a C++ exception
184 checkFinleyError();
185 return merged_meshes;
186 }
187
188 } // end of namespace

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26