/[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 1345 by ksteube, Wed Nov 14 07:53:34 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       // Attributes: 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("numDim",numDim) )
169            throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);
170       if (!dataFile.add_att("order",mesh->order) )
171            throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);
172       if (!dataFile.add_att("reduced_order",mesh->reduced_order) )
173            throw DataException("Error - MeshAdapter::dump: appending reduced_order to NetCDF file failed: " + *newFileName);
174       if (!dataFile.add_att("numNodes",numNodes) )
175            throw DataException("Error - MeshAdapter::dump: appending numNodes to NetCDF file failed: " + *newFileName);
176       if (!dataFile.add_att("num_Elements",num_Elements) )
177            throw DataException("Error - MeshAdapter::dump: appending num_Elements to NetCDF file failed: " + *newFileName);
178       if (!dataFile.add_att("num_FaceElements",num_FaceElements) )
179            throw DataException("Error - MeshAdapter::dump: appending num_FaceElements to NetCDF file failed: " + *newFileName);
180       if (!dataFile.add_att("num_ContactElements",num_ContactElements) )
181            throw DataException("Error - MeshAdapter::dump: appending num_ContactElements to NetCDF file failed: " + *newFileName);
182       if (!dataFile.add_att("num_Points",num_Points) )
183            throw DataException("Error - MeshAdapter::dump: appending num_Points to NetCDF file failed: " + *newFileName);
184    
185       // // // // // Nodes // // // // //
186    
187       // Only write nodes if non-empty because NetCDF doesn't like empty arrays (it treats them as NC_UNLIMITED)
188       if (numNodes>0) {
189    
190       // Nodes Id
191       if (! ( ids = dataFile.add_var("Nodes_Id", ncInt, ncdims[0])) )
192            throw DataException("Error - MeshAdapter::dump: appending Nodes_Id to netCDF file failed: " + *newFileName);
193       int_ptr = &mesh->Nodes->Id[0];
194       if (! (ids->put(int_ptr, numNodes)) )
195            throw DataException("Error - MeshAdapter::dump: copy Nodes_Id to netCDF buffer failed: " + *newFileName);
196    
197       // Nodes Tag
198       if (! ( ids = dataFile.add_var("Nodes_Tag", ncInt, ncdims[0])) )
199            throw DataException("Error - MeshAdapter::dump: appending Nodes_Tag to netCDF file failed: " + *newFileName);
200       int_ptr = &mesh->Nodes->Tag[0];
201       if (! (ids->put(int_ptr, numNodes)) )
202            throw DataException("Error - MeshAdapter::dump: copy Nodes_Tag to netCDF buffer failed: " + *newFileName);
203    
204       // Nodes gDOF
205       if (! ( ids = dataFile.add_var("Nodes_gDOF", ncInt, ncdims[0])) )
206            throw DataException("Error - MeshAdapter::dump: appending Nodes_gDOF to netCDF file failed: " + *newFileName);
207       int_ptr = &mesh->Nodes->globalDegreesOfFreedom[0];
208       if (! (ids->put(int_ptr, numNodes)) )
209            throw DataException("Error - MeshAdapter::dump: copy Nodes_gDOF to netCDF buffer failed: " + *newFileName);
210    
211       // Nodes global node index
212       if (! ( ids = dataFile.add_var("Nodes_gNI", ncInt, ncdims[0])) )
213            throw DataException("Error - MeshAdapter::dump: appending Nodes_gNI to netCDF file failed: " + *newFileName);
214       int_ptr = &mesh->Nodes->globalNodesIndex[0];
215       if (! (ids->put(int_ptr, numNodes)) )
216            throw DataException("Error - MeshAdapter::dump: copy Nodes_gNI to netCDF buffer failed: " + *newFileName);
217    
218       // Nodes grDof
219       if (! ( ids = dataFile.add_var("Nodes_grDfI", ncInt, ncdims[0])) )
220            throw DataException("Error - MeshAdapter::dump: appending Nodes_grDfI to netCDF file failed: " + *newFileName);
221       int_ptr = &mesh->Nodes->globalReducedDOFIndex[0];
222       if (! (ids->put(int_ptr, numNodes)) )
223            throw DataException("Error - MeshAdapter::dump: copy Nodes_grDfI to netCDF buffer failed: " + *newFileName);
224    
225       // Nodes grNI
226       if (! ( ids = dataFile.add_var("Nodes_grNI", ncInt, ncdims[0])) )
227            throw DataException("Error - MeshAdapter::dump: appending Nodes_grNI to netCDF file failed: " + *newFileName);
228       int_ptr = &mesh->Nodes->globalReducedNodesIndex[0];
229       if (! (ids->put(int_ptr, numNodes)) )
230            throw DataException("Error - MeshAdapter::dump: copy Nodes_grNI to netCDF buffer failed: " + *newFileName);
231    
232       // Nodes Coordinates
233       if (! ( ids = dataFile.add_var("Nodes_Coordinates", ncDouble, ncdims[0], ncdims[1]) ) )
234            throw DataException("Error - MeshAdapter::dump: appending Nodes_Coordinates to netCDF file failed: " + *newFileName);
235       if (! (ids->put(&(mesh->Nodes->Coordinates[INDEX2(0,0,numDim)]), numNodes, numDim)) )
236            throw DataException("Error - MeshAdapter::dump: copy Nodes_Coordinates to netCDF buffer failed: " + *newFileName);
237    
238       // Nodes degreesOfFreedomDistribution
239       if (! ( ids = dataFile.add_var("Nodes_DofDistribution", ncInt, ncdims[2])) )
240            throw DataException("Error - MeshAdapter::dump: appending Nodes_DofDistribution to netCDF file failed: " + *newFileName);
241       int_ptr = &mesh->Nodes->degreesOfFreedomDistribution->first_component[0];
242       if (! (ids->put(int_ptr, mpi_size+1)) )
243            throw DataException("Error - MeshAdapter::dump: copy Nodes_DofDistribution to netCDF buffer failed: " + *newFileName);
244    
245       }
246    
247       // // // // // Elements // // // // //
248    
249       if (num_Elements>0) {
250    
251         // Temp storage to gather node IDs
252         int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);
253    
254         // Elements ReferenceElement->ElementTypeId
255         if (!dataFile.add_att("Elements_TypeId", mesh->Elements->ReferenceElement->Type->TypeId) )
256            throw DataException("Error - MeshAdapter::dump: appending Elements_TypeId to NetCDF file failed: " + *newFileName);
257    
258         // Elements_Id
259         if (! ( ids = dataFile.add_var("Elements_Id", ncInt, ncdims[3])) )
260            throw DataException("Error - MeshAdapter::dump: appending Elements_Id to netCDF file failed: " + *newFileName);
261         int_ptr = &mesh->Elements->Id[0];
262         if (! (ids->put(int_ptr, num_Elements)) )
263            throw DataException("Error - MeshAdapter::dump: copy Elements_Id to netCDF buffer failed: " + *newFileName);
264    
265         // Elements_Tag
266         if (! ( ids = dataFile.add_var("Elements_Tag", ncInt, ncdims[3])) )
267            throw DataException("Error - MeshAdapter::dump: appending Elements_Tag to netCDF file failed: " + *newFileName);
268         int_ptr = &mesh->Elements->Tag[0];
269         if (! (ids->put(int_ptr, num_Elements)) )
270            throw DataException("Error - MeshAdapter::dump: copy Elements_Tag to netCDF buffer failed: " + *newFileName);
271    
272         // Elements_Owner
273         if (! ( ids = dataFile.add_var("Elements_Owner", ncInt, ncdims[3])) )
274            throw DataException("Error - MeshAdapter::dump: appending Elements_Owner to netCDF file failed: " + *newFileName);
275         int_ptr = &mesh->Elements->Owner[0];
276         if (! (ids->put(int_ptr, num_Elements)) )
277            throw DataException("Error - MeshAdapter::dump: copy Elements_Owner to netCDF buffer failed: " + *newFileName);
278    
279         // Elements_Color
280         if (! ( ids = dataFile.add_var("Elements_Color", ncInt, ncdims[3])) )
281            throw DataException("Error - MeshAdapter::dump: appending Elements_Color to netCDF file failed: " + *newFileName);
282         int_ptr = &mesh->Elements->Color[0];
283         if (! (ids->put(int_ptr, num_Elements)) )
284            throw DataException("Error - MeshAdapter::dump: copy Elements_Color to netCDF buffer failed: " + *newFileName);
285    
286         // Elements_Nodes
287         for (int i=0; i<num_Elements; i++)
288           for (int j=0; j<num_Elements_numNodes; j++)
289             Elements_Nodes[INDEX2(j,i,num_Elements_numNodes)] = mesh->Nodes->Id[mesh->Elements->Nodes[INDEX2(j,i,num_Elements_numNodes)]];
290         if (! ( ids = dataFile.add_var("Elements_Nodes", ncInt, ncdims[3], ncdims[7]) ) )
291            throw DataException("Error - MeshAdapter::dump: appending Elements_Nodes to netCDF file failed: " + *newFileName);
292         if (! (ids->put(&(Elements_Nodes[0]), num_Elements, num_Elements_numNodes)) )
293            throw DataException("Error - MeshAdapter::dump: copy Elements_Nodes to netCDF buffer failed: " + *newFileName);
294    
295         TMPMEMFREE(Elements_Nodes);
296    
297       }
298    
299       // // // // // Face_Elements // // // // //
300    
301       if (num_FaceElements>0) {
302    
303         // Temp storage to gather node IDs
304         int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);
305    
306         // FaceElements ReferenceElement->ElementTypeId
307         if (!dataFile.add_att("FaceElements_TypeId", mesh->FaceElements->ReferenceElement->Type->TypeId) )
308            throw DataException("Error - MeshAdapter::dump: appending FaceElements_TypeId to NetCDF file failed: " + *newFileName);
309    
310         // FaceElements_Id
311         if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )
312            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Id to netCDF file failed: " + *newFileName);
313         int_ptr = &mesh->FaceElements->Id[0];
314         if (! (ids->put(int_ptr, num_FaceElements)) )
315            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Id to netCDF buffer failed: " + *newFileName);
316    
317         // FaceElements_Tag
318         if (! ( ids = dataFile.add_var("FaceElements_Tag", ncInt, ncdims[4])) )
319            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Tag to netCDF file failed: " + *newFileName);
320         int_ptr = &mesh->FaceElements->Tag[0];
321         if (! (ids->put(int_ptr, num_FaceElements)) )
322            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Tag to netCDF buffer failed: " + *newFileName);
323    
324         // FaceElements_Owner
325         if (! ( ids = dataFile.add_var("FaceElements_Owner", ncInt, ncdims[4])) )
326            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Owner to netCDF file failed: " + *newFileName);
327         int_ptr = &mesh->FaceElements->Owner[0];
328         if (! (ids->put(int_ptr, num_FaceElements)) )
329            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Owner to netCDF buffer failed: " + *newFileName);
330    
331         // FaceElements_Color
332         if (! ( ids = dataFile.add_var("FaceElements_Color", ncInt, ncdims[4])) )
333            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Color to netCDF file failed: " + *newFileName);
334         int_ptr = &mesh->FaceElements->Color[0];
335         if (! (ids->put(int_ptr, num_FaceElements)) )
336            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Color to netCDF buffer failed: " + *newFileName);
337    
338         // FaceElements_Nodes
339         for (int i=0; i<num_FaceElements; i++)
340           for (int j=0; j<num_FaceElements_numNodes; j++)
341             FaceElements_Nodes[INDEX2(j,i,num_FaceElements_numNodes)] = mesh->Nodes->Id[mesh->FaceElements->Nodes[INDEX2(j,i,num_FaceElements_numNodes)]];
342         if (! ( ids = dataFile.add_var("FaceElements_Nodes", ncInt, ncdims[4], ncdims[8]) ) )
343            throw DataException("Error - MeshAdapter::dump: appending FaceElements_Nodes to netCDF file failed: " + *newFileName);
344         if (! (ids->put(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )
345            throw DataException("Error - MeshAdapter::dump: copy FaceElements_Nodes to netCDF buffer failed: " + *newFileName);
346    
347         TMPMEMFREE(FaceElements_Nodes);
348    
349       }
350    
351       // // // // // Contact_Elements // // // // //
352    
353       if (num_ContactElements>0) {
354    
355         // Temp storage to gather node IDs
356         int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);
357    
358         // ContactElements ReferenceElement->ElementTypeId
359         if (!dataFile.add_att("ContactElements_TypeId", mesh->ContactElements->ReferenceElement->Type->TypeId) )
360            throw DataException("Error - MeshAdapter::dump: appending ContactElements_TypeId to NetCDF file failed: " + *newFileName);
361    
362         // ContactElements_Id
363         if (! ( ids = dataFile.add_var("ContactElements_Id", ncInt, ncdims[5])) )
364            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Id to netCDF file failed: " + *newFileName);
365         int_ptr = &mesh->ContactElements->Id[0];
366         if (! (ids->put(int_ptr, num_ContactElements)) )
367            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Id to netCDF buffer failed: " + *newFileName);
368    
369         // ContactElements_Tag
370         if (! ( ids = dataFile.add_var("ContactElements_Tag", ncInt, ncdims[5])) )
371            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Tag to netCDF file failed: " + *newFileName);
372         int_ptr = &mesh->ContactElements->Tag[0];
373         if (! (ids->put(int_ptr, num_ContactElements)) )
374            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Tag to netCDF buffer failed: " + *newFileName);
375    
376         // ContactElements_Owner
377         if (! ( ids = dataFile.add_var("ContactElements_Owner", ncInt, ncdims[5])) )
378            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Owner to netCDF file failed: " + *newFileName);
379         int_ptr = &mesh->ContactElements->Owner[0];
380         if (! (ids->put(int_ptr, num_ContactElements)) )
381            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Owner to netCDF buffer failed: " + *newFileName);
382    
383         // ContactElements_Color
384         if (! ( ids = dataFile.add_var("ContactElements_Color", ncInt, ncdims[5])) )
385            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Color to netCDF file failed: " + *newFileName);
386         int_ptr = &mesh->ContactElements->Color[0];
387         if (! (ids->put(int_ptr, num_ContactElements)) )
388            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Color to netCDF buffer failed: " + *newFileName);
389    
390         // ContactElements_Nodes
391         for (int i=0; i<num_ContactElements; i++)
392           for (int j=0; j<num_ContactElements_numNodes; j++)
393             ContactElements_Nodes[INDEX2(j,i,num_ContactElements_numNodes)] = mesh->Nodes->Id[mesh->ContactElements->Nodes[INDEX2(j,i,num_ContactElements_numNodes)]];
394         if (! ( ids = dataFile.add_var("ContactElements_Nodes", ncInt, ncdims[5], ncdims[9]) ) )
395            throw DataException("Error - MeshAdapter::dump: appending ContactElements_Nodes to netCDF file failed: " + *newFileName);
396         if (! (ids->put(&(ContactElements_Nodes[0]), num_ContactElements, num_ContactElements_numNodes)) )
397            throw DataException("Error - MeshAdapter::dump: copy ContactElements_Nodes to netCDF buffer failed: " + *newFileName);
398    
399         TMPMEMFREE(ContactElements_Nodes);
400    
401       }
402    
403       // // // // // Points // // // // //
404    
405       if (num_Points>0) {
406    
407         fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump has not been tested with Point elements\n\n\n");
408    
409         // Temp storage to gather node IDs
410         int *Points_Nodes = TMPMEMALLOC(num_Points,int);
411    
412         // Points ReferenceElement->ElementTypeId
413         if (!dataFile.add_att("Points_TypeId", mesh->Points->ReferenceElement->Type->TypeId) )
414            throw DataException("Error - MeshAdapter::dump: appending Points_TypeId to NetCDF file failed: " + *newFileName);
415    
416         // Points_Id
417         if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )
418            throw DataException("Error - MeshAdapter::dump: appending Points_Id to netCDF file failed: " + *newFileName);
419         int_ptr = &mesh->Points->Id[0];
420         if (! (ids->put(int_ptr, num_Points)) )
421            throw DataException("Error - MeshAdapter::dump: copy Points_Id to netCDF buffer failed: " + *newFileName);
422    
423         // Points_Tag
424         if (! ( ids = dataFile.add_var("Points_Tag", ncInt, ncdims[6])) )
425            throw DataException("Error - MeshAdapter::dump: appending Points_Tag to netCDF file failed: " + *newFileName);
426         int_ptr = &mesh->Points->Tag[0];
427         if (! (ids->put(int_ptr, num_Points)) )
428            throw DataException("Error - MeshAdapter::dump: copy Points_Tag to netCDF buffer failed: " + *newFileName);
429    
430         // Points_Owner
431         if (! ( ids = dataFile.add_var("Points_Owner", ncInt, ncdims[6])) )
432            throw DataException("Error - MeshAdapter::dump: appending Points_Owner to netCDF file failed: " + *newFileName);
433         int_ptr = &mesh->Points->Owner[0];
434         if (! (ids->put(int_ptr, num_Points)) )
435            throw DataException("Error - MeshAdapter::dump: copy Points_Owner to netCDF buffer failed: " + *newFileName);
436    
437         // Points_Color
438         if (! ( ids = dataFile.add_var("Points_Color", ncInt, ncdims[6])) )
439            throw DataException("Error - MeshAdapter::dump: appending Points_Color to netCDF file failed: " + *newFileName);
440         int_ptr = &mesh->Points->Color[0];
441         if (! (ids->put(int_ptr, num_Points)) )
442            throw DataException("Error - MeshAdapter::dump: copy Points_Color to netCDF buffer failed: " + *newFileName);
443    
444         // Points_Nodes
445         // mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]]
446         for (int i=0; i<num_Points; i++)
447           Points_Nodes[i] = mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]];
448         if (! ( ids = dataFile.add_var("Points_Nodes", ncInt, ncdims[6]) ) )
449            throw DataException("Error - MeshAdapter::dump: appending Points_Nodes to netCDF file failed: " + *newFileName);
450         if (! (ids->put(&(Points_Nodes[0]), num_Points)) )
451            throw DataException("Error - MeshAdapter::dump: copy Points_Nodes to netCDF buffer failed: " + *newFileName);
452    
453         TMPMEMFREE(Points_Nodes);
454    
455       }
456    
457       // // // // // TagMap // // // // //
458    
459         fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump does not save the TagMap yet\n\n\n");
460    
461       // NetCDF file is closed by destructor of NcFile object
462    #else
463       Finley_setError(IO_ERROR, "MeshAdapter::dump: not configured with NetCDF. Please contact your installation manager.");
464    #endif  /* USE_NETCDF */
465       checkFinleyError();
466    }
467    
468  string MeshAdapter::getDescription() const  string MeshAdapter::getDescription() const
469  {  {
470    return "FinleyMesh";    return "FinleyMesh";
# Line 220  pair<int,int> MeshAdapter::getDataShape( Line 600  pair<int,int> MeshAdapter::getDataShape(
600     switch (functionSpaceCode) {     switch (functionSpaceCode) {
601        case(Nodes):        case(Nodes):
602             numDataPointsPerSample=1;             numDataPointsPerSample=1;
603             if (mesh->Nodes!=NULL) numSamples=mesh->Nodes->numNodes;             numSamples=Finley_NodeFile_getNumNodes(mesh->Nodes);
604             break;             break;
605        case(ReducedNodes):        case(ReducedNodes):
            /* TODO: add ReducedNodes */  
606             numDataPointsPerSample=1;             numDataPointsPerSample=1;
607             if (mesh->Nodes!=NULL) numSamples=mesh->Nodes->numNodes;             numSamples=Finley_NodeFile_getNumReducedNodes(mesh->Nodes);
            throw FinleyAdapterException("Error - ReducedNodes is not supported yet.");  
608             break;             break;
609        case(Elements):        case(Elements):
610             if (mesh->Elements!=NULL) {             if (mesh->Elements!=NULL) {
# Line 285  pair<int,int> MeshAdapter::getDataShape( Line 663  pair<int,int> MeshAdapter::getDataShape(
663        case(DegreesOfFreedom):        case(DegreesOfFreedom):
664             if (mesh->Nodes!=NULL) {             if (mesh->Nodes!=NULL) {
665               numDataPointsPerSample=1;               numDataPointsPerSample=1;
666  #ifndef PASO_MPI               numSamples=Finley_NodeFile_getNumDegreesOfFreedom(mesh->Nodes);
              numSamples=mesh->Nodes->numDegreesOfFreedom;  
 #else  
              numSamples=mesh->Nodes->degreeOfFreedomDistribution->numLocal;  
 #endif  
667             }             }
668             break;             break;
669        case(ReducedDegreesOfFreedom):        case(ReducedDegreesOfFreedom):
670             if (mesh->Nodes!=NULL) {             if (mesh->Nodes!=NULL) {
671               numDataPointsPerSample=1;               numDataPointsPerSample=1;
672  #ifndef PASO_MPI               numSamples=Finley_NodeFile_getNumReducedDegreesOfFreedom(mesh->Nodes);
              numSamples=mesh->Nodes->reducedNumDegreesOfFreedom;  
 #else  
              numSamples=mesh->Nodes->reducedDegreeOfFreedomDistribution->numLocal;  
 #endif  
673             }             }
674             break;             break;
675        default:        default:
# Line 344  void MeshAdapter::addPDEToSystem( Line 714  void MeshAdapter::addPDEToSystem(
714     checkFinleyError();     checkFinleyError();
715  }  }
716    
717    void  MeshAdapter::addPDEToLumpedSystem(
718                         escript::Data& mat,
719                         const escript::Data& D,
720                         const escript::Data& d) const
721    {
722       escriptDataC _mat=mat.getDataC();
723       escriptDataC _D=D.getDataC();
724       escriptDataC _d=d.getDataC();
725    
726       Finley_Mesh* mesh=m_finleyMesh.get();
727    
728       Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->Elements,&_mat, &_D);
729       Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->FaceElements,&_mat, &_d);
730    
731       checkFinleyError();
732    }
733    
734    
735  //  //
736  // adds linear PDE of second order into the right hand side only  // adds linear PDE of second order into the right hand side only
737  //  //
# Line 454  void MeshAdapter::interpolateOnDomain(es Line 842  void MeshAdapter::interpolateOnDomain(es
842       case(Elements):       case(Elements):
843          if (target.getFunctionSpace().getTypeCode()==Elements) {          if (target.getFunctionSpace().getTypeCode()==Elements) {
844             Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);             Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
845            } else if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
846               Finley_Assemble_AverageElementData(mesh->Elements,&_target,&_in);
847          } else {          } else {
848             throw FinleyAdapterException("Error - No interpolation with data on elements possible.");             throw FinleyAdapterException("Error - No interpolation with data on elements possible.");
849          }          }
# Line 468  void MeshAdapter::interpolateOnDomain(es Line 858  void MeshAdapter::interpolateOnDomain(es
858       case(FaceElements):       case(FaceElements):
859          if (target.getFunctionSpace().getTypeCode()==FaceElements) {          if (target.getFunctionSpace().getTypeCode()==FaceElements) {
860             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
861            } else if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
862               Finley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);
863          } else {          } else {
864             throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");             throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");
865         }         }
# Line 490  void MeshAdapter::interpolateOnDomain(es Line 882  void MeshAdapter::interpolateOnDomain(es
882       case(ContactElementsOne):       case(ContactElementsOne):
883          if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {          if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {
884             Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);             Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);
885            } else if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {
886               Finley_Assemble_AverageElementData(mesh->ContactElements,&_target,&_in);
887          } else {          } else {
888             throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");             throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");
889             break;             break;
# Line 508  void MeshAdapter::interpolateOnDomain(es Line 902  void MeshAdapter::interpolateOnDomain(es
902          switch(target.getFunctionSpace().getTypeCode()) {          switch(target.getFunctionSpace().getTypeCode()) {
903             case(ReducedDegreesOfFreedom):             case(ReducedDegreesOfFreedom):
904             case(DegreesOfFreedom):             case(DegreesOfFreedom):
            case(Nodes):  
            case(ReducedNodes):  
905                Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);                Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
906                break;                break;
907  #ifndef PASO_MPI  
908             case(Elements):             case(Nodes):
909             case(ReducedElements):             case(ReducedNodes):
910                Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);                if (getMPISize()>1) {
911                break;                    escript::Data temp=escript::Data(in);
912             case(FaceElements):                    temp.expand();
913             case(ReducedFaceElements):                    escriptDataC _in2 = temp.getDataC();
914                Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);                    Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
915                break;                } else {
916             case(Points):                    Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
917                Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);                }
918                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 */  
919             case(Elements):             case(Elements):
920             case(ReducedElements):             case(ReducedElements):
921                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
922                Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
923                     escriptDataC _in2 = temp.getDataC();
924                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
925                  } else {
926                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
927                  }
928                break;                break;
929             case(FaceElements):             case(FaceElements):
930             case(ReducedFaceElements):             case(ReducedFaceElements):
931                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
932                Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
933                     escriptDataC _in2 = temp.getDataC();
934                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
935    
936                  } else {
937                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
938                  }
939                break;                break;
940             case(Points):             case(Points):
941                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
942                Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
943                     escriptDataC _in2 = temp.getDataC();
944                  } else {
945                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
946                  }
947                break;                break;
948             case(ContactElementsZero):             case(ContactElementsZero):
949             case(ContactElementsOne):             case(ContactElementsOne):
950             case(ReducedContactElementsZero):             case(ReducedContactElementsZero):
951             case(ReducedContactElementsOne):             case(ReducedContactElementsOne):
952                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
953                Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(nodeTemp.getDataC()),&_target);                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
954                     escriptDataC _in2 = temp.getDataC();
955                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
956                  } else {
957                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
958                  }
959               break;               break;
 #endif  
960             default:             default:
961               stringstream temp;               stringstream temp;
962               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 970  void MeshAdapter::interpolateOnDomain(es
970               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.");
971               break;               break;
972            case(ReducedNodes):            case(ReducedNodes):
973               Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);                if (getMPISize()>1) {
974               break;                    escript::Data temp=escript::Data(in);
975                      temp.expand();
976                      escriptDataC _in2 = temp.getDataC();
977                      Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
978                  } else {
979                      Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
980                  }
981                  break;
982            case(DegreesOfFreedom):            case(DegreesOfFreedom):
983               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");
984               break;               break;
# Line 577  void MeshAdapter::interpolateOnDomain(es Line 987  void MeshAdapter::interpolateOnDomain(es
987               break;               break;
988            case(Elements):            case(Elements):
989            case(ReducedElements):            case(ReducedElements):
990               Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);                if (getMPISize()>1) {
991                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
992                     escriptDataC _in2 = temp.getDataC();
993                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
994                  } else {
995                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
996                 }
997               break;               break;
998            case(FaceElements):            case(FaceElements):
999            case(ReducedFaceElements):            case(ReducedFaceElements):
1000               Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);                if (getMPISize()>1) {
1001                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1002                     escriptDataC _in2 = temp.getDataC();
1003                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
1004                  } else {
1005                     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
1006                  }
1007               break;               break;
1008            case(Points):            case(Points):
1009               Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);                if (getMPISize()>1) {
1010                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1011                     escriptDataC _in2 = temp.getDataC();
1012                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);
1013                  } else {
1014                     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
1015                 }
1016               break;               break;
1017            case(ContactElementsZero):            case(ContactElementsZero):
1018            case(ContactElementsOne):            case(ContactElementsOne):
1019            case(ReducedContactElementsZero):            case(ReducedContactElementsZero):
1020            case(ReducedContactElementsOne):            case(ReducedContactElementsOne):
1021               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);                if (getMPISize()>1) {
1022                     escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1023                     escriptDataC _in2 = temp.getDataC();
1024                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
1025                  } else {
1026                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
1027                 }
1028               break;               break;
1029            default:            default:
1030               stringstream temp;               stringstream temp;
# Line 707  void MeshAdapter::setToIntegrals(std::ve Line 1141  void MeshAdapter::setToIntegrals(std::ve
1141    if (argDomain!=*this)    if (argDomain!=*this)
1142       throw FinleyAdapterException("Error - Illegal domain of integration kernel");       throw FinleyAdapterException("Error - Illegal domain of integration kernel");
1143    
1144      double blocktimer_start = blocktimer_time();
1145    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1146      escriptDataC _temp;
1147      escript::Data temp;
1148    escriptDataC _arg=arg.getDataC();    escriptDataC _arg=arg.getDataC();
1149    switch(arg.getFunctionSpace().getTypeCode()) {    switch(arg.getFunctionSpace().getTypeCode()) {
1150       case(Nodes):       case(Nodes):
1151          /* TODO */          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1152          throw FinleyAdapterException("Error - Integral of data on nodes is not supported.");          _temp=temp.getDataC();
1153            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1154          break;          break;
1155       case(ReducedNodes):       case(ReducedNodes):
1156          /* TODO */          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1157          throw FinleyAdapterException("Error - Integral of data on reduced nodes is not supported.");          _temp=temp.getDataC();
1158            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1159          break;          break;
1160       case(Elements):       case(Elements):
1161          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 1185  void MeshAdapter::setToIntegrals(std::ve
1185          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1186          break;          break;
1187       case(DegreesOfFreedom):       case(DegreesOfFreedom):
1188          throw FinleyAdapterException("Error - Integral of data on degrees of freedom is not supported.");          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1189            _temp=temp.getDataC();
1190            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1191          break;          break;
1192       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
1193          throw FinleyAdapterException("Error - Integral of data on reduced degrees of freedom is not supported.");          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1194            _temp=temp.getDataC();
1195            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1196          break;          break;
1197       default:       default:
1198          stringstream temp;          stringstream temp;
# Line 758  void MeshAdapter::setToIntegrals(std::ve Line 1201  void MeshAdapter::setToIntegrals(std::ve
1201          break;          break;
1202    }    }
1203    checkFinleyError();    checkFinleyError();
1204      blocktimer_increment("integrate()", blocktimer_start);
1205  }  }
1206    
1207  //  //
# Line 775  void MeshAdapter::setToGradient(escript: Line 1219  void MeshAdapter::setToGradient(escript:
1219    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1220    escriptDataC _grad=grad.getDataC();    escriptDataC _grad=grad.getDataC();
1221    escriptDataC nodeDataC;    escriptDataC nodeDataC;
1222  #ifdef PASO_MPI    escript::Data temp;
1223    escript::Data nodeTemp( arg, continuousFunction(asAbstractContinuousDomain()) );    if (getMPISize()>1) {
1224    if( arg.getFunctionSpace().getTypeCode() != Nodes )        if( arg.getFunctionSpace().getTypeCode() == DegreesOfFreedom ) {
1225    {          temp=escript::Data( arg,  continuousFunction(asAbstractContinuousDomain()) );
1226      Finley_Assemble_CopyNodalData(mesh->Nodes,&(nodeTemp.getDataC()),&(arg.getDataC()));          nodeDataC = temp.getDataC();
1227      nodeDataC = nodeTemp.getDataC();        } else if( arg.getFunctionSpace().getTypeCode() == ReducedDegreesOfFreedom ) {
1228            temp=escript::Data( arg,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1229            nodeDataC = temp.getDataC();
1230          } else {
1231            nodeDataC = arg.getDataC();
1232          }
1233      } else {
1234         nodeDataC = arg.getDataC();
1235    }    }
   else  
     nodeDataC = arg.getDataC();  
 #else  
   nodeDataC = arg.getDataC();  
 #endif  
1236    switch(grad.getFunctionSpace().getTypeCode()) {    switch(grad.getFunctionSpace().getTypeCode()) {
1237         case(Nodes):         case(Nodes):
1238            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 1363  void MeshAdapter::saveDX(const std::stri
1363    escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;    escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;
1364    escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;    escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;
1365    
1366      boost::python::list keys=arg.keys();    boost::python::list keys=arg.keys();
1367      for (int i=0;i<num_data;++i) {    for (int i=0;i<num_data;++i) {
1368             std::string n=boost::python::extract<std::string>(keys[i]);
1369           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1370           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1371               throw FinleyAdapterException("Error  in saveDX: Data must be defined on same Domain");               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1372           data[i]=d.getDataC();           data[i]=d.getDataC();
1373           ptr_data[i]=&(data[i]);           ptr_data[i]=&(data[i]);
          std::string n=boost::python::extract<std::string>(keys[i]);  
1374           c_names[i]=&(names[i][0]);           c_names[i]=&(names[i][0]);
1375           if (n.length()>MAX_namelength-1) {           if (n.length()>MAX_namelength-1) {
1376              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 1413  void MeshAdapter::saveVTK(const std::str
1413    
1414      boost::python::list keys=arg.keys();      boost::python::list keys=arg.keys();
1415      for (int i=0;i<num_data;++i) {      for (int i=0;i<num_data;++i) {
1416             std::string n=boost::python::extract<std::string>(keys[i]);
1417           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1418           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1419               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1420           data[i]=d.getDataC();           data[i]=d.getDataC();
1421           ptr_data[i]=&(data[i]);           ptr_data[i]=&(data[i]);
          std::string n=boost::python::extract<std::string>(keys[i]);  
1422           c_names[i]=&(names[i][0]);           c_names[i]=&(names[i][0]);
1423           if (n.length()>MAX_namelength-1) {           if (n.length()>MAX_namelength-1) {
1424              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 1427  void MeshAdapter::saveVTK(const std::str
1427              strcpy(c_names[i],n.c_str());              strcpy(c_names[i],n.c_str());
1428           }           }
1429      }      }
 #ifndef PASO_MPI      
1430      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  
1431    
1432  checkFinleyError();    checkFinleyError();
1433    /* win32 refactor */    /* win32 refactor */
1434    TMPMEMFREE(c_names);    TMPMEMFREE(c_names);
1435    TMPMEMFREE(data);    TMPMEMFREE(data);
# Line 1038  SystemMatrixAdapter MeshAdapter::newSyst Line 1480  SystemMatrixAdapter MeshAdapter::newSyst
1480            
1481      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);
1482      checkFinleyError();      checkFinleyError();
1483      Paso_SystemMatrix* fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);      Paso_SystemMatrix* fsystemMatrix;
1484        int trilinos = 0;
1485        if (trilinos) {
1486    #ifdef TRILINOS
1487          /* Allocation Epetra_VrbMatrix here */
1488    #endif
1489        }
1490        else {
1491          fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);
1492        }
1493      checkPasoError();      checkPasoError();
1494      Paso_SystemMatrixPattern_dealloc(fsystemMatrixPattern);      Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
1495      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);
1496  }  }
1497    
# Line 1131  bool MeshAdapter::probeInterpolationOnDo Line 1582  bool MeshAdapter::probeInterpolationOnDo
1582       case(Elements):       case(Elements):
1583          if (functionSpaceType_target==Elements) {          if (functionSpaceType_target==Elements) {
1584             return true;             return true;
1585            } else if (functionSpaceType_target==ReducedElements) {
1586               return true;
1587          } else {          } else {
1588             return false;             return false;
1589          }          }
# Line 1143  bool MeshAdapter::probeInterpolationOnDo Line 1596  bool MeshAdapter::probeInterpolationOnDo
1596       case(FaceElements):       case(FaceElements):
1597          if (functionSpaceType_target==FaceElements) {          if (functionSpaceType_target==FaceElements) {
1598             return true;             return true;
1599            } else if (functionSpaceType_target==ReducedFaceElements) {
1600               return true;
1601          } else {          } else {
1602             return false;             return false;
1603          }          }
# Line 1162  bool MeshAdapter::probeInterpolationOnDo Line 1617  bool MeshAdapter::probeInterpolationOnDo
1617       case(ContactElementsOne):       case(ContactElementsOne):
1618          if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {          if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {
1619             return true;             return true;
1620            } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1621               return true;
1622          } else {          } else {
1623             return false;             return false;
1624          }          }
# Line 1275  int* MeshAdapter::borrowSampleReferenceI Line 1732  int* MeshAdapter::borrowSampleReferenceI
1732    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1733    switch (functionSpaceType) {    switch (functionSpaceType) {
1734      case(Nodes):      case(Nodes):
1735        if (mesh->Nodes!=NULL) {        out=mesh->Nodes->Id;
1736          out=mesh->Nodes->Id;        break;
         break;  
       }  
1737      case(ReducedNodes):      case(ReducedNodes):
1738        throw FinleyAdapterException("Error -  ReducedNodes not supported yet.");        out=mesh->Nodes->reducedNodesId;
1739        break;        break;
1740      case(Elements):      case(Elements):
1741        out=mesh->Elements->Id;        out=mesh->Elements->Id;
# Line 1310  int* MeshAdapter::borrowSampleReferenceI Line 1765  int* MeshAdapter::borrowSampleReferenceI
1765        out=mesh->ContactElements->Id;        out=mesh->ContactElements->Id;
1766        break;        break;
1767      case(DegreesOfFreedom):      case(DegreesOfFreedom):
1768        out=mesh->Nodes->degreeOfFreedomId;        out=mesh->Nodes->degreesOfFreedomId;
1769        break;        break;
1770      case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1771        out=mesh->Nodes->reducedDegreeOfFreedomId;        out=mesh->Nodes->reducedDegreesOfFreedomId;
1772        break;        break;
1773      default:      default:
1774        stringstream temp;        stringstream temp;

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

  ViewVC Help
Powered by ViewVC 1.1.26