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

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

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

revision 1116 by gross, Mon Apr 23 03:36:34 2007 UTC revision 1754 by ksteube, Sun Sep 7 22:07:26 2008 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    #define IS_THERE_A_REASON_FOR_THIS_MAGIC_NAME_LENGTH  256
28    
29  using namespace std;  using namespace std;
30  using namespace escript;  using namespace escript;
# Line 45  const int MeshAdapter::ReducedContactEle Line 50  const int MeshAdapter::ReducedContactEle
50    
51  MeshAdapter::MeshAdapter(Finley_Mesh* finleyMesh)  MeshAdapter::MeshAdapter(Finley_Mesh* finleyMesh)
52  {  {
53    setFunctionSpaceTypeNames();     setFunctionSpaceTypeNames();
54    //     //
55    // 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
56    // for us.     // for us.
57    m_finleyMesh.reset(finleyMesh,null_deleter());     m_finleyMesh.reset(finleyMesh,null_deleter());
58  }  }
59    
60  //  //
# Line 57  MeshAdapter::MeshAdapter(Finley_Mesh* fi Line 62  MeshAdapter::MeshAdapter(Finley_Mesh* fi
62  MeshAdapter::MeshAdapter(const MeshAdapter& in):  MeshAdapter::MeshAdapter(const MeshAdapter& in):
63  m_finleyMesh(in.m_finleyMesh)  m_finleyMesh(in.m_finleyMesh)
64  {  {
65    setFunctionSpaceTypeNames();     setFunctionSpaceTypeNames();
66  }  }
67    
68  MeshAdapter::~MeshAdapter()  MeshAdapter::~MeshAdapter()
69  {  {
70    //     //
71    // 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.
72    //  cout << "In MeshAdapter destructor." << endl;     //  cout << "In MeshAdapter destructor." << endl;
73    if (m_finleyMesh.unique()) {     if (m_finleyMesh.unique()) {
74      //   cout << "Calling dealloc." << endl;        Finley_Mesh_free(m_finleyMesh.get());
75      Finley_Mesh_dealloc(m_finleyMesh.get());     }
     //   cout << "Finished dealloc." << endl;  
   }  
76  }  }
77    
78    int MeshAdapter::getMPISize() const
79    {
80       return m_finleyMesh.get()->MPIInfo->size;
81    }
82    int MeshAdapter::getMPIRank() const
83    {
84       return m_finleyMesh.get()->MPIInfo->rank;
85    }
86    
87    
88  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {
89     return m_finleyMesh.get();     return m_finleyMesh.get();
90  }  }
91    
92  void MeshAdapter::write(const std::string& fileName) const  void MeshAdapter::write(const std::string& fileName) const
93  {  {
94    char *fName = (fileName.size()+1>0) ? TMPMEMALLOC(fileName.size()+1,char) : (char*)NULL;     char *fName = (fileName.size()+1>0) ? TMPMEMALLOC(fileName.size()+1,char) : (char*)NULL;
95    strcpy(fName,fileName.c_str());     strcpy(fName,fileName.c_str());
96    Finley_Mesh_write(m_finleyMesh.get(),fName);     Finley_Mesh_write(m_finleyMesh.get(),fName);
97    checkFinleyError();     checkFinleyError();
98    TMPMEMFREE(fName);     TMPMEMFREE(fName);
99    }
100    
101    void MeshAdapter::Print_Mesh_Info(const bool full=false) const
102    {
103       Finley_PrintMesh_Info(m_finleyMesh.get(), full);
104    }
105    
106    void MeshAdapter::dump(const std::string& fileName) const
107    {
108    #ifdef USE_NETCDF
109       const NcDim* ncdims[12];
110       NcVar *ids;
111       int *int_ptr;
112       Finley_Mesh *mesh = m_finleyMesh.get();
113       Finley_TagMap* tag_map;
114       int num_Tags = 0;
115       int mpi_size             = mesh->MPIInfo->size;
116       int mpi_rank             = mesh->MPIInfo->rank;
117       int numDim               = mesh->Nodes->numDim;
118       int numNodes             = mesh->Nodes->numNodes;
119       int num_Elements         = mesh->Elements->numElements;
120       int num_FaceElements         = mesh->FaceElements->numElements;
121       int num_ContactElements      = mesh->ContactElements->numElements;
122       int num_Points           = mesh->Points->numElements;
123       int num_Elements_numNodes        = mesh->Elements->numNodes;
124       int num_FaceElements_numNodes    = mesh->FaceElements->numNodes;
125       int num_ContactElements_numNodes = mesh->ContactElements->numNodes;
126    
127       char *newFileName = Paso_MPI_appendRankToFileName(fileName.c_str(),
128                                                         mpi_size, mpi_rank);
129    
130       /* Figure out how much storage is required for tags */
131       tag_map = mesh->TagMap;
132       if (tag_map) {
133          while (tag_map) {
134             num_Tags++;
135             tag_map=tag_map->next;
136          }
137       }
138    
139       // NetCDF error handler
140       NcError err(NcError::verbose_nonfatal);
141       // Create the file.
142       NcFile dataFile(newFileName, NcFile::Replace);
143       // check if writing was successful
144       if (!dataFile.is_valid())
145          throw DataException("Error - MeshAdapter::dump: opening of NetCDF file for output failed: " + *newFileName);
146    
147       // Define dimensions (num_Elements and dim_Elements are identical, dim_Elements only appears if > 0)
148       if (! (ncdims[0] = dataFile.add_dim("numNodes", numNodes)) )
149          throw DataException("Error - MeshAdapter::dump: appending dimension numNodes to netCDF file failed: " + *newFileName);
150       if (! (ncdims[1] = dataFile.add_dim("numDim", numDim)) )
151          throw DataException("Error - MeshAdapter::dump: appending dimension numDim to netCDF file failed: " + *newFileName);
152       if (! (ncdims[2] = dataFile.add_dim("mpi_size_plus_1", mpi_size+1)) )
153          throw DataException("Error - MeshAdapter::dump: appending dimension mpi_size to netCDF file failed: " + *newFileName);
154       if (num_Elements>0)
155          if (! (ncdims[3] = dataFile.add_dim("dim_Elements", num_Elements)) )
156             throw DataException("Error - MeshAdapter::dump: appending dimension dim_Elements to netCDF file failed: " + *newFileName);
157       if (num_FaceElements>0)
158          if (! (ncdims[4] = dataFile.add_dim("dim_FaceElements", num_FaceElements)) )
159             throw DataException("Error - MeshAdapter::dump: appending dimension dim_FaceElements to netCDF file failed: " + *newFileName);
160       if (num_ContactElements>0)
161          if (! (ncdims[5] = dataFile.add_dim("dim_ContactElements", num_ContactElements)) )
162             throw DataException("Error - MeshAdapter::dump: appending dimension dim_ContactElements to netCDF file failed: " + *newFileName);
163       if (num_Points>0)
164          if (! (ncdims[6] = dataFile.add_dim("dim_Points", num_Points)) )
165             throw DataException("Error - MeshAdapter::dump: appending dimension dim_Points to netCDF file failed: " + *newFileName);
166       if (num_Elements>0)
167          if (! (ncdims[7] = dataFile.add_dim("dim_Elements_Nodes", num_Elements_numNodes)) )
168             throw DataException("Error - MeshAdapter::dump: appending dimension dim_Elements_Nodes to netCDF file failed: " + *newFileName);
169       if (num_FaceElements>0)
170          if (! (ncdims[8] = dataFile.add_dim("dim_FaceElements_numNodes", num_FaceElements_numNodes)) )
171             throw DataException("Error - MeshAdapter::dump: appending dimension dim_FaceElements_numNodes to netCDF file failed: " + *newFileName);
172       if (num_ContactElements>0)
173          if (! (ncdims[9] = dataFile.add_dim("dim_ContactElements_numNodes", num_ContactElements_numNodes)) )
174             throw DataException("Error - MeshAdapter::dump: appending dimension dim_ContactElements_numNodes to netCDF file failed: " + *newFileName);
175       if (num_Tags>0)
176          if (! (ncdims[10] = dataFile.add_dim("dim_Tags", num_Tags)) )
177             throw DataException("Error - MeshAdapter::dump: appending dimension dim_Tags to netCDF file failed: " + *newFileName);
178    
179       // Attributes: MPI size, MPI rank, Name, order, reduced_order
180       if (!dataFile.add_att("mpi_size", mpi_size) )
181          throw DataException("Error - MeshAdapter::dump: appending mpi_size to NetCDF file failed: " + *newFileName);
182       if (!dataFile.add_att("mpi_rank", mpi_rank) )
183          throw DataException("Error - MeshAdapter::dump: appending mpi_rank to NetCDF file failed: " + *newFileName);
184       if (!dataFile.add_att("Name",mesh->Name) )
185          throw DataException("Error - MeshAdapter::dump: appending Name to NetCDF file failed: " + *newFileName);
186       if (!dataFile.add_att("numDim",numDim) )
187          throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);
188       if (!dataFile.add_att("order",mesh->order) )
189          throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);
190       if (!dataFile.add_att("reduced_order",mesh->reduced_order) )
191          throw DataException("Error - MeshAdapter::dump: appending reduced_order to NetCDF file failed: " + *newFileName);
192       if (!dataFile.add_att("numNodes",numNodes) )
193          throw DataException("Error - MeshAdapter::dump: appending numNodes to NetCDF file failed: " + *newFileName);
194       if (!dataFile.add_att("num_Elements",num_Elements) )
195          throw DataException("Error - MeshAdapter::dump: appending num_Elements to NetCDF file failed: " + *newFileName);
196       if (!dataFile.add_att("num_FaceElements",num_FaceElements) )
197          throw DataException("Error - MeshAdapter::dump: appending num_FaceElements to NetCDF file failed: " + *newFileName);
198       if (!dataFile.add_att("num_ContactElements",num_ContactElements) )
199          throw DataException("Error - MeshAdapter::dump: appending num_ContactElements to NetCDF file failed: " + *newFileName);
200       if (!dataFile.add_att("num_Points",num_Points) )
201          throw DataException("Error - MeshAdapter::dump: appending num_Points to NetCDF file failed: " + *newFileName);
202       if (!dataFile.add_att("num_Elements_numNodes",num_Elements_numNodes) )
203          throw DataException("Error - MeshAdapter::dump: appending num_Elements_numNodes to NetCDF file failed: " + *newFileName);
204       if (!dataFile.add_att("num_FaceElements_numNodes",num_FaceElements_numNodes) )
205          throw DataException("Error - MeshAdapter::dump: appending num_FaceElements_numNodes to NetCDF file failed: " + *newFileName);
206       if (!dataFile.add_att("num_ContactElements_numNodes",num_ContactElements_numNodes) )
207          throw DataException("Error - MeshAdapter::dump: appending num_ContactElements_numNodes to NetCDF file failed: " + *newFileName);
208       if (!dataFile.add_att("Elements_TypeId", mesh->Elements->ReferenceElement->Type->TypeId) )
209          throw DataException("Error - MeshAdapter::dump: appending Elements_TypeId to NetCDF file failed: " + *newFileName);
210       if (!dataFile.add_att("FaceElements_TypeId", mesh->FaceElements->ReferenceElement->Type->TypeId) )
211          throw DataException("Error - MeshAdapter::dump: appending FaceElements_TypeId to NetCDF file failed: " + *newFileName);
212       if (!dataFile.add_att("ContactElements_TypeId", mesh->ContactElements->ReferenceElement->Type->TypeId) )
213          throw DataException("Error - MeshAdapter::dump: appending ContactElements_TypeId to NetCDF file failed: " + *newFileName);
214       if (!dataFile.add_att("Points_TypeId", mesh->Points->ReferenceElement->Type->TypeId) )
215          throw DataException("Error - MeshAdapter::dump: appending Points_TypeId to NetCDF file failed: " + *newFileName);
216       if (!dataFile.add_att("num_Tags", num_Tags) )
217          throw DataException("Error - MeshAdapter::dump: appending num_Tags to NetCDF file failed: " + *newFileName);
218    
219       // // // // // Nodes // // // // //
220    
221       // Only write nodes if non-empty because NetCDF doesn't like empty arrays (it treats them as NC_UNLIMITED)
222       if (numNodes>0) {
223    
224          // Nodes Id
225          if (! ( ids = dataFile.add_var("Nodes_Id", ncInt, ncdims[0])) )
226             throw DataException("Error - MeshAdapter::dump: appending Nodes_Id to netCDF file failed: " + *newFileName);
227          int_ptr = &mesh->Nodes->Id[0];
228          if (! (ids->put(int_ptr, numNodes)) )
229             throw DataException("Error - MeshAdapter::dump: copy Nodes_Id to netCDF buffer failed: " + *newFileName);
230    
231          // Nodes Tag
232          if (! ( ids = dataFile.add_var("Nodes_Tag", ncInt, ncdims[0])) )
233             throw DataException("Error - MeshAdapter::dump: appending Nodes_Tag to netCDF file failed: " + *newFileName);
234          int_ptr = &mesh->Nodes->Tag[0];
235          if (! (ids->put(int_ptr, numNodes)) )
236             throw DataException("Error - MeshAdapter::dump: copy Nodes_Tag to netCDF buffer failed: " + *newFileName);
237    
238          // Nodes gDOF
239          if (! ( ids = dataFile.add_var("Nodes_gDOF", ncInt, ncdims[0])) )
240             throw DataException("Error - MeshAdapter::dump: appending Nodes_gDOF to netCDF file failed: " + *newFileName);
241          int_ptr = &mesh->Nodes->globalDegreesOfFreedom[0];
242          if (! (ids->put(int_ptr, numNodes)) )
243             throw DataException("Error - MeshAdapter::dump: copy Nodes_gDOF to netCDF buffer failed: " + *newFileName);
244    
245          // Nodes global node index
246          if (! ( ids = dataFile.add_var("Nodes_gNI", ncInt, ncdims[0])) )
247             throw DataException("Error - MeshAdapter::dump: appending Nodes_gNI to netCDF file failed: " + *newFileName);
248          int_ptr = &mesh->Nodes->globalNodesIndex[0];
249          if (! (ids->put(int_ptr, numNodes)) )
250             throw DataException("Error - MeshAdapter::dump: copy Nodes_gNI to netCDF buffer failed: " + *newFileName);
251    
252          // Nodes grDof
253          if (! ( ids = dataFile.add_var("Nodes_grDfI", ncInt, ncdims[0])) )
254             throw DataException("Error - MeshAdapter::dump: appending Nodes_grDfI to netCDF file failed: " + *newFileName);
255          int_ptr = &mesh->Nodes->globalReducedDOFIndex[0];
256          if (! (ids->put(int_ptr, numNodes)) )
257             throw DataException("Error - MeshAdapter::dump: copy Nodes_grDfI to netCDF buffer failed: " + *newFileName);
258    
259          // Nodes grNI
260          if (! ( ids = dataFile.add_var("Nodes_grNI", ncInt, ncdims[0])) )
261             throw DataException("Error - MeshAdapter::dump: appending Nodes_grNI to netCDF file failed: " + *newFileName);
262          int_ptr = &mesh->Nodes->globalReducedNodesIndex[0];
263          if (! (ids->put(int_ptr, numNodes)) )
264             throw DataException("Error - MeshAdapter::dump: copy Nodes_grNI to netCDF buffer failed: " + *newFileName);
265    
266          // Nodes Coordinates
267          if (! ( ids = dataFile.add_var("Nodes_Coordinates", ncDouble, ncdims[0], ncdims[1]) ) )
268             throw DataException("Error - MeshAdapter::dump: appending Nodes_Coordinates to netCDF file failed: " + *newFileName);
269          if (! (ids->put(&(mesh->Nodes->Coordinates[INDEX2(0,0,numDim)]), numNodes, numDim)) )
270             throw DataException("Error - MeshAdapter::dump: copy Nodes_Coordinates to netCDF buffer failed: " + *newFileName);
271    
272          // Nodes degreesOfFreedomDistribution
273          if (! ( ids = dataFile.add_var("Nodes_DofDistribution", ncInt, ncdims[2])) )
274             throw DataException("Error - MeshAdapter::dump: appending Nodes_DofDistribution to netCDF file failed: " + *newFileName);
275          int_ptr = &mesh->Nodes->degreesOfFreedomDistribution->first_component[0];
276          if (! (ids->put(int_ptr, mpi_size+1)) )
277             throw DataException("Error - MeshAdapter::dump: copy Nodes_DofDistribution to netCDF buffer failed: " + *newFileName);
278    
279       }
280    
281       // // // // // Elements // // // // //
282    
283       if (num_Elements>0) {
284    
285          // Temp storage to gather node IDs
286          int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);
287    
288          // Elements_Id
289          if (! ( ids = dataFile.add_var("Elements_Id", ncInt, ncdims[3])) )
290             throw DataException("Error - MeshAdapter::dump: appending Elements_Id to netCDF file failed: " + *newFileName);
291          int_ptr = &mesh->Elements->Id[0];
292          if (! (ids->put(int_ptr, num_Elements)) )
293             throw DataException("Error - MeshAdapter::dump: copy Elements_Id to netCDF buffer failed: " + *newFileName);
294    
295          // Elements_Tag
296          if (! ( ids = dataFile.add_var("Elements_Tag", ncInt, ncdims[3])) )
297             throw DataException("Error - MeshAdapter::dump: appending Elements_Tag to netCDF file failed: " + *newFileName);
298          int_ptr = &mesh->Elements->Tag[0];
299          if (! (ids->put(int_ptr, num_Elements)) )
300             throw DataException("Error - MeshAdapter::dump: copy Elements_Tag to netCDF buffer failed: " + *newFileName);
301    
302          // Elements_Owner
303          if (! ( ids = dataFile.add_var("Elements_Owner", ncInt, ncdims[3])) )
304             throw DataException("Error - MeshAdapter::dump: appending Elements_Owner to netCDF file failed: " + *newFileName);
305          int_ptr = &mesh->Elements->Owner[0];
306          if (! (ids->put(int_ptr, num_Elements)) )
307             throw DataException("Error - MeshAdapter::dump: copy Elements_Owner to netCDF buffer failed: " + *newFileName);
308    
309          // Elements_Color
310          if (! ( ids = dataFile.add_var("Elements_Color", ncInt, ncdims[3])) )
311             throw DataException("Error - MeshAdapter::dump: appending Elements_Color to netCDF file failed: " + *newFileName);
312          int_ptr = &mesh->Elements->Color[0];
313          if (! (ids->put(int_ptr, num_Elements)) )
314             throw DataException("Error - MeshAdapter::dump: copy Elements_Color to netCDF buffer failed: " + *newFileName);
315    
316          // Elements_Nodes
317          for (int i=0; i<num_Elements; i++)
318             for (int j=0; j<num_Elements_numNodes; j++)
319                Elements_Nodes[INDEX2(j,i,num_Elements_numNodes)] = mesh->Nodes->Id[mesh->Elements->Nodes[INDEX2(j,i,num_Elements_numNodes)]];
320          if (! ( ids = dataFile.add_var("Elements_Nodes", ncInt, ncdims[3], ncdims[7]) ) )
321             throw DataException("Error - MeshAdapter::dump: appending Elements_Nodes to netCDF file failed: " + *newFileName);
322          if (! (ids->put(&(Elements_Nodes[0]), num_Elements, num_Elements_numNodes)) )
323             throw DataException("Error - MeshAdapter::dump: copy Elements_Nodes to netCDF buffer failed: " + *newFileName);
324    
325          TMPMEMFREE(Elements_Nodes);
326    
327       }
328    
329       // // // // // Face_Elements // // // // //
330    
331       if (num_FaceElements>0) {
332    
333          // Temp storage to gather node IDs
334          int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);
335    
336          // FaceElements_Id
337          if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )
338             throw DataException("Error - MeshAdapter::dump: appending FaceElements_Id to netCDF file failed: " + *newFileName);
339          int_ptr = &mesh->FaceElements->Id[0];
340          if (! (ids->put(int_ptr, num_FaceElements)) )
341             throw DataException("Error - MeshAdapter::dump: copy FaceElements_Id to netCDF buffer failed: " + *newFileName);
342    
343          // FaceElements_Tag
344          if (! ( ids = dataFile.add_var("FaceElements_Tag", ncInt, ncdims[4])) )
345             throw DataException("Error - MeshAdapter::dump: appending FaceElements_Tag to netCDF file failed: " + *newFileName);
346          int_ptr = &mesh->FaceElements->Tag[0];
347          if (! (ids->put(int_ptr, num_FaceElements)) )
348             throw DataException("Error - MeshAdapter::dump: copy FaceElements_Tag to netCDF buffer failed: " + *newFileName);
349    
350          // FaceElements_Owner
351          if (! ( ids = dataFile.add_var("FaceElements_Owner", ncInt, ncdims[4])) )
352             throw DataException("Error - MeshAdapter::dump: appending FaceElements_Owner to netCDF file failed: " + *newFileName);
353          int_ptr = &mesh->FaceElements->Owner[0];
354          if (! (ids->put(int_ptr, num_FaceElements)) )
355             throw DataException("Error - MeshAdapter::dump: copy FaceElements_Owner to netCDF buffer failed: " + *newFileName);
356    
357          // FaceElements_Color
358          if (! ( ids = dataFile.add_var("FaceElements_Color", ncInt, ncdims[4])) )
359             throw DataException("Error - MeshAdapter::dump: appending FaceElements_Color to netCDF file failed: " + *newFileName);
360          int_ptr = &mesh->FaceElements->Color[0];
361          if (! (ids->put(int_ptr, num_FaceElements)) )
362             throw DataException("Error - MeshAdapter::dump: copy FaceElements_Color to netCDF buffer failed: " + *newFileName);
363    
364          // FaceElements_Nodes
365          for (int i=0; i<num_FaceElements; i++)
366             for (int j=0; j<num_FaceElements_numNodes; j++)
367                FaceElements_Nodes[INDEX2(j,i,num_FaceElements_numNodes)] = mesh->Nodes->Id[mesh->FaceElements->Nodes[INDEX2(j,i,num_FaceElements_numNodes)]];
368          if (! ( ids = dataFile.add_var("FaceElements_Nodes", ncInt, ncdims[4], ncdims[8]) ) )
369             throw DataException("Error - MeshAdapter::dump: appending FaceElements_Nodes to netCDF file failed: " + *newFileName);
370          if (! (ids->put(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )
371             throw DataException("Error - MeshAdapter::dump: copy FaceElements_Nodes to netCDF buffer failed: " + *newFileName);
372    
373          TMPMEMFREE(FaceElements_Nodes);
374    
375       }
376    
377       // // // // // Contact_Elements // // // // //
378    
379       if (num_ContactElements>0) {
380    
381          // Temp storage to gather node IDs
382          int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);
383    
384          // ContactElements_Id
385          if (! ( ids = dataFile.add_var("ContactElements_Id", ncInt, ncdims[5])) )
386             throw DataException("Error - MeshAdapter::dump: appending ContactElements_Id to netCDF file failed: " + *newFileName);
387          int_ptr = &mesh->ContactElements->Id[0];
388          if (! (ids->put(int_ptr, num_ContactElements)) )
389             throw DataException("Error - MeshAdapter::dump: copy ContactElements_Id to netCDF buffer failed: " + *newFileName);
390    
391          // ContactElements_Tag
392          if (! ( ids = dataFile.add_var("ContactElements_Tag", ncInt, ncdims[5])) )
393             throw DataException("Error - MeshAdapter::dump: appending ContactElements_Tag to netCDF file failed: " + *newFileName);
394          int_ptr = &mesh->ContactElements->Tag[0];
395          if (! (ids->put(int_ptr, num_ContactElements)) )
396             throw DataException("Error - MeshAdapter::dump: copy ContactElements_Tag to netCDF buffer failed: " + *newFileName);
397    
398          // ContactElements_Owner
399          if (! ( ids = dataFile.add_var("ContactElements_Owner", ncInt, ncdims[5])) )
400             throw DataException("Error - MeshAdapter::dump: appending ContactElements_Owner to netCDF file failed: " + *newFileName);
401          int_ptr = &mesh->ContactElements->Owner[0];
402          if (! (ids->put(int_ptr, num_ContactElements)) )
403             throw DataException("Error - MeshAdapter::dump: copy ContactElements_Owner to netCDF buffer failed: " + *newFileName);
404    
405          // ContactElements_Color
406          if (! ( ids = dataFile.add_var("ContactElements_Color", ncInt, ncdims[5])) )
407             throw DataException("Error - MeshAdapter::dump: appending ContactElements_Color to netCDF file failed: " + *newFileName);
408          int_ptr = &mesh->ContactElements->Color[0];
409          if (! (ids->put(int_ptr, num_ContactElements)) )
410             throw DataException("Error - MeshAdapter::dump: copy ContactElements_Color to netCDF buffer failed: " + *newFileName);
411    
412          // ContactElements_Nodes
413          for (int i=0; i<num_ContactElements; i++)
414             for (int j=0; j<num_ContactElements_numNodes; j++)
415                ContactElements_Nodes[INDEX2(j,i,num_ContactElements_numNodes)] = mesh->Nodes->Id[mesh->ContactElements->Nodes[INDEX2(j,i,num_ContactElements_numNodes)]];
416          if (! ( ids = dataFile.add_var("ContactElements_Nodes", ncInt, ncdims[5], ncdims[9]) ) )
417             throw DataException("Error - MeshAdapter::dump: appending ContactElements_Nodes to netCDF file failed: " + *newFileName);
418          if (! (ids->put(&(ContactElements_Nodes[0]), num_ContactElements, num_ContactElements_numNodes)) )
419             throw DataException("Error - MeshAdapter::dump: copy ContactElements_Nodes to netCDF buffer failed: " + *newFileName);
420    
421          TMPMEMFREE(ContactElements_Nodes);
422    
423       }
424    
425       // // // // // Points // // // // //
426    
427       if (num_Points>0) {
428    
429          fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump has not been tested with Point elements\n\n\n");
430    
431          // Temp storage to gather node IDs
432          int *Points_Nodes = TMPMEMALLOC(num_Points,int);
433    
434          // Points_Id
435          if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )
436             throw DataException("Error - MeshAdapter::dump: appending Points_Id to netCDF file failed: " + *newFileName);
437          int_ptr = &mesh->Points->Id[0];
438          if (! (ids->put(int_ptr, num_Points)) )
439             throw DataException("Error - MeshAdapter::dump: copy Points_Id to netCDF buffer failed: " + *newFileName);
440    
441          // Points_Tag
442          if (! ( ids = dataFile.add_var("Points_Tag", ncInt, ncdims[6])) )
443             throw DataException("Error - MeshAdapter::dump: appending Points_Tag to netCDF file failed: " + *newFileName);
444          int_ptr = &mesh->Points->Tag[0];
445          if (! (ids->put(int_ptr, num_Points)) )
446             throw DataException("Error - MeshAdapter::dump: copy Points_Tag to netCDF buffer failed: " + *newFileName);
447    
448          // Points_Owner
449          if (! ( ids = dataFile.add_var("Points_Owner", ncInt, ncdims[6])) )
450             throw DataException("Error - MeshAdapter::dump: appending Points_Owner to netCDF file failed: " + *newFileName);
451          int_ptr = &mesh->Points->Owner[0];
452          if (! (ids->put(int_ptr, num_Points)) )
453             throw DataException("Error - MeshAdapter::dump: copy Points_Owner to netCDF buffer failed: " + *newFileName);
454    
455          // Points_Color
456          if (! ( ids = dataFile.add_var("Points_Color", ncInt, ncdims[6])) )
457             throw DataException("Error - MeshAdapter::dump: appending Points_Color to netCDF file failed: " + *newFileName);
458          int_ptr = &mesh->Points->Color[0];
459          if (! (ids->put(int_ptr, num_Points)) )
460             throw DataException("Error - MeshAdapter::dump: copy Points_Color to netCDF buffer failed: " + *newFileName);
461    
462          // Points_Nodes
463          // mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]]
464          for (int i=0; i<num_Points; i++)
465             Points_Nodes[i] = mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]];
466          if (! ( ids = dataFile.add_var("Points_Nodes", ncInt, ncdims[6]) ) )
467             throw DataException("Error - MeshAdapter::dump: appending Points_Nodes to netCDF file failed: " + *newFileName);
468          if (! (ids->put(&(Points_Nodes[0]), num_Points)) )
469             throw DataException("Error - MeshAdapter::dump: copy Points_Nodes to netCDF buffer failed: " + *newFileName);
470    
471          TMPMEMFREE(Points_Nodes);
472    
473       }
474    
475       // // // // // TagMap // // // // //
476    
477       if (num_Tags>0) {
478    
479          // Temp storage to gather node IDs
480          int *Tags_keys = TMPMEMALLOC(num_Tags, int);
481          char name_temp[4096];
482    
483          /* Copy tag data into temp arrays */
484          tag_map = mesh->TagMap;
485          if (tag_map) {
486             int i = 0;
487             while (tag_map) {
488                Tags_keys[i++] = tag_map->tag_key;
489                tag_map=tag_map->next;
490             }
491          }
492    
493          // Tags_keys
494          if (! ( ids = dataFile.add_var("Tags_keys", ncInt, ncdims[10])) )
495             throw DataException("Error - MeshAdapter::dump: appending Tags_keys to netCDF file failed: " + *newFileName);
496          int_ptr = &Tags_keys[0];
497          if (! (ids->put(int_ptr, num_Tags)) )
498             throw DataException("Error - MeshAdapter::dump: copy Tags_keys to netCDF buffer failed: " + *newFileName);
499    
500          // Tags_names_*
501          // This is an array of strings, it should be stored as an array but instead I have hacked in one attribute per string
502          // because the NetCDF manual doesn't tell how to do an array of strings
503          tag_map = mesh->TagMap;
504          if (tag_map) {
505             int i = 0;
506             while (tag_map) {
507                sprintf(name_temp, "Tags_name_%d", i);
508                if (!dataFile.add_att(name_temp, tag_map->name) )
509                   throw DataException("Error - MeshAdapter::dump: appending Tags_names_ to NetCDF file failed: " + *newFileName);
510                tag_map=tag_map->next;
511                i++;
512             }
513          }
514    
515          TMPMEMFREE(Tags_keys);
516    
517       }
518    
519    
520       // NetCDF file is closed by destructor of NcFile object
521    #else
522       Finley_setError(IO_ERROR, "MeshAdapter::dump: not configured with NetCDF. Please contact your installation manager.");
523    #endif  /* USE_NETCDF */
524       checkFinleyError();
525  }  }
526    
527  string MeshAdapter::getDescription() const  string MeshAdapter::getDescription() const
528  {  {
529    return "FinleyMesh";     return "FinleyMesh";
530  }  }
531    
532  string MeshAdapter::functionSpaceTypeAsString(int functionSpaceType) const  string MeshAdapter::functionSpaceTypeAsString(int functionSpaceType) const
533  {  {
534    FunctionSpaceNamesMapType::iterator loc;     FunctionSpaceNamesMapType::iterator loc;
535    loc=m_functionSpaceTypeNames.find(functionSpaceType);     loc=m_functionSpaceTypeNames.find(functionSpaceType);
536    if (loc==m_functionSpaceTypeNames.end()) {     if (loc==m_functionSpaceTypeNames.end()) {
537      return "Invalid function space type code.";        return "Invalid function space type code.";
538    } else {     } else {
539      return loc->second;        return loc->second;
540    }     }
541  }  }
542    
543  bool MeshAdapter::isValidFunctionSpaceType(int functionSpaceType) const  bool MeshAdapter::isValidFunctionSpaceType(int functionSpaceType) const
544  {  {
545    FunctionSpaceNamesMapType::iterator loc;     FunctionSpaceNamesMapType::iterator loc;
546    loc=m_functionSpaceTypeNames.find(functionSpaceType);     loc=m_functionSpaceTypeNames.find(functionSpaceType);
547    return (loc!=m_functionSpaceTypeNames.end());     return (loc!=m_functionSpaceTypeNames.end());
548  }  }
549    
550  void MeshAdapter::setFunctionSpaceTypeNames()  void MeshAdapter::setFunctionSpaceTypeNames()
551  {  {
552    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
553      (FunctionSpaceNamesMapType::value_type(DegreesOfFreedom,"Finley_DegreesOfFreedom"));     (FunctionSpaceNamesMapType::value_type(DegreesOfFreedom,"Finley_DegreesOfFreedom"));
554    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
555      (FunctionSpaceNamesMapType::value_type(ReducedDegreesOfFreedom,"Finley_ReducedDegreesOfFreedom"));     (FunctionSpaceNamesMapType::value_type(ReducedDegreesOfFreedom,"Finley_ReducedDegreesOfFreedom"));
556    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
557      (FunctionSpaceNamesMapType::value_type(Nodes,"Finley_Nodes"));     (FunctionSpaceNamesMapType::value_type(Nodes,"Finley_Nodes"));
558    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
559      (FunctionSpaceNamesMapType::value_type(ReducedNodes,"Finley_Reduced_Nodes"));     (FunctionSpaceNamesMapType::value_type(ReducedNodes,"Finley_Reduced_Nodes"));
560    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
561      (FunctionSpaceNamesMapType::value_type(Elements,"Finley_Elements"));     (FunctionSpaceNamesMapType::value_type(Elements,"Finley_Elements"));
562    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
563      (FunctionSpaceNamesMapType::value_type(ReducedElements,"Finley_Reduced_Elements"));     (FunctionSpaceNamesMapType::value_type(ReducedElements,"Finley_Reduced_Elements"));
564    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
565      (FunctionSpaceNamesMapType::value_type(FaceElements,"Finley_Face_Elements"));     (FunctionSpaceNamesMapType::value_type(FaceElements,"Finley_Face_Elements"));
566    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
567      (FunctionSpaceNamesMapType::value_type(ReducedFaceElements,"Finley_Reduced_Face_Elements"));     (FunctionSpaceNamesMapType::value_type(ReducedFaceElements,"Finley_Reduced_Face_Elements"));
568    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
569      (FunctionSpaceNamesMapType::value_type(Points,"Finley_Points"));     (FunctionSpaceNamesMapType::value_type(Points,"Finley_Points"));
570    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
571      (FunctionSpaceNamesMapType::value_type(ContactElementsZero,"Finley_Contact_Elements_0"));     (FunctionSpaceNamesMapType::value_type(ContactElementsZero,"Finley_Contact_Elements_0"));
572    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
573      (FunctionSpaceNamesMapType::value_type(ReducedContactElementsZero,"Finley_Reduced_Contact_Elements_0"));     (FunctionSpaceNamesMapType::value_type(ReducedContactElementsZero,"Finley_Reduced_Contact_Elements_0"));
574    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
575      (FunctionSpaceNamesMapType::value_type(ContactElementsOne,"Finley_Contact_Elements_1"));     (FunctionSpaceNamesMapType::value_type(ContactElementsOne,"Finley_Contact_Elements_1"));
576    m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
577      (FunctionSpaceNamesMapType::value_type(ReducedContactElementsOne,"Finley_Reduced_Contact_Elements_1"));     (FunctionSpaceNamesMapType::value_type(ReducedContactElementsOne,"Finley_Reduced_Contact_Elements_1"));
578  }  }
579    
580  int MeshAdapter::getContinuousFunctionCode() const  int MeshAdapter::getContinuousFunctionCode() const
581  {  {
582    return Nodes;     return Nodes;
583  }  }
584  int MeshAdapter::getReducedContinuousFunctionCode() const  int MeshAdapter::getReducedContinuousFunctionCode() const
585  {  {
586    return ReducedNodes;     return ReducedNodes;
587  }  }
588    
589  int MeshAdapter::getFunctionCode() const  int MeshAdapter::getFunctionCode() const
590  {  {
591    return Elements;     return Elements;
592  }  }
593  int MeshAdapter::getReducedFunctionCode() const  int MeshAdapter::getReducedFunctionCode() const
594  {  {
595    return ReducedElements;     return ReducedElements;
596  }  }
597    
598  int MeshAdapter::getFunctionOnBoundaryCode() const  int MeshAdapter::getFunctionOnBoundaryCode() const
599  {  {
600    return FaceElements;     return FaceElements;
601  }  }
602  int MeshAdapter::getReducedFunctionOnBoundaryCode() const  int MeshAdapter::getReducedFunctionOnBoundaryCode() const
603  {  {
604    return ReducedFaceElements;     return ReducedFaceElements;
605  }  }
606    
607  int MeshAdapter::getFunctionOnContactZeroCode() const  int MeshAdapter::getFunctionOnContactZeroCode() const
608  {  {
609    return ContactElementsZero;     return ContactElementsZero;
610  }  }
611  int MeshAdapter::getReducedFunctionOnContactZeroCode() const  int MeshAdapter::getReducedFunctionOnContactZeroCode() const
612  {  {
613    return ReducedContactElementsZero;     return ReducedContactElementsZero;
614  }  }
615    
616  int MeshAdapter::getFunctionOnContactOneCode() const  int MeshAdapter::getFunctionOnContactOneCode() const
617  {  {
618    return ContactElementsOne;     return ContactElementsOne;
619  }  }
620  int MeshAdapter::getReducedFunctionOnContactOneCode() const  int MeshAdapter::getReducedFunctionOnContactOneCode() const
621  {  {
622    return ReducedContactElementsOne;     return ReducedContactElementsOne;
623  }  }
624    
625  int MeshAdapter::getSolutionCode() const  int MeshAdapter::getSolutionCode() const
626  {  {
627    return DegreesOfFreedom;     return DegreesOfFreedom;
628  }  }
629    
630  int MeshAdapter::getReducedSolutionCode() const  int MeshAdapter::getReducedSolutionCode() const
631  {  {
632    return ReducedDegreesOfFreedom;     return ReducedDegreesOfFreedom;
633  }  }
634    
635  int MeshAdapter::getDiracDeltaFunctionCode() const  int MeshAdapter::getDiracDeltaFunctionCode() const
636  {  {
637    return Points;     return Points;
638  }  }
639    
640  //  //
# Line 203  int MeshAdapter::getDiracDeltaFunctionCo Line 642  int MeshAdapter::getDiracDeltaFunctionCo
642  //  //
643  int MeshAdapter::getDim() const  int MeshAdapter::getDim() const
644  {  {
645    int numDim=Finley_Mesh_getDim(m_finleyMesh.get());     int numDim=Finley_Mesh_getDim(m_finleyMesh.get());
646    checkFinleyError();     checkFinleyError();
647    return numDim;     return numDim;
648    }
649    
650    //
651    // Return the number of data points summed across all MPI processes
652    //
653    int MeshAdapter::getNumDataPointsGlobal() const
654    {
655       return Finley_NodeFile_getGlobalNumNodes(m_finleyMesh.get()->Nodes);
656  }  }
657    
658  //  //
# Line 218  pair<int,int> MeshAdapter::getDataShape( Line 665  pair<int,int> MeshAdapter::getDataShape(
665     int numSamples=0;     int numSamples=0;
666     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
667     switch (functionSpaceCode) {     switch (functionSpaceCode) {
668        case(Nodes):     case(Nodes):
669             numDataPointsPerSample=1;     numDataPointsPerSample=1;
670             if (mesh->Nodes!=NULL) numSamples=mesh->Nodes->numNodes;     numSamples=Finley_NodeFile_getNumNodes(mesh->Nodes);
671             break;     break;
672        case(ReducedNodes):     case(ReducedNodes):
673             /* TODO: add ReducedNodes */     numDataPointsPerSample=1;
674             numDataPointsPerSample=1;     numSamples=Finley_NodeFile_getNumReducedNodes(mesh->Nodes);
675             if (mesh->Nodes!=NULL) numSamples=mesh->Nodes->numNodes;     break;
676             throw FinleyAdapterException("Error - ReducedNodes is not supported yet.");     case(Elements):
677             break;     if (mesh->Elements!=NULL) {
678        case(Elements):        numSamples=mesh->Elements->numElements;
679             if (mesh->Elements!=NULL) {        numDataPointsPerSample=mesh->Elements->ReferenceElement->numQuadNodes;
680               numSamples=mesh->Elements->numElements;     }
681               numDataPointsPerSample=mesh->Elements->ReferenceElement->numQuadNodes;     break;
682             }     case(ReducedElements):
683             break;     if (mesh->Elements!=NULL) {
684        case(ReducedElements):        numSamples=mesh->Elements->numElements;
685             if (mesh->Elements!=NULL) {        numDataPointsPerSample=mesh->Elements->ReferenceElementReducedOrder->numQuadNodes;
686               numSamples=mesh->Elements->numElements;     }
687               numDataPointsPerSample=mesh->Elements->ReferenceElementReducedOrder->numQuadNodes;     break;
688             }     case(FaceElements):
689             break;     if (mesh->FaceElements!=NULL) {
690        case(FaceElements):        numDataPointsPerSample=mesh->FaceElements->ReferenceElement->numQuadNodes;
691             if (mesh->FaceElements!=NULL) {        numSamples=mesh->FaceElements->numElements;
692                  numDataPointsPerSample=mesh->FaceElements->ReferenceElement->numQuadNodes;     }
693                  numSamples=mesh->FaceElements->numElements;     break;
694             }     case(ReducedFaceElements):
695             break;     if (mesh->FaceElements!=NULL) {
696        case(ReducedFaceElements):        numDataPointsPerSample=mesh->FaceElements->ReferenceElementReducedOrder->numQuadNodes;
697             if (mesh->FaceElements!=NULL) {        numSamples=mesh->FaceElements->numElements;
698                  numDataPointsPerSample=mesh->FaceElements->ReferenceElementReducedOrder->numQuadNodes;     }
699                  numSamples=mesh->FaceElements->numElements;     break;
700             }     case(Points):
701             break;     if (mesh->Points!=NULL) {
702        case(Points):        numDataPointsPerSample=1;
703             if (mesh->Points!=NULL) {        numSamples=mesh->Points->numElements;
704               numDataPointsPerSample=1;     }
705               numSamples=mesh->Points->numElements;     break;
706             }     case(ContactElementsZero):
707             break;     if (mesh->ContactElements!=NULL) {
708        case(ContactElementsZero):        numDataPointsPerSample=mesh->ContactElements->ReferenceElement->numQuadNodes;
709             if (mesh->ContactElements!=NULL) {        numSamples=mesh->ContactElements->numElements;
710               numDataPointsPerSample=mesh->ContactElements->ReferenceElement->numQuadNodes;     }
711               numSamples=mesh->ContactElements->numElements;     break;
712             }     case(ReducedContactElementsZero):
713             break;     if (mesh->ContactElements!=NULL) {
714        case(ReducedContactElementsZero):        numDataPointsPerSample=mesh->ContactElements->ReferenceElementReducedOrder->numQuadNodes;
715             if (mesh->ContactElements!=NULL) {        numSamples=mesh->ContactElements->numElements;
716               numDataPointsPerSample=mesh->ContactElements->ReferenceElementReducedOrder->numQuadNodes;     }
717               numSamples=mesh->ContactElements->numElements;     break;
718             }     case(ContactElementsOne):
719             break;     if (mesh->ContactElements!=NULL) {
720        case(ContactElementsOne):        numDataPointsPerSample=mesh->ContactElements->ReferenceElement->numQuadNodes;
721             if (mesh->ContactElements!=NULL) {        numSamples=mesh->ContactElements->numElements;
722               numDataPointsPerSample=mesh->ContactElements->ReferenceElement->numQuadNodes;     }
723               numSamples=mesh->ContactElements->numElements;     break;
724             }     case(ReducedContactElementsOne):
725             break;     if (mesh->ContactElements!=NULL) {
726        case(ReducedContactElementsOne):        numDataPointsPerSample=mesh->ContactElements->ReferenceElementReducedOrder->numQuadNodes;
727             if (mesh->ContactElements!=NULL) {        numSamples=mesh->ContactElements->numElements;
728               numDataPointsPerSample=mesh->ContactElements->ReferenceElementReducedOrder->numQuadNodes;     }
729               numSamples=mesh->ContactElements->numElements;     break;
730             }     case(DegreesOfFreedom):
731             break;     if (mesh->Nodes!=NULL) {
732        case(DegreesOfFreedom):        numDataPointsPerSample=1;
733             if (mesh->Nodes!=NULL) {        numSamples=Finley_NodeFile_getNumDegreesOfFreedom(mesh->Nodes);
734               numDataPointsPerSample=1;     }
735  #ifndef PASO_MPI     break;
736               numSamples=mesh->Nodes->numDegreesOfFreedom;     case(ReducedDegreesOfFreedom):
737  #else     if (mesh->Nodes!=NULL) {
738               numSamples=mesh->Nodes->degreeOfFreedomDistribution->numLocal;        numDataPointsPerSample=1;
739  #endif        numSamples=Finley_NodeFile_getNumReducedDegreesOfFreedom(mesh->Nodes);
740             }     }
741             break;     break;
742        case(ReducedDegreesOfFreedom):     default:
743             if (mesh->Nodes!=NULL) {        stringstream temp;
744               numDataPointsPerSample=1;        temp << "Error - Invalid function space type: " << functionSpaceCode << " for domain: " << getDescription();
745  #ifndef PASO_MPI        throw FinleyAdapterException(temp.str());
746               numSamples=mesh->Nodes->reducedNumDegreesOfFreedom;        break;
747  #else     }
748               numSamples=mesh->Nodes->reducedDegreeOfFreedomDistribution->numLocal;     return pair<int,int>(numDataPointsPerSample,numSamples);
 #endif  
            }  
            break;  
       default:  
         stringstream temp;  
         temp << "Error - Invalid function space type: " << functionSpaceCode << " for domain: " << getDescription();  
         throw FinleyAdapterException(temp.str());  
         break;  
       }  
       return pair<int,int>(numDataPointsPerSample,numSamples);  
749  }  }
750    
751  //  //
752  // adds linear PDE of second order into a given stiffness matrix and right hand side:  // adds linear PDE of second order into a given stiffness matrix and right hand side:
753  //  //
754  void MeshAdapter::addPDEToSystem(  void MeshAdapter::addPDEToSystem(
755                       SystemMatrixAdapter& mat, escript::Data& rhs,                                   SystemMatrixAdapter& mat, escript::Data& rhs,
756                       const escript::Data& A, const escript::Data& B, const escript::Data& C,const  escript::Data& D,const  escript::Data& X,const  escript::Data& Y,                                   const escript::Data& A, const escript::Data& B, const escript::Data& C,const  escript::Data& D,const  escript::Data& X,const  escript::Data& Y,
757                       const escript::Data& d, const escript::Data& y,                                   const escript::Data& d, const escript::Data& y,
758                       const escript::Data& d_contact,const escript::Data& y_contact) const                                   const escript::Data& d_contact,const escript::Data& y_contact) const
759  {  {
760     escriptDataC _rhs=rhs.getDataC();     escriptDataC _rhs=rhs.getDataC();
761     escriptDataC _A  =A.getDataC();     escriptDataC _A  =A.getDataC();
# Line 344  void MeshAdapter::addPDEToSystem( Line 781  void MeshAdapter::addPDEToSystem(
781     checkFinleyError();     checkFinleyError();
782  }  }
783    
784    void  MeshAdapter::addPDEToLumpedSystem(
785                                            escript::Data& mat,
786                                            const escript::Data& D,
787                                            const escript::Data& d) const
788    {
789       escriptDataC _mat=mat.getDataC();
790       escriptDataC _D=D.getDataC();
791       escriptDataC _d=d.getDataC();
792    
793       Finley_Mesh* mesh=m_finleyMesh.get();
794    
795       Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->Elements,&_mat, &_D);
796       Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->FaceElements,&_mat, &_d);
797    
798       checkFinleyError();
799    }
800    
801    
802  //  //
803  // adds linear PDE of second order into the right hand side only  // adds linear PDE of second order into the right hand side only
804  //  //
# Line 366  void MeshAdapter::addPDEToRHS( escript:: Line 821  void MeshAdapter::addPDEToRHS( escript::
821     Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, 0, &_rhs , 0, 0, 0, 0, 0, &_y_contact );     Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, 0, &_rhs , 0, 0, 0, 0, 0, &_y_contact );
822     checkFinleyError();     checkFinleyError();
823  }  }
824    //
825    // adds PDE of second order into a transport problem
826    //
827    void MeshAdapter::addPDEToTransportProblem(
828                                               TransportProblemAdapter& tp, escript::Data& source, const escript::Data& M,
829                                               const escript::Data& A, const escript::Data& B, const escript::Data& C,
830                                               const  escript::Data& D,const  escript::Data& X,const  escript::Data& Y,
831                                               const escript::Data& d, const escript::Data& y,
832                                               const escript::Data& d_contact,const escript::Data& y_contact) const
833    {
834       DataArrayView::ShapeType shape;
835       source.expand();
836       escriptDataC _source=source.getDataC();
837       escriptDataC _M=M.getDataC();
838       escriptDataC _A=A.getDataC();
839       escriptDataC _B=B.getDataC();
840       escriptDataC _C=C.getDataC();
841       escriptDataC _D=D.getDataC();
842       escriptDataC _X=X.getDataC();
843       escriptDataC _Y=Y.getDataC();
844       escriptDataC _d=d.getDataC();
845       escriptDataC _y=y.getDataC();
846       escriptDataC _d_contact=d_contact.getDataC();
847       escriptDataC _y_contact=y_contact.getDataC();
848    
849       Finley_Mesh* mesh=m_finleyMesh.get();
850       Paso_FCTransportProblem* _tp = tp.getPaso_FCTransportProblem();
851    
852       Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,_tp->mass_matrix, &_source, 0, 0, 0, &_M, 0, 0 );
853       checkFinleyError();
854    
855       Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,_tp->transport_matrix, &_source, &_A, &_B, &_C, &_D, &_X, &_Y );
856       checkFinleyError();
857    
858       Finley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, _tp->transport_matrix, &_source, 0, 0, 0, &_d, 0, &_y );
859       checkFinleyError();
860    
861       Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, _tp->transport_matrix, &_source , 0, 0, 0, &_d_contact, 0, &_y_contact );
862       checkFinleyError();
863    }
864    
865  //  //
866  // interpolates data between different function spaces:  // interpolates data between different function spaces:
867  //  //
868  void MeshAdapter::interpolateOnDomain(escript::Data& target,const escript::Data& in) const  void MeshAdapter::interpolateOnDomain(escript::Data& target,const escript::Data& in) const
869  {  {
870    const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(in.getFunctionSpace().getDomain());     const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(in.getFunctionSpace().getDomain());
871    const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());
872    if (inDomain!=*this)       if (inDomain!=*this)  
873      throw FinleyAdapterException("Error - Illegal domain of interpolant.");        throw FinleyAdapterException("Error - Illegal domain of interpolant.");
874    if (targetDomain!=*this)     if (targetDomain!=*this)
875      throw FinleyAdapterException("Error - Illegal domain of interpolation target.");        throw FinleyAdapterException("Error - Illegal domain of interpolation target.");
876    
877    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
878    escriptDataC _target=target.getDataC();     escriptDataC _target=target.getDataC();
879    escriptDataC _in=in.getDataC();     escriptDataC _in=in.getDataC();
880    switch(in.getFunctionSpace().getTypeCode()) {     switch(in.getFunctionSpace().getTypeCode()) {
881       case(Nodes):     case(Nodes):
882          switch(target.getFunctionSpace().getTypeCode()) {     switch(target.getFunctionSpace().getTypeCode()) {
883             case(Nodes):     case(Nodes):
884             case(ReducedNodes):     case(ReducedNodes):
885             case(DegreesOfFreedom):     case(DegreesOfFreedom):
886             case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
887                 Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
888                 break;     break;
889             case(Elements):     case(Elements):
890             case(ReducedElements):     case(ReducedElements):
891                 Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
892                 break;     break;
893             case(FaceElements):     case(FaceElements):
894             case(ReducedFaceElements):     case(ReducedFaceElements):
895                 Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
896                 break;     break;
897             case(Points):     case(Points):
898                 Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
899                 break;     break;
900             case(ContactElementsZero):     case(ContactElementsZero):
901             case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
902                 Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
903                 break;     break;
904             case(ContactElementsOne):     case(ContactElementsOne):
905             case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
906                 Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
907                 break;     break;
908             default:     default:
909                 stringstream temp;        stringstream temp;
910                 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();
911                 throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
912                 break;        break;
913          }     }
914          break;     break;
915       case(ReducedNodes):     case(ReducedNodes):
916          switch(target.getFunctionSpace().getTypeCode()) {     switch(target.getFunctionSpace().getTypeCode()) {
917             case(Nodes):     case(Nodes):
918             case(ReducedNodes):     case(ReducedNodes):
919             case(DegreesOfFreedom):     case(DegreesOfFreedom):
920             case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
921                 Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
922                 break;     break;
923             case(Elements):     case(Elements):
924             case(ReducedElements):     case(ReducedElements):
925                 Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
926                 break;     break;
927             case(FaceElements):     case(FaceElements):
928             case(ReducedFaceElements):     case(ReducedFaceElements):
929                 Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
930                 break;     break;
931             case(Points):     case(Points):
932                 Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
933                 break;     break;
934             case(ContactElementsZero):     case(ContactElementsZero):
935             case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
936                 Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
937                 break;     break;
938             case(ContactElementsOne):     case(ContactElementsOne):
939             case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
940                 Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
941                 break;     break;
942             default:     default:
943                 stringstream temp;        stringstream temp;
944                 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();
945                 throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
946                 break;        break;
947          }     }
948          break;     break;
949       case(Elements):     case(Elements):
950          if (target.getFunctionSpace().getTypeCode()==Elements) {     if (target.getFunctionSpace().getTypeCode()==Elements) {
951             Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);        Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
952          } else if (target.getFunctionSpace().getTypeCode()==ReducedElements) {     } else if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
953             Finley_Assemble_AverageElementData(mesh->Elements,&_target,&_in);        Finley_Assemble_AverageElementData(mesh->Elements,&_target,&_in);
954          } else {     } else {
955             throw FinleyAdapterException("Error - No interpolation with data on elements possible.");        throw FinleyAdapterException("Error - No interpolation with data on elements possible.");
956          }     }
957          break;     break;
958       case(ReducedElements):     case(ReducedElements):
959          if (target.getFunctionSpace().getTypeCode()==ReducedElements) {     if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
960             Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);        Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
961          } else {     } else {
962             throw FinleyAdapterException("Error - No interpolation with data on elements with reduced integration order possible.");        throw FinleyAdapterException("Error - No interpolation with data on elements with reduced integration order possible.");
963          }     }
964          break;     break;
965       case(FaceElements):     case(FaceElements):
966          if (target.getFunctionSpace().getTypeCode()==FaceElements) {     if (target.getFunctionSpace().getTypeCode()==FaceElements) {
967             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);        Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
968          } else if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {     } else if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
969             Finley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);        Finley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);
970          } else {     } else {
971             throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");        throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");
972         }     }
973         break;     break;
974       case(ReducedFaceElements):     case(ReducedFaceElements):
975          if (target.getFunctionSpace().getTypeCode()==FaceElements) {     if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
976             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);        Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
977          } else {     } else {
978             throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");        throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");
979         }     }
980         break;     break;
981       case(Points):     case(Points):
982          if (target.getFunctionSpace().getTypeCode()==Points) {     if (target.getFunctionSpace().getTypeCode()==Points) {
983             Finley_Assemble_CopyElementData(mesh->Points,&_target,&_in);        Finley_Assemble_CopyElementData(mesh->Points,&_target,&_in);
984          } else {     } else {
985             throw FinleyAdapterException("Error - No interpolation with data on points possible.");        throw FinleyAdapterException("Error - No interpolation with data on points possible.");
986          }     }
987          break;     break;
988       case(ContactElementsZero):     case(ContactElementsZero):
989       case(ContactElementsOne):     case(ContactElementsOne):
990          if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {     if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {
991             Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);        Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);
992          } else if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {     } else if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {
993             Finley_Assemble_AverageElementData(mesh->ContactElements,&_target,&_in);        Finley_Assemble_AverageElementData(mesh->ContactElements,&_target,&_in);
994          } else {     } else {
995             throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");        throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");
996             break;     }
997          }     break;
998          break;     case(ReducedContactElementsZero):
999       case(ReducedContactElementsZero):     case(ReducedContactElementsOne):
1000       case(ReducedContactElementsOne):     if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {
1001          if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {        Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);
1002             Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);     } else {
1003          } else {        throw FinleyAdapterException("Error - No interpolation with data on contact elements with reduced integration order possible.");
1004             throw FinleyAdapterException("Error - No interpolation with data on contact elements with reduced integration order possible.");     }
1005             break;     break;
1006          }     case(DegreesOfFreedom):      
1007          break;     switch(target.getFunctionSpace().getTypeCode()) {
1008       case(DegreesOfFreedom):           case(ReducedDegreesOfFreedom):
1009          switch(target.getFunctionSpace().getTypeCode()) {     case(DegreesOfFreedom):
1010             case(ReducedDegreesOfFreedom):     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
1011             case(DegreesOfFreedom):     break;
1012             case(Nodes):  
1013             case(ReducedNodes):     case(Nodes):
1014                Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);     case(ReducedNodes):
1015                break;     if (getMPISize()>1) {
1016  #ifndef PASO_MPI        escript::Data temp=escript::Data(in);
1017             case(Elements):        temp.expand();
1018             case(ReducedElements):        escriptDataC _in2 = temp.getDataC();
1019                Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
1020                break;     } else {
1021             case(FaceElements):        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
1022             case(ReducedFaceElements):     }
1023                Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);     break;
1024                break;     case(Elements):
1025             case(Points):     case(ReducedElements):
1026                Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);     if (getMPISize()>1) {
1027                break;        escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1028             case(ContactElementsZero):        escriptDataC _in2 = temp.getDataC();
1029             case(ContactElementsOne):        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
1030             case(ReducedContactElementsZero):     } else {
1031             case(ReducedContactElementsOne):        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
1032                Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);     }
1033               break;     break;
1034  #else     case(FaceElements):
1035             /* need to copy Degrees of freedom data to nodal data so that the external values are available */     case(ReducedFaceElements):
1036             case(Elements):     if (getMPISize()>1) {
1037             case(ReducedElements):        escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1038                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );        escriptDataC _in2 = temp.getDataC();
1039                Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&(nodeTemp.getDataC()),&_target);        Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
1040                break;  
1041             case(FaceElements):     } else {
1042             case(ReducedFaceElements):        Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
1043                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );     }
1044                Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&(nodeTemp.getDataC()),&_target);     break;
1045                break;     case(Points):
1046             case(Points):     if (getMPISize()>1) {
1047                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );        escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1048                Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&(nodeTemp.getDataC()),&_target);        escriptDataC _in2 = temp.getDataC();
1049                break;     } else {
1050             case(ContactElementsZero):        Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
1051             case(ContactElementsOne):     }
1052             case(ReducedContactElementsZero):     break;
1053             case(ReducedContactElementsOne):     case(ContactElementsZero):
1054                escript::Data nodeTemp( in, continuousFunction(asAbstractContinuousDomain()) );     case(ContactElementsOne):
1055                Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(nodeTemp.getDataC()),&_target);     case(ReducedContactElementsZero):
1056               break;     case(ReducedContactElementsOne):
1057  #endif     if (getMPISize()>1) {
1058             default:        escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1059               stringstream temp;        escriptDataC _in2 = temp.getDataC();
1060               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();        Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
1061               throw FinleyAdapterException(temp.str());     } else {
1062               break;        Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
1063          }     }
1064          break;     break;
1065       case(ReducedDegreesOfFreedom):     default:
1066         switch(target.getFunctionSpace().getTypeCode()) {        stringstream temp;
1067            case(Nodes):        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
1068               throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");        throw FinleyAdapterException(temp.str());
1069               break;        break;
1070            case(ReducedNodes):     }
1071               Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);     break;
1072               break;     case(ReducedDegreesOfFreedom):
1073            case(DegreesOfFreedom):     switch(target.getFunctionSpace().getTypeCode()) {
1074               throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");     case(Nodes):
1075               break;     throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");
1076            case(ReducedDegreesOfFreedom):     break;
1077               Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);     case(ReducedNodes):
1078               break;     if (getMPISize()>1) {
1079            case(Elements):        escript::Data temp=escript::Data(in);
1080            case(ReducedElements):        temp.expand();
1081               Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);        escriptDataC _in2 = temp.getDataC();
1082               break;        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
1083            case(FaceElements):     } else {
1084            case(ReducedFaceElements):        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
1085               Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);     }
1086               break;     break;
1087            case(Points):     case(DegreesOfFreedom):
1088               Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);     throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");
1089               break;     break;
1090            case(ContactElementsZero):     case(ReducedDegreesOfFreedom):
1091            case(ContactElementsOne):     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
1092            case(ReducedContactElementsZero):     break;
1093            case(ReducedContactElementsOne):     case(Elements):
1094               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);     case(ReducedElements):
1095               break;     if (getMPISize()>1) {
1096            default:        escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1097               stringstream temp;        escriptDataC _in2 = temp.getDataC();
1098               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
1099               throw FinleyAdapterException(temp.str());     } else {
1100               break;        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
1101         }     }
1102         break;     break;
1103       default:     case(FaceElements):
1104          stringstream temp;     case(ReducedFaceElements):
1105          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type %d" << in.getFunctionSpace().getTypeCode();     if (getMPISize()>1) {
1106          throw FinleyAdapterException(temp.str());        escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1107          break;        escriptDataC _in2 = temp.getDataC();
1108    }        Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
1109    checkFinleyError();     } else {
1110          Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
1111       }
1112       break;
1113       case(Points):
1114       if (getMPISize()>1) {
1115          escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1116          escriptDataC _in2 = temp.getDataC();
1117          Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);
1118       } else {
1119          Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
1120       }
1121       break;
1122       case(ContactElementsZero):
1123       case(ContactElementsOne):
1124       case(ReducedContactElementsZero):
1125       case(ReducedContactElementsOne):
1126       if (getMPISize()>1) {
1127          escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1128          escriptDataC _in2 = temp.getDataC();
1129          Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
1130       } else {
1131          Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
1132       }
1133       break;
1134       default:
1135          stringstream temp;
1136          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
1137          throw FinleyAdapterException(temp.str());
1138          break;
1139       }
1140       break;
1141       default:
1142          stringstream temp;
1143          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type %d" << in.getFunctionSpace().getTypeCode();
1144          throw FinleyAdapterException(temp.str());
1145          break;
1146       }
1147       checkFinleyError();
1148  }  }
1149    
1150  //  //
# Line 619  void MeshAdapter::interpolateOnDomain(es Line 1152  void MeshAdapter::interpolateOnDomain(es
1152  //  //
1153  void MeshAdapter::setToX(escript::Data& arg) const  void MeshAdapter::setToX(escript::Data& arg) const
1154  {  {
1155    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());
1156    if (argDomain!=*this)     if (argDomain!=*this)
1157       throw FinleyAdapterException("Error - Illegal domain of data point locations");        throw FinleyAdapterException("Error - Illegal domain of data point locations");
1158    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1159    // in case of values node coordinates we can do the job directly:     // in case of values node coordinates we can do the job directly:
1160    if (arg.getFunctionSpace().getTypeCode()==Nodes) {     if (arg.getFunctionSpace().getTypeCode()==Nodes) {
1161       escriptDataC _arg=arg.getDataC();        escriptDataC _arg=arg.getDataC();
1162       Finley_Assemble_NodeCoordinates(mesh->Nodes,&_arg);        Finley_Assemble_NodeCoordinates(mesh->Nodes,&_arg);
1163    } else {     } else {
1164       escript::Data tmp_data=Vector(0.0,continuousFunction(asAbstractContinuousDomain()),true);        escript::Data tmp_data=Vector(0.0,continuousFunction(asAbstractContinuousDomain()),true);
1165       escriptDataC _tmp_data=tmp_data.getDataC();        escriptDataC _tmp_data=tmp_data.getDataC();
1166       Finley_Assemble_NodeCoordinates(mesh->Nodes,&_tmp_data);        Finley_Assemble_NodeCoordinates(mesh->Nodes,&_tmp_data);
1167       // this is then interpolated onto arg:        // this is then interpolated onto arg:
1168       interpolateOnDomain(arg,tmp_data);        interpolateOnDomain(arg,tmp_data);
1169    }     }
1170    checkFinleyError();     checkFinleyError();
1171  }  }
1172    
1173  //  //
# Line 642  void MeshAdapter::setToX(escript::Data& Line 1175  void MeshAdapter::setToX(escript::Data&
1175  //  //
1176  void MeshAdapter::setToNormal(escript::Data& normal) const  void MeshAdapter::setToNormal(escript::Data& normal) const
1177  {  {
1178    const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());     const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());
1179    if (normalDomain!=*this)     if (normalDomain!=*this)
1180       throw FinleyAdapterException("Error - Illegal domain of normal locations");        throw FinleyAdapterException("Error - Illegal domain of normal locations");
1181    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1182    escriptDataC _normal=normal.getDataC();     escriptDataC _normal=normal.getDataC();
1183    switch(normal.getFunctionSpace().getTypeCode()) {     switch(normal.getFunctionSpace().getTypeCode()) {
1184      case(Nodes):     case(Nodes):
1185        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for nodes");     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for nodes");
1186        break;     break;
1187      case(ReducedNodes):     case(ReducedNodes):
1188        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced nodes");     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced nodes");
1189        break;     break;
1190      case(Elements):     case(Elements):
1191        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements");     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements");
1192        break;     break;
1193      case(ReducedElements):     case(ReducedElements):
1194        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements with reduced integration order");     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements with reduced integration order");
1195        break;     break;
1196      case (FaceElements):     case (FaceElements):
1197        Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);     Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);
1198        break;     break;
1199      case (ReducedFaceElements):     case (ReducedFaceElements):
1200        Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);     Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);
1201        break;     break;
1202      case(Points):     case(Points):
1203        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");
1204        break;     break;
1205      case (ContactElementsOne):     case (ContactElementsOne):
1206      case (ContactElementsZero):     case (ContactElementsZero):
1207        Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&_normal);     Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&_normal);
1208        break;     break;
1209      case (ReducedContactElementsOne):     case (ReducedContactElementsOne):
1210      case (ReducedContactElementsZero):     case (ReducedContactElementsZero):
1211        Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&_normal);     Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&_normal);
1212        break;     break;
1213      case(DegreesOfFreedom):     case(DegreesOfFreedom):
1214        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.");
1215        break;     break;
1216      case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1217        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced degrees of freedom.");     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced degrees of freedom.");
1218        break;     break;
1219      default:     default:
1220        stringstream temp;        stringstream temp;
1221        temp << "Error - Normal Vectors: Finley does not know anything about function space type " << normal.getFunctionSpace().getTypeCode();        temp << "Error - Normal Vectors: Finley does not know anything about function space type " << normal.getFunctionSpace().getTypeCode();
1222        throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
1223        break;        break;
1224    }     }
1225    checkFinleyError();     checkFinleyError();
1226  }  }
1227    
1228  //  //
# Line 697  void MeshAdapter::setToNormal(escript::D Line 1230  void MeshAdapter::setToNormal(escript::D
1230  //  //
1231  void MeshAdapter::interpolateACross(escript::Data& target,const escript::Data& source) const  void MeshAdapter::interpolateACross(escript::Data& target,const escript::Data& source) const
1232  {  {
1233    const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());
1234    if (targetDomain!=*this)     if (targetDomain!=*this)
1235       throw FinleyAdapterException("Error - Illegal domain of interpolation target");        throw FinleyAdapterException("Error - Illegal domain of interpolation target");
1236    
1237    throw FinleyAdapterException("Error - Finley does not allow interpolation across domains yet.");     throw FinleyAdapterException("Error - Finley does not allow interpolation across domains yet.");
1238  }  }
1239    
1240  //  //
# Line 709  void MeshAdapter::interpolateACross(escr Line 1242  void MeshAdapter::interpolateACross(escr
1242  //  //
1243  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const
1244  {  {
1245    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());
1246    if (argDomain!=*this)     if (argDomain!=*this)
1247       throw FinleyAdapterException("Error - Illegal domain of integration kernel");        throw FinleyAdapterException("Error - Illegal domain of integration kernel");
1248    
1249    Finley_Mesh* mesh=m_finleyMesh.get();     double blocktimer_start = blocktimer_time();
1250    escriptDataC _arg=arg.getDataC();     Finley_Mesh* mesh=m_finleyMesh.get();
1251    switch(arg.getFunctionSpace().getTypeCode()) {     escriptDataC _temp;
1252       case(Nodes):     escript::Data temp;
1253          /* TODO */     escriptDataC _arg=arg.getDataC();
1254          throw FinleyAdapterException("Error - Integral of data on nodes is not supported.");     switch(arg.getFunctionSpace().getTypeCode()) {
1255          break;     case(Nodes):
1256       case(ReducedNodes):     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1257          /* TODO */     _temp=temp.getDataC();
1258          throw FinleyAdapterException("Error - Integral of data on reduced nodes is not supported.");     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1259          break;     break;
1260       case(Elements):     case(ReducedNodes):
1261          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1262          break;     _temp=temp.getDataC();
1263       case(ReducedElements):     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1264          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);     break;
1265          break;     case(Elements):
1266       case(FaceElements):     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);
1267          Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);     break;
1268          break;     case(ReducedElements):
1269       case(ReducedFaceElements):     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);
1270          Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);     break;
1271          break;     case(FaceElements):
1272       case(Points):     Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);
1273          throw FinleyAdapterException("Error - Integral of data on points is not supported.");     break;
1274          break;     case(ReducedFaceElements):
1275       case(ContactElementsZero):     Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);
1276          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);     break;
1277          break;     case(Points):
1278       case(ReducedContactElementsZero):     throw FinleyAdapterException("Error - Integral of data on points is not supported.");
1279          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);     break;
1280          break;     case(ContactElementsZero):
1281       case(ContactElementsOne):     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1282          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);     break;
1283          break;     case(ReducedContactElementsZero):
1284       case(ReducedContactElementsOne):     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1285          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);     break;
1286          break;     case(ContactElementsOne):
1287       case(DegreesOfFreedom):     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1288          throw FinleyAdapterException("Error - Integral of data on degrees of freedom is not supported.");     break;
1289          break;     case(ReducedContactElementsOne):
1290       case(ReducedDegreesOfFreedom):     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1291          throw FinleyAdapterException("Error - Integral of data on reduced degrees of freedom is not supported.");     break;
1292          break;     case(DegreesOfFreedom):
1293       default:     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1294          stringstream temp;     _temp=temp.getDataC();
1295          temp << "Error - Integrals: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1296          throw FinleyAdapterException(temp.str());     break;
1297          break;     case(ReducedDegreesOfFreedom):
1298    }     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );
1299    checkFinleyError();     _temp=temp.getDataC();
1300       Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1301       break;
1302       default:
1303          stringstream temp;
1304          temp << "Error - Integrals: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();
1305          throw FinleyAdapterException(temp.str());
1306          break;
1307       }
1308       checkFinleyError();
1309       blocktimer_increment("integrate()", blocktimer_start);
1310  }  }
1311    
1312  //  //
# Line 771  void MeshAdapter::setToIntegrals(std::ve Line 1314  void MeshAdapter::setToIntegrals(std::ve
1314  //  //
1315  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const
1316  {  {
1317    const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());
1318    if (argDomain!=*this)     if (argDomain!=*this)
1319      throw FinleyAdapterException("Error - Illegal domain of gradient argument");        throw FinleyAdapterException("Error - Illegal domain of gradient argument");
1320    const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(grad.getFunctionSpace().getDomain());     const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(grad.getFunctionSpace().getDomain());
1321    if (gradDomain!=*this)     if (gradDomain!=*this)
1322       throw FinleyAdapterException("Error - Illegal domain of gradient");        throw FinleyAdapterException("Error - Illegal domain of gradient");
1323    
1324    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1325    escriptDataC _grad=grad.getDataC();     escriptDataC _grad=grad.getDataC();
1326    escriptDataC nodeDataC;     escriptDataC nodeDataC;
1327  #ifdef PASO_MPI     escript::Data temp;
1328    escript::Data nodeTemp( arg, continuousFunction(asAbstractContinuousDomain()) );     if (getMPISize()>1) {
1329    if( arg.getFunctionSpace().getTypeCode() != Nodes )        if( arg.getFunctionSpace().getTypeCode() == DegreesOfFreedom ) {
1330    {           temp=escript::Data( arg,  continuousFunction(asAbstractContinuousDomain()) );
1331      Finley_Assemble_CopyNodalData(mesh->Nodes,&(nodeTemp.getDataC()),&(arg.getDataC()));           nodeDataC = temp.getDataC();
1332      nodeDataC = nodeTemp.getDataC();        } else if( arg.getFunctionSpace().getTypeCode() == ReducedDegreesOfFreedom ) {
1333    }           temp=escript::Data( arg,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1334    else           nodeDataC = temp.getDataC();
1335      nodeDataC = arg.getDataC();        } else {
1336  #else           nodeDataC = arg.getDataC();
1337    nodeDataC = arg.getDataC();        }
1338  #endif     } else {
1339    switch(grad.getFunctionSpace().getTypeCode()) {        nodeDataC = arg.getDataC();
1340         case(Nodes):     }
1341            throw FinleyAdapterException("Error - Gradient at nodes is not supported.");     switch(grad.getFunctionSpace().getTypeCode()) {
1342            break;     case(Nodes):
1343         case(ReducedNodes):     throw FinleyAdapterException("Error - Gradient at nodes is not supported.");
1344            throw FinleyAdapterException("Error - Gradient at reduced nodes is not supported.");     break;
1345            break;     case(ReducedNodes):
1346         case(Elements):     throw FinleyAdapterException("Error - Gradient at reduced nodes is not supported.");
1347            Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);     break;
1348            break;     case(Elements):
1349         case(ReducedElements):     Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);
1350            Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);     break;
1351            break;     case(ReducedElements):
1352         case(FaceElements):     Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);
1353            Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);     break;
1354            break;     case(FaceElements):
1355         case(ReducedFaceElements):     Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);
1356            Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);     break;
1357            break;     case(ReducedFaceElements):
1358         case(Points):     Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);
1359            throw FinleyAdapterException("Error - Gradient at points is not supported.");     break;
1360            break;     case(Points):
1361         case(ContactElementsZero):     throw FinleyAdapterException("Error - Gradient at points is not supported.");
1362            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);     break;
1363            break;     case(ContactElementsZero):
1364         case(ReducedContactElementsZero):     Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1365            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);     break;
1366            break;     case(ReducedContactElementsZero):
1367         case(ContactElementsOne):     Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1368            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);     break;
1369            break;     case(ContactElementsOne):
1370         case(ReducedContactElementsOne):     Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1371            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);     break;
1372            break;     case(ReducedContactElementsOne):
1373         case(DegreesOfFreedom):     Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);
1374            throw FinleyAdapterException("Error - Gradient at degrees of freedom is not supported.");     break;
1375            break;     case(DegreesOfFreedom):
1376         case(ReducedDegreesOfFreedom):     throw FinleyAdapterException("Error - Gradient at degrees of freedom is not supported.");
1377            throw FinleyAdapterException("Error - Gradient at reduced degrees of freedom is not supported.");     break;
1378            break;     case(ReducedDegreesOfFreedom):
1379         default:     throw FinleyAdapterException("Error - Gradient at reduced degrees of freedom is not supported.");
1380            stringstream temp;     break;
1381            temp << "Error - Gradient: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();     default:
1382            throw FinleyAdapterException(temp.str());        stringstream temp;
1383            break;        temp << "Error - Gradient: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();
1384    }        throw FinleyAdapterException(temp.str());
1385    checkFinleyError();        break;
1386       }
1387       checkFinleyError();
1388  }  }
1389    
1390  //  //
# Line 847  void MeshAdapter::setToGradient(escript: Line 1392  void MeshAdapter::setToGradient(escript:
1392  //  //
1393  void MeshAdapter::setToSize(escript::Data& size) const  void MeshAdapter::setToSize(escript::Data& size) const
1394  {  {
1395    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1396    escriptDataC tmp=size.getDataC();     escriptDataC tmp=size.getDataC();
1397    switch(size.getFunctionSpace().getTypeCode()) {     switch(size.getFunctionSpace().getTypeCode()) {
1398         case(Nodes):     case(Nodes):
1399            throw FinleyAdapterException("Error - Size of nodes is not supported.");     throw FinleyAdapterException("Error - Size of nodes is not supported.");
1400            break;     break;
1401         case(ReducedNodes):     case(ReducedNodes):
1402            throw FinleyAdapterException("Error - Size of reduced nodes is not supported.");     throw FinleyAdapterException("Error - Size of reduced nodes is not supported.");
1403            break;     break;
1404         case(Elements):     case(Elements):
1405            Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);     Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);
1406            break;     break;
1407         case(ReducedElements):     case(ReducedElements):
1408            Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);     Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);
1409            break;     break;
1410         case(FaceElements):     case(FaceElements):
1411            Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);     Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);
1412            break;     break;
1413         case(ReducedFaceElements):     case(ReducedFaceElements):
1414            Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);     Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);
1415            break;     break;
1416         case(Points):     case(Points):
1417            throw FinleyAdapterException("Error - Size of point elements is not supported.");     throw FinleyAdapterException("Error - Size of point elements is not supported.");
1418            break;     break;
1419         case(ContactElementsZero):     case(ContactElementsZero):
1420         case(ContactElementsOne):     case(ContactElementsOne):
1421            Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);     Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);
1422            break;     break;
1423         case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1424         case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1425            Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);     Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);
1426            break;     break;
1427         case(DegreesOfFreedom):     case(DegreesOfFreedom):
1428            throw FinleyAdapterException("Error - Size of degrees of freedom is not supported.");     throw FinleyAdapterException("Error - Size of degrees of freedom is not supported.");
1429            break;     break;
1430         case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1431            throw FinleyAdapterException("Error - Size of reduced degrees of freedom is not supported.");     throw FinleyAdapterException("Error - Size of reduced degrees of freedom is not supported.");
1432            break;     break;
1433         default:     default:
1434            stringstream temp;        stringstream temp;
1435            temp << "Error - Element size: Finley does not know anything about function space type " << size.getFunctionSpace().getTypeCode();        temp << "Error - Element size: Finley does not know anything about function space type " << size.getFunctionSpace().getTypeCode();
1436            throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
1437            break;        break;
1438    }     }
1439    checkFinleyError();     checkFinleyError();
1440  }  }
1441    
1442  // sets the location of nodes:  // sets the location of nodes:
1443  void MeshAdapter::setNewX(const escript::Data& new_x)  void MeshAdapter::setNewX(const escript::Data& new_x)
1444  {  {
1445    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1446    escriptDataC tmp;     escriptDataC tmp;
1447    const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(new_x.getFunctionSpace().getDomain());     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(new_x.getFunctionSpace().getDomain());
1448    if (newDomain!=*this)     if (newDomain!=*this)
1449       throw FinleyAdapterException("Error - Illegal domain of new point locations");        throw FinleyAdapterException("Error - Illegal domain of new point locations");
1450    tmp = new_x.getDataC();     tmp = new_x.getDataC();
1451    Finley_Mesh_setCoordinates(mesh,&tmp);     Finley_Mesh_setCoordinates(mesh,&tmp);
1452    checkFinleyError();     checkFinleyError();
1453  }  }
1454    
1455  // saves a data array in openDX format:  // saves a data array in openDX format:
1456  void MeshAdapter::saveDX(const std::string& filename,const boost::python::dict& arg) const  void MeshAdapter::saveDX(const std::string& filename,const boost::python::dict& arg) const
1457  {  {
1458      int MAX_namelength=256;     unsigned int MAX_namelength=IS_THERE_A_REASON_FOR_THIS_MAGIC_NAME_LENGTH;
1459      const int num_data=boost::python::extract<int>(arg.attr("__len__")());     const int num_data=boost::python::extract<int>(arg.attr("__len__")());
1460    /* win32 refactor */     /* win32 refactor */
1461    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;     char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
1462    for(int i=0;i<num_data;i++)     for(int i=0;i<num_data;i++)
1463    {     {
1464      names[i] = (MAX_namelength>0) ? TMPMEMALLOC(MAX_namelength,char) : (char*)NULL;        names[i] = (MAX_namelength>0) ? TMPMEMALLOC(MAX_namelength,char) : (char*)NULL;
1465    }     }
1466    
1467    char* *c_names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;     escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;
1468    escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;     escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;
1469    escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;  
1470       boost::python::list keys=arg.keys();
1471      boost::python::list keys=arg.keys();     for (int i=0;i<num_data;++i) {
1472      for (int i=0;i<num_data;++i) {        std::string n=boost::python::extract<std::string>(keys[i]);
1473           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1474           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)        if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1475               throw FinleyAdapterException("Error  in saveDX: Data must be defined on same Domain");           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1476           data[i]=d.getDataC();        data[i]=d.getDataC();
1477           ptr_data[i]=&(data[i]);        ptr_data[i]= &(data[i]);
1478           std::string n=boost::python::extract<std::string>(keys[i]);        if (n.length()>MAX_namelength-1) {
1479           c_names[i]=&(names[i][0]);           strncpy(names[i],n.c_str(),MAX_namelength-1);
1480           if (n.length()>MAX_namelength-1) {           names[i][MAX_namelength-1]='\0';
1481              strncpy(c_names[i],n.c_str(),MAX_namelength-1);        } else {
1482              c_names[i][MAX_namelength-1]='\0';           strcpy(names[i],n.c_str());
1483           } else {        }
1484              strcpy(c_names[i],n.c_str());     }
1485           }     Finley_Mesh_saveDX(filename.c_str(),m_finleyMesh.get(),num_data,names,ptr_data);
1486      }     checkFinleyError();
1487      Finley_Mesh_saveDX(filename.c_str(),m_finleyMesh.get(),num_data,c_names,ptr_data);  
1488      checkFinleyError();     /* win32 refactor */
1489           TMPMEMFREE(data);
1490        /* win32 refactor */     TMPMEMFREE(ptr_data);
1491    TMPMEMFREE(c_names);     for(int i=0;i<num_data;i++)
1492    TMPMEMFREE(data);     {
1493    TMPMEMFREE(ptr_data);        TMPMEMFREE(names[i]);
1494    for(int i=0;i<num_data;i++)     }
1495    {     TMPMEMFREE(names);
     TMPMEMFREE(names[i]);  
   }  
   TMPMEMFREE(names);  
1496    
1497      return;     return;
1498  }  }
1499    
1500  // saves a data array in openVTK format:  // saves a data array in openVTK format:
1501  void MeshAdapter::saveVTK(const std::string& filename,const boost::python::dict& arg) const  void MeshAdapter::saveVTK(const std::string& filename,const boost::python::dict& arg) const
1502  {  {
1503      int MAX_namelength=256;     unsigned int MAX_namelength=IS_THERE_A_REASON_FOR_THIS_MAGIC_NAME_LENGTH;
1504      const int num_data=boost::python::extract<int>(arg.attr("__len__")());     const int num_data=boost::python::extract<int>(arg.attr("__len__")());
1505    /* win32 refactor */     /* win32 refactor */
1506    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;     char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
1507    for(int i=0;i<num_data;i++)     for(int i=0;i<num_data;i++)
1508    {     {
1509      names[i] = (MAX_namelength>0) ? TMPMEMALLOC(MAX_namelength,char) : (char*)NULL;        names[i] = (MAX_namelength>0) ? TMPMEMALLOC(MAX_namelength,char) : (char*)NULL;
1510    }     }
1511    
1512    char* *c_names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;     escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;
1513    escriptDataC *data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC) : (escriptDataC*)NULL;     escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;
1514    escriptDataC* *ptr_data = (num_data>0) ? TMPMEMALLOC(num_data,escriptDataC*) : (escriptDataC**)NULL;  
1515       boost::python::list keys=arg.keys();
1516      boost::python::list keys=arg.keys();     for (int i=0;i<num_data;++i) {
1517      for (int i=0;i<num_data;++i) {        std::string n=boost::python::extract<std::string>(keys[i]);
1518           escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1519           if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)        if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
1520               throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1521           data[i]=d.getDataC();        data[i]=d.getDataC();
1522           ptr_data[i]=&(data[i]);        ptr_data[i]=&(data[i]);
1523           std::string n=boost::python::extract<std::string>(keys[i]);        if (n.length()>MAX_namelength-1) {
1524           c_names[i]=&(names[i][0]);           strncpy(names[i],n.c_str(),MAX_namelength-1);
1525           if (n.length()>MAX_namelength-1) {           names[i][MAX_namelength-1]='\0';
1526              strncpy(c_names[i],n.c_str(),MAX_namelength-1);        } else {
1527              c_names[i][MAX_namelength-1]='\0';           strcpy(names[i],n.c_str());
1528           } else {        }
1529              strcpy(c_names[i],n.c_str());     }
1530           }     Finley_Mesh_saveVTK(filename.c_str(),m_finleyMesh.get(),num_data,names,ptr_data);
     }  
 #ifndef PASO_MPI      
     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  
1531    
1532  checkFinleyError();     checkFinleyError();
1533    /* win32 refactor */     /* win32 refactor */
1534    TMPMEMFREE(c_names);     TMPMEMFREE(data);
1535    TMPMEMFREE(data);     TMPMEMFREE(ptr_data);
1536    TMPMEMFREE(ptr_data);     for(int i=0;i<num_data;i++)
1537    for(int i=0;i<num_data;i++)     {
1538    {        TMPMEMFREE(names[i]);
1539      TMPMEMFREE(names[i]);     }
1540    }     TMPMEMFREE(names);
   TMPMEMFREE(names);  
1541    
1542      return;     return;
1543  }  }
1544                                                                                                                                                                                                                                                                                                                                                
1545                                                                                                                                                                                                                                                                                                                                                
1546  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
1547  SystemMatrixAdapter MeshAdapter::newSystemMatrix(  SystemMatrixAdapter MeshAdapter::newSystemMatrix(
1548                        const int row_blocksize,                                                   const int row_blocksize,
1549                        const escript::FunctionSpace& row_functionspace,                                                   const escript::FunctionSpace& row_functionspace,
1550                        const int column_blocksize,                                                   const int column_blocksize,
1551                        const escript::FunctionSpace& column_functionspace,                                                   const escript::FunctionSpace& column_functionspace,
1552                        const int type) const                                                   const int type) const
1553  {  {
1554      int reduceRowOrder=0;     int reduceRowOrder=0;
1555      int reduceColOrder=0;     int reduceColOrder=0;
1556      // is the domain right?     // is the domain right?
1557      const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(row_functionspace.getDomain());     const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(row_functionspace.getDomain());
1558      if (row_domain!=*this)     if (row_domain!=*this)
1559            throw FinleyAdapterException("Error - domain of row function space does not match the domain of matrix generator.");        throw FinleyAdapterException("Error - domain of row function space does not match the domain of matrix generator.");
1560      const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(column_functionspace.getDomain());     const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(column_functionspace.getDomain());
1561      if (col_domain!=*this)     if (col_domain!=*this)
1562            throw FinleyAdapterException("Error - domain of columnn function space does not match the domain of matrix generator.");        throw FinleyAdapterException("Error - domain of columnn function space does not match the domain of matrix generator.");
1563      // is the function space type right     // is the function space type right
1564      if (row_functionspace.getTypeCode()==DegreesOfFreedom) {     if (row_functionspace.getTypeCode()==DegreesOfFreedom) {
1565          reduceRowOrder=0;        reduceRowOrder=0;
1566      } else if (row_functionspace.getTypeCode()==ReducedDegreesOfFreedom) {     } else if (row_functionspace.getTypeCode()==ReducedDegreesOfFreedom) {
1567          reduceRowOrder=1;        reduceRowOrder=1;
1568      } else {     } else {
1569          throw FinleyAdapterException("Error - illegal function space type for system matrix rows.");        throw FinleyAdapterException("Error - illegal function space type for system matrix rows.");
1570      }     }
1571      if (column_functionspace.getTypeCode()==DegreesOfFreedom) {     if (column_functionspace.getTypeCode()==DegreesOfFreedom) {
1572          reduceColOrder=0;        reduceColOrder=0;
1573      } else if (column_functionspace.getTypeCode()==ReducedDegreesOfFreedom) {     } else if (column_functionspace.getTypeCode()==ReducedDegreesOfFreedom) {
1574          reduceColOrder=1;        reduceColOrder=1;
1575      } else {     } else {
1576          throw FinleyAdapterException("Error - illegal function space type for system matrix columns.");        throw FinleyAdapterException("Error - illegal function space type for system matrix columns.");
1577      }     }
1578      // generate matrix:     // generate matrix:
1579        
1580      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);     Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);
1581      checkFinleyError();     checkFinleyError();
1582      Paso_SystemMatrix* fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);     Paso_SystemMatrix* fsystemMatrix;
1583      checkPasoError();     int trilinos = 0;
1584      Paso_SystemMatrixPattern_dealloc(fsystemMatrixPattern);     if (trilinos) {
1585      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);  #ifdef TRILINOS
1586          /* Allocation Epetra_VrbMatrix here */
1587    #endif
1588       }
1589       else {
1590          fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);
1591       }
1592       checkPasoError();
1593       Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
1594       return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);
1595    }
1596    // creates a TransportProblemAdapter
1597    TransportProblemAdapter MeshAdapter::newTransportProblem(
1598                                                             const double theta,
1599                                                             const int blocksize,
1600                                                             const escript::FunctionSpace& functionspace,
1601                                                             const int type) const
1602    {
1603       int reduceOrder=0;
1604       // is the domain right?
1605       const MeshAdapter& domain=dynamic_cast<const MeshAdapter&>(functionspace.getDomain());
1606       if (domain!=*this)
1607          throw FinleyAdapterException("Error - domain of function space does not match the domain of transport problem generator.");
1608       // is the function space type right
1609       if (functionspace.getTypeCode()==DegreesOfFreedom) {
1610          reduceOrder=0;
1611       } else if (functionspace.getTypeCode()==ReducedDegreesOfFreedom) {
1612          reduceOrder=1;
1613       } else {
1614          throw FinleyAdapterException("Error - illegal function space type for system matrix rows.");
1615       }
1616       // generate matrix:
1617    
1618       Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceOrder,reduceOrder);
1619       checkFinleyError();
1620       Paso_FCTransportProblem* transportProblem;
1621       transportProblem=Paso_FCTransportProblem_alloc(theta,fsystemMatrixPattern,blocksize);
1622       checkPasoError();
1623       Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
1624       return TransportProblemAdapter(transportProblem,theta,blocksize,functionspace);
1625  }  }
1626    
1627  //  //
# Line 1059  SystemMatrixAdapter MeshAdapter::newSyst Line 1633  SystemMatrixAdapter MeshAdapter::newSyst
1633  // returns true if data at the atom_type is considered as being cell centered:  // returns true if data at the atom_type is considered as being cell centered:
1634  bool MeshAdapter::isCellOriented(int functionSpaceCode) const  bool MeshAdapter::isCellOriented(int functionSpaceCode) const
1635  {  {
1636    switch(functionSpaceCode) {     switch(functionSpaceCode) {
1637         case(Nodes):     case(Nodes):
1638         case(DegreesOfFreedom):     case(DegreesOfFreedom):
1639         case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1640            return false;     return false;
1641            break;     break;
1642         case(Elements):     case(Elements):
1643         case(FaceElements):     case(FaceElements):
1644         case(Points):     case(Points):
1645         case(ContactElementsZero):     case(ContactElementsZero):
1646         case(ContactElementsOne):     case(ContactElementsOne):
1647         case(ReducedElements):     case(ReducedElements):
1648         case(ReducedFaceElements):     case(ReducedFaceElements):
1649         case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1650         case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1651            return true;     return true;
1652            break;     break;
1653         default:     default:
1654            stringstream temp;        stringstream temp;
1655            temp << "Error - Cell: Finley does not know anything about function space type " << functionSpaceCode;        temp << "Error - Cell: Finley does not know anything about function space type " << functionSpaceCode;
1656            throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
1657            break;        break;
1658    }     }
1659    checkFinleyError();     checkFinleyError();
1660    return false;     return false;
1661  }  }
1662    
1663  bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const  bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const
1664  {  {
1665    switch(functionSpaceType_source) {     switch(functionSpaceType_source) {
1666       case(Nodes):     case(Nodes):
1667          switch(functionSpaceType_target) {     switch(functionSpaceType_target) {
1668             case(Nodes):     case(Nodes):
1669             case(ReducedNodes):     case(ReducedNodes):
1670             case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1671             case(DegreesOfFreedom):     case(DegreesOfFreedom):
1672             case(Elements):     case(Elements):
1673             case(ReducedElements):     case(ReducedElements):
1674             case(FaceElements):     case(FaceElements):
1675             case(ReducedFaceElements):     case(ReducedFaceElements):
1676             case(Points):     case(Points):
1677             case(ContactElementsZero):     case(ContactElementsZero):
1678             case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1679             case(ContactElementsOne):     case(ContactElementsOne):
1680             case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1681                 return true;     return true;
1682             default:     default:
1683                 stringstream temp;        stringstream temp;
1684                 temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1685                 throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
1686          }     }
1687          break;     break;
1688       case(ReducedNodes):     case(ReducedNodes):
1689          switch(functionSpaceType_target) {     switch(functionSpaceType_target) {
1690             case(ReducedNodes):     case(ReducedNodes):
1691             case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1692             case(Elements):     case(Elements):
1693             case(ReducedElements):     case(ReducedElements):
1694             case(FaceElements):     case(FaceElements):
1695             case(ReducedFaceElements):     case(ReducedFaceElements):
1696             case(Points):     case(Points):
1697             case(ContactElementsZero):     case(ContactElementsZero):
1698             case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1699             case(ContactElementsOne):     case(ContactElementsOne):
1700             case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1701                 return true;     return true;
1702            case(Nodes):     case(Nodes):
1703            case(DegreesOfFreedom):     case(DegreesOfFreedom):
1704               return false;     return false;
1705             default:     default:
1706                 stringstream temp;        stringstream temp;
1707                 temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1708                 throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
1709          }     }
1710          break;     break;
1711       case(Elements):     case(Elements):
1712          if (functionSpaceType_target==Elements) {     if (functionSpaceType_target==Elements) {
1713             return true;        return true;
1714          } else if (functionSpaceType_target==ReducedElements) {     } else if (functionSpaceType_target==ReducedElements) {
1715             return true;        return true;
1716          } else {     } else {
1717             return false;        return false;
1718          }     }
1719       case(ReducedElements):     case(ReducedElements):
1720          if (functionSpaceType_target==ReducedElements) {     if (functionSpaceType_target==ReducedElements) {
1721             return true;        return true;
1722          } else {     } else {
1723             return false;        return false;
1724          }     }
1725       case(FaceElements):     case(FaceElements):
1726          if (functionSpaceType_target==FaceElements) {     if (functionSpaceType_target==FaceElements) {
1727             return true;        return true;
1728          } else if (functionSpaceType_target==ReducedFaceElements) {     } else if (functionSpaceType_target==ReducedFaceElements) {
1729             return true;        return true;
1730          } else {     } else {
1731             return false;        return false;
1732          }     }
1733       case(ReducedFaceElements):     case(ReducedFaceElements):
1734          if (functionSpaceType_target==ReducedFaceElements) {     if (functionSpaceType_target==ReducedFaceElements) {
1735             return true;        return true;
1736          } else {     } else {
1737             return false;        return false;
1738          }     }
1739       case(Points):     case(Points):
1740          if (functionSpaceType_target==Points) {     if (functionSpaceType_target==Points) {
1741             return true;        return true;
1742          } else {     } else {
1743             return false;        return false;
1744          }     }
1745       case(ContactElementsZero):     case(ContactElementsZero):
1746       case(ContactElementsOne):     case(ContactElementsOne):
1747          if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {     if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {
1748             return true;        return true;
1749          } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {     } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1750             return true;        return true;
1751          } else {     } else {
1752             return false;        return false;
1753          }     }
1754       case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1755       case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1756          if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {     if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1757             return true;        return true;
1758          } else {     } else {
1759             return false;        return false;
1760          }     }
1761       case(DegreesOfFreedom):     case(DegreesOfFreedom):
1762          switch(functionSpaceType_target) {     switch(functionSpaceType_target) {
1763             case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1764             case(DegreesOfFreedom):     case(DegreesOfFreedom):
1765             case(Nodes):     case(Nodes):
1766             case(ReducedNodes):     case(ReducedNodes):
1767             case(Elements):     case(Elements):
1768             case(ReducedElements):     case(ReducedElements):
1769             case(Points):     case(Points):
1770             case(FaceElements):     case(FaceElements):
1771             case(ReducedFaceElements):     case(ReducedFaceElements):
1772             case(ContactElementsZero):     case(ContactElementsZero):
1773             case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1774             case(ContactElementsOne):     case(ContactElementsOne):
1775             case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1776                return true;     return true;
1777             default:     default:
1778               stringstream temp;        stringstream temp;
1779               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1780               throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
1781          }     }
1782          break;     break;
1783       case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1784         switch(functionSpaceType_target) {     switch(functionSpaceType_target) {
1785            case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1786            case(ReducedNodes):     case(ReducedNodes):
1787            case(Elements):     case(Elements):
1788            case(ReducedElements):     case(ReducedElements):
1789            case(FaceElements):     case(FaceElements):
1790            case(ReducedFaceElements):     case(ReducedFaceElements):
1791            case(Points):     case(Points):
1792            case(ContactElementsZero):     case(ContactElementsZero):
1793            case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1794            case(ContactElementsOne):     case(ContactElementsOne):
1795            case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1796                return true;     return true;
1797            case(Nodes):     case(Nodes):
1798            case(DegreesOfFreedom):     case(DegreesOfFreedom):
1799               return false;     return false;
1800            default:     default:
1801               stringstream temp;        stringstream temp;
1802               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1803               throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
1804         }     }
1805         break;     break;
1806       default:     default:
1807          stringstream temp;        stringstream temp;
1808          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_source;        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_source;
1809          throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
1810          break;        break;
1811    }     }
1812    checkFinleyError();     checkFinleyError();
1813    return false;     return false;
1814  }  }
1815    
1816  bool MeshAdapter::probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const  bool MeshAdapter::probeInterpolationACross(int functionSpaceType_source,const AbstractDomain& targetDomain, int functionSpaceType_target) const
1817  {  {
1818      return false;     return false;
1819  }  }
1820    
1821  bool MeshAdapter::operator==(const AbstractDomain& other) const  bool MeshAdapter::operator==(const AbstractDomain& other) const
1822  {  {
1823    const MeshAdapter* temp=dynamic_cast<const MeshAdapter*>(&other);     const MeshAdapter* temp=dynamic_cast<const MeshAdapter*>(&other);
1824    if (temp!=0) {     if (temp!=0) {
1825      return (m_finleyMesh==temp->m_finleyMesh);        return (m_finleyMesh==temp->m_finleyMesh);
1826    } else {     } else {
1827      return false;        return false;
1828    }     }
1829  }  }
1830    
1831  bool MeshAdapter::operator!=(const AbstractDomain& other) const  bool MeshAdapter::operator!=(const AbstractDomain& other) const
1832  {  {
1833    return !(operator==(other));     return !(operator==(other));
1834  }  }
1835    
1836  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const
# Line 1268  int MeshAdapter::getSystemMatrixTypeId(c Line 1842  int MeshAdapter::getSystemMatrixTypeId(c
1842    
1843  escript::Data MeshAdapter::getX() const  escript::Data MeshAdapter::getX() const
1844  {  {
1845    return continuousFunction(asAbstractContinuousDomain()).getX();     return continuousFunction(asAbstractContinuousDomain()).getX();
1846  }  }
1847    
1848  escript::Data MeshAdapter::getNormal() const  escript::Data MeshAdapter::getNormal() const
1849  {  {
1850    return functionOnBoundary(asAbstractContinuousDomain()).getNormal();     return functionOnBoundary(asAbstractContinuousDomain()).getNormal();
1851  }  }
1852    
1853  escript::Data MeshAdapter::getSize() const  escript::Data MeshAdapter::getSize() const
1854  {  {
1855    return function(asAbstractContinuousDomain()).getSize();     return function(asAbstractContinuousDomain()).getSize();
1856  }  }
1857    
1858  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const
1859  {  {
1860    int *out=0,i;     int *out = NULL;
1861    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1862    switch (functionSpaceType) {     switch (functionSpaceType) {
1863      case(Nodes):     case(Nodes):
1864        if (mesh->Nodes!=NULL) {     out=mesh->Nodes->Id;
1865          out=mesh->Nodes->Id;     break;
1866          break;     case(ReducedNodes):
1867        }     out=mesh->Nodes->reducedNodesId;
1868      case(ReducedNodes):     break;
1869        throw FinleyAdapterException("Error -  ReducedNodes not supported yet.");     case(Elements):
1870        break;     out=mesh->Elements->Id;
1871      case(Elements):     break;
1872        out=mesh->Elements->Id;     case(ReducedElements):
1873        break;     out=mesh->Elements->Id;
1874      case(ReducedElements):     break;
1875        out=mesh->Elements->Id;     case(FaceElements):
1876        break;     out=mesh->FaceElements->Id;
1877      case(FaceElements):     break;
1878        out=mesh->FaceElements->Id;     case(ReducedFaceElements):
1879        break;     out=mesh->FaceElements->Id;
1880      case(ReducedFaceElements):     break;
1881        out=mesh->FaceElements->Id;     case(Points):
1882        break;     out=mesh->Points->Id;
1883      case(Points):     break;
1884        out=mesh->Points->Id;     case(ContactElementsZero):
1885        break;     out=mesh->ContactElements->Id;
1886      case(ContactElementsZero):     break;
1887        out=mesh->ContactElements->Id;     case(ReducedContactElementsZero):
1888        break;     out=mesh->ContactElements->Id;
1889      case(ReducedContactElementsZero):     break;
1890        out=mesh->ContactElements->Id;     case(ContactElementsOne):
1891        break;     out=mesh->ContactElements->Id;
1892      case(ContactElementsOne):     break;
1893        out=mesh->ContactElements->Id;     case(ReducedContactElementsOne):
1894        break;     out=mesh->ContactElements->Id;
1895      case(ReducedContactElementsOne):     break;
1896        out=mesh->ContactElements->Id;     case(DegreesOfFreedom):
1897        break;     out=mesh->Nodes->degreesOfFreedomId;
1898      case(DegreesOfFreedom):     break;
1899        out=mesh->Nodes->degreeOfFreedomId;     case(ReducedDegreesOfFreedom):
1900        break;     out=mesh->Nodes->reducedDegreesOfFreedomId;
1901      case(ReducedDegreesOfFreedom):     break;
1902        out=mesh->Nodes->reducedDegreeOfFreedomId;     default:
       break;  
     default:  
1903        stringstream temp;        stringstream temp;
1904        temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();        temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
1905        throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
1906        break;        break;
1907    }     }
1908    return out;     return out;
1909  }  }
1910  int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const  int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const
1911  {  {
1912    int out=0;     int out=0;
1913    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1914    switch (functionSpaceType) {     switch (functionSpaceType) {
1915    case(Nodes):     case(Nodes):
1916      out=mesh->Nodes->Tag[sampleNo];     out=mesh->Nodes->Tag[sampleNo];
1917      break;     break;
1918    case(ReducedNodes):     case(ReducedNodes):
1919      throw FinleyAdapterException(" Error - ReducedNodes does not support tags.");     throw FinleyAdapterException(" Error - ReducedNodes does not support tags.");
1920      break;     break;
1921    case(Elements):     case(Elements):
1922      out=mesh->Elements->Tag[sampleNo];     out=mesh->Elements->Tag[sampleNo];
1923      break;     break;
1924    case(ReducedElements):     case(ReducedElements):
1925      out=mesh->Elements->Tag[sampleNo];     out=mesh->Elements->Tag[sampleNo];
1926      break;     break;
1927    case(FaceElements):     case(FaceElements):
1928      out=mesh->FaceElements->Tag[sampleNo];     out=mesh->FaceElements->Tag[sampleNo];
1929      break;     break;
1930    case(ReducedFaceElements):     case(ReducedFaceElements):
1931      out=mesh->FaceElements->Tag[sampleNo];     out=mesh->FaceElements->Tag[sampleNo];
1932      break;     break;
1933    case(Points):     case(Points):
1934      out=mesh->Points->Tag[sampleNo];     out=mesh->Points->Tag[sampleNo];
1935      break;     break;
1936    case(ContactElementsZero):     case(ContactElementsZero):
1937      out=mesh->ContactElements->Tag[sampleNo];     out=mesh->ContactElements->Tag[sampleNo];
1938      break;     break;
1939    case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1940      out=mesh->ContactElements->Tag[sampleNo];     out=mesh->ContactElements->Tag[sampleNo];
1941      break;     break;
1942    case(ContactElementsOne):     case(ContactElementsOne):
1943      out=mesh->ContactElements->Tag[sampleNo];     out=mesh->ContactElements->Tag[sampleNo];
1944      break;     break;
1945    case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1946      out=mesh->ContactElements->Tag[sampleNo];     out=mesh->ContactElements->Tag[sampleNo];
1947      break;     break;
1948    case(DegreesOfFreedom):     case(DegreesOfFreedom):
1949      throw FinleyAdapterException(" Error - DegreesOfFreedom does not support tags.");     throw FinleyAdapterException(" Error - DegreesOfFreedom does not support tags.");
1950      break;     break;
1951    case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1952      throw FinleyAdapterException(" Error - ReducedDegreesOfFreedom does not support tags.");     throw FinleyAdapterException(" Error - ReducedDegreesOfFreedom does not support tags.");
1953      break;     break;
1954    default:     default:
1955      stringstream temp;        stringstream temp;
1956      temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();        temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
1957      throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
1958      break;        break;
1959    }     }
1960    return out;     return out;
1961  }  }
1962    
1963    
1964  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
1965  {  {
1966    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1967    escriptDataC tmp=mask.getDataC();     escriptDataC tmp=mask.getDataC();
1968    switch(functionSpaceType) {     switch(functionSpaceType) {
1969         case(Nodes):     case(Nodes):
1970            Finley_NodeFile_setTags(mesh->Nodes,newTag,&tmp);     Finley_NodeFile_setTags(mesh->Nodes,newTag,&tmp);
1971            break;     break;
1972         case(ReducedNodes):     case(ReducedNodes):
1973            throw FinleyAdapterException("Error - ReducedNodes does not support tags");     throw FinleyAdapterException("Error - ReducedNodes does not support tags");
1974            break;     break;
1975         case(DegreesOfFreedom):     case(DegreesOfFreedom):
1976            throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");     throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");
1977            break;     break;
1978         case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1979            throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");     throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");
1980            break;     break;
1981         case(Elements):     case(Elements):
1982            Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);     Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);
1983            break;     break;
1984         case(ReducedElements):     case(ReducedElements):
1985            Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);     Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);
1986            break;     break;
1987         case(FaceElements):     case(FaceElements):
1988            Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);     Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);
1989            break;     break;
1990         case(ReducedFaceElements):     case(ReducedFaceElements):
1991            Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);     Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);
1992            break;     break;
1993         case(Points):     case(Points):
1994            Finley_ElementFile_setTags(mesh->Points,newTag,&tmp);     Finley_ElementFile_setTags(mesh->Points,newTag,&tmp);
1995            break;     break;
1996         case(ContactElementsZero):     case(ContactElementsZero):
1997            Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);     Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
1998            break;     break;
1999         case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
2000            Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);     Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
2001            break;     break;
2002         case(ContactElementsOne):     case(ContactElementsOne):
2003            Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);     Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
2004            break;     break;
2005         case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
2006            Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);     Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);
2007            break;     break;
2008         default:     default:
2009            stringstream temp;        stringstream temp;
2010            temp << "Error - Finley does not know anything about function space type " << functionSpaceType;        temp << "Error - Finley does not know anything about function space type " << functionSpaceType;
2011            throw FinleyAdapterException(temp.str());        throw FinleyAdapterException(temp.str());
2012    }     }
2013    checkFinleyError();     checkFinleyError();
2014    return;     return;
2015  }  }
2016    
2017  void MeshAdapter::setTagMap(const std::string& name,  int tag)  void MeshAdapter::setTagMap(const std::string& name,  int tag)
2018  {  {
2019    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
2020    Finley_Mesh_addTagMap(mesh, name.c_str(),tag);     Finley_Mesh_addTagMap(mesh, name.c_str(),tag);
2021    checkPasoError();     checkPasoError();
2022    // throwStandardException("MeshAdapter::set TagMap is not implemented.");     // throwStandardException("MeshAdapter::set TagMap is not implemented.");
2023  }  }
2024    
2025  int MeshAdapter::getTag(const std::string& name) const  int MeshAdapter::getTag(const std::string& name) const
2026  {  {
2027    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
2028    int tag=0;     int tag=0;
2029    tag=Finley_Mesh_getTag(mesh, name.c_str());     tag=Finley_Mesh_getTag(mesh, name.c_str());
2030    checkPasoError();     checkPasoError();
2031    // throwStandardException("MeshAdapter::getTag is not implemented.");     // throwStandardException("MeshAdapter::getTag is not implemented.");
2032    return tag;     return tag;
2033  }  }
2034    
2035  bool MeshAdapter::isValidTagName(const std::string& name) const  bool MeshAdapter::isValidTagName(const std::string& name) const
2036  {  {
2037    Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
2038    return Finley_Mesh_isValidTagName(mesh,name.c_str());     return Finley_Mesh_isValidTagName(mesh,name.c_str());
2039  }  }
2040    
2041  std::string MeshAdapter::showTagNames() const  std::string MeshAdapter::showTagNames() const
2042  {  {
2043    stringstream temp;     stringstream temp;
2044       Finley_Mesh* mesh=m_finleyMesh.get();
2045       Finley_TagMap* tag_map=mesh->TagMap;
2046       while (tag_map) {
2047          temp << tag_map->name;
2048          tag_map=tag_map->next;
2049          if (tag_map) temp << ", ";
2050       }
2051       return temp.str();
2052    }
2053    
2054    int MeshAdapter::getNumberOfTagsInUse(int functionSpaceCode) const
2055    {
2056      Finley_Mesh* mesh=m_finleyMesh.get();
2057      dim_t numTags=0;
2058      switch(functionSpaceCode) {
2059       case(Nodes):
2060              numTags=mesh->Nodes->numTagsInUse;
2061              break;
2062       case(ReducedNodes):
2063              throw FinleyAdapterException("Error - ReducedNodes does not support tags");
2064              break;
2065       case(DegreesOfFreedom):
2066              throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");
2067              break;
2068       case(ReducedDegreesOfFreedom):
2069              throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");
2070              break;
2071       case(Elements):
2072       case(ReducedElements):
2073              numTags=mesh->Elements->numTagsInUse;
2074              break;
2075       case(FaceElements):
2076       case(ReducedFaceElements):
2077              numTags=mesh->FaceElements->numTagsInUse;
2078              break;
2079       case(Points):
2080              numTags=mesh->Points->numTagsInUse;
2081              break;
2082       case(ContactElementsZero):
2083       case(ReducedContactElementsZero):
2084       case(ContactElementsOne):
2085       case(ReducedContactElementsOne):
2086              numTags=mesh->ContactElements->numTagsInUse;
2087              break;
2088       default:
2089          stringstream temp;
2090          temp << "Error - Finley does not know anything about function space type " << functionSpaceCode;
2091          throw FinleyAdapterException(temp.str());
2092      }
2093      return numTags;
2094    }
2095    int* MeshAdapter::borrowListOfTagsInUse(int functionSpaceCode) const
2096    {
2097    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
2098    Finley_TagMap* tag_map=mesh->TagMap;    index_t* tags=NULL;
2099    while (tag_map) {    switch(functionSpaceCode) {
2100       temp << tag_map->name;     case(Nodes):
2101       tag_map=tag_map->next;            tags=mesh->Nodes->tagsInUse;
2102       if (tag_map) temp << ", ";            break;
2103       case(ReducedNodes):
2104              throw FinleyAdapterException("Error - ReducedNodes does not support tags");
2105              break;
2106       case(DegreesOfFreedom):
2107              throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");
2108              break;
2109       case(ReducedDegreesOfFreedom):
2110              throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");
2111              break;
2112       case(Elements):
2113       case(ReducedElements):
2114              tags=mesh->Elements->tagsInUse;
2115              break;
2116       case(FaceElements):
2117       case(ReducedFaceElements):
2118              tags=mesh->FaceElements->tagsInUse;
2119              break;
2120       case(Points):
2121              tags=mesh->Points->tagsInUse;
2122              break;
2123       case(ContactElementsZero):
2124       case(ReducedContactElementsZero):
2125       case(ContactElementsOne):
2126       case(ReducedContactElementsOne):
2127              tags=mesh->ContactElements->tagsInUse;
2128              break;
2129       default:
2130          stringstream temp;
2131          temp << "Error - Finley does not know anything about function space type " << functionSpaceCode;
2132          throw FinleyAdapterException(temp.str());
2133    }    }
2134    return temp.str();    return tags;
2135  }  }
2136    
2137    
2138  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.1116  
changed lines
  Added in v.1754

  ViewVC Help
Powered by ViewVC 1.1.26