/[escript]/branches/diaplayground/finley/src/CPPAdapter/MeshAdapter.cpp
ViewVC logotype

Diff of /branches/diaplayground/finley/src/CPPAdapter/MeshAdapter.cpp

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

revision 1080 by gross, Wed Apr 11 06:07:30 2007 UTC revision 1344 by ksteube, Wed Nov 14 04:28:25 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         TMPMEMFREE(Elements_Nodes);
288    
289       }
290    
291       // // // // // Face_Elements // // // // //
292    
293       if (num_FaceElements>0) {
294    
295         // Temp storage to gather node IDs
296         int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);
297    
298         // FaceElements ReferenceElement->ElementTypeId
299         if (!dataFile.add_att("FaceElements_TypeId", mesh->FaceElements->ReferenceElement->Type->TypeId) )
300            throw DataException("Error - MeshAdapter::dump: appending FaceElements_TypeId to NetCDF file failed: " + *newFileName);
301    
302         // FaceElements_Id
303         if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )
304            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Id to netCDF file failed: " + *newFileName);
305         int_ptr = &mesh->FaceElements->Id[0];
306         if (! (ids->put(int_ptr, num_FaceElements)) )
307            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Id to netCDF buffer failed: " + *newFileName);
308    
309         // FaceElements_Tag
310         if (! ( ids = dataFile.add_var("FaceElements_Tag", ncInt, ncdims[4])) )
311            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Tag to netCDF file failed: " + *newFileName);
312         int_ptr = &mesh->FaceElements->Tag[0];
313         if (! (ids->put(int_ptr, num_FaceElements)) )
314            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Tag to netCDF buffer failed: " + *newFileName);
315    
316         // FaceElements_Owner
317         if (! ( ids = dataFile.add_var("FaceElements_Owner", ncInt, ncdims[4])) )
318            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Owner to netCDF file failed: " + *newFileName);
319         int_ptr = &mesh->FaceElements->Owner[0];
320         if (! (ids->put(int_ptr, num_FaceElements)) )
321            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Owner to netCDF buffer failed: " + *newFileName);
322    
323         // FaceElements_Color
324         if (! ( ids = dataFile.add_var("FaceElements_Color", ncInt, ncdims[4])) )
325            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Color to netCDF file failed: " + *newFileName);
326         int_ptr = &mesh->FaceElements->Color[0];
327         if (! (ids->put(int_ptr, num_FaceElements)) )
328            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Color to netCDF buffer failed: " + *newFileName);
329    
330         // FaceElements_Nodes
331         for (int i=0; i<num_FaceElements; i++)
332           for (int j=0; j<num_FaceElements_numNodes; j++)
333             FaceElements_Nodes[INDEX2(j,i,num_FaceElements_numNodes)] = mesh->Nodes->Id[mesh->FaceElements->Nodes[INDEX2(j,i,num_FaceElements_numNodes)]];
334         if (! ( ids = dataFile.add_var("FaceElements_Nodes", ncInt, ncdims[4], ncdims[8]) ) )
335            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Nodes to netCDF file failed: " + *newFileName);
336         if (! (ids->put(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )
337            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Nodes to netCDF buffer failed: " + *newFileName);
338    
339         TMPMEMFREE(FaceElements_Nodes);
340    
341       }
342    
343       // // // // // Contact_Elements // // // // //
344    
345       if (num_ContactElements>0) {
346    
347         // Temp storage to gather node IDs
348         int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);
349    
350         // ContactElements ReferenceElement->ElementTypeId
351         if (!dataFile.add_att("ContactElements_TypeId", mesh->ContactElements->ReferenceElement->Type->TypeId) )
352            throw DataException("Error - MeshAdapter::dump: appending ContactElements_TypeId to NetCDF file failed: " + *newFileName);
353    
354         // ContactElements_Id
355         if (! ( ids = dataFile.add_var("ContactElements_Id", ncInt, ncdims[5])) )
356            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Id to netCDF file failed: " + *newFileName);
357         int_ptr = &mesh->ContactElements->Id[0];
358         if (! (ids->put(int_ptr, num_ContactElements)) )
359            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Id to netCDF buffer failed: " + *newFileName);
360    
361         // ContactElements_Tag
362         if (! ( ids = dataFile.add_var("ContactElements_Tag", ncInt, ncdims[5])) )
363            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Tag to netCDF file failed: " + *newFileName);
364         int_ptr = &mesh->ContactElements->Tag[0];
365         if (! (ids->put(int_ptr, num_ContactElements)) )
366            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Tag to netCDF buffer failed: " + *newFileName);
367    
368         // ContactElements_Owner
369         if (! ( ids = dataFile.add_var("ContactElements_Owner", ncInt, ncdims[5])) )
370            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Owner to netCDF file failed: " + *newFileName);
371         int_ptr = &mesh->ContactElements->Owner[0];
372         if (! (ids->put(int_ptr, num_ContactElements)) )
373            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Owner to netCDF buffer failed: " + *newFileName);
374    
375         // ContactElements_Color
376         if (! ( ids = dataFile.add_var("ContactElements_Color", ncInt, ncdims[5])) )
377            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Color to netCDF file failed: " + *newFileName);
378         int_ptr = &mesh->ContactElements->Color[0];
379         if (! (ids->put(int_ptr, num_ContactElements)) )
380            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Color to netCDF buffer failed: " + *newFileName);
381    
382         // ContactElements_Nodes
383         for (int i=0; i<num_ContactElements; i++)
384           for (int j=0; j<num_ContactElements_numNodes; j++)
385             ContactElements_Nodes[INDEX2(j,i,num_ContactElements_numNodes)] = mesh->Nodes->Id[mesh->ContactElements->Nodes[INDEX2(j,i,num_ContactElements_numNodes)]];
386         if (! ( ids = dataFile.add_var("ContactElements_Nodes", ncInt, ncdims[5], ncdims[9]) ) )
387            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Nodes to netCDF file failed: " + *newFileName);
388         if (! (ids->put(&(ContactElements_Nodes[0]), num_ContactElements, num_ContactElements_numNodes)) )
389            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Nodes to netCDF buffer failed: " + *newFileName);
390    
391         TMPMEMFREE(ContactElements_Nodes);
392    
393       }
394    
395       // // // // // Points // // // // //
396    
397       if (num_Points>0) {
398    
399         fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump has not been tested with Point elements\n\n\n");
400    
401         // Temp storage to gather node IDs
402         int *Points_Nodes = TMPMEMALLOC(num_Points,int);
403    
404         // Points ReferenceElement->ElementTypeId
405         if (!dataFile.add_att("Points_TypeId", mesh->Points->ReferenceElement->Type->TypeId) )
406            throw DataException("Error - MeshAdapter::dump: appending Points_TypeId to NetCDF file failed: " + *newFileName);
407    
408         // Points_Id
409         if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )
410            throw DataException("Error - MeshAdapter::dump: appending Points_Id to netCDF file failed: " + *newFileName);
411         int_ptr = &mesh->Points->Id[0];
412         if (! (ids->put(int_ptr, num_Points)) )
413            throw DataException("Error - MeshAdapter::dump: copy Points_Id to netCDF buffer failed: " + *newFileName);
414    
415         // Points_Tag
416         if (! ( ids = dataFile.add_var("Points_Tag", ncInt, ncdims[6])) )
417            throw DataException("Error - MeshAdapter::dump: appending Points_Tag to netCDF file failed: " + *newFileName);
418         int_ptr = &mesh->Points->Tag[0];
419         if (! (ids->put(int_ptr, num_Points)) )
420            throw DataException("Error - MeshAdapter::dump: copy Points_Tag to netCDF buffer failed: " + *newFileName);
421    
422         // Points_Owner
423         if (! ( ids = dataFile.add_var("Points_Owner", ncInt, ncdims[6])) )
424            throw DataException("Error - MeshAdapter::dump: appending Points_Owner to netCDF file failed: " + *newFileName);
425         int_ptr = &mesh->Points->Owner[0];
426         if (! (ids->put(int_ptr, num_Points)) )
427            throw DataException("Error - MeshAdapter::dump: copy Points_Owner to netCDF buffer failed: " + *newFileName);
428    
429         // Points_Color
430         if (! ( ids = dataFile.add_var("Points_Color", ncInt, ncdims[6])) )
431            throw DataException("Error - MeshAdapter::dump: appending Points_Color to netCDF file failed: " + *newFileName);
432         int_ptr = &mesh->Points->Color[0];
433         if (! (ids->put(int_ptr, num_Points)) )
434            throw DataException("Error - MeshAdapter::dump: copy Points_Color to netCDF buffer failed: " + *newFileName);
435    
436         // Points_Nodes
437         // mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]]
438         for (int i=0; i<num_Points; i++)
439           Points_Nodes[i] = mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]];
440         if (! ( ids = dataFile.add_var("Points_Nodes", ncInt, ncdims[6]) ) )
441            throw DataException("Error - MeshAdapter::dump: appending Points_Nodes to netCDF file failed: " + *newFileName);
442         if (! (ids->put(&(Points_Nodes[0]), num_Points)) )
443            throw DataException("Error - MeshAdapter::dump: copy Points_Nodes to netCDF buffer failed: " + *newFileName);
444    
445         TMPMEMFREE(Points_Nodes);
446    
447       }
448    
449       // // // // // TagMap // // // // //
450    
451         fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump does not save the TagMap yet\n\n\n");
452    
453       // NetCDF file is closed by destructor of NcFile object
454    #else
455       Finley_setError(IO_ERROR, "MeshAdapter::dump: not configured with NetCDF. Please contact your installation manager.");
456    #endif  /* USE_NETCDF */
457       checkFinleyError();
458    }
459    
460  string MeshAdapter::getDescription() const  string MeshAdapter::getDescription() const
461  {  {
462    return "FinleyMesh";    return "FinleyMesh";
# Line 220  pair<int,int> MeshAdapter::getDataShape( Line 592  pair<int,int> MeshAdapter::getDataShape(
592     switch (functionSpaceCode) {     switch (functionSpaceCode) {
593        case(Nodes):        case(Nodes):
594             numDataPointsPerSample=1;             numDataPointsPerSample=1;
595             if (mesh->Nodes!=NULL) numSamples=mesh->Nodes->numNodes;             numSamples=Finley_NodeFile_getNumNodes(mesh->Nodes);
596             break;             break;
597        case(ReducedNodes):        case(ReducedNodes):
            /* TODO: add ReducedNodes */  
598             numDataPointsPerSample=1;             numDataPointsPerSample=1;
599             if (mesh->Nodes!=NULL) numSamples=mesh->Nodes->numNodes;             numSamples=Finley_NodeFile_getNumReducedNodes(mesh->Nodes);
            throw FinleyAdapterException("Error - ReducedNodes is not supported yet.");  
600             break;             break;
601        case(Elements):        case(Elements):
602             if (mesh->Elements!=NULL) {             if (mesh->Elements!=NULL) {
# Line 285  pair<int,int> MeshAdapter::getDataShape( Line 655  pair<int,int> MeshAdapter::getDataShape(
655        case(DegreesOfFreedom):        case(DegreesOfFreedom):
656             if (mesh->Nodes!=NULL) {             if (mesh->Nodes!=NULL) {
657               numDataPointsPerSample=1;               numDataPointsPerSample=1;
658  #ifndef PASO_MPI               numSamples=Finley_NodeFile_getNumDegreesOfFreedom(mesh->Nodes);
              numSamples=mesh->Nodes->numDegreesOfFreedom;  
 #else  
              numSamples=mesh->Nodes->degreeOfFreedomDistribution->numLocal;  
 #endif  
659             }             }
660             break;             break;
661        case(ReducedDegreesOfFreedom):        case(ReducedDegreesOfFreedom):
662             if (mesh->Nodes!=NULL) {             if (mesh->Nodes!=NULL) {
663               numDataPointsPerSample=1;               numDataPointsPerSample=1;
664  #ifndef PASO_MPI               numSamples=Finley_NodeFile_getNumReducedDegreesOfFreedom(mesh->Nodes);
              numSamples=mesh->Nodes->reducedNumDegreesOfFreedom;  
 #else  
              numSamples=mesh->Nodes->reducedDegreeOfFreedomDistribution->numLocal;  
 #endif  
665             }             }
666             break;             break;
667        default:        default:
# Line 344  void MeshAdapter::addPDEToSystem( Line 706  void MeshAdapter::addPDEToSystem(
706     checkFinleyError();     checkFinleyError();
707  }  }
708    
709    void  MeshAdapter::addPDEToLumpedSystem(
710                         escript::Data& mat,
711                         const escript::Data& D,
712                         const escript::Data& d) const
713    {
714       escriptDataC _mat=mat.getDataC();
715       escriptDataC _D=D.getDataC();
716       escriptDataC _d=d.getDataC();
717    
718       Finley_Mesh* mesh=m_finleyMesh.get();
719    
720       Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->Elements,&_mat, &_D);
721       Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->FaceElements,&_mat, &_d);
722    
723       checkFinleyError();
724    }
725    
726    
727  //  //
728  // adds linear PDE of second order into the right hand side only  // adds linear PDE of second order into the right hand side only
729  //  //
# Line 454  void MeshAdapter::interpolateOnDomain(es Line 834  void MeshAdapter::interpolateOnDomain(es
834       case(Elements):       case(Elements):
835          if (target.getFunctionSpace().getTypeCode()==Elements) {          if (target.getFunctionSpace().getTypeCode()==Elements) {
836             Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);             Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
837            } else if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
838               Finley_Assemble_AverageElementData(mesh->Elements,&_target,&_in);
839          } else {          } else {
840             throw FinleyAdapterException("Error - No interpolation with data on elements possible.");             throw FinleyAdapterException("Error - No interpolation with data on elements possible.");
841          }          }
# Line 468  void MeshAdapter::interpolateOnDomain(es Line 850  void MeshAdapter::interpolateOnDomain(es
850       case(FaceElements):       case(FaceElements):
851          if (target.getFunctionSpace().getTypeCode()==FaceElements) {          if (target.getFunctionSpace().getTypeCode()==FaceElements) {
852             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
853            } else if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
854               Finley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);
855          } else {          } else {
856             throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");             throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");
857         }         }
# Line 490  void MeshAdapter::interpolateOnDomain(es Line 874  void MeshAdapter::interpolateOnDomain(es
874       case(ContactElementsOne):       case(ContactElementsOne):
875          if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {          if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {
876             Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);             Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);
877            } else if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {
878               Finley_Assemble_AverageElementData(mesh->ContactElements,&_target,&_in);
879          } else {          } else {
880             throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");             throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");
881             break;             break;
# Line 508  void MeshAdapter::interpolateOnDomain(es Line 894  void MeshAdapter::interpolateOnDomain(es
894          switch(target.getFunctionSpace().getTypeCode()) {          switch(target.getFunctionSpace().getTypeCode()) {
895             case(ReducedDegreesOfFreedom):             case(ReducedDegreesOfFreedom):
896             case(DegreesOfFreedom):             case(DegreesOfFreedom):
            case(Nodes):  
            case(ReducedNodes):  
897                Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);                Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
898                break;                break;
899  #ifndef PASO_MPI  
900             case(Elements):             case(Nodes):
901             case(ReducedElements):             case(ReducedNodes):
902                Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);                if (getMPISize()>1) {
903                break;                    escript::Data temp=escript::Data(in);
904             case(FaceElements):                    temp.expand();
905             case(ReducedFaceElements):                    escriptDataC _in2 = temp.getDataC();
906                Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);                    Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
907                break;                } else {
908             case(Points):                    Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
909                Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);                }
910                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 */  
911             case(Elements):             case(Elements):
912             case(ReducedElements):             case(ReducedElements):
913                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
914                Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
915                     escriptDataC _in2 = temp.getDataC();
916                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
917                  } else {
918                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
919                  }
920                break;                break;
921             case(FaceElements):             case(FaceElements):
922             case(ReducedFaceElements):             case(ReducedFaceElements):
923                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
924                Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
925                     escriptDataC _in2 = temp.getDataC();
926                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
927    
928                  } else {
929                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
930                  }
931                break;                break;
932             case(Points):             case(Points):
933                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
934                Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
935                     escriptDataC _in2 = temp.getDataC();
936                  } else {
937                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
938                  }
939                break;                break;
940             case(ContactElementsZero):             case(ContactElementsZero):
941             case(ContactElementsOne):             case(ContactElementsOne):
942             case(ReducedContactElementsZero):             case(ReducedContactElementsZero):
943             case(ReducedContactElementsOne):             case(ReducedContactElementsOne):
944                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
945                Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
946                     escriptDataC _in2 = temp.getDataC();
947                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
948                  } else {
949                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
950                  }
951               break;               break;
 #endif  
952             default:             default:
953               stringstream temp;               stringstream temp;
954               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 567  void MeshAdapter::interpolateOnDomain(es Line 962  void MeshAdapter::interpolateOnDomain(es
962               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.");
963               break;               break;
964            case(ReducedNodes):            case(ReducedNodes):
965               Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);                if (getMPISize()>1) {
966               break;                    escript::Data temp=escript::Data(in);
967                      temp.expand();
968                      escriptDataC _in2 = temp.getDataC();
969                      Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
970                  } else {
971                      Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
972                  }
973                  break;
974            case(DegreesOfFreedom):            case(DegreesOfFreedom):
975               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");
976               break;               break;
# Line 577  void MeshAdapter::interpolateOnDomain(es Line 979  void MeshAdapter::interpolateOnDomain(es
979               break;               break;
980            case(Elements):            case(Elements):
981            case(ReducedElements):            case(ReducedElements):
982               Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);                if (getMPISize()>1) {
983                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
984                     escriptDataC _in2 = temp.getDataC();
985                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
986                  } else {
987                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
988                 }
989               break;               break;
990            case(FaceElements):            case(FaceElements):
991            case(ReducedFaceElements):            case(ReducedFaceElements):
992               Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);                if (getMPISize()>1) {
993                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
994                     escriptDataC _in2 = temp.getDataC();
995                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
996                  } else {
997                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
998                  }
999               break;               break;
1000            case(Points):            case(Points):
1001               Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);                if (getMPISize()>1) {
1002                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1003                     escriptDataC _in2 = temp.getDataC();
1004                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);
1005                  } else {
1006                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
1007                 }
1008               break;               break;
1009            case(ContactElementsZero):            case(ContactElementsZero):
1010            case(ContactElementsOne):            case(ContactElementsOne):
1011            case(ReducedContactElementsZero):            case(ReducedContactElementsZero):
1012            case(ReducedContactElementsOne):            case(ReducedContactElementsOne):
1013               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);                if (getMPISize()>1) {
1014                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1015                     escriptDataC _in2 = temp.getDataC();
1016                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
1017                  } else {
1018                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
1019                 }
1020               break;               break;
1021            default:            default:
1022               stringstream temp;               stringstream temp;
# Line 707  void MeshAdapter::setToIntegrals(std::ve Line 1133  void MeshAdapter::setToIntegrals(std::ve
1133    if (argDomain!=*this)    if (argDomain!=*this)
1134       throw FinleyAdapterException("Error - Illegal domain of integration kernel");       throw FinleyAdapterException("Error - Illegal domain of integration kernel");
1135    
1136      double blocktimer_start = blocktimer_time();
1137    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1138      escriptDataC _temp;
1139      escript::Data temp;
1140    escriptDataC _arg=arg.getDataC();    escriptDataC _arg=arg.getDataC();
1141    switch(arg.getFunctionSpace().getTypeCode()) {    switch(arg.getFunctionSpace().getTypeCode()) {
1142       case(Nodes):       case(Nodes):
1143          /* TODO */          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1144          throw FinleyAdapterException("Error - Integral of data on nodes is not supported.");          _temp=temp.getDataC();
1145            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1146          break;          break;
1147       case(ReducedNodes):       case(ReducedNodes):
1148          /* TODO */          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1149          throw FinleyAdapterException("Error - Integral of data on reduced nodes is not supported.");          _temp=temp.getDataC();
1150            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1151          break;          break;
1152       case(Elements):       case(Elements):
1153          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);
# Line 746  void MeshAdapter::setToIntegrals(std::ve Line 1177  void MeshAdapter::setToIntegrals(std::ve
1177          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1178          break;          break;
1179       case(DegreesOfFreedom):       case(DegreesOfFreedom):
1180          throw FinleyAdapterException("Error - Integral of data on degrees of freedom is not supported.");          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1181            _temp=temp.getDataC();
1182            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1183          break;          break;
1184       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
1185          throw FinleyAdapterException("Error - Integral of data on reduced degrees of freedom is not supported.");          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1186            _temp=temp.getDataC();
1187            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1188          break;          break;
1189       default:       default:
1190          stringstream temp;          stringstream temp;
# Line 758  void MeshAdapter::setToIntegrals(std::ve Line 1193  void MeshAdapter::setToIntegrals(std::ve
1193          break;          break;
1194    }    }
1195    checkFinleyError();    checkFinleyError();
1196      blocktimer_increment("integrate()", blocktimer_start);
1197  }  }
1198    
1199  //  //
# Line 775  void MeshAdapter::setToGradient(escript: Line 1211  void MeshAdapter::setToGradient(escript:
1211    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1212    escriptDataC _grad=grad.getDataC();    escriptDataC _grad=grad.getDataC();
1213    escriptDataC nodeDataC;    escriptDataC nodeDataC;
1214  #ifdef PASO_MPI    escript::Data temp;
1215    escript::Data nodeTemp( arg, continuousFunction(asAbstractContinuousDomain()) );    if (getMPISize()>1) {
1216    if( arg.getFunctionSpace().getTypeCode() != Nodes )        if( arg.getFunctionSpace().getTypeCode() == DegreesOfFreedom ) {
1217    {          temp=escript::Data( arg,  continuousFunction(asAbstractContinuousDomain()) );
1218      Finley_Assemble_CopyNodalData(mesh->Nodes,&(nodeTemp.getDataC()),&(arg.getDataC()));          nodeDataC = temp.getDataC();
1219      nodeDataC = nodeTemp.getDataC();        } else if( arg.getFunctionSpace().getTypeCode() == ReducedDegreesOfFreedom ) {
1220            temp=escript::Data( arg,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1221            nodeDataC = temp.getDataC();
1222          } else {
1223            nodeDataC = arg.getDataC();
1224          }
1225      } else {
1226         nodeDataC = arg.getDataC();
1227    }    }
   else  
     nodeDataC = arg.getDataC();  
 #else  
   nodeDataC = arg.getDataC();  
 #endif  
1228    switch(grad.getFunctionSpace().getTypeCode()) {    switch(grad.getFunctionSpace().getTypeCode()) {
1229         case(Nodes):         case(Nodes):
1230            throw FinleyAdapterException("Error - Gradient at nodes is not supported.");            throw FinleyAdapterException("Error - Gradient at nodes is not supported.");
# Line 917  void MeshAdapter::saveDX(const std::stri Line 1355  void MeshAdapter::saveDX(const std::stri
1355    escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;    escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;
1356    escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;    escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;
1357    
1358      boost::python::list keys=arg.keys();    boost::python::list keys=arg.keys();
1359      for (int i=0;i<num_data;++i) {    for (int i=0;i<num_data;++i) {
1360             std::string n=boost::python::extract<std::string>(keys[i]);
1361           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1362           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1363               throw FinleyAdapterException("Error  in saveDX: Data must be defined on same Domain");               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1364           data[i]=d.getDataC();           data[i]=d.getDataC();
1365           ptr_data[i]=&(data[i]);           ptr_data[i]=&(data[i]);
          std::string n=boost::python::extract<std::string>(keys[i]);  
1366           c_names[i]=&(names[i][0]);           c_names[i]=&(names[i][0]);
1367           if (n.length()>MAX_namelength-1) {           if (n.length()>MAX_namelength-1) {
1368              strncpy(c_names[i],n.c_str(),MAX_namelength-1);              strncpy(c_names[i],n.c_str(),MAX_namelength-1);
# Line 967  void MeshAdapter::saveVTK(const std::str Line 1405  void MeshAdapter::saveVTK(const std::str
1405    
1406      boost::python::list keys=arg.keys();      boost::python::list keys=arg.keys();
1407      for (int i=0;i<num_data;++i) {      for (int i=0;i<num_data;++i) {
1408             std::string n=boost::python::extract<std::string>(keys[i]);
1409           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1410           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1411               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1412           data[i]=d.getDataC();           data[i]=d.getDataC();
1413           ptr_data[i]=&(data[i]);           ptr_data[i]=&(data[i]);
          std::string n=boost::python::extract<std::string>(keys[i]);  
1414           c_names[i]=&(names[i][0]);           c_names[i]=&(names[i][0]);
1415           if (n.length()>MAX_namelength-1) {           if (n.length()>MAX_namelength-1) {
1416              strncpy(c_names[i],n.c_str(),MAX_namelength-1);              strncpy(c_names[i],n.c_str(),MAX_namelength-1);
# Line 981  void MeshAdapter::saveVTK(const std::str Line 1419  void MeshAdapter::saveVTK(const std::str
1419              strcpy(c_names[i],n.c_str());              strcpy(c_names[i],n.c_str());
1420           }           }
1421      }      }
 #ifndef PASO_MPI      
1422      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  
1423    
1424  checkFinleyError();    checkFinleyError();
1425    /* win32 refactor */    /* win32 refactor */
1426    TMPMEMFREE(c_names);    TMPMEMFREE(c_names);
1427    TMPMEMFREE(data);    TMPMEMFREE(data);
# Line 1038  SystemMatrixAdapter MeshAdapter::newSyst Line 1472  SystemMatrixAdapter MeshAdapter::newSyst
1472            
1473      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);
1474      checkFinleyError();      checkFinleyError();
1475      Paso_SystemMatrix* fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);      Paso_SystemMatrix* fsystemMatrix;
1476        int trilinos = 0;
1477        if (trilinos) {
1478    #ifdef TRILINOS
1479          /* Allocation Epetra_VrbMatrix here */
1480    #endif
1481        }
1482        else {
1483          fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);
1484        }
1485      checkPasoError();      checkPasoError();
1486      Paso_SystemMatrixPattern_dealloc(fsystemMatrixPattern);      Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
1487      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);
1488  }  }
1489    
# Line 1131  bool MeshAdapter::probeInterpolationOnDo Line 1574  bool MeshAdapter::probeInterpolationOnDo
1574       case(Elements):       case(Elements):
1575          if (functionSpaceType_target==Elements) {          if (functionSpaceType_target==Elements) {
1576             return true;             return true;
1577            } else if (functionSpaceType_target==ReducedElements) {
1578               return true;
1579          } else {          } else {
1580             return false;             return false;
1581          }          }
# Line 1143  bool MeshAdapter::probeInterpolationOnDo Line 1588  bool MeshAdapter::probeInterpolationOnDo
1588       case(FaceElements):       case(FaceElements):
1589          if (functionSpaceType_target==FaceElements) {          if (functionSpaceType_target==FaceElements) {
1590             return true;             return true;
1591            } else if (functionSpaceType_target==ReducedFaceElements) {
1592               return true;
1593          } else {          } else {
1594             return false;             return false;
1595          }          }
# Line 1162  bool MeshAdapter::probeInterpolationOnDo Line 1609  bool MeshAdapter::probeInterpolationOnDo
1609       case(ContactElementsOne):       case(ContactElementsOne):
1610          if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {          if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {
1611             return true;             return true;
1612            } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1613               return true;
1614          } else {          } else {
1615             return false;             return false;
1616          }          }
# Line 1275  int* MeshAdapter::borrowSampleReferenceI Line 1724  int* MeshAdapter::borrowSampleReferenceI
1724    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1725    switch (functionSpaceType) {    switch (functionSpaceType) {
1726      case(Nodes):      case(Nodes):
1727        if (mesh->Nodes!=NULL) {        out=mesh->Nodes->Id;
1728          out=mesh->Nodes->Id;        break;
         break;  
       }  
1729      case(ReducedNodes):      case(ReducedNodes):
1730        throw FinleyAdapterException("Error -  ReducedNodes not supported yet.");        out=mesh->Nodes->reducedNodesId;
1731        break;        break;
1732      case(Elements):      case(Elements):
1733        out=mesh->Elements->Id;        out=mesh->Elements->Id;
# Line 1310  int* MeshAdapter::borrowSampleReferenceI Line 1757  int* MeshAdapter::borrowSampleReferenceI
1757        out=mesh->ContactElements->Id;        out=mesh->ContactElements->Id;
1758        break;        break;
1759      case(DegreesOfFreedom):      case(DegreesOfFreedom):
1760        out=mesh->Nodes->degreeOfFreedomId;        out=mesh->Nodes->degreesOfFreedomId;
1761        break;        break;
1762      case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1763        out=mesh->Nodes->reducedDegreeOfFreedomId;        out=mesh->Nodes->reducedDegreesOfFreedomId;
1764        break;        break;
1765      default:      default:
1766        stringstream temp;        stringstream temp;

Legend:
Removed from v.1080  
changed lines
  Added in v.1344

  ViewVC Help
Powered by ViewVC 1.1.26