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

Diff of /trunk/finley/src/CPPAdapter/MeshAdapter.cpp

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

revision 817 by ksteube, Sat Aug 26 03:08:52 2006 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 32  MeshAdapter::FunctionSpaceNamesMapType M Line 35  MeshAdapter::FunctionSpaceNamesMapType M
35  const int MeshAdapter::DegreesOfFreedom=FINLEY_DEGREES_OF_FREEDOM;  const int MeshAdapter::DegreesOfFreedom=FINLEY_DEGREES_OF_FREEDOM;
36  const int MeshAdapter::ReducedDegreesOfFreedom=FINLEY_REDUCED_DEGREES_OF_FREEDOM;  const int MeshAdapter::ReducedDegreesOfFreedom=FINLEY_REDUCED_DEGREES_OF_FREEDOM;
37  const int MeshAdapter::Nodes=FINLEY_NODES;  const int MeshAdapter::Nodes=FINLEY_NODES;
38    const int MeshAdapter::ReducedNodes=FINLEY_REDUCED_NODES;
39  const int MeshAdapter::Elements=FINLEY_ELEMENTS;  const int MeshAdapter::Elements=FINLEY_ELEMENTS;
40    const int MeshAdapter::ReducedElements=FINLEY_REDUCED_ELEMENTS;
41  const int MeshAdapter::FaceElements=FINLEY_FACE_ELEMENTS;  const int MeshAdapter::FaceElements=FINLEY_FACE_ELEMENTS;
42    const int MeshAdapter::ReducedFaceElements=FINLEY_REDUCED_FACE_ELEMENTS;
43  const int MeshAdapter::Points=FINLEY_POINTS;  const int MeshAdapter::Points=FINLEY_POINTS;
44  const int MeshAdapter::ContactElementsZero=FINLEY_CONTACT_ELEMENTS_1;  const int MeshAdapter::ContactElementsZero=FINLEY_CONTACT_ELEMENTS_1;
45    const int MeshAdapter::ReducedContactElementsZero=FINLEY_REDUCED_CONTACT_ELEMENTS_1;
46  const int MeshAdapter::ContactElementsOne=FINLEY_CONTACT_ELEMENTS_2;  const int MeshAdapter::ContactElementsOne=FINLEY_CONTACT_ELEMENTS_2;
47    const int MeshAdapter::ReducedContactElementsOne=FINLEY_REDUCED_CONTACT_ELEMENTS_2;
48    
49  MeshAdapter::MeshAdapter(Finley_Mesh* finleyMesh)  MeshAdapter::MeshAdapter(Finley_Mesh* finleyMesh)
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 61  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 80  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 112  void MeshAdapter::setFunctionSpaceTypeNa Line 489  void MeshAdapter::setFunctionSpaceTypeNa
489    m_functionSpaceTypeNames.insert    m_functionSpaceTypeNames.insert
490      (FunctionSpaceNamesMapType::value_type(Nodes,"Finley_Nodes"));      (FunctionSpaceNamesMapType::value_type(Nodes,"Finley_Nodes"));
491    m_functionSpaceTypeNames.insert    m_functionSpaceTypeNames.insert
492        (FunctionSpaceNamesMapType::value_type(ReducedNodes,"Finley_Reduced_Nodes"));
493      m_functionSpaceTypeNames.insert
494      (FunctionSpaceNamesMapType::value_type(Elements,"Finley_Elements"));      (FunctionSpaceNamesMapType::value_type(Elements,"Finley_Elements"));
495    m_functionSpaceTypeNames.insert    m_functionSpaceTypeNames.insert
496        (FunctionSpaceNamesMapType::value_type(ReducedElements,"Finley_Reduced_Elements"));
497      m_functionSpaceTypeNames.insert
498      (FunctionSpaceNamesMapType::value_type(FaceElements,"Finley_Face_Elements"));      (FunctionSpaceNamesMapType::value_type(FaceElements,"Finley_Face_Elements"));
499    m_functionSpaceTypeNames.insert    m_functionSpaceTypeNames.insert
500        (FunctionSpaceNamesMapType::value_type(ReducedFaceElements,"Finley_Reduced_Face_Elements"));
501      m_functionSpaceTypeNames.insert
502      (FunctionSpaceNamesMapType::value_type(Points,"Finley_Points"));      (FunctionSpaceNamesMapType::value_type(Points,"Finley_Points"));
503    m_functionSpaceTypeNames.insert    m_functionSpaceTypeNames.insert
504      (FunctionSpaceNamesMapType::value_type(ContactElementsZero,"Finley_Contact_Elements_0"));      (FunctionSpaceNamesMapType::value_type(ContactElementsZero,"Finley_Contact_Elements_0"));
505    m_functionSpaceTypeNames.insert    m_functionSpaceTypeNames.insert
506        (FunctionSpaceNamesMapType::value_type(ReducedContactElementsZero,"Finley_Reduced_Contact_Elements_0"));
507      m_functionSpaceTypeNames.insert
508      (FunctionSpaceNamesMapType::value_type(ContactElementsOne,"Finley_Contact_Elements_1"));      (FunctionSpaceNamesMapType::value_type(ContactElementsOne,"Finley_Contact_Elements_1"));
509      m_functionSpaceTypeNames.insert
510        (FunctionSpaceNamesMapType::value_type(ReducedContactElementsOne,"Finley_Reduced_Contact_Elements_1"));
511  }  }
512    
513  int MeshAdapter::getContinuousFunctionCode() const  int MeshAdapter::getContinuousFunctionCode() const
514  {  {
515    return Nodes;    return Nodes;
516  }  }
517    int MeshAdapter::getReducedContinuousFunctionCode() const
518    {
519      return ReducedNodes;
520    }
521    
522  int MeshAdapter::getFunctionCode() const  int MeshAdapter::getFunctionCode() const
523  {  {
524    return Elements;    return Elements;
525  }  }
526    int MeshAdapter::getReducedFunctionCode() const
527    {
528      return ReducedElements;
529    }
530    
531  int MeshAdapter::getFunctionOnBoundaryCode() const  int MeshAdapter::getFunctionOnBoundaryCode() const
532  {  {
533    return FaceElements;    return FaceElements;
534  }  }
535    int MeshAdapter::getReducedFunctionOnBoundaryCode() const
536    {
537      return ReducedFaceElements;
538    }
539    
540  int MeshAdapter::getFunctionOnContactZeroCode() const  int MeshAdapter::getFunctionOnContactZeroCode() const
541  {  {
542    return ContactElementsZero;    return ContactElementsZero;
543  }  }
544    int MeshAdapter::getReducedFunctionOnContactZeroCode() const
545    {
546      return ReducedContactElementsZero;
547    }
548    
549  int MeshAdapter::getFunctionOnContactOneCode() const  int MeshAdapter::getFunctionOnContactOneCode() const
550  {  {
551    return ContactElementsOne;    return ContactElementsOne;
552  }  }
553    int MeshAdapter::getReducedFunctionOnContactOneCode() const
554    {
555      return ReducedContactElementsOne;
556    }
557    
558  int MeshAdapter::getSolutionCode() const  int MeshAdapter::getSolutionCode() const
559  {  {
# Line 185  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;
597          case(ReducedNodes):
598               numDataPointsPerSample=1;
599               numSamples=Finley_NodeFile_getNumReducedNodes(mesh->Nodes);
600             break;             break;
601        case(Elements):        case(Elements):
602             if (mesh->Elements!=NULL) {             if (mesh->Elements!=NULL) {
# Line 193  pair<int,int> MeshAdapter::getDataShape( Line 604  pair<int,int> MeshAdapter::getDataShape(
604               numDataPointsPerSample=mesh->Elements->ReferenceElement->numQuadNodes;               numDataPointsPerSample=mesh->Elements->ReferenceElement->numQuadNodes;
605             }             }
606             break;             break;
607          case(ReducedElements):
608               if (mesh->Elements!=NULL) {
609                 numSamples=mesh->Elements->numElements;
610                 numDataPointsPerSample=mesh->Elements->ReferenceElementReducedOrder->numQuadNodes;
611               }
612               break;
613        case(FaceElements):        case(FaceElements):
614             if (mesh->FaceElements!=NULL) {             if (mesh->FaceElements!=NULL) {
615                  numDataPointsPerSample=mesh->FaceElements->ReferenceElement->numQuadNodes;                  numDataPointsPerSample=mesh->FaceElements->ReferenceElement->numQuadNodes;
616                  numSamples=mesh->FaceElements->numElements;                  numSamples=mesh->FaceElements->numElements;
617             }             }
618             break;             break;
619          case(ReducedFaceElements):
620               if (mesh->FaceElements!=NULL) {
621                    numDataPointsPerSample=mesh->FaceElements->ReferenceElementReducedOrder->numQuadNodes;
622                    numSamples=mesh->FaceElements->numElements;
623               }
624               break;
625        case(Points):        case(Points):
626             if (mesh->Points!=NULL) {             if (mesh->Points!=NULL) {
627               numDataPointsPerSample=1;               numDataPointsPerSample=1;
# Line 211  pair<int,int> MeshAdapter::getDataShape( Line 634  pair<int,int> MeshAdapter::getDataShape(
634               numSamples=mesh->ContactElements->numElements;               numSamples=mesh->ContactElements->numElements;
635             }             }
636             break;             break;
637          case(ReducedContactElementsZero):
638               if (mesh->ContactElements!=NULL) {
639                 numDataPointsPerSample=mesh->ContactElements->ReferenceElementReducedOrder->numQuadNodes;
640                 numSamples=mesh->ContactElements->numElements;
641               }
642               break;
643        case(ContactElementsOne):        case(ContactElementsOne):
644             if (mesh->ContactElements!=NULL) {             if (mesh->ContactElements!=NULL) {
645               numDataPointsPerSample=mesh->ContactElements->ReferenceElement->numQuadNodes;               numDataPointsPerSample=mesh->ContactElements->ReferenceElement->numQuadNodes;
646               numSamples=mesh->ContactElements->numElements;               numSamples=mesh->ContactElements->numElements;
647             }             }
648             break;             break;
649          case(ReducedContactElementsOne):
650               if (mesh->ContactElements!=NULL) {
651                 numDataPointsPerSample=mesh->ContactElements->ReferenceElementReducedOrder->numQuadNodes;
652                 numSamples=mesh->ContactElements->numElements;
653               }
654               break;
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 279  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 315  void MeshAdapter::interpolateOnDomain(es Line 760  void MeshAdapter::interpolateOnDomain(es
760      throw FinleyAdapterException("Error - Illegal domain of interpolation target.");      throw FinleyAdapterException("Error - Illegal domain of interpolation target.");
761    
762    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
763      escriptDataC _target=target.getDataC();
764      escriptDataC _in=in.getDataC();
765    switch(in.getFunctionSpace().getTypeCode()) {    switch(in.getFunctionSpace().getTypeCode()) {
766       case(Nodes):       case(Nodes):
767          switch(target.getFunctionSpace().getTypeCode()) {          switch(target.getFunctionSpace().getTypeCode()) {
768             case(Nodes):             case(Nodes):
769               case(ReducedNodes):
770               case(DegreesOfFreedom):
771             case(ReducedDegreesOfFreedom):             case(ReducedDegreesOfFreedom):
772                   Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
773                   break;
774               case(Elements):
775               case(ReducedElements):
776                   Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
777                   break;
778               case(FaceElements):
779               case(ReducedFaceElements):
780                   Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
781                   break;
782               case(Points):
783                   Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
784                   break;
785               case(ContactElementsZero):
786               case(ReducedContactElementsZero):
787                   Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
788                   break;
789               case(ContactElementsOne):
790               case(ReducedContactElementsOne):
791                   Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
792                   break;
793               default:
794                   stringstream temp;
795                   temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
796                   throw FinleyAdapterException(temp.str());
797                   break;
798            }
799            break;
800         case(ReducedNodes):
801            switch(target.getFunctionSpace().getTypeCode()) {
802               case(Nodes):
803               case(ReducedNodes):
804             case(DegreesOfFreedom):             case(DegreesOfFreedom):
805                 Finley_Assemble_CopyNodalData(mesh->Nodes,&(target.getDataC()),&(in.getDataC()));             case(ReducedDegreesOfFreedom):
806                   Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
807                 break;                 break;
808             case(Elements):             case(Elements):
809                 Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&(in.getDataC()),&(target.getDataC()));             case(ReducedElements):
810                   Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
811                 break;                 break;
812             case(FaceElements):             case(FaceElements):
813                 Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&(in.getDataC()),&(target.getDataC()));             case(ReducedFaceElements):
814                   Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
815                 break;                 break;
816             case(Points):             case(Points):
817                 Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&(in.getDataC()),&(target.getDataC()));                 Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
818                 break;                 break;
819             case(ContactElementsZero):             case(ContactElementsZero):
820                 Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));             case(ReducedContactElementsZero):
821                   Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
822                 break;                 break;
823             case(ContactElementsOne):             case(ContactElementsOne):
824                 Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));             case(ReducedContactElementsOne):
825                   Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
826                 break;                 break;
827             default:             default:
828                 stringstream temp;                 stringstream temp;
# Line 347  void MeshAdapter::interpolateOnDomain(es Line 833  void MeshAdapter::interpolateOnDomain(es
833          break;          break;
834       case(Elements):       case(Elements):
835          if (target.getFunctionSpace().getTypeCode()==Elements) {          if (target.getFunctionSpace().getTypeCode()==Elements) {
836             Finley_Assemble_CopyElementData(mesh->Elements,&(target.getDataC()),&(in.getDataC()));             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          }          }
842          break;          break;
843         case(ReducedElements):
844            if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
845               Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
846            } else {
847               throw FinleyAdapterException("Error - No interpolation with data on elements with reduced integration order possible.");
848            }
849            break;
850       case(FaceElements):       case(FaceElements):
851          if (target.getFunctionSpace().getTypeCode()==FaceElements) {          if (target.getFunctionSpace().getTypeCode()==FaceElements) {
852             Finley_Assemble_CopyElementData(mesh->FaceElements,&(target.getDataC()),&(in.getDataC()));             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.");
            break;  
857         }         }
858           break;
859         case(ReducedFaceElements):
860            if (target.getFunctionSpace().getTypeCode()==FaceElements) {
861               Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
862            } else {
863               throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");
864           }
865           break;
866       case(Points):       case(Points):
867          if (target.getFunctionSpace().getTypeCode()==Points) {          if (target.getFunctionSpace().getTypeCode()==Points) {
868             Finley_Assemble_CopyElementData(mesh->Points,&(target.getDataC()),&(in.getDataC()));             Finley_Assemble_CopyElementData(mesh->Points,&_target,&_in);
869          } else {          } else {
870             throw FinleyAdapterException("Error - No interpolation with data on points possible.");             throw FinleyAdapterException("Error - No interpolation with data on points possible.");
            break;  
871          }          }
872          break;          break;
873       case(ContactElementsZero):       case(ContactElementsZero):
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.getDataC()),&(in.getDataC()));             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;
882          }          }
883          break;          break;
884         case(ReducedContactElementsZero):
885         case(ReducedContactElementsOne):
886            if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {
887               Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);
888            } else {
889               throw FinleyAdapterException("Error - No interpolation with data on contact elements with reduced integration order possible.");
890               break;
891            }
892            break;
893       case(DegreesOfFreedom):             case(DegreesOfFreedom):      
894          switch(target.getFunctionSpace().getTypeCode()) {          switch(target.getFunctionSpace().getTypeCode()) {
895             case(ReducedDegreesOfFreedom):             case(ReducedDegreesOfFreedom):
896             case(DegreesOfFreedom):             case(DegreesOfFreedom):
897             case(Nodes):                Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
               Finley_Assemble_CopyNodalData(mesh->Nodes,&(target.getDataC()),&(in.getDataC()));  
               break;  
 #ifndef PASO_MPI  
            case(Elements):  
               Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&(in.getDataC()),&(target.getDataC()));  
898                break;                break;
899             case(FaceElements):  
900                Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&(in.getDataC()),&(target.getDataC()));             case(Nodes):
901                break;             case(ReducedNodes):
902             case(Points):                if (getMPISize()>1) {
903                Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&(in.getDataC()),&(target.getDataC()));                    escript::Data temp=escript::Data(in);
904                      temp.expand();
905                      escriptDataC _in2 = temp.getDataC();
906                      Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
907                  } else {
908                      Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
909                  }
910                break;                break;
            case(ContactElementsZero):  
            case(ContactElementsOne):  
               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));  
              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):
913                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
914                Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&(nodeTemp.getDataC()),&(target.getDataC()));                   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):
923                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                if (getMPISize()>1) {
924                Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&(nodeTemp.getDataC()),&(target.getDataC()));                   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             {                if (getMPISize()>1) {
934                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
935                Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&(nodeTemp.getDataC()),&(target.getDataC()));                   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):
943                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );             case(ReducedContactElementsOne):
944                Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(nodeTemp.getDataC()),&(target.getDataC()));                if (getMPISize()>1) {
945                     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 434  void MeshAdapter::interpolateOnDomain(es Line 958  void MeshAdapter::interpolateOnDomain(es
958          break;          break;
959       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
960         switch(target.getFunctionSpace().getTypeCode()) {         switch(target.getFunctionSpace().getTypeCode()) {
961              case(Nodes):
962                 throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");
963                 break;
964              case(ReducedNodes):
965                  if (getMPISize()>1) {
966                      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):
975                 throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");
976                 break;
977            case(ReducedDegreesOfFreedom):            case(ReducedDegreesOfFreedom):
978               Finley_Assemble_CopyNodalData(mesh->Nodes,&(target.getDataC()),&(in.getDataC()));               Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
979               break;               break;
980            case(Elements):            case(Elements):
981               Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&(in.getDataC()),&(target.getDataC()));            case(ReducedElements):
982                  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               Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&(in.getDataC()),&(target.getDataC()));            case(ReducedFaceElements):
992                  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.getDataC()),&(target.getDataC()));                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               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));            case(ReducedContactElementsZero):
1012               break;            case(ReducedContactElementsOne):
1013            case(Nodes):                if (getMPISize()>1) {
1014               throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");                   escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1015               break;                   escriptDataC _in2 = temp.getDataC();
1016            case(DegreesOfFreedom):                   Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
1017               throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");                } else {
1018                     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
1019                 }
1020               break;               break;
1021            default:            default:
1022               stringstream temp;               stringstream temp;
# Line 483  void MeshAdapter::setToX(escript::Data& Line 1045  void MeshAdapter::setToX(escript::Data&
1045    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1046    // in case of values node coordinates we can do the job directly:    // in case of values node coordinates we can do the job directly:
1047    if (arg.getFunctionSpace().getTypeCode()==Nodes) {    if (arg.getFunctionSpace().getTypeCode()==Nodes) {
1048       Finley_Assemble_NodeCoordinates(mesh->Nodes,&(arg.getDataC()));       escriptDataC _arg=arg.getDataC();
1049         Finley_Assemble_NodeCoordinates(mesh->Nodes,&_arg);
1050    } else {    } else {
1051       escript::Data tmp_data=Vector(0.0,continuousFunction(asAbstractContinuousDomain()),true);       escript::Data tmp_data=Vector(0.0,continuousFunction(asAbstractContinuousDomain()),true);
1052       Finley_Assemble_NodeCoordinates(mesh->Nodes,&(tmp_data.getDataC()));       escriptDataC _tmp_data=tmp_data.getDataC();
1053         Finley_Assemble_NodeCoordinates(mesh->Nodes,&_tmp_data);
1054       // this is then interpolated onto arg:       // this is then interpolated onto arg:
1055       interpolateOnDomain(arg,tmp_data);       interpolateOnDomain(arg,tmp_data);
1056    }    }
# Line 502  void MeshAdapter::setToNormal(escript::D Line 1066  void MeshAdapter::setToNormal(escript::D
1066    if (normalDomain!=*this)    if (normalDomain!=*this)
1067       throw FinleyAdapterException("Error - Illegal domain of normal locations");       throw FinleyAdapterException("Error - Illegal domain of normal locations");
1068    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1069      escriptDataC _normal=normal.getDataC();
1070    switch(normal.getFunctionSpace().getTypeCode()) {    switch(normal.getFunctionSpace().getTypeCode()) {
1071      case(Nodes):      case(Nodes):
1072        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for nodes");        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for nodes");
1073        break;        break;
1074        case(ReducedNodes):
1075          throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced nodes");
1076          break;
1077      case(Elements):      case(Elements):
1078        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements");        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements");
1079        break;        break;
1080        case(ReducedElements):
1081          throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements with reduced integration order");
1082          break;
1083      case (FaceElements):      case (FaceElements):
1084        Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&(normal.getDataC()));        Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);
1085          break;
1086        case (ReducedFaceElements):
1087          Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);
1088        break;        break;
1089      case(Points):      case(Points):
1090        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for point elements");        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for point elements");
1091        break;        break;
1092      case (ContactElementsOne):      case (ContactElementsOne):
1093      case (ContactElementsZero):      case (ContactElementsZero):
1094        Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&(normal.getDataC()));        Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&_normal);
1095          break;
1096        case (ReducedContactElementsOne):
1097        case (ReducedContactElementsZero):
1098          Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&_normal);
1099        break;        break;
1100      case(DegreesOfFreedom):      case(DegreesOfFreedom):
1101        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for degrees of freedom.");        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for degrees of freedom.");
# Line 555  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();
1141    switch(arg.getFunctionSpace().getTypeCode()) {    switch(arg.getFunctionSpace().getTypeCode()) {
1142       case(Nodes):       case(Nodes):
1143          throw FinleyAdapterException("Error - Integral of data on nodes is not supported.");          temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1144            _temp=temp.getDataC();
1145            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1146            break;
1147         case(ReducedNodes):
1148            temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1149            _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.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);
1154            break;
1155         case(ReducedElements):
1156            Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);
1157          break;          break;
1158       case(FaceElements):       case(FaceElements):
1159          Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);
1160            break;
1161         case(ReducedFaceElements):
1162            Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);
1163          break;          break;
1164       case(Points):       case(Points):
1165          throw FinleyAdapterException("Error - Integral of data on points is not supported.");          throw FinleyAdapterException("Error - Integral of data on points is not supported.");
1166          break;          break;
1167       case(ContactElementsZero):       case(ContactElementsZero):
1168          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1169            break;
1170         case(ReducedContactElementsZero):
1171            Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1172          break;          break;
1173       case(ContactElementsOne):       case(ContactElementsOne):
1174          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1175            break;
1176         case(ReducedContactElementsOne):
1177            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 588  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 603  void MeshAdapter::setToGradient(escript: Line 1209  void MeshAdapter::setToGradient(escript:
1209       throw FinleyAdapterException("Error - Illegal domain of gradient");       throw FinleyAdapterException("Error - Illegal domain of gradient");
1210    
1211    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1212      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.");
1231            break;            break;
1232           case(ReducedNodes):
1233              throw FinleyAdapterException("Error - Gradient at reduced nodes is not supported.");
1234              break;
1235         case(Elements):         case(Elements):
1236            Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&(grad.getDataC()),&nodeDataC);            Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);
1237              break;
1238           case(ReducedElements):
1239              Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);
1240            break;            break;
1241         case(FaceElements):         case(FaceElements):
1242            Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&(grad.getDataC()),&nodeDataC);            Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);
1243              break;
1244           case(ReducedFaceElements):
1245              Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);
1246            break;            break;
1247         case(Points):         case(Points):
1248            throw FinleyAdapterException("Error - Gradient at points is not supported.");            throw FinleyAdapterException("Error - Gradient at points is not supported.");
1249            break;            break;
1250         case(ContactElementsZero):         case(ContactElementsZero):
1251            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&(grad.getDataC()),&nodeDataC);            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1252              break;
1253           case(ReducedContactElementsZero):
1254              Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1255            break;            break;
1256         case(ContactElementsOne):         case(ContactElementsOne):
1257            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&(grad.getDataC()),&nodeDataC);            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1258              break;
1259           case(ReducedContactElementsOne):
1260              Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1261            break;            break;
1262         case(DegreesOfFreedom):         case(DegreesOfFreedom):
1263            throw FinleyAdapterException("Error - Gradient at degrees of freedom is not supported.");            throw FinleyAdapterException("Error - Gradient at degrees of freedom is not supported.");
# Line 661  void MeshAdapter::setToSize(escript::Dat Line 1285  void MeshAdapter::setToSize(escript::Dat
1285         case(Nodes):         case(Nodes):
1286            throw FinleyAdapterException("Error - Size of nodes is not supported.");            throw FinleyAdapterException("Error - Size of nodes is not supported.");
1287            break;            break;
1288           case(ReducedNodes):
1289              throw FinleyAdapterException("Error - Size of reduced nodes is not supported.");
1290              break;
1291         case(Elements):         case(Elements):
1292            Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);            Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);
1293            break;            break;
1294           case(ReducedElements):
1295              Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);
1296              break;
1297         case(FaceElements):         case(FaceElements):
1298            Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);            Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);
1299            break;            break;
1300           case(ReducedFaceElements):
1301              Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);
1302              break;
1303         case(Points):         case(Points):
1304            throw FinleyAdapterException("Error - Size of point elements is not supported.");            throw FinleyAdapterException("Error - Size of point elements is not supported.");
1305            break;            break;
# Line 674  void MeshAdapter::setToSize(escript::Dat Line 1307  void MeshAdapter::setToSize(escript::Dat
1307         case(ContactElementsOne):         case(ContactElementsOne):
1308            Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);            Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);
1309            break;            break;
1310           case(ReducedContactElementsZero):
1311           case(ReducedContactElementsOne):
1312              Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);
1313              break;
1314         case(DegreesOfFreedom):         case(DegreesOfFreedom):
1315            throw FinleyAdapterException("Error - Size of degrees of freedom is not supported.");            throw FinleyAdapterException("Error - Size of degrees of freedom is not supported.");
1316            break;            break;
# Line 718  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 768  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 782  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 839  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 865  bool MeshAdapter::isCellOriented(int fun Line 1507  bool MeshAdapter::isCellOriented(int fun
1507         case(Points):         case(Points):
1508         case(ContactElementsZero):         case(ContactElementsZero):
1509         case(ContactElementsOne):         case(ContactElementsOne):
1510           case(ReducedElements):
1511           case(ReducedFaceElements):
1512           case(ReducedContactElementsZero):
1513           case(ReducedContactElementsOne):
1514            return true;            return true;
1515            break;            break;
1516         default:         default:
# Line 883  bool MeshAdapter::probeInterpolationOnDo Line 1529  bool MeshAdapter::probeInterpolationOnDo
1529       case(Nodes):       case(Nodes):
1530          switch(functionSpaceType_target) {          switch(functionSpaceType_target) {
1531             case(Nodes):             case(Nodes):
1532               case(ReducedNodes):
1533             case(ReducedDegreesOfFreedom):             case(ReducedDegreesOfFreedom):
1534             case(DegreesOfFreedom):             case(DegreesOfFreedom):
1535             case(Elements):             case(Elements):
1536               case(ReducedElements):
1537             case(FaceElements):             case(FaceElements):
1538               case(ReducedFaceElements):
1539             case(Points):             case(Points):
1540             case(ContactElementsZero):             case(ContactElementsZero):
1541               case(ReducedContactElementsZero):
1542             case(ContactElementsOne):             case(ContactElementsOne):
1543               case(ReducedContactElementsOne):
1544                 return true;                 return true;
1545             default:             default:
1546                 stringstream temp;                 stringstream temp;
# Line 897  bool MeshAdapter::probeInterpolationOnDo Line 1548  bool MeshAdapter::probeInterpolationOnDo
1548                 throw FinleyAdapterException(temp.str());                 throw FinleyAdapterException(temp.str());
1549          }          }
1550          break;          break;
1551         case(ReducedNodes):
1552            switch(functionSpaceType_target) {
1553               case(ReducedNodes):
1554               case(ReducedDegreesOfFreedom):
1555               case(Elements):
1556               case(ReducedElements):
1557               case(FaceElements):
1558               case(ReducedFaceElements):
1559               case(Points):
1560               case(ContactElementsZero):
1561               case(ReducedContactElementsZero):
1562               case(ContactElementsOne):
1563               case(ReducedContactElementsOne):
1564                   return true;
1565              case(Nodes):
1566              case(DegreesOfFreedom):
1567                 return false;
1568               default:
1569                   stringstream temp;
1570                   temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1571                   throw FinleyAdapterException(temp.str());
1572            }
1573            break;
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 {
1580               return false;
1581            }
1582         case(ReducedElements):
1583            if (functionSpaceType_target==ReducedElements) {
1584               return true;
1585          } else {          } else {
1586             return false;             return false;
1587          }          }
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 {
1594               return false;
1595            }
1596         case(ReducedFaceElements):
1597            if (functionSpaceType_target==ReducedFaceElements) {
1598               return true;
1599          } else {          } else {
1600             return false;             return false;
1601          }          }
# Line 919  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 {
1615               return false;
1616            }
1617         case(ReducedContactElementsZero):
1618         case(ReducedContactElementsOne):
1619            if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1620               return true;
1621          } else {          } else {
1622             return false;             return false;
1623          }          }
# Line 927  bool MeshAdapter::probeInterpolationOnDo Line 1626  bool MeshAdapter::probeInterpolationOnDo
1626             case(ReducedDegreesOfFreedom):             case(ReducedDegreesOfFreedom):
1627             case(DegreesOfFreedom):             case(DegreesOfFreedom):
1628             case(Nodes):             case(Nodes):
1629               case(ReducedNodes):
1630             case(Elements):             case(Elements):
1631             case(FaceElements):             case(ReducedElements):
1632             case(Points):             case(Points):
1633               case(FaceElements):
1634               case(ReducedFaceElements):
1635             case(ContactElementsZero):             case(ContactElementsZero):
1636               case(ReducedContactElementsZero):
1637             case(ContactElementsOne):             case(ContactElementsOne):
1638               case(ReducedContactElementsOne):
1639                return true;                return true;
1640             default:             default:
1641               stringstream temp;               stringstream temp;
# Line 942  bool MeshAdapter::probeInterpolationOnDo Line 1646  bool MeshAdapter::probeInterpolationOnDo
1646       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
1647         switch(functionSpaceType_target) {         switch(functionSpaceType_target) {
1648            case(ReducedDegreesOfFreedom):            case(ReducedDegreesOfFreedom):
1649              case(ReducedNodes):
1650            case(Elements):            case(Elements):
1651              case(ReducedElements):
1652            case(FaceElements):            case(FaceElements):
1653              case(ReducedFaceElements):
1654            case(Points):            case(Points):
1655            case(ContactElementsZero):            case(ContactElementsZero):
1656              case(ReducedContactElementsZero):
1657            case(ContactElementsOne):            case(ContactElementsOne):
1658              case(ReducedContactElementsOne):
1659                return true;                return true;
1660            case(Nodes):            case(Nodes):
1661            case(DegreesOfFreedom):            case(DegreesOfFreedom):
# Line 1009  escript::Data MeshAdapter::getSize() con Line 1718  escript::Data MeshAdapter::getSize() con
1718    return function(asAbstractContinuousDomain()).getSize();    return function(asAbstractContinuousDomain()).getSize();
1719  }  }
1720    
1721    int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const
1722    {
1723      int *out=0,i;
1724      Finley_Mesh* mesh=m_finleyMesh.get();
1725      switch (functionSpaceType) {
1726        case(Nodes):
1727          out=mesh->Nodes->Id;
1728          break;
1729        case(ReducedNodes):
1730          out=mesh->Nodes->reducedNodesId;
1731          break;
1732        case(Elements):
1733          out=mesh->Elements->Id;
1734          break;
1735        case(ReducedElements):
1736          out=mesh->Elements->Id;
1737          break;
1738        case(FaceElements):
1739          out=mesh->FaceElements->Id;
1740          break;
1741        case(ReducedFaceElements):
1742          out=mesh->FaceElements->Id;
1743          break;
1744        case(Points):
1745          out=mesh->Points->Id;
1746          break;
1747        case(ContactElementsZero):
1748          out=mesh->ContactElements->Id;
1749          break;
1750        case(ReducedContactElementsZero):
1751          out=mesh->ContactElements->Id;
1752          break;
1753        case(ContactElementsOne):
1754          out=mesh->ContactElements->Id;
1755          break;
1756        case(ReducedContactElementsOne):
1757          out=mesh->ContactElements->Id;
1758          break;
1759        case(DegreesOfFreedom):
1760          out=mesh->Nodes->degreesOfFreedomId;
1761          break;
1762        case(ReducedDegreesOfFreedom):
1763          out=mesh->Nodes->reducedDegreesOfFreedomId;
1764          break;
1765        default:
1766          stringstream temp;
1767          temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
1768          throw FinleyAdapterException(temp.str());
1769          break;
1770      }
1771      return out;
1772    }
1773  int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const  int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const
1774  {  {
1775    int out=0;    int out=0;
# Line 1017  int MeshAdapter::getTagFromSampleNo(int Line 1778  int MeshAdapter::getTagFromSampleNo(int
1778    case(Nodes):    case(Nodes):
1779      out=mesh->Nodes->Tag[sampleNo];      out=mesh->Nodes->Tag[sampleNo];
1780      break;      break;
1781      case(ReducedNodes):
1782        throw FinleyAdapterException(" Error - ReducedNodes does not support tags.");
1783        break;
1784    case(Elements):    case(Elements):
1785      out=mesh->Elements->Tag[sampleNo];      out=mesh->Elements->Tag[sampleNo];
1786      break;      break;
1787      case(ReducedElements):
1788        out=mesh->Elements->Tag[sampleNo];
1789        break;
1790    case(FaceElements):    case(FaceElements):
1791      out=mesh->FaceElements->Tag[sampleNo];      out=mesh->FaceElements->Tag[sampleNo];
1792      break;      break;
1793      case(ReducedFaceElements):
1794        out=mesh->FaceElements->Tag[sampleNo];
1795        break;
1796    case(Points):    case(Points):
1797      out=mesh->Points->Tag[sampleNo];      out=mesh->Points->Tag[sampleNo];
1798      break;      break;
1799    case(ContactElementsZero):    case(ContactElementsZero):
1800      out=mesh->ContactElements->Tag[sampleNo];      out=mesh->ContactElements->Tag[sampleNo];
1801      break;      break;
1802    case(ContactElementsOne):    case(ReducedContactElementsZero):
1803      out=mesh->ContactElements->Tag[sampleNo];      out=mesh->ContactElements->Tag[sampleNo];
1804      break;      break;
   case(DegreesOfFreedom):  
     break;  
   case(ReducedDegreesOfFreedom):  
     break;  
   default:  
     stringstream temp;  
     temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();  
     throw FinleyAdapterException(temp.str());  
     break;  
   }  
   return out;  
 }  
 int MeshAdapter::getReferenceNoFromSampleNo(int functionSpaceType, int sampleNo) const  
 {  
   int out=0,i;  
   Finley_Mesh* mesh=m_finleyMesh.get();  
   switch (functionSpaceType) {  
   case(Nodes):  
     if (mesh->Nodes!=NULL) {  
       out=mesh->Nodes->Id[sampleNo];  
       break;  
     }  
   case(Elements):  
     out=mesh->Elements->Id[sampleNo];  
     break;  
   case(FaceElements):  
     out=mesh->FaceElements->Id[sampleNo];  
     break;  
   case(Points):  
     out=mesh->Points->Id[sampleNo];  
     break;  
   case(ContactElementsZero):  
     out=mesh->ContactElements->Id[sampleNo];  
     break;  
1805    case(ContactElementsOne):    case(ContactElementsOne):
1806      out=mesh->ContactElements->Id[sampleNo];      out=mesh->ContactElements->Tag[sampleNo];
1807        break;
1808      case(ReducedContactElementsOne):
1809        out=mesh->ContactElements->Tag[sampleNo];
1810      break;      break;
1811    case(DegreesOfFreedom):    case(DegreesOfFreedom):
1812      for (i=0;i<mesh->Nodes->numNodes; ++i) {      throw FinleyAdapterException(" Error - DegreesOfFreedom does not support tags.");
        if (mesh->Nodes->degreeOfFreedom[i]==sampleNo) {  
           out=mesh->Nodes->Id[i];  
           break;  
        }  
     }  
1813      break;      break;
1814    case(ReducedDegreesOfFreedom):    case(ReducedDegreesOfFreedom):
1815      for (i=0;i<mesh->Nodes->numNodes; ++i) {      throw FinleyAdapterException(" Error - ReducedDegreesOfFreedom does not support tags.");
        if (mesh->Nodes->reducedDegreeOfFreedom[i]==sampleNo) {  
           out=mesh->Nodes->Id[i];  
           break;  
        }  
     }  
1816      break;      break;
1817    default:    default:
1818      stringstream temp;      stringstream temp;
# Line 1094  int MeshAdapter::getReferenceNoFromSampl Line 1823  int MeshAdapter::getReferenceNoFromSampl
1823    return out;    return out;
1824  }  }
1825    
1826    
1827  void MeshAdapter::setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const  void MeshAdapter::setTags(const int functionSpaceType, const int newTag, const escript::Data& mask) const
1828  {  {
1829    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
# Line 1102  void MeshAdapter::setTags(const int func Line 1832  void MeshAdapter::setTags(const int func
1832         case(Nodes):         case(Nodes):
1833            Finley_NodeFile_setTags(mesh->Nodes,newTag,&tmp);            Finley_NodeFile_setTags(mesh->Nodes,newTag,&tmp);
1834            break;            break;
1835           case(ReducedNodes):
1836              throw FinleyAdapterException("Error - ReducedNodes does not support tags");
1837              break;
1838         case(DegreesOfFreedom):         case(DegreesOfFreedom):
1839            throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");            throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");
1840            break;            break;
# Line 1111  void MeshAdapter::setTags(const int func Line 1844  void MeshAdapter::setTags(const int func
1844         case(Elements):         case(Elements):
1845            Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);            Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);
1846            break;            break;
1847           case(ReducedElements):
1848              Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);
1849              break;
1850         case(FaceElements):         case(FaceElements):
1851            Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);            Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);
1852            break;            break;
1853           case(ReducedFaceElements):
1854              Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);
1855              break;
1856         case(Points):         case(Points):
1857            Finley_ElementFile_setTags(mesh->Points,newTag,&tmp);            Finley_ElementFile_setTags(mesh->Points,newTag,&tmp);
1858            break;            break;
1859         case(ContactElementsZero):         case(ContactElementsZero):
1860            Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);            Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
1861            break;            break;
1862           case(ReducedContactElementsZero):
1863              Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
1864              break;
1865         case(ContactElementsOne):         case(ContactElementsOne):
1866            Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);            Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
1867            break;            break;
1868           case(ReducedContactElementsOne):
1869              Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
1870              break;
1871         default:         default:
1872            stringstream temp;            stringstream temp;
1873            temp << "Error - Finley does not know anything about function space type " << functionSpaceType;            temp << "Error - Finley does not know anything about function space type " << functionSpaceType;
# Line 1132  void MeshAdapter::setTags(const int func Line 1877  void MeshAdapter::setTags(const int func
1877    return;    return;
1878  }  }
1879    
1880    void MeshAdapter::setTagMap(const std::string& name,  int tag)
1881    {
1882      Finley_Mesh* mesh=m_finleyMesh.get();
1883      Finley_Mesh_addTagMap(mesh, name.c_str(),tag);
1884      checkPasoError();
1885      // throwStandardException("MeshAdapter::set TagMap is not implemented.");
1886    }
1887    
1888    int MeshAdapter::getTag(const std::string& name) const
1889    {
1890      Finley_Mesh* mesh=m_finleyMesh.get();
1891      int tag=0;
1892      tag=Finley_Mesh_getTag(mesh, name.c_str());
1893      checkPasoError();
1894      // throwStandardException("MeshAdapter::getTag is not implemented.");
1895      return tag;
1896    }
1897    
1898    bool MeshAdapter::isValidTagName(const std::string& name) const
1899    {
1900      Finley_Mesh* mesh=m_finleyMesh.get();
1901      return Finley_Mesh_isValidTagName(mesh,name.c_str());
1902    }
1903    
1904    std::string MeshAdapter::showTagNames() const
1905    {
1906      stringstream temp;
1907      Finley_Mesh* mesh=m_finleyMesh.get();
1908      Finley_TagMap* tag_map=mesh->TagMap;
1909      while (tag_map) {
1910         temp << tag_map->name;
1911         tag_map=tag_map->next;
1912         if (tag_map) temp << ", ";
1913      }
1914      return temp.str();
1915    }
1916    
1917  }  // end of namespace  }  // end of namespace

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

  ViewVC Help
Powered by ViewVC 1.1.26