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

Diff of /branches/more_shared_ptrs_from_1812/finley/src/CPPAdapter/MeshAdapterFactory.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/finley/src/finley/CPPAdapter/MeshAdapterFactory.cpp revision 201 by jgs, Wed Nov 23 04:10:21 2005 UTC trunk/finley/src/CPPAdapter/MeshAdapterFactory.cpp revision 757 by woo409, Mon Jun 26 13:12:56 2006 UTC
# Line 13  Line 13 
13   ******************************************************************************   ******************************************************************************
14  */  */
15    
16  extern "C" {  #include "MeshAdapterFactory.h"
17  #include "finley/finleyC/Finley.h"  #include "FinleyError.h"
 #include "finley/finleyC/Mesh.h"  
 #include "finley/finleyC/RectangularMesh.h"  
 }  
 #include "finley/CPPAdapter/FinleyError.h"  
 #include "finley/CPPAdapter/MeshAdapterFactory.h"  
18    
 #include <iostream>  
 #include <sstream>  
19  #include <boost/python/extract.hpp>  #include <boost/python/extract.hpp>
20    
21    #include <sstream>
22    
23  using namespace std;  using namespace std;
24  using namespace escript;  using namespace escript;
25    
# Line 36  namespace finley { Line 31  namespace finley {
31      //      //
32      // create a copy of the filename to overcome the non-constness of call      // create a copy of the filename to overcome the non-constness of call
33      // to Finley_Mesh_read      // to Finley_Mesh_read
34      char fName[fileName.size()+1];      Finley_Mesh* fMesh=0;
35        // Win32 refactor
36        char *fName = ((fileName.size()+1)>0) ? TMPMEMALLOC((fileName.size()+1),char) : (char*)NULL;
37      strcpy(fName,fileName.c_str());      strcpy(fName,fileName.c_str());
38      Finley_Mesh* fMesh=Finley_Mesh_read(fName,integrationOrder);  
39    #ifndef PASO_MPI
40        fMesh=Finley_Mesh_read(fName,integrationOrder);
41    #else
42        {
43          stringstream temp;
44          temp << "Unable to read meshes from file under MPI yet...";
45          setFinleyError(VALUE_ERROR,temp.str().c_str());
46        }
47    #endif
48      checkFinleyError();      checkFinleyError();
49      AbstractContinuousDomain* temp=new MeshAdapter(fMesh);      AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
50        
51        /* win32 refactor */
52        TMPMEMFREE(fName);
53        
54      return temp;      return temp;
55    }    }
56    
# Line 66  namespace finley { Line 76  namespace finley {
76    
77      //      //
78      // linearInterpolation      // linearInterpolation
79      Finley_Mesh* fMesh;      Finley_Mesh* fMesh=NULL;
80    
81      if (order==1) {      if (order==1) {
82        fMesh=Finley_RectangularMesh_Hex8(numElements,length,periodic,integrationOrder,        fMesh=Finley_RectangularMesh_Hex8(numElements,length,periodic,integrationOrder,
83                      useElementsOnFace) ;                      useElementsOnFace) ;
84      } else if (order==2) {      }
85    #ifndef PASO_MPI
86            else if (order==2) {
87        fMesh=Finley_RectangularMesh_Hex20(numElements,length,periodic,integrationOrder,        fMesh=Finley_RectangularMesh_Hex20(numElements,length,periodic,integrationOrder,
88                       useElementsOnFace) ;                       useElementsOnFace) ;
89      } else {      } else {
# Line 78  namespace finley { Line 91  namespace finley {
91        temp << "Illegal interpolation order: " << order;        temp << "Illegal interpolation order: " << order;
92        setFinleyError(VALUE_ERROR,temp.str().c_str());        setFinleyError(VALUE_ERROR,temp.str().c_str());
93      }      }
94    #else
95            else {
96          stringstream temp;
97          temp << "type of 3D regular mesh requested is unavailable under MPI\nOR\nIllegal interpolation order: " << order;
98          setFinleyError(VALUE_ERROR,temp.str().c_str());
99        }
100    #endif
101      //      //
102      // Convert any finley errors into a C++ exception      // Convert any finley errors into a C++ exception
103      checkFinleyError();      checkFinleyError();
# Line 94  namespace finley { Line 114  namespace finley {
114      double length[]={l0,l1};      double length[]={l0,l1};
115      int periodic[]={periodic0, periodic1};      int periodic[]={periodic0, periodic1};
116    
117      Finley_Mesh* fMesh;      Finley_Mesh* fMesh=0;
118      if (order==1) {      if (order==1) {
119        fMesh=Finley_RectangularMesh_Rec4(numElements, length,periodic,integrationOrder,        fMesh=Finley_RectangularMesh_Rec4(numElements, length,periodic,integrationOrder,
120                      useElementsOnFace);                      useElementsOnFace);
121      } else if (order==2) {      }
122    #ifndef PASO_MPI
123        else if (order==2) {
124        fMesh=Finley_RectangularMesh_Rec8(numElements,length,periodic,integrationOrder,        fMesh=Finley_RectangularMesh_Rec8(numElements,length,periodic,integrationOrder,
125                      useElementsOnFace);                      useElementsOnFace);
126      } else {      }
127    #endif
128        else {
129        stringstream temp;        stringstream temp;
130        temp << "Illegal interpolation order: " << order;        temp << "Illegal interpolation order: " << order;
131        setFinleyError(VALUE_ERROR,temp.str().c_str());        setFinleyError(VALUE_ERROR,temp.str().c_str());
# Line 123  namespace finley { Line 147  namespace finley {
147      if (order==1) {      if (order==1) {
148        fMesh=Finley_RectangularMesh_Line2(numElements, length,periodic,integrationOrder,        fMesh=Finley_RectangularMesh_Line2(numElements, length,periodic,integrationOrder,
149                       useElementsOnFace);                       useElementsOnFace);
150      } else if (order==2) {      }
151    #ifndef PASO_MPI
152        else if (order==2) {
153        fMesh=Finley_RectangularMesh_Line3(numElements,length,periodic,integrationOrder,        fMesh=Finley_RectangularMesh_Line3(numElements,length,periodic,integrationOrder,
154                       useElementsOnFace);                       useElementsOnFace);
155      } else {      }
156    #endif
157        else {
158        stringstream temp;        stringstream temp;
159        temp << "Illegal interpolation order: " << order;        temp << "Illegal interpolation order: " << order;
160        setFinleyError(VALUE_ERROR,temp.str().c_str());        setFinleyError(VALUE_ERROR,temp.str().c_str());
# Line 142  namespace finley { Line 170  namespace finley {
170      Finley_Mesh* fMesh=0;      Finley_Mesh* fMesh=0;
171      //      //
172      // extract the meshes from meshList      // extract the meshes from meshList
173    #ifndef PASO_MPI
174      int numMsh=boost::python::extract<int>(meshList.attr("__len__")());      int numMsh=boost::python::extract<int>(meshList.attr("__len__")());
175      Finley_Mesh* mshes[numMsh];      Finley_Mesh **mshes = (numMsh) ? TMPMEMALLOC(numMsh,Finley_Mesh*) : (Finley_Mesh**)NULL;
176      for (int i=0;i<numMsh;++i) {      for (int i=0;i<numMsh;++i) {
177           AbstractContinuousDomain& meshListMember=boost::python::extract<AbstractContinuousDomain&>(meshList[i]);           AbstractContinuousDomain& meshListMember=boost::python::extract<AbstractContinuousDomain&>(meshList[i]);
178           const MeshAdapter* finley_meshListMember=static_cast<const MeshAdapter*>(&meshListMember);           const MeshAdapter* finley_meshListMember=static_cast<const MeshAdapter*>(&meshListMember);
# Line 152  namespace finley { Line 181  namespace finley {
181      //      //
182      // merge the meshes:      // merge the meshes:
183      fMesh=Finley_Mesh_merge(numMsh,mshes);      fMesh=Finley_Mesh_merge(numMsh,mshes);
184    #else
185        {
186          stringstream temp;
187          temp << "meshMerge() not available in MPI yet...";
188          setFinleyError(VALUE_ERROR,temp.str().c_str());
189        }
190    #endif
191      //      //
192      // Convert any finley errors into a C++ exception      // Convert any finley errors into a C++ exception
193      checkFinleyError();      checkFinleyError();
194      AbstractContinuousDomain* temp=new MeshAdapter(fMesh);      AbstractContinuousDomain* temp=new MeshAdapter(fMesh);
195        TMPMEMFREE(mshes);
196    
197      return temp;      return temp;
198    }    }
199    AbstractContinuousDomain*  glueFaces(const boost::python::list& meshList,    AbstractContinuousDomain*  glueFaces(const boost::python::list& meshList,
# Line 163  namespace finley { Line 201  namespace finley {
201              double tolerance)              double tolerance)
202    {    {
203      Finley_Mesh* fMesh=0;      Finley_Mesh* fMesh=0;
204    #ifndef PASO_MPI
205      //      //
206      // merge the meshes:      // merge the meshes:
207      AbstractContinuousDomain* merged_meshes=meshMerge(meshList);      AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
# Line 171  namespace finley { Line 210  namespace finley {
210      const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);      const MeshAdapter* merged_finley_meshes=static_cast<const MeshAdapter*>(merged_meshes);
211      fMesh=merged_finley_meshes->getFinley_Mesh();      fMesh=merged_finley_meshes->getFinley_Mesh();
212      Finley_Mesh_glueFaces(fMesh,safety_factor,tolerance);      Finley_Mesh_glueFaces(fMesh,safety_factor,tolerance);
213    
214      //      //
215      // Convert any finley errors into a C++ exception      // Convert any finley errors into a C++ exception
216      checkFinleyError();      checkFinleyError();
217      return merged_meshes;      return merged_meshes;
218    #else
219        {
220          stringstream temp;
221          temp << "glueFaces() not available in MPI yet...";
222          setFinleyError(VALUE_ERROR,temp.str().c_str());
223        }
224    
225        //
226        // Convert any finley errors into a C++ exception
227        checkFinleyError();
228        return (AbstractContinuousDomain*)0;
229    #endif
230    
231    }    }
232    AbstractContinuousDomain*  joinFaces(const boost::python::list& meshList,    AbstractContinuousDomain*  joinFaces(const boost::python::list& meshList,
233              double safety_factor,              double safety_factor,
# Line 183  namespace finley { Line 236  namespace finley {
236      Finley_Mesh* fMesh=0;      Finley_Mesh* fMesh=0;
237      //      //
238      // merge the meshes:      // merge the meshes:
239    #ifndef PASO_MPI
240      AbstractContinuousDomain* merged_meshes=meshMerge(meshList);      AbstractContinuousDomain* merged_meshes=meshMerge(meshList);
241      //      //
242      // join the faces:      // join the faces:
# Line 193  namespace finley { Line 247  namespace finley {
247      // Convert any finley errors into a C++ exception      // Convert any finley errors into a C++ exception
248      checkFinleyError();      checkFinleyError();
249      return merged_meshes;      return merged_meshes;
250    #else
251        {
252          stringstream temp;
253          temp << "joinFaces() not available in MPI yet...";
254          setFinleyError(VALUE_ERROR,temp.str().c_str());
255        }
256        //
257        // Convert any finley errors into a C++ exception
258        checkFinleyError();
259        return (AbstractContinuousDomain*)0;
260    
261    #endif
262    }    }
263    
264  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.201  
changed lines
  Added in v.757

  ViewVC Help
Powered by ViewVC 1.1.26