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

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

  ViewVC Help
Powered by ViewVC 1.1.26