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