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

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

  ViewVC Help
Powered by ViewVC 1.1.26