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

Legend:
Removed from v.1388  
changed lines
  Added in v.1748

  ViewVC Help
Powered by ViewVC 1.1.26