/[escript]/branches/domexper/dudley/src/CPPAdapter/MeshAdapter.cpp
ViewVC logotype

Diff of /branches/domexper/dudley/src/CPPAdapter/MeshAdapter.cpp

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

revision 1137 by gross, Thu May 10 08:11:31 2007 UTC revision 1343 by ksteube, Wed Nov 14 02:48:02 2007 UTC
# Line 1  Line 1 
 // $Id$  
 /*  
  ******************************************************************************  
  *                                                                            *  
  *       COPYRIGHT  ACcESS 2004 -  All Rights Reserved                        *  
  *                                                                            *  
  * This software is the property of ACcESS. No part of this code              *  
  * may be copied in any form or by any means without the expressed written    *  
  * consent of ACcESS.  Copying, use or modification of this software          *  
  * by any unauthorised person is illegal unless that person has a software    *  
  * license agreement with ACcESS.                                             *  
  *                                                                            *  
  ******************************************************************************  
 */  
1    
2  #ifdef PASO_MPI  /* $Id$ */
3  #include <mpi.h>  
4  #endif  /*******************************************************
5  #include "MeshAdapter.h"   *
6     *           Copyright 2003-2007 by ACceSS MNRF
7     *       Copyright 2007 by University of Queensland
8     *
9     *                http://esscc.uq.edu.au
10     *        Primary Business: Queensland, Australia
11     *  Licensed under the Open Software License version 3.0
12     *     http://www.opensource.org/licenses/osl-3.0.php
13     *
14     *******************************************************/
15    
16    #include "MeshAdapter.h"
17  #include "escript/Data.h"  #include "escript/Data.h"
18  #include "escript/DataFactory.h"  #include "escript/DataFactory.h"
19    #ifdef USE_NETCDF
20    #include <netcdfcpp.h>
21    #endif
22    extern "C" {
23    #include "escript/blocktimer.h"
24    }
25    #include <vector>
26    
27  using namespace std;  using namespace std;
28  using namespace escript;  using namespace escript;
# Line 47  MeshAdapter::MeshAdapter(Finley_Mesh* fi Line 50  MeshAdapter::MeshAdapter(Finley_Mesh* fi
50  {  {
51    setFunctionSpaceTypeNames();    setFunctionSpaceTypeNames();
52    //    //
53    // need to use a null_deleter as Finley_Mesh_dealloc deletes the pointer    // need to use a null_deleter as Finley_Mesh_free deletes the pointer
54    // for us.    // for us.
55    m_finleyMesh.reset(finleyMesh,null_deleter());    m_finleyMesh.reset(finleyMesh,null_deleter());
56  }  }
# Line 66  MeshAdapter::~MeshAdapter() Line 69  MeshAdapter::~MeshAdapter()
69    // I hope the case for the pointer being zero has been taken care of.    // I hope the case for the pointer being zero has been taken care of.
70    //  cout << "In MeshAdapter destructor." << endl;    //  cout << "In MeshAdapter destructor." << endl;
71    if (m_finleyMesh.unique()) {    if (m_finleyMesh.unique()) {
72      //   cout << "Calling dealloc." << endl;      Finley_Mesh_free(m_finleyMesh.get());
     Finley_Mesh_dealloc(m_finleyMesh.get());  
     //   cout << "Finished dealloc." << endl;  
73    }    }
74  }  }
75    
76    int MeshAdapter::getMPISize() const
77    {
78       return m_finleyMesh.get()->MPIInfo->size;
79    }
80    int MeshAdapter::getMPIRank() const
81    {
82       return m_finleyMesh.get()->MPIInfo->rank;
83    }
84    
85    
86  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {
87     return m_finleyMesh.get();     return m_finleyMesh.get();
88  }  }
# Line 85  void MeshAdapter::write(const std::strin Line 96  void MeshAdapter::write(const std::strin
96    TMPMEMFREE(fName);    TMPMEMFREE(fName);
97  }  }
98    
99    void MeshAdapter::Print_Mesh_Info(const bool full=false) const
100    {
101      Finley_PrintMesh_Info(m_finleyMesh.get(), full);
102    }
103    
104    void MeshAdapter::dump(const std::string& fileName) const
105    {
106    #ifdef USE_NETCDF
107       const NcDim* ncdims[25]; /* ksteube how big should ncdims be? */
108       NcVar *ids, *data;
109       int *int_ptr;
110       Finley_Mesh *mesh = m_finleyMesh.get();
111       int mpi_size             = mesh->MPIInfo->size;
112       int mpi_rank             = mesh->MPIInfo->rank;
113       int numDim               = mesh->Nodes->numDim;
114       int numNodes             = mesh->Nodes->numNodes;
115       int num_Elements         = mesh->Elements->numElements;
116       int num_FaceElements         = mesh->FaceElements->numElements;
117       int num_ContactElements      = mesh->ContactElements->numElements;
118       int num_Points           = mesh->Points->numElements;
119       int num_Elements_numNodes        = mesh->Elements->numNodes;
120       int num_FaceElements_numNodes    = mesh->FaceElements->numNodes;
121       int num_ContactElements_numNodes = mesh->ContactElements->numNodes;
122       char *newFileName = Paso_MPI_appendRankToFileName(strdup(fileName.c_str()), mpi_size, mpi_rank);
123    
124       // NetCDF error handler
125       NcError err(NcError::verbose_nonfatal);
126       // Create the file.
127       NcFile dataFile(newFileName, NcFile::Replace);
128       // check if writing was successful
129       if (!dataFile.is_valid())
130            throw DataException("Error - MeshAdapter::dump: opening of NetCDF file for output failed: " + *newFileName);
131    
132       // Define dimensions (num_Elements and dim_Elements are identical, dim_Elements only appears if > 0)
133       if (! (ncdims[0] = dataFile.add_dim("numNodes", numNodes)) )
134            throw DataException("Error - MeshAdapter::dump: appending dimension numNodes to netCDF file failed: " + *newFileName);
135       if (! (ncdims[1] = dataFile.add_dim("numDim", numDim)) )
136            throw DataException("Error - MeshAdapter::dump: appending dimension numDim to netCDF file failed: " + *newFileName);
137       if (! (ncdims[2] = dataFile.add_dim("mpi_size_plus_1", mpi_size+1)) )
138            throw DataException("Error - MeshAdapter::dump: appending dimension mpi_size to netCDF file failed: " + *newFileName);
139       if (num_Elements>0)
140          if (! (ncdims[3] = dataFile.add_dim("dim_Elements", num_Elements)) )
141            throw DataException("Error - MeshAdapter::dump: appending dimension dim_Elements to netCDF file failed: " + *newFileName);
142       if (num_FaceElements>0)
143          if (! (ncdims[4] = dataFile.add_dim("dim_FaceElements", num_FaceElements)) )
144            throw DataException("Error - MeshAdapter::dump: appending dimension dim_FaceElements to netCDF file failed: " + *newFileName);
145       if (num_ContactElements>0)
146          if (! (ncdims[5] = dataFile.add_dim("dim_ContactElements", num_ContactElements)) )
147            throw DataException("Error - MeshAdapter::dump: appending dimension dim_ContactElements to netCDF file failed: " + *newFileName);
148       if (num_Points>0)
149          if (! (ncdims[6] = dataFile.add_dim("dim_Points", num_Points)) )
150            throw DataException("Error - MeshAdapter::dump: appending dimension dim_Points to netCDF file failed: " + *newFileName);
151       if (num_Elements>0)
152          if (! (ncdims[7] = dataFile.add_dim("dim_Elements_Nodes", num_Elements_numNodes)) )
153            throw DataException("Error - MeshAdapter::dump: appending dimension dim_Elements_Nodes to netCDF file failed: " + *newFileName);
154       if (num_FaceElements>0)
155          if (! (ncdims[8] = dataFile.add_dim("dim_FaceElements_numNodes", num_FaceElements_numNodes)) )
156            throw DataException("Error - MeshAdapter::dump: appending dimension dim_FaceElements_numNodes to netCDF file failed: " + *newFileName);
157       if (num_ContactElements>0)
158          if (! (ncdims[9] = dataFile.add_dim("dim_ContactElements_numNodes", num_ContactElements_numNodes)) )
159            throw DataException("Error - MeshAdapter::dump: appending dimension dim_ContactElements_numNodes to netCDF file failed: " + *newFileName);
160    
161       // MPI size, MPI rank, Name, order, reduced_order
162       if (!dataFile.add_att("mpi_size", mpi_size) )
163            throw DataException("Error - MeshAdapter::dump: appending mpi_size to NetCDF file failed: " + *newFileName);
164       if (!dataFile.add_att("mpi_rank", mpi_rank) )
165            throw DataException("Error - MeshAdapter::dump: appending mpi_rank to NetCDF file failed: " + *newFileName);
166       if (!dataFile.add_att("Name",mesh->Name) )
167            throw DataException("Error - MeshAdapter::dump: appending Name to NetCDF file failed: " + *newFileName);
168       if (!dataFile.add_att("order",mesh->order) )
169            throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);
170       if (!dataFile.add_att("reduced_order",mesh->reduced_order) )
171            throw DataException("Error - MeshAdapter::dump: appending reduced_order to NetCDF file failed: " + *newFileName);
172       if (!dataFile.add_att("num_Elements",num_Elements) )
173            throw DataException("Error - MeshAdapter::dump: appending num_Elements to NetCDF file failed: " + *newFileName);
174       if (!dataFile.add_att("num_FaceElements",num_FaceElements) )
175            throw DataException("Error - MeshAdapter::dump: appending num_FaceElements to NetCDF file failed: " + *newFileName);
176       if (!dataFile.add_att("num_ContactElements",num_ContactElements) )
177            throw DataException("Error - MeshAdapter::dump: appending num_ContactElements to NetCDF file failed: " + *newFileName);
178       if (!dataFile.add_att("num_Points",num_Points) )
179            throw DataException("Error - MeshAdapter::dump: appending num_Points to NetCDF file failed: " + *newFileName);
180    
181       // // // // // Nodes // // // // //
182    
183       // Nodes Id
184       if (! ( ids = dataFile.add_var("Nodes_Id", ncInt, ncdims[0])) )
185            throw DataException("Error - MeshAdapter::dump: appending Nodes_Id to netCDF file failed: " + *newFileName);
186       int_ptr = &mesh->Nodes->Id[0];
187       if (! (ids->put(int_ptr, numNodes)) )
188            throw DataException("Error - MeshAdapter::dump: copy Nodes_Id to netCDF buffer failed: " + *newFileName);
189    
190       // Nodes Tag
191       if (! ( ids = dataFile.add_var("Nodes_Tag", ncInt, ncdims[0])) )
192            throw DataException("Error - MeshAdapter::dump: appending Nodes_Tag to netCDF file failed: " + *newFileName);
193       int_ptr = &mesh->Nodes->Tag[0];
194       if (! (ids->put(int_ptr, numNodes)) )
195            throw DataException("Error - MeshAdapter::dump: copy Nodes_Tag to netCDF buffer failed: " + *newFileName);
196    
197       // Nodes gDOF
198       if (! ( ids = dataFile.add_var("Nodes_gDOF", ncInt, ncdims[0])) )
199            throw DataException("Error - MeshAdapter::dump: appending Nodes_gDOF to netCDF file failed: " + *newFileName);
200       int_ptr = &mesh->Nodes->globalDegreesOfFreedom[0];
201       if (! (ids->put(int_ptr, numNodes)) )
202            throw DataException("Error - MeshAdapter::dump: copy Nodes_gDOF to netCDF buffer failed: " + *newFileName);
203    
204       // Nodes global node index
205       if (! ( ids = dataFile.add_var("Nodes_gNI", ncInt, ncdims[0])) )
206            throw DataException("Error - MeshAdapter::dump: appending Nodes_gNI to netCDF file failed: " + *newFileName);
207       int_ptr = &mesh->Nodes->globalNodesIndex[0];
208       if (! (ids->put(int_ptr, numNodes)) )
209            throw DataException("Error - MeshAdapter::dump: copy Nodes_gNI to netCDF buffer failed: " + *newFileName);
210    
211       // Nodes grDof
212       if (! ( ids = dataFile.add_var("Nodes_grDfI", ncInt, ncdims[0])) )
213            throw DataException("Error - MeshAdapter::dump: appending Nodes_grDfI to netCDF file failed: " + *newFileName);
214       int_ptr = &mesh->Nodes->globalReducedDOFIndex[0];
215       if (! (ids->put(int_ptr, numNodes)) )
216            throw DataException("Error - MeshAdapter::dump: copy Nodes_grDfI to netCDF buffer failed: " + *newFileName);
217    
218       // Nodes grNI
219       if (! ( ids = dataFile.add_var("Nodes_grNI", ncInt, ncdims[0])) )
220            throw DataException("Error - MeshAdapter::dump: appending Nodes_grNI to netCDF file failed: " + *newFileName);
221       int_ptr = &mesh->Nodes->globalReducedNodesIndex[0];
222       if (! (ids->put(int_ptr, numNodes)) )
223            throw DataException("Error - MeshAdapter::dump: copy Nodes_grNI to netCDF buffer failed: " + *newFileName);
224    
225       // Nodes Coordinates
226       if (! ( ids = dataFile.add_var("Nodes_Coordinates", ncDouble, ncdims[0], ncdims[1]) ) )
227            throw DataException("Error - MeshAdapter::dump: appending Nodes_Coordinates to netCDF file failed: " + *newFileName);
228       if (! (ids->put(&(mesh->Nodes->Coordinates[INDEX2(0,0,numDim)]), numNodes, numDim)) )
229            throw DataException("Error - MeshAdapter::dump: copy Nodes_Coordinates to netCDF buffer failed: " + *newFileName);
230    
231       // Nodes degreesOfFreedomDistribution
232       if (! ( ids = dataFile.add_var("Nodes_DofDistribution", ncInt, ncdims[2])) )
233            throw DataException("Error - MeshAdapter::dump: appending Nodes_DofDistribution to netCDF file failed: " + *newFileName);
234       int_ptr = &mesh->Nodes->degreesOfFreedomDistribution->first_component[0];
235       if (! (ids->put(int_ptr, mpi_size+1)) )
236            throw DataException("Error - MeshAdapter::dump: copy Nodes_DofDistribution to netCDF buffer failed: " + *newFileName);
237    
238       // // // // // Elements // // // // //
239    
240       // Only write elements if non-empty because NetCDF doesn't like empty arrays (it treats them as NC_UNLIMITED)
241       if (num_Elements>0) {
242    
243         // Temp storage to gather node IDs
244         int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);
245    
246         // Elements ReferenceElement->ElementTypeId
247         if (!dataFile.add_att("Elements_TypeId", mesh->Elements->ReferenceElement->Type->TypeId) )
248            throw DataException("Error - MeshAdapter::dump: appending Elements_TypeId to NetCDF file failed: " + *newFileName);
249    
250         // Elements_Id
251         if (! ( ids = dataFile.add_var("Elements_Id", ncInt, ncdims[3])) )
252            throw DataException("Error - MeshAdapter::dump: appending Elements_Id to netCDF file failed: " + *newFileName);
253         int_ptr = &mesh->Elements->Id[0];
254         if (! (ids->put(int_ptr, num_Elements)) )
255            throw DataException("Error - MeshAdapter::dump: copy Elements_Id to netCDF buffer failed: " + *newFileName);
256    
257         // Elements_Tag
258         if (! ( ids = dataFile.add_var("Elements_Tag", ncInt, ncdims[3])) )
259            throw DataException("Error - MeshAdapter::dump: appending Elements_Tag to netCDF file failed: " + *newFileName);
260         int_ptr = &mesh->Elements->Tag[0];
261         if (! (ids->put(int_ptr, num_Elements)) )
262            throw DataException("Error - MeshAdapter::dump: copy Elements_Tag to netCDF buffer failed: " + *newFileName);
263    
264         // Elements_Owner
265         if (! ( ids = dataFile.add_var("Elements_Owner", ncInt, ncdims[3])) )
266            throw DataException("Error - MeshAdapter::dump: appending Elements_Owner to netCDF file failed: " + *newFileName);
267         int_ptr = &mesh->Elements->Owner[0];
268         if (! (ids->put(int_ptr, num_Elements)) )
269            throw DataException("Error - MeshAdapter::dump: copy Elements_Owner to netCDF buffer failed: " + *newFileName);
270    
271         // Elements_Color
272         if (! ( ids = dataFile.add_var("Elements_Color", ncInt, ncdims[3])) )
273            throw DataException("Error - MeshAdapter::dump: appending Elements_Color to netCDF file failed: " + *newFileName);
274         int_ptr = &mesh->Elements->Color[0];
275         if (! (ids->put(int_ptr, num_Elements)) )
276            throw DataException("Error - MeshAdapter::dump: copy Elements_Color to netCDF buffer failed: " + *newFileName);
277    
278         // Elements_Nodes
279         for (int i=0; i<num_Elements; i++)
280           for (int j=0; j<num_Elements_numNodes; j++)
281             Elements_Nodes[INDEX2(j,i,num_Elements_numNodes)] = mesh->Nodes->Id[mesh->Elements->Nodes[INDEX2(j,i,num_Elements_numNodes)]];
282         if (! ( ids = dataFile.add_var("Elements_Nodes", ncInt, ncdims[3], ncdims[7]) ) )
283            throw DataException("Error - MeshAdapter::dump: appending Elements_Nodes to netCDF file failed: " + *newFileName);
284         if (! (ids->put(&(Elements_Nodes[0]), num_Elements, num_Elements_numNodes)) )
285            throw DataException("Error - MeshAdapter::dump: copy Elements_Nodes to netCDF buffer failed: " + *newFileName);
286    
287       }
288    
289       // // // // // Face_Elements // // // // //
290    
291       if (num_FaceElements>0) {
292    
293         // Temp storage to gather node IDs
294         int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);
295    
296         // FaceElements ReferenceElement->ElementTypeId
297         if (!dataFile.add_att("FaceElements_TypeId", mesh->FaceElements->ReferenceElement->Type->TypeId) )
298            throw DataException("Error - MeshAdapter::dump: appending FaceElements_TypeId to NetCDF file failed: " + *newFileName);
299    
300         // FaceElements_Id
301         if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )
302            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Id to netCDF file failed: " + *newFileName);
303         int_ptr = &mesh->FaceElements->Id[0];
304         if (! (ids->put(int_ptr, num_FaceElements)) )
305            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Id to netCDF buffer failed: " + *newFileName);
306    
307         // FaceElements_Tag
308         if (! ( ids = dataFile.add_var("FaceElements_Tag", ncInt, ncdims[4])) )
309            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Tag to netCDF file failed: " + *newFileName);
310         int_ptr = &mesh->FaceElements->Tag[0];
311         if (! (ids->put(int_ptr, num_FaceElements)) )
312            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Tag to netCDF buffer failed: " + *newFileName);
313    
314         // FaceElements_Owner
315         if (! ( ids = dataFile.add_var("FaceElements_Owner", ncInt, ncdims[4])) )
316            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Owner to netCDF file failed: " + *newFileName);
317         int_ptr = &mesh->FaceElements->Owner[0];
318         if (! (ids->put(int_ptr, num_FaceElements)) )
319            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Owner to netCDF buffer failed: " + *newFileName);
320    
321         // FaceElements_Color
322         if (! ( ids = dataFile.add_var("FaceElements_Color", ncInt, ncdims[4])) )
323            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Color to netCDF file failed: " + *newFileName);
324         int_ptr = &mesh->FaceElements->Color[0];
325         if (! (ids->put(int_ptr, num_FaceElements)) )
326            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Color to netCDF buffer failed: " + *newFileName);
327    
328         // FaceElements_Nodes
329         for (int i=0; i<num_FaceElements; i++)
330           for (int j=0; j<num_FaceElements_numNodes; j++)
331             FaceElements_Nodes[INDEX2(j,i,num_FaceElements_numNodes)] = mesh->Nodes->Id[mesh->FaceElements->Nodes[INDEX2(j,i,num_FaceElements_numNodes)]];
332         if (! ( ids = dataFile.add_var("FaceElements_Nodes", ncInt, ncdims[4], ncdims[8]) ) )
333            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Nodes to netCDF file failed: " + *newFileName);
334         if (! (ids->put(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )
335            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Nodes to netCDF buffer failed: " + *newFileName);
336    
337       }
338    
339       // // // // // Contact_Elements // // // // //
340    
341       if (num_ContactElements>0) {
342    
343         // Temp storage to gather node IDs
344         int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);
345    
346         // ContactElements ReferenceElement->ElementTypeId
347         if (!dataFile.add_att("ContactElements_TypeId", mesh->ContactElements->ReferenceElement->Type->TypeId) )
348            throw DataException("Error - MeshAdapter::dump: appending ContactElements_TypeId to NetCDF file failed: " + *newFileName);
349    
350         // ContactElements_Id
351         if (! ( ids = dataFile.add_var("ContactElements_Id", ncInt, ncdims[5])) )
352            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Id to netCDF file failed: " + *newFileName);
353         int_ptr = &mesh->ContactElements->Id[0];
354         if (! (ids->put(int_ptr, num_ContactElements)) )
355            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Id to netCDF buffer failed: " + *newFileName);
356    
357         // ContactElements_Tag
358         if (! ( ids = dataFile.add_var("ContactElements_Tag", ncInt, ncdims[5])) )
359            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Tag to netCDF file failed: " + *newFileName);
360         int_ptr = &mesh->ContactElements->Tag[0];
361         if (! (ids->put(int_ptr, num_ContactElements)) )
362            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Tag to netCDF buffer failed: " + *newFileName);
363    
364         // ContactElements_Owner
365         if (! ( ids = dataFile.add_var("ContactElements_Owner", ncInt, ncdims[5])) )
366            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Owner to netCDF file failed: " + *newFileName);
367         int_ptr = &mesh->ContactElements->Owner[0];
368         if (! (ids->put(int_ptr, num_ContactElements)) )
369            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Owner to netCDF buffer failed: " + *newFileName);
370    
371         // ContactElements_Color
372         if (! ( ids = dataFile.add_var("ContactElements_Color", ncInt, ncdims[5])) )
373            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Color to netCDF file failed: " + *newFileName);
374         int_ptr = &mesh->ContactElements->Color[0];
375         if (! (ids->put(int_ptr, num_ContactElements)) )
376            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Color to netCDF buffer failed: " + *newFileName);
377    
378         // ContactElements_Nodes
379         for (int i=0; i<num_ContactElements; i++)
380           for (int j=0; j<num_ContactElements_numNodes; j++)
381             ContactElements_Nodes[INDEX2(j,i,num_ContactElements_numNodes)] = mesh->Nodes->Id[mesh->ContactElements->Nodes[INDEX2(j,i,num_ContactElements_numNodes)]];
382         if (! ( ids = dataFile.add_var("ContactElements_Nodes", ncInt, ncdims[5], ncdims[9]) ) )
383            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Nodes to netCDF file failed: " + *newFileName);
384         if (! (ids->put(&(ContactElements_Nodes[0]), num_ContactElements, num_ContactElements_numNodes)) )
385            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Nodes to netCDF buffer failed: " + *newFileName);
386    
387       }
388    
389       // // // // // Points // // // // //
390    
391       if (num_Points>0) {
392    
393         fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump has not been tested with Point elements\n\n\n");
394    
395         // Temp storage to gather node IDs
396         int *Points_Nodes = TMPMEMALLOC(num_Points,int);
397    
398         // Points ReferenceElement->ElementTypeId
399         if (!dataFile.add_att("Points_TypeId", mesh->Points->ReferenceElement->Type->TypeId) )
400            throw DataException("Error - MeshAdapter::dump: appending Points_TypeId to NetCDF file failed: " + *newFileName);
401    
402         // Points_Id
403         if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )
404            throw DataException("Error - MeshAdapter::dump: appending Points_Id to netCDF file failed: " + *newFileName);
405         int_ptr = &mesh->Points->Id[0];
406         if (! (ids->put(int_ptr, num_Points)) )
407            throw DataException("Error - MeshAdapter::dump: copy Points_Id to netCDF buffer failed: " + *newFileName);
408    
409         // Points_Tag
410         if (! ( ids = dataFile.add_var("Points_Tag", ncInt, ncdims[6])) )
411            throw DataException("Error - MeshAdapter::dump: appending Points_Tag to netCDF file failed: " + *newFileName);
412         int_ptr = &mesh->Points->Tag[0];
413         if (! (ids->put(int_ptr, num_Points)) )
414            throw DataException("Error - MeshAdapter::dump: copy Points_Tag to netCDF buffer failed: " + *newFileName);
415    
416         // Points_Owner
417         if (! ( ids = dataFile.add_var("Points_Owner", ncInt, ncdims[6])) )
418            throw DataException("Error - MeshAdapter::dump: appending Points_Owner to netCDF file failed: " + *newFileName);
419         int_ptr = &mesh->Points->Owner[0];
420         if (! (ids->put(int_ptr, num_Points)) )
421            throw DataException("Error - MeshAdapter::dump: copy Points_Owner to netCDF buffer failed: " + *newFileName);
422    
423         // Points_Color
424         if (! ( ids = dataFile.add_var("Points_Color", ncInt, ncdims[6])) )
425            throw DataException("Error - MeshAdapter::dump: appending Points_Color to netCDF file failed: " + *newFileName);
426         int_ptr = &mesh->Points->Color[0];
427         if (! (ids->put(int_ptr, num_Points)) )
428            throw DataException("Error - MeshAdapter::dump: copy Points_Color to netCDF buffer failed: " + *newFileName);
429    
430         // Points_Nodes
431         // mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]]
432         for (int i=0; i<num_Points; i++)
433           Points_Nodes[i] = mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]];
434         if (! ( ids = dataFile.add_var("Points_Nodes", ncInt, ncdims[6]) ) )
435            throw DataException("Error - MeshAdapter::dump: appending Points_Nodes to netCDF file failed: " + *newFileName);
436         if (! (ids->put(&(Points_Nodes[0]), num_Points)) )
437            throw DataException("Error - MeshAdapter::dump: copy Points_Nodes to netCDF buffer failed: " + *newFileName);
438    
439       }
440    
441       // // // // // TagMap // // // // //
442    
443         fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump does not save the TagMap yet\n\n\n");
444    
445       // NetCDF file is closed by destructor of NcFile object
446    #else
447       Finley_setError(IO_ERROR, "MeshAdapter::dump: not configured with NetCDF. Please contact your installation manager.");
448    #endif  /* USE_NETCDF */
449       checkFinleyError();
450    }
451    
452  string MeshAdapter::getDescription() const  string MeshAdapter::getDescription() const
453  {  {
454    return string("FinleyMesh");    return "FinleyMesh";
455  }  }
456    
457  string MeshAdapter::functionSpaceTypeAsString(int functionSpaceType) const  string MeshAdapter::functionSpaceTypeAsString(int functionSpaceType) const
# Line 97  string MeshAdapter::functionSpaceTypeAsS Line 461  string MeshAdapter::functionSpaceTypeAsS
461    if (loc==m_functionSpaceTypeNames.end()) {    if (loc==m_functionSpaceTypeNames.end()) {
462      return "Invalid function space type code.";      return "Invalid function space type code.";
463    } else {    } else {
464      return string(loc->second);      return loc->second;
465    }    }
466  }  }
467    
# Line 220  pair<int,int> MeshAdapter::getDataShape( Line 584  pair<int,int> MeshAdapter::getDataShape(
584     switch (functionSpaceCode) {     switch (functionSpaceCode) {
585        case(Nodes):        case(Nodes):
586             numDataPointsPerSample=1;             numDataPointsPerSample=1;
587             if (mesh->Nodes!=NULL) numSamples=mesh->Nodes->numNodes;             numSamples=Finley_NodeFile_getNumNodes(mesh->Nodes);
588             break;             break;
589        case(ReducedNodes):        case(ReducedNodes):
            /* TODO: add ReducedNodes */  
590             numDataPointsPerSample=1;             numDataPointsPerSample=1;
591             if (mesh->Nodes!=NULL) numSamples=mesh->Nodes->numNodes;             numSamples=Finley_NodeFile_getNumReducedNodes(mesh->Nodes);
            throw FinleyAdapterException("Error - ReducedNodes is not supported yet.");  
592             break;             break;
593        case(Elements):        case(Elements):
594             if (mesh->Elements!=NULL) {             if (mesh->Elements!=NULL) {
# Line 285  pair<int,int> MeshAdapter::getDataShape( Line 647  pair<int,int> MeshAdapter::getDataShape(
647        case(DegreesOfFreedom):        case(DegreesOfFreedom):
648             if (mesh->Nodes!=NULL) {             if (mesh->Nodes!=NULL) {
649               numDataPointsPerSample=1;               numDataPointsPerSample=1;
650  #ifndef PASO_MPI               numSamples=Finley_NodeFile_getNumDegreesOfFreedom(mesh->Nodes);
              numSamples=mesh->Nodes->numDegreesOfFreedom;  
 #else  
              numSamples=mesh->Nodes->degreeOfFreedomDistribution->numLocal;  
 #endif  
651             }             }
652             break;             break;
653        case(ReducedDegreesOfFreedom):        case(ReducedDegreesOfFreedom):
654             if (mesh->Nodes!=NULL) {             if (mesh->Nodes!=NULL) {
655               numDataPointsPerSample=1;               numDataPointsPerSample=1;
656  #ifndef PASO_MPI               numSamples=Finley_NodeFile_getNumReducedDegreesOfFreedom(mesh->Nodes);
              numSamples=mesh->Nodes->reducedNumDegreesOfFreedom;  
 #else  
              numSamples=mesh->Nodes->reducedDegreeOfFreedomDistribution->numLocal;  
 #endif  
657             }             }
658             break;             break;
659        default:        default:
# Line 344  void MeshAdapter::addPDEToSystem( Line 698  void MeshAdapter::addPDEToSystem(
698     checkFinleyError();     checkFinleyError();
699  }  }
700    
701    void  MeshAdapter::addPDEToLumpedSystem(
702                         escript::Data& mat,
703                         const escript::Data& D,
704                         const escript::Data& d) const
705    {
706       escriptDataC _mat=mat.getDataC();
707       escriptDataC _D=D.getDataC();
708       escriptDataC _d=d.getDataC();
709    
710       Finley_Mesh* mesh=m_finleyMesh.get();
711    
712       Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->Elements,&_mat, &_D);
713       Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->FaceElements,&_mat, &_d);
714    
715       checkFinleyError();
716    }
717    
718    
719  //  //
720  // adds linear PDE of second order into the right hand side only  // adds linear PDE of second order into the right hand side only
721  //  //
# Line 514  void MeshAdapter::interpolateOnDomain(es Line 886  void MeshAdapter::interpolateOnDomain(es
886          switch(target.getFunctionSpace().getTypeCode()) {          switch(target.getFunctionSpace().getTypeCode()) {
887             case(ReducedDegreesOfFreedom):             case(ReducedDegreesOfFreedom):
888             case(DegreesOfFreedom):             case(DegreesOfFreedom):
            case(Nodes):  
            case(ReducedNodes):  
889                Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);                Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
890                break;                break;
891  #ifndef PASO_MPI  
892             case(Elements):             case(Nodes):
893             case(ReducedElements):             case(ReducedNodes):
894                Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);                if (getMPISize()>1) {
895                break;                    escript::Data temp=escript::Data(in);
896             case(FaceElements):                    temp.expand();
897             case(ReducedFaceElements):                    escriptDataC _in2 = temp.getDataC();
898                Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);                    Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
899                break;                } else {
900             case(Points):                    Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
901                Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);                }
902                break;                break;
            case(ContactElementsZero):  
            case(ContactElementsOne):  
            case(ReducedContactElementsZero):  
            case(ReducedContactElementsOne):  
               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);  
              break;  
 #else  
            /* need to copy Degrees of freedom data to nodal data so that the external values are available */  
903             case(Elements):             case(Elements):
904             case(ReducedElements):             case(ReducedElements):
905                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
906                Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
907                     escriptDataC _in2 = temp.getDataC();
908                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
909                  } else {
910                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
911                  }
912                break;                break;
913             case(FaceElements):             case(FaceElements):
914             case(ReducedFaceElements):             case(ReducedFaceElements):
915                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
916                Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
917                     escriptDataC _in2 = temp.getDataC();
918                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
919    
920                  } else {
921                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
922                  }
923                break;                break;
924             case(Points):             case(Points):
925                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
926                Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
927                     escriptDataC _in2 = temp.getDataC();
928                  } else {
929                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
930                  }
931                break;                break;
932             case(ContactElementsZero):             case(ContactElementsZero):
933             case(ContactElementsOne):             case(ContactElementsOne):
934             case(ReducedContactElementsZero):             case(ReducedContactElementsZero):
935             case(ReducedContactElementsOne):             case(ReducedContactElementsOne):
936                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
937                Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
938                     escriptDataC _in2 = temp.getDataC();
939                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
940                  } else {
941                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
942                  }
943               break;               break;
 #endif  
944             default:             default:
945               stringstream temp;               stringstream temp;
946               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
# Line 573  void MeshAdapter::interpolateOnDomain(es Line 954  void MeshAdapter::interpolateOnDomain(es
954               throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");               throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");
955               break;               break;
956            case(ReducedNodes):            case(ReducedNodes):
957               Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);                if (getMPISize()>1) {
958               break;                    escript::Data temp=escript::Data(in);
959                      temp.expand();
960                      escriptDataC _in2 = temp.getDataC();
961                      Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
962                  } else {
963                      Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
964                  }
965                  break;
966            case(DegreesOfFreedom):            case(DegreesOfFreedom):
967               throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");               throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");
968               break;               break;
# Line 583  void MeshAdapter::interpolateOnDomain(es Line 971  void MeshAdapter::interpolateOnDomain(es
971               break;               break;
972            case(Elements):            case(Elements):
973            case(ReducedElements):            case(ReducedElements):
974               Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);                if (getMPISize()>1) {
975                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
976                     escriptDataC _in2 = temp.getDataC();
977                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
978                  } else {
979                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
980                 }
981               break;               break;
982            case(FaceElements):            case(FaceElements):
983            case(ReducedFaceElements):            case(ReducedFaceElements):
984               Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);                if (getMPISize()>1) {
985                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
986                     escriptDataC _in2 = temp.getDataC();
987                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
988                  } else {
989                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
990                  }
991               break;               break;
992            case(Points):            case(Points):
993               Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);                if (getMPISize()>1) {
994                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
995                     escriptDataC _in2 = temp.getDataC();
996                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);
997                  } else {
998                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
999                 }
1000               break;               break;
1001            case(ContactElementsZero):            case(ContactElementsZero):
1002            case(ContactElementsOne):            case(ContactElementsOne):
1003            case(ReducedContactElementsZero):            case(ReducedContactElementsZero):
1004            case(ReducedContactElementsOne):            case(ReducedContactElementsOne):
1005               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);                if (getMPISize()>1) {
1006                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1007                     escriptDataC _in2 = temp.getDataC();
1008                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
1009                  } else {
1010                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
1011                 }
1012               break;               break;
1013            default:            default:
1014               stringstream temp;               stringstream temp;
# Line 713  void MeshAdapter::setToIntegrals(std::ve Line 1125  void MeshAdapter::setToIntegrals(std::ve
1125    if (argDomain!=*this)    if (argDomain!=*this)
1126       throw FinleyAdapterException("Error - Illegal domain of integration kernel");       throw FinleyAdapterException("Error - Illegal domain of integration kernel");
1127    
1128      double blocktimer_start = blocktimer_time();
1129    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1130      escriptDataC _temp;
1131      escript::Data temp;
1132    escriptDataC _arg=arg.getDataC();    escriptDataC _arg=arg.getDataC();
1133    switch(arg.getFunctionSpace().getTypeCode()) {    switch(arg.getFunctionSpace().getTypeCode()) {
1134       case(Nodes):       case(Nodes):
1135          /* TODO */          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1136          throw FinleyAdapterException("Error - Integral of data on nodes is not supported.");          _temp=temp.getDataC();
1137            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1138          break;          break;
1139       case(ReducedNodes):       case(ReducedNodes):
1140          /* TODO */          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1141          throw FinleyAdapterException("Error - Integral of data on reduced nodes is not supported.");          _temp=temp.getDataC();
1142            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1143          break;          break;
1144       case(Elements):       case(Elements):
1145          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);
# Line 752  void MeshAdapter::setToIntegrals(std::ve Line 1169  void MeshAdapter::setToIntegrals(std::ve
1169          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1170          break;          break;
1171       case(DegreesOfFreedom):       case(DegreesOfFreedom):
1172          throw FinleyAdapterException("Error - Integral of data on degrees of freedom is not supported.");          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1173            _temp=temp.getDataC();
1174            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1175          break;          break;
1176       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
1177          throw FinleyAdapterException("Error - Integral of data on reduced degrees of freedom is not supported.");          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1178            _temp=temp.getDataC();
1179            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1180          break;          break;
1181       default:       default:
1182          stringstream temp;          stringstream temp;
# Line 764  void MeshAdapter::setToIntegrals(std::ve Line 1185  void MeshAdapter::setToIntegrals(std::ve
1185          break;          break;
1186    }    }
1187    checkFinleyError();    checkFinleyError();
1188      blocktimer_increment("integrate()", blocktimer_start);
1189  }  }
1190    
1191  //  //
# Line 781  void MeshAdapter::setToGradient(escript: Line 1203  void MeshAdapter::setToGradient(escript:
1203    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1204    escriptDataC _grad=grad.getDataC();    escriptDataC _grad=grad.getDataC();
1205    escriptDataC nodeDataC;    escriptDataC nodeDataC;
1206  #ifdef PASO_MPI    escript::Data temp;
1207    escript::Data nodeTemp( arg, continuousFunction(asAbstractContinuousDomain()) );    if (getMPISize()>1) {
1208    if( arg.getFunctionSpace().getTypeCode() != Nodes )        if( arg.getFunctionSpace().getTypeCode() == DegreesOfFreedom ) {
1209    {          temp=escript::Data( arg,  continuousFunction(asAbstractContinuousDomain()) );
1210      Finley_Assemble_CopyNodalData(mesh->Nodes,&(nodeTemp.getDataC()),&(arg.getDataC()));          nodeDataC = temp.getDataC();
1211      nodeDataC = nodeTemp.getDataC();        } else if( arg.getFunctionSpace().getTypeCode() == ReducedDegreesOfFreedom ) {
1212            temp=escript::Data( arg,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1213            nodeDataC = temp.getDataC();
1214          } else {
1215            nodeDataC = arg.getDataC();
1216          }
1217      } else {
1218         nodeDataC = arg.getDataC();
1219    }    }
   else  
     nodeDataC = arg.getDataC();  
 #else  
   nodeDataC = arg.getDataC();  
 #endif  
1220    switch(grad.getFunctionSpace().getTypeCode()) {    switch(grad.getFunctionSpace().getTypeCode()) {
1221         case(Nodes):         case(Nodes):
1222            throw FinleyAdapterException("Error - Gradient at nodes is not supported.");            throw FinleyAdapterException("Error - Gradient at nodes is not supported.");
# Line 923  void MeshAdapter::saveDX(const std::stri Line 1347  void MeshAdapter::saveDX(const std::stri
1347    escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;    escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;
1348    escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;    escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;
1349    
1350      boost::python::list keys=arg.keys();    boost::python::list keys=arg.keys();
1351      for (int i=0;i<num_data;++i) {    for (int i=0;i<num_data;++i) {
1352             std::string n=boost::python::extract<std::string>(keys[i]);
1353           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1354           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1355               throw FinleyAdapterException("Error  in saveDX: Data must be defined on same Domain");               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1356           data[i]=d.getDataC();           data[i]=d.getDataC();
1357           ptr_data[i]=&(data[i]);           ptr_data[i]=&(data[i]);
          std::string n=boost::python::extract<std::string>(keys[i]);  
1358           c_names[i]=&(names[i][0]);           c_names[i]=&(names[i][0]);
1359           if (n.length()>MAX_namelength-1) {           if (n.length()>MAX_namelength-1) {
1360              strncpy(c_names[i],n.c_str(),MAX_namelength-1);              strncpy(c_names[i],n.c_str(),MAX_namelength-1);
# Line 973  void MeshAdapter::saveVTK(const std::str Line 1397  void MeshAdapter::saveVTK(const std::str
1397    
1398      boost::python::list keys=arg.keys();      boost::python::list keys=arg.keys();
1399      for (int i=0;i<num_data;++i) {      for (int i=0;i<num_data;++i) {
1400             std::string n=boost::python::extract<std::string>(keys[i]);
1401           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1402           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1403               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1404           data[i]=d.getDataC();           data[i]=d.getDataC();
1405           ptr_data[i]=&(data[i]);           ptr_data[i]=&(data[i]);
          std::string n=boost::python::extract<std::string>(keys[i]);  
1406           c_names[i]=&(names[i][0]);           c_names[i]=&(names[i][0]);
1407           if (n.length()>MAX_namelength-1) {           if (n.length()>MAX_namelength-1) {
1408              strncpy(c_names[i],n.c_str(),MAX_namelength-1);              strncpy(c_names[i],n.c_str(),MAX_namelength-1);
# Line 987  void MeshAdapter::saveVTK(const std::str Line 1411  void MeshAdapter::saveVTK(const std::str
1411              strcpy(c_names[i],n.c_str());              strcpy(c_names[i],n.c_str());
1412           }           }
1413      }      }
 #ifndef PASO_MPI      
1414      Finley_Mesh_saveVTK(filename.c_str(),m_finleyMesh.get(),num_data,c_names,ptr_data);      Finley_Mesh_saveVTK(filename.c_str(),m_finleyMesh.get(),num_data,c_names,ptr_data);
 #else  
     Finley_Mesh_saveVTK_MPIO(filename.c_str(),m_finleyMesh.get(),num_data,c_names,ptr_data);  
 #endif  
1415    
1416  checkFinleyError();    checkFinleyError();
1417    /* win32 refactor */    /* win32 refactor */
1418    TMPMEMFREE(c_names);    TMPMEMFREE(c_names);
1419    TMPMEMFREE(data);    TMPMEMFREE(data);
# Line 1044  SystemMatrixAdapter MeshAdapter::newSyst Line 1464  SystemMatrixAdapter MeshAdapter::newSyst
1464            
1465      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);
1466      checkFinleyError();      checkFinleyError();
1467      Paso_SystemMatrix* fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);      Paso_SystemMatrix* fsystemMatrix;
1468        int trilinos = 0;
1469        if (trilinos) {
1470    #ifdef TRILINOS
1471          /* Allocation Epetra_VrbMatrix here */
1472    #endif
1473        }
1474        else {
1475          fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);
1476        }
1477      checkPasoError();      checkPasoError();
1478      Paso_SystemMatrixPattern_dealloc(fsystemMatrixPattern);      Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
1479      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);
1480  }  }
1481    
# Line 1287  int* MeshAdapter::borrowSampleReferenceI Line 1716  int* MeshAdapter::borrowSampleReferenceI
1716    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1717    switch (functionSpaceType) {    switch (functionSpaceType) {
1718      case(Nodes):      case(Nodes):
1719        if (mesh->Nodes!=NULL) {        out=mesh->Nodes->Id;
1720          out=mesh->Nodes->Id;        break;
         break;  
       }  
1721      case(ReducedNodes):      case(ReducedNodes):
1722        throw FinleyAdapterException("Error -  ReducedNodes not supported yet.");        out=mesh->Nodes->reducedNodesId;
1723        break;        break;
1724      case(Elements):      case(Elements):
1725        out=mesh->Elements->Id;        out=mesh->Elements->Id;
# Line 1322  int* MeshAdapter::borrowSampleReferenceI Line 1749  int* MeshAdapter::borrowSampleReferenceI
1749        out=mesh->ContactElements->Id;        out=mesh->ContactElements->Id;
1750        break;        break;
1751      case(DegreesOfFreedom):      case(DegreesOfFreedom):
1752        out=mesh->Nodes->degreeOfFreedomId;        out=mesh->Nodes->degreesOfFreedomId;
1753        break;        break;
1754      case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1755        out=mesh->Nodes->reducedDegreeOfFreedomId;        out=mesh->Nodes->reducedDegreesOfFreedomId;
1756        break;        break;
1757      default:      default:
1758        stringstream temp;        stringstream temp;
# Line 1476  std::string MeshAdapter::showTagNames() Line 1903  std::string MeshAdapter::showTagNames()
1903       tag_map=tag_map->next;       tag_map=tag_map->next;
1904       if (tag_map) temp << ", ";       if (tag_map) temp << ", ";
1905    }    }
1906    return string(temp.str());    return temp.str();
1907  }  }
1908    
1909  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.1137  
changed lines
  Added in v.1343

  ViewVC Help
Powered by ViewVC 1.1.26