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

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

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

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

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

  ViewVC Help
Powered by ViewVC 1.1.26