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

Legend:
Removed from v.1464  
changed lines
  Added in v.1800

  ViewVC Help
Powered by ViewVC 1.1.26