/[escript]/branches/domexper/dudley/src/CPPAdapter/MeshAdapter.cpp
ViewVC logotype

Diff of /branches/domexper/dudley/src/CPPAdapter/MeshAdapter.cpp

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

trunk/finley/src/CPPAdapter/MeshAdapter.cpp revision 2748 by gross, Tue Nov 17 07:32:59 2009 UTC branches/domexper/dudley/src/CPPAdapter/MeshAdapter.cpp revision 3152 by jfenwick, Fri Sep 3 05:48:31 2010 UTC
# Line 1  Line 1 
1    
2  /*******************************************************  /*******************************************************
3  *  *
4  * Copyright (c) 2003-2009 by University of Queensland  * Copyright (c) 2003-2010 by University of Queensland
5  * Earth Systems Science Computational Center (ESSCC)  * Earth Systems Science Computational Center (ESSCC)
6  * http://www.uq.edu.au/esscc  * http://www.uq.edu.au/esscc
7  *  *
# Line 29  extern "C" { Line 29  extern "C" {
29  using namespace std;  using namespace std;
30  using namespace escript;  using namespace escript;
31    
32  namespace finley {  namespace dudley {
33    
34  //  //
35  // define the static constants  // define the static constants
36  MeshAdapter::FunctionSpaceNamesMapType MeshAdapter::m_functionSpaceTypeNames;  MeshAdapter::FunctionSpaceNamesMapType MeshAdapter::m_functionSpaceTypeNames;
37  const int MeshAdapter::DegreesOfFreedom=FINLEY_DEGREES_OF_FREEDOM;  const int MeshAdapter::DegreesOfFreedom=DUDLEY_DEGREES_OF_FREEDOM;
38  const int MeshAdapter::ReducedDegreesOfFreedom=FINLEY_REDUCED_DEGREES_OF_FREEDOM;  const int MeshAdapter::ReducedDegreesOfFreedom=DUDLEY_REDUCED_DEGREES_OF_FREEDOM;
39  const int MeshAdapter::Nodes=FINLEY_NODES;  const int MeshAdapter::Nodes=DUDLEY_NODES;
40  const int MeshAdapter::ReducedNodes=FINLEY_REDUCED_NODES;  const int MeshAdapter::ReducedNodes=DUDLEY_REDUCED_NODES;
41  const int MeshAdapter::Elements=FINLEY_ELEMENTS;  const int MeshAdapter::Elements=DUDLEY_ELEMENTS;
42  const int MeshAdapter::ReducedElements=FINLEY_REDUCED_ELEMENTS;  const int MeshAdapter::ReducedElements=DUDLEY_REDUCED_ELEMENTS;
43  const int MeshAdapter::FaceElements=FINLEY_FACE_ELEMENTS;  const int MeshAdapter::FaceElements=DUDLEY_FACE_ELEMENTS;
44  const int MeshAdapter::ReducedFaceElements=FINLEY_REDUCED_FACE_ELEMENTS;  const int MeshAdapter::ReducedFaceElements=DUDLEY_REDUCED_FACE_ELEMENTS;
45  const int MeshAdapter::Points=FINLEY_POINTS;  const int MeshAdapter::Points=DUDLEY_POINTS;
 const int MeshAdapter::ContactElementsZero=FINLEY_CONTACT_ELEMENTS_1;  
 const int MeshAdapter::ReducedContactElementsZero=FINLEY_REDUCED_CONTACT_ELEMENTS_1;  
 const int MeshAdapter::ContactElementsOne=FINLEY_CONTACT_ELEMENTS_2;  
 const int MeshAdapter::ReducedContactElementsOne=FINLEY_REDUCED_CONTACT_ELEMENTS_2;  
46    
47  MeshAdapter::MeshAdapter(Finley_Mesh* finleyMesh)  MeshAdapter::MeshAdapter(Dudley_Mesh* dudleyMesh)
48  {  {
49     setFunctionSpaceTypeNames();     setFunctionSpaceTypeNames();
50     //     //
51     // need to use a null_deleter as Finley_Mesh_free deletes the pointer     // need to use a null_deleter as Dudley_Mesh_free deletes the pointer
52     // for us.     // for us.
53     m_finleyMesh.reset(finleyMesh,null_deleter());     m_dudleyMesh.reset(dudleyMesh,null_deleter());
54  }  }
55    
56  //  //
57  // The copy constructor should just increment the use count  // The copy constructor should just increment the use count
58  MeshAdapter::MeshAdapter(const MeshAdapter& in):  MeshAdapter::MeshAdapter(const MeshAdapter& in):
59  m_finleyMesh(in.m_finleyMesh)  m_dudleyMesh(in.m_dudleyMesh)
60  {  {
61     setFunctionSpaceTypeNames();     setFunctionSpaceTypeNames();
62  }  }
# Line 70  MeshAdapter::~MeshAdapter() Line 66  MeshAdapter::~MeshAdapter()
66     //     //
67     // 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.
68     //  cout << "In MeshAdapter destructor." << endl;     //  cout << "In MeshAdapter destructor." << endl;
69     if (m_finleyMesh.unique()) {     if (m_dudleyMesh.unique()) {
70        Finley_Mesh_free(m_finleyMesh.get());        Dudley_Mesh_free(m_dudleyMesh.get());
71     }     }
72  }  }
73    
74  int MeshAdapter::getMPISize() const  int MeshAdapter::getMPISize() const
75  {  {
76     return m_finleyMesh.get()->MPIInfo->size;     return m_dudleyMesh.get()->MPIInfo->size;
77  }  }
78  int MeshAdapter::getMPIRank() const  int MeshAdapter::getMPIRank() const
79  {  {
80     return m_finleyMesh.get()->MPIInfo->rank;     return m_dudleyMesh.get()->MPIInfo->rank;
81  }  }
82  void MeshAdapter::MPIBarrier() const  void MeshAdapter::MPIBarrier() const
83  {  {
84  #ifdef PASO_MPI  #ifdef PASO_MPI
85     MPI_Barrier(m_finleyMesh.get()->MPIInfo->comm);     MPI_Barrier(m_dudleyMesh.get()->MPIInfo->comm);
86  #endif  #endif
87     return;     return;
88  }  }
89  bool MeshAdapter::onMasterProcessor() const  bool MeshAdapter::onMasterProcessor() const
90  {  {
91     return m_finleyMesh.get()->MPIInfo->rank == 0;     return m_dudleyMesh.get()->MPIInfo->rank == 0;
92  }  }
93    
94    
# Line 104  bool MeshAdapter::onMasterProcessor() co Line 100  bool MeshAdapter::onMasterProcessor() co
100  MeshAdapter::getMPIComm() const  MeshAdapter::getMPIComm() const
101  {  {
102  #ifdef PASO_MPI  #ifdef PASO_MPI
103      return m_finleyMesh->MPIInfo->comm;      return m_dudleyMesh->MPIInfo->comm;
104  #else  #else
105      return 0;      return 0;
106  #endif  #endif
107  }  }
108    
109    
110  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {  Dudley_Mesh* MeshAdapter::getDudley_Mesh() const {
111     return m_finleyMesh.get();     return m_dudleyMesh.get();
112  }  }
113    
114  void MeshAdapter::write(const std::string& fileName) const  void MeshAdapter::write(const string& fileName) const
115  {  {
116     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;
117     strcpy(fName,fileName.c_str());     strcpy(fName,fileName.c_str());
118     Finley_Mesh_write(m_finleyMesh.get(),fName);     Dudley_Mesh_write(m_dudleyMesh.get(),fName);
119     checkFinleyError();     checkDudleyError();
120     TMPMEMFREE(fName);     TMPMEMFREE(fName);
121  }  }
122    
123  void MeshAdapter::Print_Mesh_Info(const bool full) const  void MeshAdapter::Print_Mesh_Info(const bool full) const
124  {  {
125     Finley_PrintMesh_Info(m_finleyMesh.get(), full);     Dudley_PrintMesh_Info(m_dudleyMesh.get(), full);
126  }  }
127    
128  void MeshAdapter::dump(const std::string& fileName) const  void MeshAdapter::dump(const string& fileName) const
129  {  {
130  #ifdef USE_NETCDF  #ifdef USE_NETCDF
131     const NcDim* ncdims[12] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};     const NcDim* ncdims[12] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
132     NcVar *ids;     NcVar *ids;
133     int *int_ptr;     int *int_ptr;
134     Finley_Mesh *mesh = m_finleyMesh.get();     Dudley_Mesh *mesh = m_dudleyMesh.get();
135     Finley_TagMap* tag_map;     Dudley_TagMap* tag_map;
136     int num_Tags = 0;     int num_Tags = 0;
137     int mpi_size             = mesh->MPIInfo->size;     int mpi_size             = mesh->MPIInfo->size;
138     int mpi_rank             = mesh->MPIInfo->rank;     int mpi_rank             = mesh->MPIInfo->rank;
# Line 144  void MeshAdapter::dump(const std::string Line 140  void MeshAdapter::dump(const std::string
140     int numNodes             = mesh->Nodes->numNodes;     int numNodes             = mesh->Nodes->numNodes;
141     int num_Elements         = mesh->Elements->numElements;     int num_Elements         = mesh->Elements->numElements;
142     int num_FaceElements         = mesh->FaceElements->numElements;     int num_FaceElements         = mesh->FaceElements->numElements;
    int num_ContactElements      = mesh->ContactElements->numElements;  
143     int num_Points           = mesh->Points->numElements;     int num_Points           = mesh->Points->numElements;
144     int num_Elements_numNodes        = mesh->Elements->numNodes;     int num_Elements_numNodes        = mesh->Elements->numNodes;
145     int num_FaceElements_numNodes    = mesh->FaceElements->numNodes;     int num_FaceElements_numNodes    = mesh->FaceElements->numNodes;
    int num_ContactElements_numNodes = mesh->ContactElements->numNodes;  
146  #ifdef PASO_MPI  #ifdef PASO_MPI
147     MPI_Status status;     MPI_Status status;
148  #endif  #endif
# Line 164  void MeshAdapter::dump(const std::string Line 158  void MeshAdapter::dump(const std::string
158     /* Figure out how much storage is required for tags */     /* Figure out how much storage is required for tags */
159     tag_map = mesh->TagMap;     tag_map = mesh->TagMap;
160     num_Tags = 0;     num_Tags = 0;
161     if (tag_map) {     while (tag_map) {
162        while (tag_map) {        num_Tags++;
163           num_Tags++;        tag_map=tag_map->next;
          tag_map=tag_map->next;  
       }  
164     }     }
165    
166     // NetCDF error handler     // NetCDF error handler
167     NcError err(NcError::verbose_nonfatal);     NcError err(NcError::verbose_nonfatal);
168     // Create the file.     // Create the file.
169     NcFile dataFile(newFileName, NcFile::Replace);     NcFile dataFile(newFileName, NcFile::Replace);
170       string msgPrefix("Error in MeshAdapter::dump: NetCDF operation failed - ");
171     // check if writing was successful     // check if writing was successful
172     if (!dataFile.is_valid())     if (!dataFile.is_valid())
173        throw DataException("Error - MeshAdapter::dump: opening of NetCDF file for output failed: " + *newFileName);        throw DataException(msgPrefix+"Open file for output");
174    
175     // Define dimensions (num_Elements and dim_Elements are identical, dim_Elements only appears if > 0)     // Define dimensions (num_Elements and dim_Elements are identical,
176       // dim_Elements only appears if > 0)
177     if (! (ncdims[0] = dataFile.add_dim("numNodes", numNodes)) )     if (! (ncdims[0] = dataFile.add_dim("numNodes", numNodes)) )
178        throw DataException("Error - MeshAdapter::dump: appending dimension numNodes to netCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_dim(numNodes)");
179     if (! (ncdims[1] = dataFile.add_dim("numDim", numDim)) )     if (! (ncdims[1] = dataFile.add_dim("numDim", numDim)) )
180        throw DataException("Error - MeshAdapter::dump: appending dimension numDim to netCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_dim(numDim)");
181     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)) )
182        throw DataException("Error - MeshAdapter::dump: appending dimension mpi_size to netCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_dim(mpi_size)");
183     if (num_Elements>0)     if (num_Elements>0)
184        if (! (ncdims[3] = dataFile.add_dim("dim_Elements", num_Elements)) )        if (! (ncdims[3] = dataFile.add_dim("dim_Elements", num_Elements)) )
185           throw DataException("Error - MeshAdapter::dump: appending dimension dim_Elements to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_dim(dim_Elements)");
186     if (num_FaceElements>0)     if (num_FaceElements>0)
187        if (! (ncdims[4] = dataFile.add_dim("dim_FaceElements", num_FaceElements)) )        if (! (ncdims[4] = dataFile.add_dim("dim_FaceElements", num_FaceElements)) )
188           throw DataException("Error - MeshAdapter::dump: appending dimension dim_FaceElements to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_dim(dim_FaceElements)");
    if (num_ContactElements>0)  
       if (! (ncdims[5] = dataFile.add_dim("dim_ContactElements", num_ContactElements)) )  
          throw DataException("Error - MeshAdapter::dump: appending dimension dim_ContactElements to netCDF file failed: " + *newFileName);  
189     if (num_Points>0)     if (num_Points>0)
190        if (! (ncdims[6] = dataFile.add_dim("dim_Points", num_Points)) )        if (! (ncdims[6] = dataFile.add_dim("dim_Points", num_Points)) )
191           throw DataException("Error - MeshAdapter::dump: appending dimension dim_Points to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_dim(dim_Points)");
192     if (num_Elements>0)     if (num_Elements>0)
193        if (! (ncdims[7] = dataFile.add_dim("dim_Elements_Nodes", num_Elements_numNodes)) )        if (! (ncdims[7] = dataFile.add_dim("dim_Elements_Nodes", num_Elements_numNodes)) )
194           throw DataException("Error - MeshAdapter::dump: appending dimension dim_Elements_Nodes to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_dim(dim_Elements_Nodes)");
195     if (num_FaceElements>0)     if (num_FaceElements>0)
196        if (! (ncdims[8] = dataFile.add_dim("dim_FaceElements_numNodes", num_FaceElements_numNodes)) )        if (! (ncdims[8] = dataFile.add_dim("dim_FaceElements_numNodes", num_FaceElements_numNodes)) )
197           throw DataException("Error - MeshAdapter::dump: appending dimension dim_FaceElements_numNodes to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_dim(dim_FaceElements_numNodes)");
    if (num_ContactElements>0)  
       if (! (ncdims[9] = dataFile.add_dim("dim_ContactElements_numNodes", num_ContactElements_numNodes)) )  
          throw DataException("Error - MeshAdapter::dump: appending dimension dim_ContactElements_numNodes to netCDF file failed: " + *newFileName);  
198     if (num_Tags>0)     if (num_Tags>0)
199        if (! (ncdims[10] = dataFile.add_dim("dim_Tags", num_Tags)) )        if (! (ncdims[10] = dataFile.add_dim("dim_Tags", num_Tags)) )
200           throw DataException("Error - MeshAdapter::dump: appending dimension dim_Tags to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_dim(dim_Tags)");
201    
202     // Attributes: MPI size, MPI rank, Name, order, reduced_order     // Attributes: MPI size, MPI rank, Name, order, reduced_order
203     if (!dataFile.add_att("mpi_size", mpi_size) )     if (!dataFile.add_att("mpi_size", mpi_size) )
204        throw DataException("Error - MeshAdapter::dump: appending mpi_size to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(mpi_size)");
205     if (!dataFile.add_att("mpi_rank", mpi_rank) )     if (!dataFile.add_att("mpi_rank", mpi_rank) )
206        throw DataException("Error - MeshAdapter::dump: appending mpi_rank to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(mpi_rank)");
207     if (!dataFile.add_att("Name",mesh->Name) )     if (!dataFile.add_att("Name",mesh->Name) )
208        throw DataException("Error - MeshAdapter::dump: appending Name to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(Name)");
209     if (!dataFile.add_att("numDim",numDim) )     if (!dataFile.add_att("numDim",numDim) )
210        throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(order)");
211     if (!dataFile.add_att("order",mesh->order) )     if (!dataFile.add_att("order",mesh->integrationOrder) )
212        throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(order)");
213     if (!dataFile.add_att("reduced_order",mesh->reduced_order) )     if (!dataFile.add_att("reduced_order",mesh->reducedIntegrationOrder) )
214        throw DataException("Error - MeshAdapter::dump: appending reduced_order to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(reduced_order)");
215     if (!dataFile.add_att("numNodes",numNodes) )     if (!dataFile.add_att("numNodes",numNodes) )
216        throw DataException("Error - MeshAdapter::dump: appending numNodes to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(numNodes)");
217     if (!dataFile.add_att("num_Elements",num_Elements) )     if (!dataFile.add_att("num_Elements",num_Elements) )
218        throw DataException("Error - MeshAdapter::dump: appending num_Elements to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(num_Elements)");
219     if (!dataFile.add_att("num_FaceElements",num_FaceElements) )     if (!dataFile.add_att("num_FaceElements",num_FaceElements) )
220        throw DataException("Error - MeshAdapter::dump: appending num_FaceElements to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(num_FaceElements)");
    if (!dataFile.add_att("num_ContactElements",num_ContactElements) )  
       throw DataException("Error - MeshAdapter::dump: appending num_ContactElements to NetCDF file failed: " + *newFileName);  
221     if (!dataFile.add_att("num_Points",num_Points) )     if (!dataFile.add_att("num_Points",num_Points) )
222        throw DataException("Error - MeshAdapter::dump: appending num_Points to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(num_Points)");
223     if (!dataFile.add_att("num_Elements_numNodes",num_Elements_numNodes) )     if (!dataFile.add_att("num_Elements_numNodes",num_Elements_numNodes) )
224        throw DataException("Error - MeshAdapter::dump: appending num_Elements_numNodes to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(num_Elements_numNodes)");
225     if (!dataFile.add_att("num_FaceElements_numNodes",num_FaceElements_numNodes) )     if (!dataFile.add_att("num_FaceElements_numNodes",num_FaceElements_numNodes) )
226        throw DataException("Error - MeshAdapter::dump: appending num_FaceElements_numNodes to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(num_FaceElements_numNodes)");
    if (!dataFile.add_att("num_ContactElements_numNodes",num_ContactElements_numNodes) )  
       throw DataException("Error - MeshAdapter::dump: appending num_ContactElements_numNodes to NetCDF file failed: " + *newFileName);  
227     if (!dataFile.add_att("Elements_TypeId", mesh->Elements->referenceElementSet->referenceElement->Type->TypeId) )     if (!dataFile.add_att("Elements_TypeId", mesh->Elements->referenceElementSet->referenceElement->Type->TypeId) )
228        throw DataException("Error - MeshAdapter::dump: appending Elements_TypeId to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(Elements_TypeId)");
229     if (!dataFile.add_att("FaceElements_TypeId", mesh->FaceElements->referenceElementSet->referenceElement->Type->TypeId) )     if (!dataFile.add_att("FaceElements_TypeId", mesh->FaceElements->referenceElementSet->referenceElement->Type->TypeId) )
230        throw DataException("Error - MeshAdapter::dump: appending FaceElements_TypeId to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(FaceElements_TypeId)");
    if (!dataFile.add_att("ContactElements_TypeId", mesh->ContactElements->referenceElementSet->referenceElement->Type->TypeId) )  
       throw DataException("Error - MeshAdapter::dump: appending ContactElements_TypeId to NetCDF file failed: " + *newFileName);  
231     if (!dataFile.add_att("Points_TypeId", mesh->Points->referenceElementSet->referenceElement->Type->TypeId) )     if (!dataFile.add_att("Points_TypeId", mesh->Points->referenceElementSet->referenceElement->Type->TypeId) )
232        throw DataException("Error - MeshAdapter::dump: appending Points_TypeId to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(Points_TypeId)");
233     if (!dataFile.add_att("num_Tags", num_Tags) )     if (!dataFile.add_att("num_Tags", num_Tags) )
234        throw DataException("Error - MeshAdapter::dump: appending num_Tags to NetCDF file failed: " + *newFileName);        throw DataException(msgPrefix+"add_att(num_Tags)");
235    
236     // // // // // Nodes // // // // //     // // // // // Nodes // // // // //
237    
238     // Only write nodes if non-empty because NetCDF doesn't like empty arrays (it treats them as NC_UNLIMITED)     // Nodes nodeDistribution
239       if (! ( ids = dataFile.add_var("Nodes_NodeDistribution", ncInt, ncdims[2])) )
240          throw DataException(msgPrefix+"add_var(Nodes_NodeDistribution)");
241       int_ptr = &mesh->Nodes->nodesDistribution->first_component[0];
242       if (! (ids->put(int_ptr, mpi_size+1)) )
243          throw DataException(msgPrefix+"put(Nodes_NodeDistribution)");
244    
245       // Nodes degreesOfFreedomDistribution
246       if (! ( ids = dataFile.add_var("Nodes_DofDistribution", ncInt, ncdims[2])) )
247          throw DataException(msgPrefix+"add_var(Nodes_DofDistribution)");
248       int_ptr = &mesh->Nodes->degreesOfFreedomDistribution->first_component[0];
249       if (! (ids->put(int_ptr, mpi_size+1)) )
250          throw DataException(msgPrefix+"put(Nodes_DofDistribution)");
251    
252       // Only write nodes if non-empty because NetCDF doesn't like empty arrays
253       // (it treats them as NC_UNLIMITED)
254     if (numNodes>0) {     if (numNodes>0) {
255    
256        // Nodes Id        // Nodes Id
257        if (! ( ids = dataFile.add_var("Nodes_Id", ncInt, ncdims[0])) )        if (! ( ids = dataFile.add_var("Nodes_Id", ncInt, ncdims[0])) )
258           throw DataException("Error - MeshAdapter::dump: appending Nodes_Id to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Nodes_Id)");
259        int_ptr = &mesh->Nodes->Id[0];        int_ptr = &mesh->Nodes->Id[0];
260        if (! (ids->put(int_ptr, numNodes)) )        if (! (ids->put(int_ptr, numNodes)) )
261           throw DataException("Error - MeshAdapter::dump: copy Nodes_Id to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Nodes_Id)");
262    
263        // Nodes Tag        // Nodes Tag
264        if (! ( ids = dataFile.add_var("Nodes_Tag", ncInt, ncdims[0])) )        if (! ( ids = dataFile.add_var("Nodes_Tag", ncInt, ncdims[0])) )
265           throw DataException("Error - MeshAdapter::dump: appending Nodes_Tag to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Nodes_Tag)");
266        int_ptr = &mesh->Nodes->Tag[0];        int_ptr = &mesh->Nodes->Tag[0];
267        if (! (ids->put(int_ptr, numNodes)) )        if (! (ids->put(int_ptr, numNodes)) )
268           throw DataException("Error - MeshAdapter::dump: copy Nodes_Tag to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Nodes_Tag)");
269    
270        // Nodes gDOF        // Nodes gDOF
271        if (! ( ids = dataFile.add_var("Nodes_gDOF", ncInt, ncdims[0])) )        if (! ( ids = dataFile.add_var("Nodes_gDOF", ncInt, ncdims[0])) )
272           throw DataException("Error - MeshAdapter::dump: appending Nodes_gDOF to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Nodes_gDOF)");
273        int_ptr = &mesh->Nodes->globalDegreesOfFreedom[0];        int_ptr = &mesh->Nodes->globalDegreesOfFreedom[0];
274        if (! (ids->put(int_ptr, numNodes)) )        if (! (ids->put(int_ptr, numNodes)) )
275           throw DataException("Error - MeshAdapter::dump: copy Nodes_gDOF to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Nodes_gDOF)");
276    
277        // Nodes global node index        // Nodes global node index
278        if (! ( ids = dataFile.add_var("Nodes_gNI", ncInt, ncdims[0])) )        if (! ( ids = dataFile.add_var("Nodes_gNI", ncInt, ncdims[0])) )
279           throw DataException("Error - MeshAdapter::dump: appending Nodes_gNI to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Nodes_gNI)");
280        int_ptr = &mesh->Nodes->globalNodesIndex[0];        int_ptr = &mesh->Nodes->globalNodesIndex[0];
281        if (! (ids->put(int_ptr, numNodes)) )        if (! (ids->put(int_ptr, numNodes)) )
282           throw DataException("Error - MeshAdapter::dump: copy Nodes_gNI to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Nodes_gNI)");
283    
284        // Nodes grDof        // Nodes grDof
285        if (! ( ids = dataFile.add_var("Nodes_grDfI", ncInt, ncdims[0])) )        if (! ( ids = dataFile.add_var("Nodes_grDfI", ncInt, ncdims[0])) )
286           throw DataException("Error - MeshAdapter::dump: appending Nodes_grDfI to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Nodes_grDfI)");
287        int_ptr = &mesh->Nodes->globalReducedDOFIndex[0];        int_ptr = &mesh->Nodes->globalReducedDOFIndex[0];
288        if (! (ids->put(int_ptr, numNodes)) )        if (! (ids->put(int_ptr, numNodes)) )
289           throw DataException("Error - MeshAdapter::dump: copy Nodes_grDfI to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Nodes_grDfI)");
290    
291        // Nodes grNI        // Nodes grNI
292        if (! ( ids = dataFile.add_var("Nodes_grNI", ncInt, ncdims[0])) )        if (! ( ids = dataFile.add_var("Nodes_grNI", ncInt, ncdims[0])) )
293           throw DataException("Error - MeshAdapter::dump: appending Nodes_grNI to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Nodes_grNI)");
294        int_ptr = &mesh->Nodes->globalReducedNodesIndex[0];        int_ptr = &mesh->Nodes->globalReducedNodesIndex[0];
295        if (! (ids->put(int_ptr, numNodes)) )        if (! (ids->put(int_ptr, numNodes)) )
296           throw DataException("Error - MeshAdapter::dump: copy Nodes_grNI to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Nodes_grNI)");
297    
298        // Nodes Coordinates        // Nodes Coordinates
299        if (! ( ids = dataFile.add_var("Nodes_Coordinates", ncDouble, ncdims[0], ncdims[1]) ) )        if (! ( ids = dataFile.add_var("Nodes_Coordinates", ncDouble, ncdims[0], ncdims[1]) ) )
300           throw DataException("Error - MeshAdapter::dump: appending Nodes_Coordinates to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Nodes_Coordinates)");
301        if (! (ids->put(&(mesh->Nodes->Coordinates[INDEX2(0,0,numDim)]), numNodes, numDim)) )        if (! (ids->put(&(mesh->Nodes->Coordinates[INDEX2(0,0,numDim)]), numNodes, numDim)) )
302           throw DataException("Error - MeshAdapter::dump: copy Nodes_Coordinates to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Nodes_Coordinates)");
   
       // Nodes degreesOfFreedomDistribution  
       if (! ( ids = dataFile.add_var("Nodes_DofDistribution", ncInt, ncdims[2])) )  
          throw DataException("Error - MeshAdapter::dump: appending Nodes_DofDistribution to netCDF file failed: " + *newFileName);  
       int_ptr = &mesh->Nodes->degreesOfFreedomDistribution->first_component[0];  
       if (! (ids->put(int_ptr, mpi_size+1)) )  
          throw DataException("Error - MeshAdapter::dump: copy Nodes_DofDistribution to netCDF buffer failed: " + *newFileName);  
   
       // Nodes nodeDistribution  
       if (! ( ids = dataFile.add_var("Nodes_NodeDistribution", ncInt, ncdims[2])) )  
          throw DataException("Error - MeshAdapter::dump: appending Nodes_NodeDistribution to netCDF file failed: " + *newFileName);  
       int_ptr = &mesh->Nodes->nodesDistribution->first_component[0];  
       if (! (ids->put(int_ptr, mpi_size+1)) )  
          throw DataException("Error - MeshAdapter::dump: copy Nodes_NodeDistribution to netCDF buffer failed: " + *newFileName);  
303    
304     }     }
305    
# Line 326  void MeshAdapter::dump(const std::string Line 309  void MeshAdapter::dump(const std::string
309    
310        // Elements_Id        // Elements_Id
311        if (! ( ids = dataFile.add_var("Elements_Id", ncInt, ncdims[3])) )        if (! ( ids = dataFile.add_var("Elements_Id", ncInt, ncdims[3])) )
312           throw DataException("Error - MeshAdapter::dump: appending Elements_Id to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Elements_Id)");
313        int_ptr = &mesh->Elements->Id[0];        int_ptr = &mesh->Elements->Id[0];
314        if (! (ids->put(int_ptr, num_Elements)) )        if (! (ids->put(int_ptr, num_Elements)) )
315           throw DataException("Error - MeshAdapter::dump: copy Elements_Id to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Elements_Id)");
316    
317        // Elements_Tag        // Elements_Tag
318        if (! ( ids = dataFile.add_var("Elements_Tag", ncInt, ncdims[3])) )        if (! ( ids = dataFile.add_var("Elements_Tag", ncInt, ncdims[3])) )
319           throw DataException("Error - MeshAdapter::dump: appending Elements_Tag to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Elements_Tag)");
320        int_ptr = &mesh->Elements->Tag[0];        int_ptr = &mesh->Elements->Tag[0];
321        if (! (ids->put(int_ptr, num_Elements)) )        if (! (ids->put(int_ptr, num_Elements)) )
322           throw DataException("Error - MeshAdapter::dump: copy Elements_Tag to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Elements_Tag)");
323    
324        // Elements_Owner        // Elements_Owner
325        if (! ( ids = dataFile.add_var("Elements_Owner", ncInt, ncdims[3])) )        if (! ( ids = dataFile.add_var("Elements_Owner", ncInt, ncdims[3])) )
326           throw DataException("Error - MeshAdapter::dump: appending Elements_Owner to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Elements_Owner)");
327        int_ptr = &mesh->Elements->Owner[0];        int_ptr = &mesh->Elements->Owner[0];
328        if (! (ids->put(int_ptr, num_Elements)) )        if (! (ids->put(int_ptr, num_Elements)) )
329           throw DataException("Error - MeshAdapter::dump: copy Elements_Owner to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Elements_Owner)");
330    
331        // Elements_Color        // Elements_Color
332        if (! ( ids = dataFile.add_var("Elements_Color", ncInt, ncdims[3])) )        if (! ( ids = dataFile.add_var("Elements_Color", ncInt, ncdims[3])) )
333           throw DataException("Error - MeshAdapter::dump: appending Elements_Color to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Elements_Color)");
334        int_ptr = &mesh->Elements->Color[0];        int_ptr = &mesh->Elements->Color[0];
335        if (! (ids->put(int_ptr, num_Elements)) )        if (! (ids->put(int_ptr, num_Elements)) )
336           throw DataException("Error - MeshAdapter::dump: copy Elements_Color to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Elements_Color)");
337    
338        // Elements_Nodes        // Elements_Nodes
339        if (! ( ids = dataFile.add_var("Elements_Nodes", ncInt, ncdims[3], ncdims[7]) ) )        if (! ( ids = dataFile.add_var("Elements_Nodes", ncInt, ncdims[3], ncdims[7]) ) )
340           throw DataException("Error - MeshAdapter::dump: appending Elements_Nodes to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Elements_Nodes)");
341        if (! (ids->put(&(mesh->Elements->Nodes[0]), num_Elements, num_Elements_numNodes)) )        if (! (ids->put(&(mesh->Elements->Nodes[0]), num_Elements, num_Elements_numNodes)) )
342           throw DataException("Error - MeshAdapter::dump: copy Elements_Nodes to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Elements_Nodes)");
343    
344     }     }
345    
# Line 366  void MeshAdapter::dump(const std::string Line 349  void MeshAdapter::dump(const std::string
349    
350        // FaceElements_Id        // FaceElements_Id
351        if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )        if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )
352           throw DataException("Error - MeshAdapter::dump: appending FaceElements_Id to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(FaceElements_Id)");
353        int_ptr = &mesh->FaceElements->Id[0];        int_ptr = &mesh->FaceElements->Id[0];
354        if (! (ids->put(int_ptr, num_FaceElements)) )        if (! (ids->put(int_ptr, num_FaceElements)) )
355           throw DataException("Error - MeshAdapter::dump: copy FaceElements_Id to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(FaceElements_Id)");
356    
357        // FaceElements_Tag        // FaceElements_Tag
358        if (! ( ids = dataFile.add_var("FaceElements_Tag", ncInt, ncdims[4])) )        if (! ( ids = dataFile.add_var("FaceElements_Tag", ncInt, ncdims[4])) )
359           throw DataException("Error - MeshAdapter::dump: appending FaceElements_Tag to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(FaceElements_Tag)");
360        int_ptr = &mesh->FaceElements->Tag[0];        int_ptr = &mesh->FaceElements->Tag[0];
361        if (! (ids->put(int_ptr, num_FaceElements)) )        if (! (ids->put(int_ptr, num_FaceElements)) )
362           throw DataException("Error - MeshAdapter::dump: copy FaceElements_Tag to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(FaceElements_Tag)");
363    
364        // FaceElements_Owner        // FaceElements_Owner
365        if (! ( ids = dataFile.add_var("FaceElements_Owner", ncInt, ncdims[4])) )        if (! ( ids = dataFile.add_var("FaceElements_Owner", ncInt, ncdims[4])) )
366           throw DataException("Error - MeshAdapter::dump: appending FaceElements_Owner to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(FaceElements_Owner)");
367        int_ptr = &mesh->FaceElements->Owner[0];        int_ptr = &mesh->FaceElements->Owner[0];
368        if (! (ids->put(int_ptr, num_FaceElements)) )        if (! (ids->put(int_ptr, num_FaceElements)) )
369           throw DataException("Error - MeshAdapter::dump: copy FaceElements_Owner to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(FaceElements_Owner)");
370    
371        // FaceElements_Color        // FaceElements_Color
372        if (! ( ids = dataFile.add_var("FaceElements_Color", ncInt, ncdims[4])) )        if (! ( ids = dataFile.add_var("FaceElements_Color", ncInt, ncdims[4])) )
373           throw DataException("Error - MeshAdapter::dump: appending FaceElements_Color to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(FaceElements_Color)");
374        int_ptr = &mesh->FaceElements->Color[0];        int_ptr = &mesh->FaceElements->Color[0];
375        if (! (ids->put(int_ptr, num_FaceElements)) )        if (! (ids->put(int_ptr, num_FaceElements)) )
376           throw DataException("Error - MeshAdapter::dump: copy FaceElements_Color to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(FaceElements_Color)");
377    
378        // FaceElements_Nodes        // FaceElements_Nodes
379        if (! ( ids = dataFile.add_var("FaceElements_Nodes", ncInt, ncdims[4], ncdims[8]) ) )        if (! ( ids = dataFile.add_var("FaceElements_Nodes", ncInt, ncdims[4], ncdims[8]) ) )
380           throw DataException("Error - MeshAdapter::dump: appending FaceElements_Nodes to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(FaceElements_Nodes)");
381        if (! (ids->put(&(mesh->FaceElements->Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )        if (! (ids->put(&(mesh->FaceElements->Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )
382           throw DataException("Error - MeshAdapter::dump: copy FaceElements_Nodes to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(FaceElements_Nodes)");
   
    }  
   
    // // // // // Contact_Elements // // // // //  
   
    if (num_ContactElements>0) {  
   
       // ContactElements_Id  
       if (! ( ids = dataFile.add_var("ContactElements_Id", ncInt, ncdims[5])) )  
          throw DataException("Error - MeshAdapter::dump: appending ContactElements_Id to netCDF file failed: " + *newFileName);  
       int_ptr = &mesh->ContactElements->Id[0];  
       if (! (ids->put(int_ptr, num_ContactElements)) )  
          throw DataException("Error - MeshAdapter::dump: copy ContactElements_Id to netCDF buffer failed: " + *newFileName);  
   
       // ContactElements_Tag  
       if (! ( ids = dataFile.add_var("ContactElements_Tag", ncInt, ncdims[5])) )  
          throw DataException("Error - MeshAdapter::dump: appending ContactElements_Tag to netCDF file failed: " + *newFileName);  
       int_ptr = &mesh->ContactElements->Tag[0];  
       if (! (ids->put(int_ptr, num_ContactElements)) )  
          throw DataException("Error - MeshAdapter::dump: copy ContactElements_Tag to netCDF buffer failed: " + *newFileName);  
   
       // ContactElements_Owner  
       if (! ( ids = dataFile.add_var("ContactElements_Owner", ncInt, ncdims[5])) )  
          throw DataException("Error - MeshAdapter::dump: appending ContactElements_Owner to netCDF file failed: " + *newFileName);  
       int_ptr = &mesh->ContactElements->Owner[0];  
       if (! (ids->put(int_ptr, num_ContactElements)) )  
          throw DataException("Error - MeshAdapter::dump: copy ContactElements_Owner to netCDF buffer failed: " + *newFileName);  
   
       // ContactElements_Color  
       if (! ( ids = dataFile.add_var("ContactElements_Color", ncInt, ncdims[5])) )  
          throw DataException("Error - MeshAdapter::dump: appending ContactElements_Color to netCDF file failed: " + *newFileName);  
       int_ptr = &mesh->ContactElements->Color[0];  
       if (! (ids->put(int_ptr, num_ContactElements)) )  
          throw DataException("Error - MeshAdapter::dump: copy ContactElements_Color to netCDF buffer failed: " + *newFileName);  
   
       // ContactElements_Nodes  
       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(&(mesh->ContactElements->Nodes[0]), num_ContactElements, num_ContactElements_numNodes)) )  
          throw DataException("Error - MeshAdapter::dump: copy ContactElements_Nodes to netCDF buffer failed: " + *newFileName);  
383    
384     }     }
385    
# Line 448  void MeshAdapter::dump(const std::string Line 391  void MeshAdapter::dump(const std::string
391    
392        // Points_Id        // Points_Id
393        if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )        if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )
394           throw DataException("Error - MeshAdapter::dump: appending Points_Id to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Points_Id)");
395        int_ptr = &mesh->Points->Id[0];        int_ptr = &mesh->Points->Id[0];
396        if (! (ids->put(int_ptr, num_Points)) )        if (! (ids->put(int_ptr, num_Points)) )
397           throw DataException("Error - MeshAdapter::dump: copy Points_Id to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Points_Id)");
398    
399        // Points_Tag        // Points_Tag
400        if (! ( ids = dataFile.add_var("Points_Tag", ncInt, ncdims[6])) )        if (! ( ids = dataFile.add_var("Points_Tag", ncInt, ncdims[6])) )
401           throw DataException("Error - MeshAdapter::dump: appending Points_Tag to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Points_Tag)");
402        int_ptr = &mesh->Points->Tag[0];        int_ptr = &mesh->Points->Tag[0];
403        if (! (ids->put(int_ptr, num_Points)) )        if (! (ids->put(int_ptr, num_Points)) )
404           throw DataException("Error - MeshAdapter::dump: copy Points_Tag to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Points_Tag)");
405    
406        // Points_Owner        // Points_Owner
407        if (! ( ids = dataFile.add_var("Points_Owner", ncInt, ncdims[6])) )        if (! ( ids = dataFile.add_var("Points_Owner", ncInt, ncdims[6])) )
408           throw DataException("Error - MeshAdapter::dump: appending Points_Owner to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Points_Owner)");
409        int_ptr = &mesh->Points->Owner[0];        int_ptr = &mesh->Points->Owner[0];
410        if (! (ids->put(int_ptr, num_Points)) )        if (! (ids->put(int_ptr, num_Points)) )
411           throw DataException("Error - MeshAdapter::dump: copy Points_Owner to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Points_Owner)");
412    
413        // Points_Color        // Points_Color
414        if (! ( ids = dataFile.add_var("Points_Color", ncInt, ncdims[6])) )        if (! ( ids = dataFile.add_var("Points_Color", ncInt, ncdims[6])) )
415           throw DataException("Error - MeshAdapter::dump: appending Points_Color to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Points_Color)");
416        int_ptr = &mesh->Points->Color[0];        int_ptr = &mesh->Points->Color[0];
417        if (! (ids->put(int_ptr, num_Points)) )        if (! (ids->put(int_ptr, num_Points)) )
418           throw DataException("Error - MeshAdapter::dump: copy Points_Color to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Points_Color)");
419    
420        // Points_Nodes        // Points_Nodes
421        // mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]]        // mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]]
422        if (! ( ids = dataFile.add_var("Points_Nodes", ncInt, ncdims[6]) ) )        if (! ( ids = dataFile.add_var("Points_Nodes", ncInt, ncdims[6]) ) )
423           throw DataException("Error - MeshAdapter::dump: appending Points_Nodes to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Points_Nodes)");
424        if (! (ids->put(&(mesh->Points->Nodes[0]), num_Points)) )        if (! (ids->put(&(mesh->Points->Nodes[0]), num_Points)) )
425           throw DataException("Error - MeshAdapter::dump: copy Points_Nodes to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Points_Nodes)");
426    
427     }     }
428    
# Line 503  void MeshAdapter::dump(const std::string Line 446  void MeshAdapter::dump(const std::string
446    
447        // Tags_keys        // Tags_keys
448        if (! ( ids = dataFile.add_var("Tags_keys", ncInt, ncdims[10])) )        if (! ( ids = dataFile.add_var("Tags_keys", ncInt, ncdims[10])) )
449           throw DataException("Error - MeshAdapter::dump: appending Tags_keys to netCDF file failed: " + *newFileName);           throw DataException(msgPrefix+"add_var(Tags_keys)");
450        int_ptr = &Tags_keys[0];        int_ptr = &Tags_keys[0];
451        if (! (ids->put(int_ptr, num_Tags)) )        if (! (ids->put(int_ptr, num_Tags)) )
452           throw DataException("Error - MeshAdapter::dump: copy Tags_keys to netCDF buffer failed: " + *newFileName);           throw DataException(msgPrefix+"put(Tags_keys)");
453    
454        // Tags_names_*        // Tags_names_*
455        // This is an array of strings, it should be stored as an array but instead I have hacked in one attribute per string        // This is an array of strings, it should be stored as an array but
456        // because the NetCDF manual doesn't tell how to do an array of strings        // instead I have hacked in one attribute per string because the NetCDF
457          // manual doesn't tell how to do an array of strings
458        tag_map = mesh->TagMap;        tag_map = mesh->TagMap;
459        if (tag_map) {        if (tag_map) {
460           int i = 0;           int i = 0;
461           while (tag_map) {           while (tag_map) {
462              sprintf(name_temp, "Tags_name_%d", i);              sprintf(name_temp, "Tags_name_%d", i);
463              if (!dataFile.add_att(name_temp, tag_map->name) )              if (!dataFile.add_att(name_temp, tag_map->name) )
464                 throw DataException("Error - MeshAdapter::dump: appending Tags_names_ to NetCDF file failed: " + *newFileName);                 throw DataException(msgPrefix+"add_att(Tags_names_XX)");
465              tag_map=tag_map->next;              tag_map=tag_map->next;
466              i++;              i++;
467           }           }
468        }        }
469    
470        TMPMEMFREE(Tags_keys);        TMPMEMFREE(Tags_keys);
   
471     }     }
472    
473  /* Send token to next MPI process so he can take his turn */  /* Send token to next MPI process so he can take his turn */
# Line 535  void MeshAdapter::dump(const std::string Line 478  void MeshAdapter::dump(const std::string
478     // NetCDF file is closed by destructor of NcFile object     // NetCDF file is closed by destructor of NcFile object
479    
480  #else  #else
481     Finley_setError(IO_ERROR, "MeshAdapter::dump: not configured with NetCDF. Please contact your installation manager.");     Dudley_setError(IO_ERROR, "MeshAdapter::dump: not configured with NetCDF. Please contact your installation manager.");
482  #endif  /* USE_NETCDF */  #endif  /* USE_NETCDF */
483     checkFinleyError();     checkDudleyError();
484  }  }
485    
486  string MeshAdapter::getDescription() const  string MeshAdapter::getDescription() const
487  {  {
488     return "FinleyMesh";     return "DudleyMesh";
489  }  }
490    
491  string MeshAdapter::functionSpaceTypeAsString(int functionSpaceType) const  string MeshAdapter::functionSpaceTypeAsString(int functionSpaceType) const
# Line 566  bool MeshAdapter::isValidFunctionSpaceTy Line 509  bool MeshAdapter::isValidFunctionSpaceTy
509  void MeshAdapter::setFunctionSpaceTypeNames()  void MeshAdapter::setFunctionSpaceTypeNames()
510  {  {
511     m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
512     (FunctionSpaceNamesMapType::value_type(DegreesOfFreedom,"Finley_DegreesOfFreedom"));     (FunctionSpaceNamesMapType::value_type(DegreesOfFreedom,"Dudley_DegreesOfFreedom"));
    m_functionSpaceTypeNames.insert  
    (FunctionSpaceNamesMapType::value_type(ReducedDegreesOfFreedom,"Finley_ReducedDegreesOfFreedom"));  
513     m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
514     (FunctionSpaceNamesMapType::value_type(Nodes,"Finley_Nodes"));     (FunctionSpaceNamesMapType::value_type(ReducedDegreesOfFreedom,"Dudley_ReducedDegreesOfFreedom"));
515     m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
516     (FunctionSpaceNamesMapType::value_type(ReducedNodes,"Finley_Reduced_Nodes"));     (FunctionSpaceNamesMapType::value_type(Nodes,"Dudley_Nodes"));
517     m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
518     (FunctionSpaceNamesMapType::value_type(Elements,"Finley_Elements"));     (FunctionSpaceNamesMapType::value_type(ReducedNodes,"Dudley_Reduced_Nodes"));
519     m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
520     (FunctionSpaceNamesMapType::value_type(ReducedElements,"Finley_Reduced_Elements"));     (FunctionSpaceNamesMapType::value_type(Elements,"Dudley_Elements"));
521     m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
522     (FunctionSpaceNamesMapType::value_type(FaceElements,"Finley_Face_Elements"));     (FunctionSpaceNamesMapType::value_type(ReducedElements,"Dudley_Reduced_Elements"));
523     m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
524     (FunctionSpaceNamesMapType::value_type(ReducedFaceElements,"Finley_Reduced_Face_Elements"));     (FunctionSpaceNamesMapType::value_type(FaceElements,"Dudley_Face_Elements"));
525     m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
526     (FunctionSpaceNamesMapType::value_type(Points,"Finley_Points"));     (FunctionSpaceNamesMapType::value_type(ReducedFaceElements,"Dudley_Reduced_Face_Elements"));
527     m_functionSpaceTypeNames.insert     m_functionSpaceTypeNames.insert
528     (FunctionSpaceNamesMapType::value_type(ContactElementsZero,"Finley_Contact_Elements_0"));     (FunctionSpaceNamesMapType::value_type(Points,"Dudley_Points"));
    m_functionSpaceTypeNames.insert  
    (FunctionSpaceNamesMapType::value_type(ReducedContactElementsZero,"Finley_Reduced_Contact_Elements_0"));  
    m_functionSpaceTypeNames.insert  
    (FunctionSpaceNamesMapType::value_type(ContactElementsOne,"Finley_Contact_Elements_1"));  
    m_functionSpaceTypeNames.insert  
    (FunctionSpaceNamesMapType::value_type(ReducedContactElementsOne,"Finley_Reduced_Contact_Elements_1"));  
529  }  }
530    
531  int MeshAdapter::getContinuousFunctionCode() const  int MeshAdapter::getContinuousFunctionCode() const
# Line 622  int MeshAdapter::getReducedFunctionOnBou Line 557  int MeshAdapter::getReducedFunctionOnBou
557    
558  int MeshAdapter::getFunctionOnContactZeroCode() const  int MeshAdapter::getFunctionOnContactZeroCode() const
559  {  {
560     return ContactElementsZero;     throw DudleyAdapterException("Dudley does not support contact elements.");
561  }  }
562    
563  int MeshAdapter::getReducedFunctionOnContactZeroCode() const  int MeshAdapter::getReducedFunctionOnContactZeroCode() const
564  {  {
565     return ReducedContactElementsZero;     throw DudleyAdapterException("Dudley does not support contact elements.");
566  }  }
567    
568  int MeshAdapter::getFunctionOnContactOneCode() const  int MeshAdapter::getFunctionOnContactOneCode() const
569  {  {
570     return ContactElementsOne;     throw DudleyAdapterException("Dudley does not support contact elements.");
571  }  }
572    
573  int MeshAdapter::getReducedFunctionOnContactOneCode() const  int MeshAdapter::getReducedFunctionOnContactOneCode() const
574  {  {
575     return ReducedContactElementsOne;     throw DudleyAdapterException("Dudley does not support contact elements.");
576  }  }
577    
578  int MeshAdapter::getSolutionCode() const  int MeshAdapter::getSolutionCode() const
# Line 658  int MeshAdapter::getDiracDeltaFunctionCo Line 595  int MeshAdapter::getDiracDeltaFunctionCo
595  //  //
596  int MeshAdapter::getDim() const  int MeshAdapter::getDim() const
597  {  {
598     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
599     int numDim=Finley_Mesh_getDim(mesh);     int numDim=Dudley_Mesh_getDim(mesh);
600     checkFinleyError();     checkDudleyError();
601     return numDim;     return numDim;
602  }  }
603    
# Line 669  int MeshAdapter::getDim() const Line 606  int MeshAdapter::getDim() const
606  //  //
607  int MeshAdapter::getNumDataPointsGlobal() const  int MeshAdapter::getNumDataPointsGlobal() const
608  {  {
609     return Finley_NodeFile_getGlobalNumNodes(m_finleyMesh.get()->Nodes);     return Dudley_NodeFile_getGlobalNumNodes(m_dudleyMesh.get()->Nodes);
610  }  }
611    
612  //  //
# Line 680  pair<int,int> MeshAdapter::getDataShape( Line 617  pair<int,int> MeshAdapter::getDataShape(
617  {  {
618     int numDataPointsPerSample=0;     int numDataPointsPerSample=0;
619     int numSamples=0;     int numSamples=0;
620     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
621     switch (functionSpaceCode) {     switch (functionSpaceCode) {
622     case(Nodes):     case(Nodes):
623     numDataPointsPerSample=1;     numDataPointsPerSample=1;
624     numSamples=Finley_NodeFile_getNumNodes(mesh->Nodes);     numSamples=Dudley_NodeFile_getNumNodes(mesh->Nodes);
625     break;     break;
626     case(ReducedNodes):     case(ReducedNodes):
627     numDataPointsPerSample=1;     numDataPointsPerSample=1;
628     numSamples=Finley_NodeFile_getNumReducedNodes(mesh->Nodes);     numSamples=Dudley_NodeFile_getNumReducedNodes(mesh->Nodes);
629     break;     break;
630     case(Elements):     case(Elements):
631     if (mesh->Elements!=NULL) {     if (mesh->Elements!=NULL) {
632        numSamples=mesh->Elements->numElements;        numSamples=mesh->Elements->numElements;
633        numDataPointsPerSample=mesh->Elements->referenceElementSet->referenceElement->Parametrization->numQuadNodes;        numDataPointsPerSample=mesh->Elements->referenceElementSet->referenceElement->BasisFunctions->numQuadNodes;
634     }     }
635     break;     break;
636     case(ReducedElements):     case(ReducedElements):
637     if (mesh->Elements!=NULL) {     if (mesh->Elements!=NULL) {
638        numSamples=mesh->Elements->numElements;        numSamples=mesh->Elements->numElements;
639        numDataPointsPerSample=mesh->Elements->referenceElementSet->referenceElementReducedQuadrature->Parametrization->numQuadNodes;        numDataPointsPerSample=mesh->Elements->referenceElementSet->referenceElementReducedQuadrature->BasisFunctions->numQuadNodes;
640     }     }
641     break;     break;
642     case(FaceElements):     case(FaceElements):
643     if (mesh->FaceElements!=NULL) {     if (mesh->FaceElements!=NULL) {
644        numDataPointsPerSample=mesh->FaceElements->referenceElementSet->referenceElement->Parametrization->numQuadNodes;        numDataPointsPerSample=mesh->FaceElements->referenceElementSet->referenceElement->BasisFunctions->numQuadNodes;
645        numSamples=mesh->FaceElements->numElements;        numSamples=mesh->FaceElements->numElements;
646     }     }
647     break;     break;
648     case(ReducedFaceElements):     case(ReducedFaceElements):
649     if (mesh->FaceElements!=NULL) {     if (mesh->FaceElements!=NULL) {
650        numDataPointsPerSample=mesh->FaceElements->referenceElementSet->referenceElementReducedQuadrature->Parametrization->numQuadNodes;        numDataPointsPerSample=mesh->FaceElements->referenceElementSet->referenceElementReducedQuadrature->BasisFunctions->numQuadNodes;
651        numSamples=mesh->FaceElements->numElements;        numSamples=mesh->FaceElements->numElements;
652     }     }
653     break;     break;
# Line 720  pair<int,int> MeshAdapter::getDataShape( Line 657  pair<int,int> MeshAdapter::getDataShape(
657        numSamples=mesh->Points->numElements;        numSamples=mesh->Points->numElements;
658     }     }
659     break;     break;
    case(ContactElementsZero):  
    if (mesh->ContactElements!=NULL) {  
       numDataPointsPerSample=mesh->ContactElements->referenceElementSet->referenceElement->Parametrization->numQuadNodes;  
       numSamples=mesh->ContactElements->numElements;  
    }  
    break;  
    case(ReducedContactElementsZero):  
    if (mesh->ContactElements!=NULL) {  
       numDataPointsPerSample=mesh->ContactElements->referenceElementSet->referenceElementReducedQuadrature->Parametrization->numQuadNodes;  
       numSamples=mesh->ContactElements->numElements;  
    }  
    break;  
    case(ContactElementsOne):  
    if (mesh->ContactElements!=NULL) {  
       numDataPointsPerSample=mesh->ContactElements->referenceElementSet->referenceElement->Parametrization->numQuadNodes;  
       numSamples=mesh->ContactElements->numElements;  
    }  
    break;  
    case(ReducedContactElementsOne):  
    if (mesh->ContactElements!=NULL) {  
       numDataPointsPerSample=mesh->ContactElements->referenceElementSet->referenceElementReducedQuadrature->Parametrization->numQuadNodes;  
       numSamples=mesh->ContactElements->numElements;  
    }  
    break;  
660     case(DegreesOfFreedom):     case(DegreesOfFreedom):
661     if (mesh->Nodes!=NULL) {     if (mesh->Nodes!=NULL) {
662        numDataPointsPerSample=1;        numDataPointsPerSample=1;
663        numSamples=Finley_NodeFile_getNumDegreesOfFreedom(mesh->Nodes);        numSamples=Dudley_NodeFile_getNumDegreesOfFreedom(mesh->Nodes);
664     }     }
665     break;     break;
666     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
667     if (mesh->Nodes!=NULL) {     if (mesh->Nodes!=NULL) {
668        numDataPointsPerSample=1;        numDataPointsPerSample=1;
669        numSamples=Finley_NodeFile_getNumReducedDegreesOfFreedom(mesh->Nodes);        numSamples=Dudley_NodeFile_getNumReducedDegreesOfFreedom(mesh->Nodes);
670     }     }
671     break;     break;
672     default:     default:
673        stringstream temp;        stringstream temp;
674        temp << "Error - Invalid function space type: " << functionSpaceCode << " for domain: " << getDescription();        temp << "Error - Invalid function space type: " << functionSpaceCode << " for domain: " << getDescription();
675        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
676        break;        break;
677     }     }
678     return pair<int,int>(numDataPointsPerSample,numSamples);     return pair<int,int>(numDataPointsPerSample,numSamples);
# Line 771  pair<int,int> MeshAdapter::getDataShape( Line 684  pair<int,int> MeshAdapter::getDataShape(
684  void MeshAdapter::addPDEToSystem(  void MeshAdapter::addPDEToSystem(
685                                   SystemMatrixAdapter& mat, escript::Data& rhs,                                   SystemMatrixAdapter& mat, escript::Data& rhs,
686                                   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,
687                                   const escript::Data& d, const escript::Data& y,                                   const escript::Data& d, const escript::Data& y) const
                                  const escript::Data& d_contact,const escript::Data& y_contact) const  
688  {  {
689     escriptDataC _rhs=rhs.getDataC();     escriptDataC _rhs=rhs.getDataC();
690     escriptDataC _A  =A.getDataC();     escriptDataC _A  =A.getDataC();
# Line 783  void MeshAdapter::addPDEToSystem( Line 695  void MeshAdapter::addPDEToSystem(
695     escriptDataC _Y=Y.getDataC();     escriptDataC _Y=Y.getDataC();
696     escriptDataC _d=d.getDataC();     escriptDataC _d=d.getDataC();
697     escriptDataC _y=y.getDataC();     escriptDataC _y=y.getDataC();
    escriptDataC _d_contact=d_contact.getDataC();  
    escriptDataC _y_contact=y_contact.getDataC();  
698    
699     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
700    
701       Dudley_Assemble_PDE(mesh->Nodes,mesh->Elements,mat.getPaso_SystemMatrix(), &_rhs, &_A, &_B, &_C, &_D, &_X, &_Y );
702       checkDudleyError();
703    
    Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,mat.getPaso_SystemMatrix(), &_rhs, &_A, &_B, &_C, &_D, &_X, &_Y );  
    checkFinleyError();  
704    
705     Finley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, mat.getPaso_SystemMatrix(), &_rhs, 0, 0, 0, &_d, 0, &_y );     Dudley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, mat.getPaso_SystemMatrix(), &_rhs, 0, 0, 0, &_d, 0, &_y );
706     checkFinleyError();     checkDudleyError();
707    
708     Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, mat.getPaso_SystemMatrix(), &_rhs , 0, 0, 0, &_d_contact, 0, &_y_contact );  
709     checkFinleyError();     checkDudleyError();
710  }  }
711    
712  void  MeshAdapter::addPDEToLumpedSystem(  void  MeshAdapter::addPDEToLumpedSystem(
# Line 807  void  MeshAdapter::addPDEToLumpedSystem( Line 718  void  MeshAdapter::addPDEToLumpedSystem(
718     escriptDataC _D=D.getDataC();     escriptDataC _D=D.getDataC();
719     escriptDataC _d=d.getDataC();     escriptDataC _d=d.getDataC();
720    
721     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
722    
723     Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->Elements,&_mat, &_D);     Dudley_Assemble_LumpedSystem(mesh->Nodes,mesh->Elements,&_mat, &_D);
724     Finley_Assemble_LumpedSystem(mesh->Nodes,mesh->FaceElements,&_mat, &_d);     checkDudleyError();
725      
726       Dudley_Assemble_LumpedSystem(mesh->Nodes,mesh->FaceElements,&_mat, &_d);
727       checkDudleyError();
728    
    checkFinleyError();  
729  }  }
730    
731    
732  //  //
733  // adds linear PDE of second order into the right hand side only  // adds linear PDE of second order into the right hand side only
734  //  //
735  void MeshAdapter::addPDEToRHS( escript::Data& rhs, const  escript::Data& X,const  escript::Data& Y, const escript::Data& y, const escript::Data& y_contact) const  void MeshAdapter::addPDEToRHS( escript::Data& rhs, const  escript::Data& X,const  escript::Data& Y, const escript::Data& y) const
736  {  {
737     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
738    
739     escriptDataC _rhs=rhs.getDataC();     escriptDataC _rhs=rhs.getDataC();
740     escriptDataC _X=X.getDataC();     escriptDataC _X=X.getDataC();
741     escriptDataC _Y=Y.getDataC();     escriptDataC _Y=Y.getDataC();
742     escriptDataC _y=y.getDataC();     escriptDataC _y=y.getDataC();
    escriptDataC _y_contact=y_contact.getDataC();  
743    
744     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements, 0, &_rhs, 0, 0, 0, 0, &_X, &_Y );     Dudley_Assemble_PDE(mesh->Nodes,mesh->Elements, 0, &_rhs, 0, 0, 0, 0, &_X, &_Y );
745     checkFinleyError();     checkDudleyError();
746    
747     Finley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, 0, &_rhs, 0, 0, 0, 0, 0, &_y );     Dudley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, 0, &_rhs, 0, 0, 0, 0, 0, &_y );
748     checkFinleyError();     checkDudleyError();
749    
750     Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, 0, &_rhs , 0, 0, 0, 0, 0, &_y_contact );     checkDudleyError();
    checkFinleyError();  
751  }  }
752  //  //
753  // adds PDE of second order into a transport problem  // adds PDE of second order into a transport problem
# Line 863  void MeshAdapter::addPDEToTransportProbl Line 774  void MeshAdapter::addPDEToTransportProbl
774     escriptDataC _d_contact=d_contact.getDataC();     escriptDataC _d_contact=d_contact.getDataC();
775     escriptDataC _y_contact=y_contact.getDataC();     escriptDataC _y_contact=y_contact.getDataC();
776    
777     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
778     Paso_FCTransportProblem* _tp = tp.getPaso_FCTransportProblem();     Paso_TransportProblem* _tp = tp.getPaso_TransportProblem();
779    
780     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,_tp->mass_matrix, &_source, 0, 0, 0, &_M, 0, 0 );     Dudley_Assemble_PDE(mesh->Nodes,mesh->Elements,_tp->mass_matrix, &_source, 0, 0, 0, &_M, 0, 0 );
781     checkFinleyError();     checkDudleyError();
782    
783     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,_tp->transport_matrix, &_source, &_A, &_B, &_C, &_D, &_X, &_Y );     Dudley_Assemble_PDE(mesh->Nodes,mesh->Elements,_tp->transport_matrix, &_source, &_A, &_B, &_C, &_D, &_X, &_Y );
784     checkFinleyError();     checkDudleyError();
785    
786     Finley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, _tp->transport_matrix, &_source, 0, 0, 0, &_d, 0, &_y );     Dudley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, _tp->transport_matrix, &_source, 0, 0, 0, &_d, 0, &_y );
787     checkFinleyError();     checkDudleyError();
788    
789     Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, _tp->transport_matrix, &_source , 0, 0, 0, &_d_contact, 0, &_y_contact );     checkDudleyError();
    checkFinleyError();  
790  }  }
791    
792  //  //
# Line 887  void MeshAdapter::interpolateOnDomain(es Line 797  void MeshAdapter::interpolateOnDomain(es
797     const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(*(in.getFunctionSpace().getDomain()));     const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(*(in.getFunctionSpace().getDomain()));
798     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(*(target.getFunctionSpace().getDomain()));     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(*(target.getFunctionSpace().getDomain()));
799     if (inDomain!=*this)       if (inDomain!=*this)  
800        throw FinleyAdapterException("Error - Illegal domain of interpolant.");        throw DudleyAdapterException("Error - Illegal domain of interpolant.");
801     if (targetDomain!=*this)     if (targetDomain!=*this)
802        throw FinleyAdapterException("Error - Illegal domain of interpolation target.");        throw DudleyAdapterException("Error - Illegal domain of interpolation target.");
803    
804     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
805     escriptDataC _target=target.getDataC();     escriptDataC _target=target.getDataC();
806     escriptDataC _in=in.getDataC();     escriptDataC _in=in.getDataC();
807     switch(in.getFunctionSpace().getTypeCode()) {     switch(in.getFunctionSpace().getTypeCode()) {
# Line 901  void MeshAdapter::interpolateOnDomain(es Line 811  void MeshAdapter::interpolateOnDomain(es
811        case(ReducedNodes):        case(ReducedNodes):
812        case(DegreesOfFreedom):        case(DegreesOfFreedom):
813        case(ReducedDegreesOfFreedom):        case(ReducedDegreesOfFreedom):
814        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);        Dudley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
815        break;        break;
816        case(Elements):        case(Elements):
817        case(ReducedElements):        case(ReducedElements):
818        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);        Dudley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
819        break;        break;
820        case(FaceElements):        case(FaceElements):
821        case(ReducedFaceElements):        case(ReducedFaceElements):
822        Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);        Dudley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
823        break;        break;
824        case(Points):        case(Points):
825        Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);        Dudley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
       break;  
       case(ContactElementsZero):  
       case(ReducedContactElementsZero):  
       Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);  
       break;  
       case(ContactElementsOne):  
       case(ReducedContactElementsOne):  
       Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);  
826        break;        break;
827        default:        default:
828           stringstream temp;           stringstream temp;
829           temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();           temp << "Error - Interpolation on Domain: Dudley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
830           throw FinleyAdapterException(temp.str());           throw DudleyAdapterException(temp.str());
831           break;           break;
832        }        }
833        break;        break;
# Line 935  void MeshAdapter::interpolateOnDomain(es Line 837  void MeshAdapter::interpolateOnDomain(es
837        case(ReducedNodes):        case(ReducedNodes):
838        case(DegreesOfFreedom):        case(DegreesOfFreedom):
839        case(ReducedDegreesOfFreedom):        case(ReducedDegreesOfFreedom):
840        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);        Dudley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
841        break;        break;
842        case(Elements):        case(Elements):
843        case(ReducedElements):        case(ReducedElements):
844        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);        Dudley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
845        break;        break;
846        case(FaceElements):        case(FaceElements):
847        case(ReducedFaceElements):        case(ReducedFaceElements):
848        Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);        Dudley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
849        break;        break;
850        case(Points):        case(Points):
851        Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);        Dudley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
       break;  
       case(ContactElementsZero):  
       case(ReducedContactElementsZero):  
       Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);  
       break;  
       case(ContactElementsOne):  
       case(ReducedContactElementsOne):  
       Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);  
852        break;        break;
853        default:        default:
854           stringstream temp;           stringstream temp;
855           temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();           temp << "Error - Interpolation on Domain: Dudley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
856           throw FinleyAdapterException(temp.str());           throw DudleyAdapterException(temp.str());
857           break;           break;
858        }        }
859        break;        break;
860     case(Elements):     case(Elements):
861        if (target.getFunctionSpace().getTypeCode()==Elements) {        if (target.getFunctionSpace().getTypeCode()==Elements) {
862           Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);           Dudley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
863        } else if (target.getFunctionSpace().getTypeCode()==ReducedElements) {        } else if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
864           Finley_Assemble_AverageElementData(mesh->Elements,&_target,&_in);           Dudley_Assemble_AverageElementData(mesh->Elements,&_target,&_in);
865        } else {        } else {
866           throw FinleyAdapterException("Error - No interpolation with data on elements possible.");           throw DudleyAdapterException("Error - No interpolation with data on elements possible.");
867        }        }
868        break;        break;
869     case(ReducedElements):     case(ReducedElements):
870        if (target.getFunctionSpace().getTypeCode()==ReducedElements) {        if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
871           Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);           Dudley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
872        } else {        } else {
873           throw FinleyAdapterException("Error - No interpolation with data on elements with reduced integration order possible.");           throw DudleyAdapterException("Error - No interpolation with data on elements with reduced integration order possible.");
874        }        }
875        break;        break;
876     case(FaceElements):     case(FaceElements):
877        if (target.getFunctionSpace().getTypeCode()==FaceElements) {        if (target.getFunctionSpace().getTypeCode()==FaceElements) {
878           Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);           Dudley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
879        } else if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {        } else if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
880           Finley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);           Dudley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);
881        } else {        } else {
882           throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");           throw DudleyAdapterException("Error - No interpolation with data on face elements possible.");
883        }        }
884        break;        break;
885     case(ReducedFaceElements):     case(ReducedFaceElements):
886        if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {        if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
887           Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);           Dudley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
888        } else {        } else {
889           throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");           throw DudleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");
890        }        }
891        break;        break;
892     case(Points):     case(Points):
893        if (target.getFunctionSpace().getTypeCode()==Points) {        if (target.getFunctionSpace().getTypeCode()==Points) {
894           Finley_Assemble_CopyElementData(mesh->Points,&_target,&_in);           Dudley_Assemble_CopyElementData(mesh->Points,&_target,&_in);
       } else {  
          throw FinleyAdapterException("Error - No interpolation with data on points possible.");  
       }  
       break;  
    case(ContactElementsZero):  
    case(ContactElementsOne):  
       if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {  
          Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);  
       } else if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {  
          Finley_Assemble_AverageElementData(mesh->ContactElements,&_target,&_in);  
       } else {  
          throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");  
       }  
       break;  
    case(ReducedContactElementsZero):  
    case(ReducedContactElementsOne):  
       if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {  
          Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);  
895        } else {        } else {
896           throw FinleyAdapterException("Error - No interpolation with data on contact elements with reduced integration order possible.");           throw DudleyAdapterException("Error - No interpolation with data on points possible.");
897        }        }
898        break;        break;
899     case(DegreesOfFreedom):           case(DegreesOfFreedom):      
900        switch(target.getFunctionSpace().getTypeCode()) {        switch(target.getFunctionSpace().getTypeCode()) {
901        case(ReducedDegreesOfFreedom):        case(ReducedDegreesOfFreedom):
902        case(DegreesOfFreedom):        case(DegreesOfFreedom):
903        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);        Dudley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
904        break;        break;
905        
906        case(Nodes):        case(Nodes):
# Line 1033  void MeshAdapter::interpolateOnDomain(es Line 909  void MeshAdapter::interpolateOnDomain(es
909           escript::Data temp=escript::Data(in);           escript::Data temp=escript::Data(in);
910           temp.expand();           temp.expand();
911           escriptDataC _in2 = temp.getDataC();           escriptDataC _in2 = temp.getDataC();
912           Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);           Dudley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
913        } else {        } else {
914           Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);           Dudley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
915        }        }
916        break;        break;
917        case(Elements):        case(Elements):
# Line 1043  void MeshAdapter::interpolateOnDomain(es Line 919  void MeshAdapter::interpolateOnDomain(es
919        if (getMPISize()>1) {        if (getMPISize()>1) {
920           escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );           escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
921           escriptDataC _in2 = temp.getDataC();           escriptDataC _in2 = temp.getDataC();
922           Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
923        } else {        } else {
924           Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
925        }        }
926        break;        break;
927        case(FaceElements):        case(FaceElements):
# Line 1053  void MeshAdapter::interpolateOnDomain(es Line 929  void MeshAdapter::interpolateOnDomain(es
929        if (getMPISize()>1) {        if (getMPISize()>1) {
930           escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );           escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
931           escriptDataC _in2 = temp.getDataC();           escriptDataC _in2 = temp.getDataC();
932           Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
933        
934        } else {        } else {
935           Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
936        }        }
937        break;        break;
938        case(Points):        case(Points):
# Line 1064  void MeshAdapter::interpolateOnDomain(es Line 940  void MeshAdapter::interpolateOnDomain(es
940           escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );           escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
941           escriptDataC _in2 = temp.getDataC();           escriptDataC _in2 = temp.getDataC();
942        } else {        } else {
943           Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
       }  
       break;  
       case(ContactElementsZero):  
       case(ContactElementsOne):  
       case(ReducedContactElementsZero):  
       case(ReducedContactElementsOne):  
       if (getMPISize()>1) {  
          escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );  
          escriptDataC _in2 = temp.getDataC();  
          Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);  
       } else {  
          Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);  
944        }        }
945        break;        break;
946        default:        default:
947           stringstream temp;           stringstream temp;
948           temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();           temp << "Error - Interpolation On Domain: Dudley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
949           throw FinleyAdapterException(temp.str());           throw DudleyAdapterException(temp.str());
950           break;           break;
951        }        }
952        break;        break;
953     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
954        switch(target.getFunctionSpace().getTypeCode()) {        switch(target.getFunctionSpace().getTypeCode()) {
955        case(Nodes):        case(Nodes):
956        throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");        throw DudleyAdapterException("Error - Dudley does not support interpolation from reduced degrees of freedom to mesh nodes.");
957        break;        break;
958        case(ReducedNodes):        case(ReducedNodes):
959        if (getMPISize()>1) {        if (getMPISize()>1) {
960           escript::Data temp=escript::Data(in);           escript::Data temp=escript::Data(in);
961           temp.expand();           temp.expand();
962           escriptDataC _in2 = temp.getDataC();           escriptDataC _in2 = temp.getDataC();
963           Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);           Dudley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
964        } else {        } else {
965           Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);           Dudley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
966        }        }
967        break;        break;
968        case(DegreesOfFreedom):        case(DegreesOfFreedom):
969        throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");        throw DudleyAdapterException("Error - Dudley does not support interpolation from reduced degrees of freedom to degrees of freedom");
970        break;        break;
971        case(ReducedDegreesOfFreedom):        case(ReducedDegreesOfFreedom):
972        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);        Dudley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
973        break;        break;
974        case(Elements):        case(Elements):
975        case(ReducedElements):        case(ReducedElements):
976        if (getMPISize()>1) {        if (getMPISize()>1) {
977           escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );           escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
978           escriptDataC _in2 = temp.getDataC();           escriptDataC _in2 = temp.getDataC();
979           Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
980        } else {        } else {
981           Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
982        }        }
983        break;        break;
984        case(FaceElements):        case(FaceElements):
# Line 1122  void MeshAdapter::interpolateOnDomain(es Line 986  void MeshAdapter::interpolateOnDomain(es
986        if (getMPISize()>1) {        if (getMPISize()>1) {
987           escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );           escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
988           escriptDataC _in2 = temp.getDataC();           escriptDataC _in2 = temp.getDataC();
989           Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
990        } else {        } else {
991           Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
992        }        }
993        break;        break;
994        case(Points):        case(Points):
995        if (getMPISize()>1) {        if (getMPISize()>1) {
996           escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );           escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
997           escriptDataC _in2 = temp.getDataC();           escriptDataC _in2 = temp.getDataC();
998           Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);
999        } else {        } else {
1000           Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);           Dudley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
       }  
       break;  
       case(ContactElementsZero):  
       case(ContactElementsOne):  
       case(ReducedContactElementsZero):  
       case(ReducedContactElementsOne):  
       if (getMPISize()>1) {  
          escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );  
          escriptDataC _in2 = temp.getDataC();  
          Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);  
       } else {  
          Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);  
1001        }        }
1002        break;        break;
1003        default:        default:
1004           stringstream temp;           stringstream temp;
1005           temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();           temp << "Error - Interpolation On Domain: Dudley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
1006           throw FinleyAdapterException(temp.str());           throw DudleyAdapterException(temp.str());
1007           break;           break;
1008        }        }
1009        break;        break;
1010     default:     default:
1011        stringstream temp;        stringstream temp;
1012        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type %d" << in.getFunctionSpace().getTypeCode();        temp << "Error - Interpolation On Domain: Dudley does not know anything about function space type %d" << in.getFunctionSpace().getTypeCode();
1013        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
1014        break;        break;
1015     }     }
1016     checkFinleyError();     checkDudleyError();
1017  }  }
1018    
1019  //  //
# Line 1171  void MeshAdapter::setToX(escript::Data& Line 1023  void MeshAdapter::setToX(escript::Data&
1023  {  {
1024     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1025     if (argDomain!=*this)     if (argDomain!=*this)
1026        throw FinleyAdapterException("Error - Illegal domain of data point locations");        throw DudleyAdapterException("Error - Illegal domain of data point locations");
1027     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1028     // in case of values node coordinates we can do the job directly:     // in case of values node coordinates we can do the job directly:
1029     if (arg.getFunctionSpace().getTypeCode()==Nodes) {     if (arg.getFunctionSpace().getTypeCode()==Nodes) {
1030        escriptDataC _arg=arg.getDataC();        escriptDataC _arg=arg.getDataC();
1031        Finley_Assemble_NodeCoordinates(mesh->Nodes,&_arg);        Dudley_Assemble_NodeCoordinates(mesh->Nodes,&_arg);
1032     } else {     } else {
1033        escript::Data tmp_data=Vector(0.0,continuousFunction(asAbstractContinuousDomain()),true);        escript::Data tmp_data=Vector(0.0,continuousFunction(asAbstractContinuousDomain()),true);
1034        escriptDataC _tmp_data=tmp_data.getDataC();        escriptDataC _tmp_data=tmp_data.getDataC();
1035        Finley_Assemble_NodeCoordinates(mesh->Nodes,&_tmp_data);        Dudley_Assemble_NodeCoordinates(mesh->Nodes,&_tmp_data);
1036        // this is then interpolated onto arg:        // this is then interpolated onto arg:
1037        interpolateOnDomain(arg,tmp_data);        interpolateOnDomain(arg,tmp_data);
1038     }     }
1039     checkFinleyError();     checkDudleyError();
1040  }  }
1041    
1042  //  //
# Line 1195  void MeshAdapter::setToNormal(escript::D Line 1047  void MeshAdapter::setToNormal(escript::D
1047  /*   const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());*/  /*   const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());*/
1048     const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(*(normal.getFunctionSpace().getDomain()));     const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(*(normal.getFunctionSpace().getDomain()));
1049     if (normalDomain!=*this)     if (normalDomain!=*this)
1050        throw FinleyAdapterException("Error - Illegal domain of normal locations");        throw DudleyAdapterException("Error - Illegal domain of normal locations");
1051     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1052     escriptDataC _normal=normal.getDataC();     escriptDataC _normal=normal.getDataC();
1053     switch(normal.getFunctionSpace().getTypeCode()) {     switch(normal.getFunctionSpace().getTypeCode()) {
1054     case(Nodes):     case(Nodes):
1055     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for nodes");     throw DudleyAdapterException("Error - Dudley does not support surface normal vectors for nodes");
1056     break;     break;
1057     case(ReducedNodes):     case(ReducedNodes):
1058     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced nodes");     throw DudleyAdapterException("Error - Dudley does not support surface normal vectors for reduced nodes");
1059     break;     break;
1060     case(Elements):     case(Elements):
1061     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements");     throw DudleyAdapterException("Error - Dudley does not support surface normal vectors for elements");
1062     break;     break;
1063     case(ReducedElements):     case(ReducedElements):
1064     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements with reduced integration order");     throw DudleyAdapterException("Error - Dudley does not support surface normal vectors for elements with reduced integration order");
1065     break;     break;
1066     case (FaceElements):     case (FaceElements):
1067     Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);     Dudley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);
1068     break;     break;
1069     case (ReducedFaceElements):     case (ReducedFaceElements):
1070     Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);     Dudley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&_normal);
1071     break;     break;
1072     case(Points):     case(Points):
1073     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for point elements");     throw DudleyAdapterException("Error - Dudley does not support surface normal vectors for point elements");
    break;  
    case (ContactElementsOne):  
    case (ContactElementsZero):  
    Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&_normal);  
    break;  
    case (ReducedContactElementsOne):  
    case (ReducedContactElementsZero):  
    Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&_normal);  
1074     break;     break;
1075     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1076     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for degrees of freedom.");     throw DudleyAdapterException("Error - Dudley does not support surface normal vectors for degrees of freedom.");
1077     break;     break;
1078     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1079     throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced degrees of freedom.");     throw DudleyAdapterException("Error - Dudley does not support surface normal vectors for reduced degrees of freedom.");
1080     break;     break;
1081     default:     default:
1082        stringstream temp;        stringstream temp;
1083        temp << "Error - Normal Vectors: Finley does not know anything about function space type " << normal.getFunctionSpace().getTypeCode();        temp << "Error - Normal Vectors: Dudley does not know anything about function space type " << normal.getFunctionSpace().getTypeCode();
1084        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
1085        break;        break;
1086     }     }
1087     checkFinleyError();     checkDudleyError();
1088  }  }
1089    
1090  //  //
# Line 1251  void MeshAdapter::interpolateACross(escr Line 1095  void MeshAdapter::interpolateACross(escr
1095     const_Domain_ptr targetDomain_p=target.getFunctionSpace().getDomain();     const_Domain_ptr targetDomain_p=target.getFunctionSpace().getDomain();
1096     const MeshAdapter* targetDomain=dynamic_cast<const MeshAdapter*>(targetDomain_p.get());     const MeshAdapter* targetDomain=dynamic_cast<const MeshAdapter*>(targetDomain_p.get());
1097     if (targetDomain!=this)     if (targetDomain!=this)
1098        throw FinleyAdapterException("Error - Illegal domain of interpolation target");        throw DudleyAdapterException("Error - Illegal domain of interpolation target");
1099    
1100     throw FinleyAdapterException("Error - Finley does not allow interpolation across domains yet.");     throw DudleyAdapterException("Error - Dudley does not allow interpolation across domains yet.");
1101  }  }
1102    
1103  //  //
1104  // calculates the integral of a function defined of arg:  // calculates the integral of a function defined of arg:
1105  //  //
1106  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const  void MeshAdapter::setToIntegrals(vector<double>& integrals,const escript::Data& arg) const
1107  {  {
1108     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1109     if (argDomain!=*this)     if (argDomain!=*this)
1110        throw FinleyAdapterException("Error - Illegal domain of integration kernel");        throw DudleyAdapterException("Error - Illegal domain of integration kernel");
1111    
1112     double blocktimer_start = blocktimer_time();     double blocktimer_start = blocktimer_time();
1113     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1114     escriptDataC _temp;     escriptDataC _temp;
1115     escript::Data temp;     escript::Data temp;
1116     escriptDataC _arg=arg.getDataC();     escriptDataC _arg=arg.getDataC();
# Line 1274  void MeshAdapter::setToIntegrals(std::ve Line 1118  void MeshAdapter::setToIntegrals(std::ve
1118     case(Nodes):     case(Nodes):
1119     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1120     _temp=temp.getDataC();     _temp=temp.getDataC();
1121     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Dudley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1122     break;     break;
1123     case(ReducedNodes):     case(ReducedNodes):
1124     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1125     _temp=temp.getDataC();     _temp=temp.getDataC();
1126     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Dudley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1127     break;     break;
1128     case(Elements):     case(Elements):
1129     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);     Dudley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);
1130     break;     break;
1131     case(ReducedElements):     case(ReducedElements):
1132     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);     Dudley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_arg,&integrals[0]);
1133     break;     break;
1134     case(FaceElements):     case(FaceElements):
1135     Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);     Dudley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);
1136     break;     break;
1137     case(ReducedFaceElements):     case(ReducedFaceElements):
1138     Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);     Dudley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&_arg,&integrals[0]);
1139     break;     break;
1140     case(Points):     case(Points):
1141     throw FinleyAdapterException("Error - Integral of data on points is not supported.");     throw DudleyAdapterException("Error - Integral of data on points is not supported.");
    break;  
    case(ContactElementsZero):  
    Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);  
    break;  
    case(ReducedContactElementsZero):  
    Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);  
    break;  
    case(ContactElementsOne):  
    Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);  
    break;  
    case(ReducedContactElementsOne):  
    Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);  
1142     break;     break;
1143     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1144     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1145     _temp=temp.getDataC();     _temp=temp.getDataC();
1146     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Dudley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1147     break;     break;
1148     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1149     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1150     _temp=temp.getDataC();     _temp=temp.getDataC();
1151     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Dudley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1152     break;     break;
1153     default:     default:
1154        stringstream temp;        stringstream temp;
1155        temp << "Error - Integrals: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();        temp << "Error - Integrals: Dudley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();
1156        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
1157        break;        break;
1158     }     }
1159     checkFinleyError();     checkDudleyError();
1160     blocktimer_increment("integrate()", blocktimer_start);     blocktimer_increment("integrate()", blocktimer_start);
1161  }  }
1162    
# Line 1335  void MeshAdapter::setToGradient(escript: Line 1167  void MeshAdapter::setToGradient(escript:
1167  {  {
1168     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1169     if (argDomain!=*this)     if (argDomain!=*this)
1170        throw FinleyAdapterException("Error - Illegal domain of gradient argument");        throw DudleyAdapterException("Error - Illegal domain of gradient argument");
1171     const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(*(grad.getFunctionSpace().getDomain()));     const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(*(grad.getFunctionSpace().getDomain()));
1172     if (gradDomain!=*this)     if (gradDomain!=*this)
1173        throw FinleyAdapterException("Error - Illegal domain of gradient");        throw DudleyAdapterException("Error - Illegal domain of gradient");
1174    
1175     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1176     escriptDataC _grad=grad.getDataC();     escriptDataC _grad=grad.getDataC();
1177     escriptDataC nodeDataC;     escriptDataC nodeDataC;
1178     escript::Data temp;     escript::Data temp;
# Line 1359  void MeshAdapter::setToGradient(escript: Line 1191  void MeshAdapter::setToGradient(escript:
1191     }     }
1192     switch(grad.getFunctionSpace().getTypeCode()) {     switch(grad.getFunctionSpace().getTypeCode()) {
1193     case(Nodes):     case(Nodes):
1194     throw FinleyAdapterException("Error - Gradient at nodes is not supported.");     throw DudleyAdapterException("Error - Gradient at nodes is not supported.");
1195     break;     break;
1196     case(ReducedNodes):     case(ReducedNodes):
1197     throw FinleyAdapterException("Error - Gradient at reduced nodes is not supported.");     throw DudleyAdapterException("Error - Gradient at reduced nodes is not supported.");
1198     break;     break;
1199     case(Elements):     case(Elements):
1200     Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);     Dudley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);
1201     break;     break;
1202     case(ReducedElements):     case(ReducedElements):
1203     Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);     Dudley_Assemble_gradient(mesh->Nodes,mesh->Elements,&_grad,&nodeDataC);
1204     break;     break;
1205     case(FaceElements):     case(FaceElements):
1206     Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);     Dudley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);
1207     break;     break;
1208     case(ReducedFaceElements):     case(ReducedFaceElements):
1209     Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);     Dudley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&_grad,&nodeDataC);
1210     break;     break;
1211     case(Points):     case(Points):
1212     throw FinleyAdapterException("Error - Gradient at points is not supported.");     throw DudleyAdapterException("Error - Gradient at points is not supported.");
    break;  
    case(ContactElementsZero):  
    Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);  
    break;  
    case(ReducedContactElementsZero):  
    Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);  
    break;  
    case(ContactElementsOne):  
    Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);  
    break;  
    case(ReducedContactElementsOne):  
    Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&_grad,&nodeDataC);  
1213     break;     break;
1214     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1215     throw FinleyAdapterException("Error - Gradient at degrees of freedom is not supported.");     throw DudleyAdapterException("Error - Gradient at degrees of freedom is not supported.");
1216     break;     break;
1217     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1218     throw FinleyAdapterException("Error - Gradient at reduced degrees of freedom is not supported.");     throw DudleyAdapterException("Error - Gradient at reduced degrees of freedom is not supported.");
1219     break;     break;
1220     default:     default:
1221        stringstream temp;        stringstream temp;
1222        temp << "Error - Gradient: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();        temp << "Error - Gradient: Dudley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();
1223        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
1224        break;        break;
1225     }     }
1226     checkFinleyError();     checkDudleyError();
1227  }  }
1228    
1229  //  //
# Line 1411  void MeshAdapter::setToGradient(escript: Line 1231  void MeshAdapter::setToGradient(escript:
1231  //  //
1232  void MeshAdapter::setToSize(escript::Data& size) const  void MeshAdapter::setToSize(escript::Data& size) const
1233  {  {
1234     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1235     escriptDataC tmp=size.getDataC();     escriptDataC tmp=size.getDataC();
1236     switch(size.getFunctionSpace().getTypeCode()) {     switch(size.getFunctionSpace().getTypeCode()) {
1237     case(Nodes):     case(Nodes):
1238     throw FinleyAdapterException("Error - Size of nodes is not supported.");     throw DudleyAdapterException("Error - Size of nodes is not supported.");
1239     break;     break;
1240     case(ReducedNodes):     case(ReducedNodes):
1241     throw FinleyAdapterException("Error - Size of reduced nodes is not supported.");     throw DudleyAdapterException("Error - Size of reduced nodes is not supported.");
1242     break;     break;
1243     case(Elements):     case(Elements):
1244     Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);     Dudley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);
1245     break;     break;
1246     case(ReducedElements):     case(ReducedElements):
1247     Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);     Dudley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);
1248     break;     break;
1249     case(FaceElements):     case(FaceElements):
1250     Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);     Dudley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);
1251     break;     break;
1252     case(ReducedFaceElements):     case(ReducedFaceElements):
1253     Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);     Dudley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);
1254     break;     break;
1255     case(Points):     case(Points):
1256     throw FinleyAdapterException("Error - Size of point elements is not supported.");     throw DudleyAdapterException("Error - Size of point elements is not supported.");
    break;  
    case(ContactElementsZero):  
    case(ContactElementsOne):  
    Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);  
    break;  
    case(ReducedContactElementsZero):  
    case(ReducedContactElementsOne):  
    Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);  
1257     break;     break;
1258     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1259     throw FinleyAdapterException("Error - Size of degrees of freedom is not supported.");     throw DudleyAdapterException("Error - Size of degrees of freedom is not supported.");
1260     break;     break;
1261     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1262     throw FinleyAdapterException("Error - Size of reduced degrees of freedom is not supported.");     throw DudleyAdapterException("Error - Size of reduced degrees of freedom is not supported.");
1263     break;     break;
1264     default:     default:
1265        stringstream temp;        stringstream temp;
1266        temp << "Error - Element size: Finley does not know anything about function space type " << size.getFunctionSpace().getTypeCode();        temp << "Error - Element size: Dudley does not know anything about function space type " << size.getFunctionSpace().getTypeCode();
1267        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
1268        break;        break;
1269     }     }
1270     checkFinleyError();     checkDudleyError();
1271  }  }
1272    
1273  //  //
# Line 1463  void MeshAdapter::setToSize(escript::Dat Line 1275  void MeshAdapter::setToSize(escript::Dat
1275  //  //
1276  void MeshAdapter::setNewX(const escript::Data& new_x)  void MeshAdapter::setNewX(const escript::Data& new_x)
1277  {  {
1278     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1279     escriptDataC tmp;     escriptDataC tmp;
1280     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));
1281     if (newDomain!=*this)     if (newDomain!=*this)
1282        throw FinleyAdapterException("Error - Illegal domain of new point locations");        throw DudleyAdapterException("Error - Illegal domain of new point locations");
1283     if ( new_x.getFunctionSpace() == continuousFunction(asAbstractContinuousDomain()) ) {     if ( new_x.getFunctionSpace() == continuousFunction(asAbstractContinuousDomain()) ) {
1284         tmp = new_x.getDataC();         tmp = new_x.getDataC();
1285         Finley_Mesh_setCoordinates(mesh,&tmp);         Dudley_Mesh_setCoordinates(mesh,&tmp);
1286     } else {     } else {
1287         escript::Data new_x_inter=escript::Data( new_x,  continuousFunction(asAbstractContinuousDomain()) );         escript::Data new_x_inter=escript::Data( new_x,  continuousFunction(asAbstractContinuousDomain()) );
1288         tmp = new_x_inter.getDataC();         tmp = new_x_inter.getDataC();
1289         Finley_Mesh_setCoordinates(mesh,&tmp);         Dudley_Mesh_setCoordinates(mesh,&tmp);
1290     }     }
1291     checkFinleyError();     checkDudleyError();
1292  }  }
1293    
1294  //  //
# Line 1493  void MeshAdapter::extractArgsFromDict(co Line 1305  void MeshAdapter::extractArgsFromDict(co
1305    
1306     boost::python::list keys=arg.keys();     boost::python::list keys=arg.keys();
1307     for (int i=0; i<numData; ++i) {     for (int i=0; i<numData; ++i) {
1308        std::string n=boost::python::extract<std::string>(keys[i]);        string n=boost::python::extract<string>(keys[i]);
1309        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1310        if (dynamic_cast<const MeshAdapter&>(*(d.getFunctionSpace().getDomain())) !=*this)        if (dynamic_cast<const MeshAdapter&>(*(d.getFunctionSpace().getDomain())) !=*this)
1311           throw FinleyAdapterException("Error: Data must be defined on same Domain");           throw DudleyAdapterException("Error: Data must be defined on same Domain");
1312        data[i] = d.getDataC();        data[i] = d.getDataC();
1313        dataPtr[i] = &(data[i]);        dataPtr[i] = &(data[i]);
1314        names[i] = TMPMEMALLOC(n.length()+1, char);        names[i] = TMPMEMALLOC(n.length()+1, char);
# Line 1507  void MeshAdapter::extractArgsFromDict(co Line 1319  void MeshAdapter::extractArgsFromDict(co
1319  //  //
1320  // saves mesh and optionally data arrays in openDX format  // saves mesh and optionally data arrays in openDX format
1321  //  //
1322  void MeshAdapter::saveDX(const std::string& filename,const boost::python::dict& arg) const  void MeshAdapter::saveDX(const string& filename,const boost::python::dict& arg) const
1323  {  {
1324     int num_data;     int num_data;
1325     char **names;     char **names;
# Line 1515  void MeshAdapter::saveDX(const std::stri Line 1327  void MeshAdapter::saveDX(const std::stri
1327     escriptDataC **ptr_data;     escriptDataC **ptr_data;
1328    
1329     extractArgsFromDict(arg, num_data, names, data, ptr_data);     extractArgsFromDict(arg, num_data, names, data, ptr_data);
1330     Finley_Mesh_saveDX(filename.c_str(), m_finleyMesh.get(), num_data, names, ptr_data);     Dudley_Mesh_saveDX(filename.c_str(), m_dudleyMesh.get(), num_data, names, ptr_data);
1331     checkFinleyError();     checkDudleyError();
1332    
1333     /* win32 refactor */     /* win32 refactor */
1334     TMPMEMFREE(data);     TMPMEMFREE(data);
# Line 1533  void MeshAdapter::saveDX(const std::stri Line 1345  void MeshAdapter::saveDX(const std::stri
1345  //  //
1346  // saves mesh and optionally data arrays in VTK format  // saves mesh and optionally data arrays in VTK format
1347  //  //
1348  void MeshAdapter::saveVTK(const std::string& filename,const boost::python::dict& arg,  const std::string& metadata, const std::string& metadata_schema) const  void MeshAdapter::saveVTK(const string& filename,const boost::python::dict& arg,  const string& metadata, const string& metadata_schema) const
1349  {  {
1350     int num_data;     int num_data;
1351     char **names;     char **names;
# Line 1541  void MeshAdapter::saveVTK(const std::str Line 1353  void MeshAdapter::saveVTK(const std::str
1353     escriptDataC **ptr_data;     escriptDataC **ptr_data;
1354    
1355     extractArgsFromDict(arg, num_data, names, data, ptr_data);     extractArgsFromDict(arg, num_data, names, data, ptr_data);
1356     Finley_Mesh_saveVTK(filename.c_str(), m_finleyMesh.get(), num_data, names, ptr_data, metadata.c_str(), metadata_schema.c_str());     Dudley_Mesh_saveVTK(filename.c_str(), m_dudleyMesh.get(), num_data, names, ptr_data, metadata.c_str(), metadata_schema.c_str());
1357     checkFinleyError();     checkDudleyError();
1358    
1359     /* win32 refactor */     /* win32 refactor */
1360     TMPMEMFREE(data);     TMPMEMFREE(data);
# Line 1559  bool MeshAdapter::ownSample(int fs_code, Line 1371  bool MeshAdapter::ownSample(int fs_code,
1371  #ifdef PASO_MPI  #ifdef PASO_MPI
1372      index_t myFirstNode=0, myLastNode=0, k=0;      index_t myFirstNode=0, myLastNode=0, k=0;
1373      index_t* globalNodeIndex=0;      index_t* globalNodeIndex=0;
1374      Finley_Mesh* mesh_p=m_finleyMesh.get();      Dudley_Mesh* mesh_p=m_dudleyMesh.get();
1375      if (fs_code == FINLEY_REDUCED_NODES)      if (fs_code == DUDLEY_REDUCED_NODES)
1376      {      {
1377      myFirstNode = Finley_NodeFile_getFirstReducedNode(mesh_p->Nodes);      myFirstNode = Dudley_NodeFile_getFirstReducedNode(mesh_p->Nodes);
1378      myLastNode = Finley_NodeFile_getLastReducedNode(mesh_p->Nodes);      myLastNode = Dudley_NodeFile_getLastReducedNode(mesh_p->Nodes);
1379      globalNodeIndex = Finley_NodeFile_borrowGlobalReducedNodesIndex(mesh_p->Nodes);      globalNodeIndex = Dudley_NodeFile_borrowGlobalReducedNodesIndex(mesh_p->Nodes);
1380      }      }
1381      else      else
1382      {      {
1383      myFirstNode = Finley_NodeFile_getFirstNode(mesh_p->Nodes);      myFirstNode = Dudley_NodeFile_getFirstNode(mesh_p->Nodes);
1384      myLastNode = Finley_NodeFile_getLastNode(mesh_p->Nodes);      myLastNode = Dudley_NodeFile_getLastNode(mesh_p->Nodes);
1385      globalNodeIndex = Finley_NodeFile_borrowGlobalNodesIndex(mesh_p->Nodes);      globalNodeIndex = Dudley_NodeFile_borrowGlobalNodesIndex(mesh_p->Nodes);
1386      }      }
1387      k=globalNodeIndex[id];      k=globalNodeIndex[id];
1388      return static_cast<bool>( (myFirstNode <= k) && (k < myLastNode) );      return static_cast<bool>( (myFirstNode <= k) && (k < myLastNode) );
# Line 1595  SystemMatrixAdapter MeshAdapter::newSyst Line 1407  SystemMatrixAdapter MeshAdapter::newSyst
1407     // is the domain right?     // is the domain right?
1408     const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(*(row_functionspace.getDomain()));     const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(*(row_functionspace.getDomain()));
1409     if (row_domain!=*this)     if (row_domain!=*this)
1410        throw FinleyAdapterException("Error - domain of row function space does not match the domain of matrix generator.");        throw DudleyAdapterException("Error - domain of row function space does not match the domain of matrix generator.");
1411     const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(*(column_functionspace.getDomain()));     const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(*(column_functionspace.getDomain()));
1412     if (col_domain!=*this)     if (col_domain!=*this)
1413        throw FinleyAdapterException("Error - domain of columnn function space does not match the domain of matrix generator.");        throw DudleyAdapterException("Error - domain of columnn function space does not match the domain of matrix generator.");
1414     // is the function space type right     // is the function space type right
1415     if (row_functionspace.getTypeCode()==DegreesOfFreedom) {     if (row_functionspace.getTypeCode()==DegreesOfFreedom) {
1416        reduceRowOrder=0;        reduceRowOrder=0;
1417     } else if (row_functionspace.getTypeCode()==ReducedDegreesOfFreedom) {     } else if (row_functionspace.getTypeCode()==ReducedDegreesOfFreedom) {
1418        reduceRowOrder=1;        reduceRowOrder=1;
1419     } else {     } else {
1420        throw FinleyAdapterException("Error - illegal function space type for system matrix rows.");        throw DudleyAdapterException("Error - illegal function space type for system matrix rows.");
1421     }     }
1422     if (column_functionspace.getTypeCode()==DegreesOfFreedom) {     if (column_functionspace.getTypeCode()==DegreesOfFreedom) {
1423        reduceColOrder=0;        reduceColOrder=0;
1424     } else if (column_functionspace.getTypeCode()==ReducedDegreesOfFreedom) {     } else if (column_functionspace.getTypeCode()==ReducedDegreesOfFreedom) {
1425        reduceColOrder=1;        reduceColOrder=1;
1426     } else {     } else {
1427        throw FinleyAdapterException("Error - illegal function space type for system matrix columns.");        throw DudleyAdapterException("Error - illegal function space type for system matrix columns.");
1428     }     }
1429     // generate matrix:     // generate matrix:
1430    
1431     Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);     Paso_SystemMatrixPattern* fsystemMatrixPattern=Dudley_getPattern(getDudley_Mesh(),reduceRowOrder,reduceColOrder);
1432     checkFinleyError();     checkDudleyError();
1433     Paso_SystemMatrix* fsystemMatrix;     Paso_SystemMatrix* fsystemMatrix;
1434     int trilinos = 0;     int trilinos = 0;
1435     if (trilinos) {     if (trilinos) {
# Line 1637  SystemMatrixAdapter MeshAdapter::newSyst Line 1449  SystemMatrixAdapter MeshAdapter::newSyst
1449  // creates a TransportProblemAdapter  // creates a TransportProblemAdapter
1450  //  //
1451  TransportProblemAdapter MeshAdapter::newTransportProblem(  TransportProblemAdapter MeshAdapter::newTransportProblem(
1452                                                           const double theta,                                                           const bool useBackwardEuler,
1453                                                           const int blocksize,                                                           const int blocksize,
1454                                                           const escript::FunctionSpace& functionspace,                                                           const escript::FunctionSpace& functionspace,
1455                                                           const int type) const                                                           const int type) const
# Line 1646  TransportProblemAdapter MeshAdapter::new Line 1458  TransportProblemAdapter MeshAdapter::new
1458     // is the domain right?     // is the domain right?
1459     const MeshAdapter& domain=dynamic_cast<const MeshAdapter&>(*(functionspace.getDomain()));     const MeshAdapter& domain=dynamic_cast<const MeshAdapter&>(*(functionspace.getDomain()));
1460     if (domain!=*this)     if (domain!=*this)
1461        throw FinleyAdapterException("Error - domain of function space does not match the domain of transport problem generator.");        throw DudleyAdapterException("Error - domain of function space does not match the domain of transport problem generator.");
1462     // is the function space type right     // is the function space type right
1463     if (functionspace.getTypeCode()==DegreesOfFreedom) {     if (functionspace.getTypeCode()==DegreesOfFreedom) {
1464        reduceOrder=0;        reduceOrder=0;
1465     } else if (functionspace.getTypeCode()==ReducedDegreesOfFreedom) {     } else if (functionspace.getTypeCode()==ReducedDegreesOfFreedom) {
1466        reduceOrder=1;        reduceOrder=1;
1467     } else {     } else {
1468        throw FinleyAdapterException("Error - illegal function space type for system matrix rows.");        throw DudleyAdapterException("Error - illegal function space type for system matrix rows.");
1469     }     }
1470     // generate matrix:     // generate matrix:
1471    
1472     Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceOrder,reduceOrder);     Paso_SystemMatrixPattern* fsystemMatrixPattern=Dudley_getPattern(getDudley_Mesh(),reduceOrder,reduceOrder);
1473     checkFinleyError();     checkDudleyError();
1474     Paso_FCTransportProblem* transportProblem;     Paso_TransportProblem* transportProblem;
1475     transportProblem=Paso_FCTransportProblem_alloc(theta,fsystemMatrixPattern,blocksize);     transportProblem=Paso_TransportProblem_alloc(useBackwardEuler,fsystemMatrixPattern,blocksize);
1476     checkPasoError();     checkPasoError();
1477     Paso_SystemMatrixPattern_free(fsystemMatrixPattern);     Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
1478     return TransportProblemAdapter(transportProblem,theta,blocksize,functionspace);     return TransportProblemAdapter(transportProblem,useBackwardEuler,blocksize,functionspace);
1479  }  }
1480    
1481  //  //
# Line 1684  bool MeshAdapter::isCellOriented(int fun Line 1496  bool MeshAdapter::isCellOriented(int fun
1496     case(Elements):     case(Elements):
1497     case(FaceElements):     case(FaceElements):
1498     case(Points):     case(Points):
    case(ContactElementsZero):  
    case(ContactElementsOne):  
1499     case(ReducedElements):     case(ReducedElements):
1500     case(ReducedFaceElements):     case(ReducedFaceElements):
    case(ReducedContactElementsZero):  
    case(ReducedContactElementsOne):  
1501     return true;     return true;
1502     break;     break;
1503     default:     default:
1504        stringstream temp;        stringstream temp;
1505        temp << "Error - Cell: Finley does not know anything about function space type " << functionSpaceCode;        temp << "Error - Cell: Dudley does not know anything about function space type " << functionSpaceCode;
1506        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
1507        break;        break;
1508     }     }
1509     checkFinleyError();     checkDudleyError();
1510     return false;     return false;
1511  }  }
1512    
1513  bool  bool
1514  MeshAdapter::commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const  MeshAdapter::commonFunctionSpace(const vector<int>& fs, int& resultcode) const
1515  {  {
1516     /* The idea is to use equivalence classes. [Types which can be interpolated back and forth]     /* The idea is to use equivalence classes. [Types which can be interpolated back and forth]
1517      class 1: DOF <-> Nodes      class 1: DOF <-> Nodes
# Line 1726  MeshAdapter::commonFunctionSpace(const s Line 1534  MeshAdapter::commonFunctionSpace(const s
1534     For classes with multiple members (eg class 2) we have vars to record if there is at least one instance.     For classes with multiple members (eg class 2) we have vars to record if there is at least one instance.
1535     eg hasnodes is true if we have at least one instance of Nodes.     eg hasnodes is true if we have at least one instance of Nodes.
1536     */     */
1537      if (fs.size()==0)      if (fs.empty())
1538      {      {
1539      return false;          return false;
1540      }      }
1541      std::vector<int> hasclass(10);      vector<int> hasclass(10);
1542      std::vector<int> hasline(4);          vector<int> hasline(4);
1543      bool hasnodes=false;      bool hasnodes=false;
1544      bool hasrednodes=false;      bool hasrednodes=false;
     bool hascez=false;  
     bool hasrcez=false;  
1545      for (int i=0;i<fs.size();++i)      for (int i=0;i<fs.size();++i)
1546      {      {
1547      switch(fs[i])      switch(fs[i])
# Line 1768  MeshAdapter::commonFunctionSpace(const s Line 1574  MeshAdapter::commonFunctionSpace(const s
1574          hasclass[7]=1;          hasclass[7]=1;
1575          hasline[2]=1;          hasline[2]=1;
1576          break;          break;
     case(ContactElementsZero):  hascez=true;    // no break is deliberate  
     case(ContactElementsOne):  
         hasclass[8]=1;  
         hasline[3]=1;  
         break;  
     case(ReducedContactElementsZero):   hasrcez=true;   // no break is deliberate  
     case(ReducedContactElementsOne):  
         hasclass[9]=1;  
         hasline[3]=1;  
         break;  
1577      default:      default:
1578          return false;          return false;
1579      }      }
# Line 1819  MeshAdapter::commonFunctionSpace(const s Line 1615  MeshAdapter::commonFunctionSpace(const s
1615      }      }
1616      else    // so we must be in line3      else    // so we must be in line3
1617      {      {
1618          if (hasclass[9]==1)  
1619          {          throw DudleyAdapterException("Programmer Error - choosing between contact elements - we should never get here.");
1620          // need something from class 9  
         resultcode=(hasrcez?ReducedContactElementsZero:ReducedContactElementsOne);  
         }  
         else  
         {  
         // something from class 8  
         resultcode=(hascez?ContactElementsZero:ContactElementsOne);  
         }  
1621      }      }
1622      }      }
1623      else    // totlines==0      else    // totlines==0
# Line 1860  bool MeshAdapter::probeInterpolationOnDo Line 1649  bool MeshAdapter::probeInterpolationOnDo
1649      case(FaceElements):      case(FaceElements):
1650      case(ReducedFaceElements):      case(ReducedFaceElements):
1651      case(Points):      case(Points):
     case(ContactElementsZero):  
     case(ReducedContactElementsZero):  
     case(ContactElementsOne):  
     case(ReducedContactElementsOne):  
1652      return true;      return true;
1653      default:      default:
1654            stringstream temp;            stringstream temp;
1655            temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;            temp << "Error - Interpolation On Domain: Dudley does not know anything about function space type " << functionSpaceType_target;
1656            throw FinleyAdapterException(temp.str());            throw DudleyAdapterException(temp.str());
1657     }     }
1658     break;     break;
1659     case(ReducedNodes):     case(ReducedNodes):
# Line 1880  bool MeshAdapter::probeInterpolationOnDo Line 1665  bool MeshAdapter::probeInterpolationOnDo
1665      case(FaceElements):      case(FaceElements):
1666      case(ReducedFaceElements):      case(ReducedFaceElements):
1667      case(Points):      case(Points):
     case(ContactElementsZero):  
     case(ReducedContactElementsZero):  
     case(ContactElementsOne):  
     case(ReducedContactElementsOne):  
1668      return true;      return true;
1669      case(Nodes):      case(Nodes):
1670      case(DegreesOfFreedom):      case(DegreesOfFreedom):
1671      return false;      return false;
1672      default:      default:
1673          stringstream temp;          stringstream temp;
1674          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;          temp << "Error - Interpolation On Domain: Dudley does not know anything about function space type " << functionSpaceType_target;
1675          throw FinleyAdapterException(temp.str());          throw DudleyAdapterException(temp.str());
1676     }     }
1677     break;     break;
1678     case(Elements):     case(Elements):
# Line 1928  bool MeshAdapter::probeInterpolationOnDo Line 1709  bool MeshAdapter::probeInterpolationOnDo
1709      } else {      } else {
1710              return false;              return false;
1711      }      }
    case(ContactElementsZero):  
    case(ContactElementsOne):  
     if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {  
             return true;  
     } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {  
             return true;  
     } else {  
             return false;  
     }  
    case(ReducedContactElementsZero):  
    case(ReducedContactElementsOne):  
     if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {  
             return true;  
     } else {  
             return false;  
     }  
1712     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1713      switch(functionSpaceType_target) {      switch(functionSpaceType_target) {
1714      case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
# Line 1955  bool MeshAdapter::probeInterpolationOnDo Line 1720  bool MeshAdapter::probeInterpolationOnDo
1720      case(Points):      case(Points):
1721      case(FaceElements):      case(FaceElements):
1722      case(ReducedFaceElements):      case(ReducedFaceElements):
     case(ContactElementsZero):  
     case(ReducedContactElementsZero):  
     case(ContactElementsOne):  
     case(ReducedContactElementsOne):  
1723      return true;      return true;
1724      default:      default:
1725          stringstream temp;          stringstream temp;
1726          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;          temp << "Error - Interpolation On Domain: Dudley does not know anything about function space type " << functionSpaceType_target;
1727          throw FinleyAdapterException(temp.str());          throw DudleyAdapterException(temp.str());
1728      }      }
1729      break;      break;
1730     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
# Line 1975  bool MeshAdapter::probeInterpolationOnDo Line 1736  bool MeshAdapter::probeInterpolationOnDo
1736      case(FaceElements):      case(FaceElements):
1737      case(ReducedFaceElements):      case(ReducedFaceElements):
1738      case(Points):      case(Points):
     case(ContactElementsZero):  
     case(ReducedContactElementsZero):  
     case(ContactElementsOne):  
     case(ReducedContactElementsOne):  
1739      return true;      return true;
1740      case(Nodes):      case(Nodes):
1741      case(DegreesOfFreedom):      case(DegreesOfFreedom):
1742      return false;      return false;
1743      default:      default:
1744          stringstream temp;          stringstream temp;
1745          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;          temp << "Error - Interpolation On Domain: Dudley does not know anything about function space type " << functionSpaceType_target;
1746          throw FinleyAdapterException(temp.str());          throw DudleyAdapterException(temp.str());
1747      }      }
1748      break;      break;
1749     default:     default:
1750        stringstream temp;        stringstream temp;
1751        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_source;        temp << "Error - Interpolation On Domain: Dudley does not know anything about function space type " << functionSpaceType_source;
1752        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
1753        break;        break;
1754     }     }
1755     checkFinleyError();     checkDudleyError();
1756     return false;     return false;
1757  }  }
1758    
# Line 2008  bool MeshAdapter::operator==(const Abstr Line 1765  bool MeshAdapter::operator==(const Abstr
1765  {  {
1766     const MeshAdapter* temp=dynamic_cast<const MeshAdapter*>(&other);     const MeshAdapter* temp=dynamic_cast<const MeshAdapter*>(&other);
1767     if (temp!=0) {     if (temp!=0) {
1768        return (m_finleyMesh==temp->m_finleyMesh);        return (m_dudleyMesh==temp->m_dudleyMesh);
1769     } else {     } else {
1770        return false;        return false;
1771     }     }
# Line 2021  bool MeshAdapter::operator!=(const Abstr Line 1778  bool MeshAdapter::operator!=(const Abstr
1778    
1779  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const
1780  {  {
1781     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1782     int out=Paso_SystemMatrix_getSystemMatrixTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(preconditioner), SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0, mesh->MPIInfo);     int out=Paso_SystemMatrix_getSystemMatrixTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(preconditioner), SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0, mesh->MPIInfo);
1783     checkPasoError();     checkPasoError();
1784     return out;     return out;
1785  }  }
1786  int MeshAdapter::getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const  int MeshAdapter::getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const
1787  {  {
1788     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1789     int out=Paso_FCTransportProblem_getTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(preconditioner), SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0, mesh->MPIInfo);     int out=Paso_TransportProblem_getTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(preconditioner), SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0, mesh->MPIInfo);
1790     checkPasoError();     checkPasoError();
1791     return out;     return out;
1792  }  }
# Line 2052  escript::Data MeshAdapter::getSize() con Line 1809  escript::Data MeshAdapter::getSize() con
1809  const int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const  const int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const
1810  {  {
1811     int *out = NULL;     int *out = NULL;
1812     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1813     switch (functionSpaceType) {     switch (functionSpaceType) {
1814     case(Nodes):     case(Nodes):
1815     out=mesh->Nodes->Id;     out=mesh->Nodes->Id;
# Line 2075  const int* MeshAdapter::borrowSampleRefe Line 1832  const int* MeshAdapter::borrowSampleRefe
1832     case(Points):     case(Points):
1833     out=mesh->Points->Id;     out=mesh->Points->Id;
1834     break;     break;
    case(ContactElementsZero):  
    out=mesh->ContactElements->Id;  
    break;  
    case(ReducedContactElementsZero):  
    out=mesh->ContactElements->Id;  
    break;  
    case(ContactElementsOne):  
    out=mesh->ContactElements->Id;  
    break;  
    case(ReducedContactElementsOne):  
    out=mesh->ContactElements->Id;  
    break;  
1835     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1836     out=mesh->Nodes->degreesOfFreedomId;     out=mesh->Nodes->degreesOfFreedomId;
1837     break;     break;
# Line 2096  const int* MeshAdapter::borrowSampleRefe Line 1841  const int* MeshAdapter::borrowSampleRefe
1841     default:     default:
1842        stringstream temp;        stringstream temp;
1843        temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();        temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
1844        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
1845        break;        break;
1846     }     }
1847     return out;     return out;
# Line 2104  const int* MeshAdapter::borrowSampleRefe Line 1849  const int* MeshAdapter::borrowSampleRefe
1849  int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const  int MeshAdapter::getTagFromSampleNo(int functionSpaceType, int sampleNo) const
1850  {  {
1851     int out=0;     int out=0;
1852     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1853     switch (functionSpaceType) {     switch (functionSpaceType) {
1854     case(Nodes):     case(Nodes):
1855     out=mesh->Nodes->Tag[sampleNo];     out=mesh->Nodes->Tag[sampleNo];
1856     break;     break;
1857     case(ReducedNodes):     case(ReducedNodes):
1858     throw FinleyAdapterException(" Error - ReducedNodes does not support tags.");     throw DudleyAdapterException(" Error - ReducedNodes does not support tags.");
1859     break;     break;
1860     case(Elements):     case(Elements):
1861     out=mesh->Elements->Tag[sampleNo];     out=mesh->Elements->Tag[sampleNo];
# Line 2127  int MeshAdapter::getTagFromSampleNo(int Line 1872  int MeshAdapter::getTagFromSampleNo(int
1872     case(Points):     case(Points):
1873     out=mesh->Points->Tag[sampleNo];     out=mesh->Points->Tag[sampleNo];
1874     break;     break;
    case(ContactElementsZero):  
    out=mesh->ContactElements->Tag[sampleNo];  
    break;  
    case(ReducedContactElementsZero):  
    out=mesh->ContactElements->Tag[sampleNo];  
    break;  
    case(ContactElementsOne):  
    out=mesh->ContactElements->Tag[sampleNo];  
    break;  
    case(ReducedContactElementsOne):  
    out=mesh->ContactElements->Tag[sampleNo];  
    break;  
1875     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1876     throw FinleyAdapterException(" Error - DegreesOfFreedom does not support tags.");     throw DudleyAdapterException(" Error - DegreesOfFreedom does not support tags.");
1877     break;     break;
1878     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1879     throw FinleyAdapterException(" Error - ReducedDegreesOfFreedom does not support tags.");     throw DudleyAdapterException(" Error - ReducedDegreesOfFreedom does not support tags.");
1880     break;     break;
1881     default:     default:
1882        stringstream temp;        stringstream temp;
1883        temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();        temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
1884        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
1885        break;        break;
1886     }     }
1887     return out;     return out;
# Line 2157  int MeshAdapter::getTagFromSampleNo(int Line 1890  int MeshAdapter::getTagFromSampleNo(int
1890    
1891  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
1892  {  {
1893     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1894     escriptDataC tmp=mask.getDataC();     escriptDataC tmp=mask.getDataC();
1895     switch(functionSpaceType) {     switch(functionSpaceType) {
1896     case(Nodes):     case(Nodes):
1897     Finley_NodeFile_setTags(mesh->Nodes,newTag,&tmp);     Dudley_NodeFile_setTags(mesh->Nodes,newTag,&tmp);
1898     break;     break;
1899     case(ReducedNodes):     case(ReducedNodes):
1900     throw FinleyAdapterException("Error - ReducedNodes does not support tags");     throw DudleyAdapterException("Error - ReducedNodes does not support tags");
1901     break;     break;
1902     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1903     throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");     throw DudleyAdapterException("Error - DegreesOfFreedom does not support tags");
1904     break;     break;
1905     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1906     throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");     throw DudleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");
1907     break;     break;
1908     case(Elements):     case(Elements):
1909     Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);     Dudley_ElementFile_setTags(mesh->Elements,newTag,&tmp);
1910     break;     break;
1911     case(ReducedElements):     case(ReducedElements):
1912     Finley_ElementFile_setTags(mesh->Elements,newTag,&tmp);     Dudley_ElementFile_setTags(mesh->Elements,newTag,&tmp);
1913     break;     break;
1914     case(FaceElements):     case(FaceElements):
1915     Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);     Dudley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);
1916     break;     break;
1917     case(ReducedFaceElements):     case(ReducedFaceElements):
1918     Finley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);     Dudley_ElementFile_setTags(mesh->FaceElements,newTag,&tmp);
1919     break;     break;
1920     case(Points):     case(Points):
1921     Finley_ElementFile_setTags(mesh->Points,newTag,&tmp);     Dudley_ElementFile_setTags(mesh->Points,newTag,&tmp);
    break;  
    case(ContactElementsZero):  
    Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);  
    break;  
    case(ReducedContactElementsZero):  
    Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);  
    break;  
    case(ContactElementsOne):  
    Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);  
    break;  
    case(ReducedContactElementsOne):  
    Finley_ElementFile_setTags(mesh->ContactElements,newTag,&tmp);  
1922     break;     break;
1923     default:     default:
1924        stringstream temp;        stringstream temp;
1925        temp << "Error - Finley does not know anything about function space type " << functionSpaceType;        temp << "Error - Dudley does not know anything about function space type " << functionSpaceType;
1926        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
1927     }     }
1928     checkFinleyError();     checkDudleyError();
1929     return;     return;
1930  }  }
1931    
1932  void MeshAdapter::setTagMap(const std::string& name,  int tag)  void MeshAdapter::setTagMap(const string& name,  int tag)
1933  {  {
1934     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1935     Finley_Mesh_addTagMap(mesh, name.c_str(),tag);     Dudley_Mesh_addTagMap(mesh, name.c_str(),tag);
1936     checkPasoError();     checkPasoError();
1937     // throwStandardException("MeshAdapter::set TagMap is not implemented.");     // throwStandardException("MeshAdapter::set TagMap is not implemented.");
1938  }  }
1939    
1940  int MeshAdapter::getTag(const std::string& name) const  int MeshAdapter::getTag(const string& name) const
1941  {  {
1942     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1943     int tag=0;     int tag=0;
1944     tag=Finley_Mesh_getTag(mesh, name.c_str());     tag=Dudley_Mesh_getTag(mesh, name.c_str());
1945     checkPasoError();     checkPasoError();
1946     // throwStandardException("MeshAdapter::getTag is not implemented.");     // throwStandardException("MeshAdapter::getTag is not implemented.");
1947     return tag;     return tag;
1948  }  }
1949    
1950  bool MeshAdapter::isValidTagName(const std::string& name) const  bool MeshAdapter::isValidTagName(const string& name) const
1951  {  {
1952     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1953     return Finley_Mesh_isValidTagName(mesh,name.c_str());     return Dudley_Mesh_isValidTagName(mesh,name.c_str());
1954  }  }
1955    
1956  std::string MeshAdapter::showTagNames() const  string MeshAdapter::showTagNames() const
1957  {  {
1958     stringstream temp;     stringstream temp;
1959     Finley_Mesh* mesh=m_finleyMesh.get();     Dudley_Mesh* mesh=m_dudleyMesh.get();
1960     Finley_TagMap* tag_map=mesh->TagMap;     Dudley_TagMap* tag_map=mesh->TagMap;
1961     while (tag_map) {     while (tag_map) {
1962        temp << tag_map->name;        temp << tag_map->name;
1963        tag_map=tag_map->next;        tag_map=tag_map->next;
# Line 2247  std::string MeshAdapter::showTagNames() Line 1968  std::string MeshAdapter::showTagNames()
1968    
1969  int MeshAdapter::getNumberOfTagsInUse(int functionSpaceCode) const  int MeshAdapter::getNumberOfTagsInUse(int functionSpaceCode) const
1970  {  {
1971    Finley_Mesh* mesh=m_finleyMesh.get();    Dudley_Mesh* mesh=m_dudleyMesh.get();
1972    dim_t numTags=0;    dim_t numTags=0;
1973    switch(functionSpaceCode) {    switch(functionSpaceCode) {
1974     case(Nodes):     case(Nodes):
1975            numTags=mesh->Nodes->numTagsInUse;            numTags=mesh->Nodes->numTagsInUse;
1976            break;            break;
1977     case(ReducedNodes):     case(ReducedNodes):
1978            throw FinleyAdapterException("Error - ReducedNodes does not support tags");            throw DudleyAdapterException("Error - ReducedNodes does not support tags");
1979            break;            break;
1980     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1981            throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");            throw DudleyAdapterException("Error - DegreesOfFreedom does not support tags");
1982            break;            break;
1983     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1984            throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");            throw DudleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");
1985            break;            break;
1986     case(Elements):     case(Elements):
1987     case(ReducedElements):     case(ReducedElements):
# Line 2273  int MeshAdapter::getNumberOfTagsInUse(in Line 1994  int MeshAdapter::getNumberOfTagsInUse(in
1994     case(Points):     case(Points):
1995            numTags=mesh->Points->numTagsInUse;            numTags=mesh->Points->numTagsInUse;
1996            break;            break;
    case(ContactElementsZero):  
    case(ReducedContactElementsZero):  
    case(ContactElementsOne):  
    case(ReducedContactElementsOne):  
           numTags=mesh->ContactElements->numTagsInUse;  
           break;  
1997     default:     default:
1998        stringstream temp;        stringstream temp;
1999        temp << "Error - Finley does not know anything about function space type " << functionSpaceCode;        temp << "Error - Dudley does not know anything about function space type " << functionSpaceCode;
2000        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
2001    }    }
2002    return numTags;    return numTags;
2003  }  }
2004    
2005  const int* MeshAdapter::borrowListOfTagsInUse(int functionSpaceCode) const  const int* MeshAdapter::borrowListOfTagsInUse(int functionSpaceCode) const
2006  {  {
2007    Finley_Mesh* mesh=m_finleyMesh.get();    Dudley_Mesh* mesh=m_dudleyMesh.get();
2008    index_t* tags=NULL;    index_t* tags=NULL;
2009    switch(functionSpaceCode) {    switch(functionSpaceCode) {
2010     case(Nodes):     case(Nodes):
2011            tags=mesh->Nodes->tagsInUse;            tags=mesh->Nodes->tagsInUse;
2012            break;            break;
2013     case(ReducedNodes):     case(ReducedNodes):
2014            throw FinleyAdapterException("Error - ReducedNodes does not support tags");            throw DudleyAdapterException("Error - ReducedNodes does not support tags");
2015            break;            break;
2016     case(DegreesOfFreedom):     case(DegreesOfFreedom):
2017            throw FinleyAdapterException("Error - DegreesOfFreedom does not support tags");            throw DudleyAdapterException("Error - DegreesOfFreedom does not support tags");
2018            break;            break;
2019     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
2020            throw FinleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");            throw DudleyAdapterException("Error - ReducedDegreesOfFreedom does not support tags");
2021            break;            break;
2022     case(Elements):     case(Elements):
2023     case(ReducedElements):     case(ReducedElements):
# Line 2315  const int* MeshAdapter::borrowListOfTags Line 2030  const int* MeshAdapter::borrowListOfTags
2030     case(Points):     case(Points):
2031            tags=mesh->Points->tagsInUse;            tags=mesh->Points->tagsInUse;
2032            break;            break;
    case(ContactElementsZero):  
    case(ReducedContactElementsZero):  
    case(ContactElementsOne):  
    case(ReducedContactElementsOne):  
           tags=mesh->ContactElements->tagsInUse;  
           break;  
2033     default:     default:
2034        stringstream temp;        stringstream temp;
2035        temp << "Error - Finley does not know anything about function space type " << functionSpaceCode;        temp << "Error - Dudley does not know anything about function space type " << functionSpaceCode;
2036        throw FinleyAdapterException(temp.str());        throw DudleyAdapterException(temp.str());
2037    }    }
2038    return tags;    return tags;
2039  }  }
# Line 2339  bool MeshAdapter::canTag(int functionSpa Line 2048  bool MeshAdapter::canTag(int functionSpa
2048     case(FaceElements):     case(FaceElements):
2049     case(ReducedFaceElements):     case(ReducedFaceElements):
2050     case(Points):     case(Points):
    case(ContactElementsZero):  
    case(ReducedContactElementsZero):  
    case(ContactElementsOne):  
    case(ReducedContactElementsOne):  
2051            return true;            return true;
2052     case(ReducedNodes):     case(ReducedNodes):
2053     case(DegreesOfFreedom):     case(DegreesOfFreedom):
# Line 2355  bool MeshAdapter::canTag(int functionSpa Line 2060  bool MeshAdapter::canTag(int functionSpa
2060    
2061  AbstractDomain::StatusType MeshAdapter::getStatus() const  AbstractDomain::StatusType MeshAdapter::getStatus() const
2062  {  {
2063    Finley_Mesh* mesh=m_finleyMesh.get();    Dudley_Mesh* mesh=m_dudleyMesh.get();
2064    return Finley_Mesh_getStatus(mesh);    return Dudley_Mesh_getStatus(mesh);
2065    }
2066    
2067    int MeshAdapter::getApproximationOrder(const int functionSpaceCode) const
2068    {
2069      
2070      Dudley_Mesh* mesh=m_dudleyMesh.get();
2071      int order =-1;
2072      switch(functionSpaceCode) {
2073       case(Nodes):
2074       case(DegreesOfFreedom):
2075              order=mesh->approximationOrder;
2076              break;
2077       case(ReducedNodes):
2078       case(ReducedDegreesOfFreedom):
2079              order=mesh->reducedApproximationOrder;
2080              break;
2081       case(Elements):
2082       case(FaceElements):
2083       case(Points):
2084              order=mesh->integrationOrder;
2085              break;
2086       case(ReducedElements):
2087       case(ReducedFaceElements):
2088              order=mesh->reducedIntegrationOrder;
2089              break;
2090       default:
2091          stringstream temp;
2092          temp << "Error - Dudley does not know anything about function space type " << functionSpaceCode;
2093          throw DudleyAdapterException(temp.str());
2094      }
2095      return order;
2096    }
2097    
2098    
2099    bool MeshAdapter::supportsContactElements() const
2100    {
2101        return false;
2102  }  }
2103    
2104    ReferenceElementSetWrapper::ReferenceElementSetWrapper(ElementTypeId id, index_t order, index_t reducedOrder)
2105    {
2106      m_refSet = Dudley_ReferenceElementSet_alloc(id, order, reducedOrder);
2107    }
2108    
2109    ReferenceElementSetWrapper::~ReferenceElementSetWrapper()
2110    {
2111      Dudley_ReferenceElementSet_dealloc(m_refSet);
2112    }
2113    
2114  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.2748  
changed lines
  Added in v.3152

  ViewVC Help
Powered by ViewVC 1.1.26