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

Legend:
Removed from v.1346  
changed lines
  Added in v.1801

  ViewVC Help
Powered by ViewVC 1.1.26