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

Annotation of /branches/RW_WIN32/finley/src/CPPAdapter/MeshAdapterFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 210 - (hide annotations)
Wed Nov 23 09:54:02 2005 UTC (15 years ago) by robwdcock
File size: 7061 byte(s)
PARTIAL WIN32 BUILD SYSTEM AND PORT
+ All libraries now build under new build system. No unit test routines yet
+ Reversed some incorrect refactorings in Bruce.cpp

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26