/[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

revision 1343 by ksteube, Wed Nov 14 02:48:02 2007 UTC revision 1455 by phornby, Thu Feb 28 17:19:44 2008 UTC
# Line 24  extern "C" { Line 24  extern "C" {
24  }  }
25  #include <vector>  #include <vector>
26    
27    #define IS_THERE_A_REASON_FOR_THIS_MAGIC_NAME_LENGTH  256
28    
29  using namespace std;  using namespace std;
30  using namespace escript;  using namespace escript;
31    
# Line 104  void MeshAdapter::Print_Mesh_Info(const Line 106  void MeshAdapter::Print_Mesh_Info(const
106  void MeshAdapter::dump(const std::string& fileName) const  void MeshAdapter::dump(const std::string& fileName) const
107  {  {
108  #ifdef USE_NETCDF  #ifdef USE_NETCDF
109     const NcDim* ncdims[25]; /* ksteube how big should ncdims be? */     const NcDim* ncdims[12];
110     NcVar *ids, *data;     NcVar *ids, *data;
111     int *int_ptr;     int *int_ptr;
112     Finley_Mesh *mesh = m_finleyMesh.get();     Finley_Mesh *mesh = m_finleyMesh.get();
113       Finley_TagMap* tag_map;
114       int num_Tags = 0;
115     int mpi_size             = mesh->MPIInfo->size;     int mpi_size             = mesh->MPIInfo->size;
116     int mpi_rank             = mesh->MPIInfo->rank;     int mpi_rank             = mesh->MPIInfo->rank;
117     int numDim               = mesh->Nodes->numDim;     int numDim               = mesh->Nodes->numDim;
# Line 121  void MeshAdapter::dump(const std::string Line 125  void MeshAdapter::dump(const std::string
125     int num_ContactElements_numNodes = mesh->ContactElements->numNodes;     int num_ContactElements_numNodes = mesh->ContactElements->numNodes;
126     char *newFileName = Paso_MPI_appendRankToFileName(strdup(fileName.c_str()), mpi_size, mpi_rank);     char *newFileName = Paso_MPI_appendRankToFileName(strdup(fileName.c_str()), mpi_size, mpi_rank);
127    
128       /* Figure out how much storage is required for tags */
129       tag_map = mesh->TagMap;
130       if (tag_map) {
131         while (tag_map) {
132        num_Tags++;
133            tag_map=tag_map->next;
134         }
135       }
136    
137     // NetCDF error handler     // NetCDF error handler
138     NcError err(NcError::verbose_nonfatal);     NcError err(NcError::verbose_nonfatal);
139     // Create the file.     // Create the file.
# Line 157  void MeshAdapter::dump(const std::string Line 170  void MeshAdapter::dump(const std::string
170     if (num_ContactElements>0)     if (num_ContactElements>0)
171        if (! (ncdims[9] = dataFile.add_dim("dim_ContactElements_numNodes", num_ContactElements_numNodes)) )        if (! (ncdims[9] = dataFile.add_dim("dim_ContactElements_numNodes", num_ContactElements_numNodes)) )
172          throw DataException("Error - MeshAdapter::dump: appending dimension dim_ContactElements_numNodes to netCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending dimension dim_ContactElements_numNodes to netCDF file failed: " + *newFileName);
173       if (num_Tags>0)
174          if (! (ncdims[10] = dataFile.add_dim("dim_Tags", num_Tags)) )
175            throw DataException("Error - MeshAdapter::dump: appending dimension dim_Tags to netCDF file failed: " + *newFileName);
176    
177     // MPI size, MPI rank, Name, order, reduced_order     // Attributes: MPI size, MPI rank, Name, order, reduced_order
178     if (!dataFile.add_att("mpi_size", mpi_size) )     if (!dataFile.add_att("mpi_size", mpi_size) )
179          throw DataException("Error - MeshAdapter::dump: appending mpi_size to NetCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending mpi_size to NetCDF file failed: " + *newFileName);
180     if (!dataFile.add_att("mpi_rank", mpi_rank) )     if (!dataFile.add_att("mpi_rank", mpi_rank) )
181          throw DataException("Error - MeshAdapter::dump: appending mpi_rank to NetCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending mpi_rank to NetCDF file failed: " + *newFileName);
182     if (!dataFile.add_att("Name",mesh->Name) )     if (!dataFile.add_att("Name",mesh->Name) )
183          throw DataException("Error - MeshAdapter::dump: appending Name to NetCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending Name to NetCDF file failed: " + *newFileName);
184       if (!dataFile.add_att("numDim",numDim) )
185            throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);
186     if (!dataFile.add_att("order",mesh->order) )     if (!dataFile.add_att("order",mesh->order) )
187          throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending order to NetCDF file failed: " + *newFileName);
188     if (!dataFile.add_att("reduced_order",mesh->reduced_order) )     if (!dataFile.add_att("reduced_order",mesh->reduced_order) )
189          throw DataException("Error - MeshAdapter::dump: appending reduced_order to NetCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending reduced_order to NetCDF file failed: " + *newFileName);
190       if (!dataFile.add_att("numNodes",numNodes) )
191            throw DataException("Error - MeshAdapter::dump: appending numNodes to NetCDF file failed: " + *newFileName);
192     if (!dataFile.add_att("num_Elements",num_Elements) )     if (!dataFile.add_att("num_Elements",num_Elements) )
193          throw DataException("Error - MeshAdapter::dump: appending num_Elements to NetCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending num_Elements to NetCDF file failed: " + *newFileName);
194     if (!dataFile.add_att("num_FaceElements",num_FaceElements) )     if (!dataFile.add_att("num_FaceElements",num_FaceElements) )
# Line 177  void MeshAdapter::dump(const std::string Line 197  void MeshAdapter::dump(const std::string
197          throw DataException("Error - MeshAdapter::dump: appending num_ContactElements to NetCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending num_ContactElements to NetCDF file failed: " + *newFileName);
198     if (!dataFile.add_att("num_Points",num_Points) )     if (!dataFile.add_att("num_Points",num_Points) )
199          throw DataException("Error - MeshAdapter::dump: appending num_Points to NetCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending num_Points to NetCDF file failed: " + *newFileName);
200       if (!dataFile.add_att("num_Elements_numNodes",num_Elements_numNodes) )
201            throw DataException("Error - MeshAdapter::dump: appending num_Elements_numNodes to NetCDF file failed: " + *newFileName);
202       if (!dataFile.add_att("num_FaceElements_numNodes",num_FaceElements_numNodes) )
203            throw DataException("Error - MeshAdapter::dump: appending num_FaceElements_numNodes to NetCDF file failed: " + *newFileName);
204       if (!dataFile.add_att("num_ContactElements_numNodes",num_ContactElements_numNodes) )
205            throw DataException("Error - MeshAdapter::dump: appending num_ContactElements_numNodes to NetCDF file failed: " + *newFileName);
206       if (!dataFile.add_att("Elements_TypeId", mesh->Elements->ReferenceElement->Type->TypeId) )
207          throw DataException("Error - MeshAdapter::dump: appending Elements_TypeId to NetCDF file failed: " + *newFileName);
208       if (!dataFile.add_att("FaceElements_TypeId", mesh->FaceElements->ReferenceElement->Type->TypeId) )
209          throw DataException("Error - MeshAdapter::dump: appending FaceElements_TypeId to NetCDF file failed: " + *newFileName);
210       if (!dataFile.add_att("ContactElements_TypeId", mesh->ContactElements->ReferenceElement->Type->TypeId) )
211          throw DataException("Error - MeshAdapter::dump: appending ContactElements_TypeId to NetCDF file failed: " + *newFileName);
212       if (!dataFile.add_att("Points_TypeId", mesh->Points->ReferenceElement->Type->TypeId) )
213          throw DataException("Error - MeshAdapter::dump: appending Points_TypeId to NetCDF file failed: " + *newFileName);
214       if (!dataFile.add_att("num_Tags", num_Tags) )
215          throw DataException("Error - MeshAdapter::dump: appending num_Tags to NetCDF file failed: " + *newFileName);
216    
217     // // // // // Nodes // // // // //     // // // // // Nodes // // // // //
218    
219       // Only write nodes if non-empty because NetCDF doesn't like empty arrays (it treats them as NC_UNLIMITED)
220       if (numNodes>0) {
221    
222     // Nodes Id     // Nodes Id
223     if (! ( ids = dataFile.add_var("Nodes_Id", ncInt, ncdims[0])) )     if (! ( ids = dataFile.add_var("Nodes_Id", ncInt, ncdims[0])) )
224          throw DataException("Error - MeshAdapter::dump: appending Nodes_Id to netCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending Nodes_Id to netCDF file failed: " + *newFileName);
# Line 235  void MeshAdapter::dump(const std::string Line 274  void MeshAdapter::dump(const std::string
274     if (! (ids->put(int_ptr, mpi_size+1)) )     if (! (ids->put(int_ptr, mpi_size+1)) )
275          throw DataException("Error - MeshAdapter::dump: copy Nodes_DofDistribution to netCDF buffer failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: copy Nodes_DofDistribution to netCDF buffer failed: " + *newFileName);
276    
277       }
278    
279     // // // // // Elements // // // // //     // // // // // Elements // // // // //
280    
    // Only write elements if non-empty because NetCDF doesn't like empty arrays (it treats them as NC_UNLIMITED)  
281     if (num_Elements>0) {     if (num_Elements>0) {
282    
283       // Temp storage to gather node IDs       // Temp storage to gather node IDs
284       int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);       int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);
285    
      // Elements ReferenceElement->ElementTypeId  
      if (!dataFile.add_att("Elements_TypeId", mesh->Elements->ReferenceElement->Type->TypeId) )  
         throw DataException("Error - MeshAdapter::dump: appending Elements_TypeId to NetCDF file failed: " + *newFileName);  
   
286       // Elements_Id       // Elements_Id
287       if (! ( ids = dataFile.add_var("Elements_Id", ncInt, ncdims[3])) )       if (! ( ids = dataFile.add_var("Elements_Id", ncInt, ncdims[3])) )
288          throw DataException("Error - MeshAdapter::dump: appending Elements_Id to netCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending Elements_Id to netCDF file failed: " + *newFileName);
# Line 284  void MeshAdapter::dump(const std::string Line 320  void MeshAdapter::dump(const std::string
320       if (! (ids->put(&(Elements_Nodes[0]), num_Elements, num_Elements_numNodes)) )       if (! (ids->put(&(Elements_Nodes[0]), num_Elements, num_Elements_numNodes)) )
321          throw DataException("Error - MeshAdapter::dump: copy Elements_Nodes to netCDF buffer failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: copy Elements_Nodes to netCDF buffer failed: " + *newFileName);
322    
323         TMPMEMFREE(Elements_Nodes);
324    
325     }     }
326    
327     // // // // // Face_Elements // // // // //     // // // // // Face_Elements // // // // //
# Line 293  void MeshAdapter::dump(const std::string Line 331  void MeshAdapter::dump(const std::string
331       // Temp storage to gather node IDs       // Temp storage to gather node IDs
332       int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);       int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);
333    
      // FaceElements ReferenceElement->ElementTypeId  
      if (!dataFile.add_att("FaceElements_TypeId", mesh->FaceElements->ReferenceElement->Type->TypeId) )  
         throw DataException("Error - MeshAdapter::dump: appending FaceElements_TypeId to NetCDF file failed: " + *newFileName);  
   
334       // FaceElements_Id       // FaceElements_Id
335       if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )       if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )
336          throw DataException("Error - MeshAdapter::dump: appending FaceElements_Id to netCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending FaceElements_Id to netCDF file failed: " + *newFileName);
# Line 334  void MeshAdapter::dump(const std::string Line 368  void MeshAdapter::dump(const std::string
368       if (! (ids->put(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )       if (! (ids->put(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )
369          throw DataException("Error - MeshAdapter::dump: copy FaceElements_Nodes to netCDF buffer failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: copy FaceElements_Nodes to netCDF buffer failed: " + *newFileName);
370    
371         TMPMEMFREE(FaceElements_Nodes);
372    
373     }     }
374    
375     // // // // // Contact_Elements // // // // //     // // // // // Contact_Elements // // // // //
# Line 343  void MeshAdapter::dump(const std::string Line 379  void MeshAdapter::dump(const std::string
379       // Temp storage to gather node IDs       // Temp storage to gather node IDs
380       int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);       int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);
381    
      // ContactElements ReferenceElement->ElementTypeId  
      if (!dataFile.add_att("ContactElements_TypeId", mesh->ContactElements->ReferenceElement->Type->TypeId) )  
         throw DataException("Error - MeshAdapter::dump: appending ContactElements_TypeId to NetCDF file failed: " + *newFileName);  
   
382       // ContactElements_Id       // ContactElements_Id
383       if (! ( ids = dataFile.add_var("ContactElements_Id", ncInt, ncdims[5])) )       if (! ( ids = dataFile.add_var("ContactElements_Id", ncInt, ncdims[5])) )
384          throw DataException("Error - MeshAdapter::dump: appending ContactElements_Id to netCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending ContactElements_Id to netCDF file failed: " + *newFileName);
# Line 384  void MeshAdapter::dump(const std::string Line 416  void MeshAdapter::dump(const std::string
416       if (! (ids->put(&(ContactElements_Nodes[0]), num_ContactElements, num_ContactElements_numNodes)) )       if (! (ids->put(&(ContactElements_Nodes[0]), num_ContactElements, num_ContactElements_numNodes)) )
417          throw DataException("Error - MeshAdapter::dump: copy ContactElements_Nodes to netCDF buffer failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: copy ContactElements_Nodes to netCDF buffer failed: " + *newFileName);
418    
419         TMPMEMFREE(ContactElements_Nodes);
420    
421     }     }
422    
423     // // // // // Points // // // // //     // // // // // Points // // // // //
# Line 395  void MeshAdapter::dump(const std::string Line 429  void MeshAdapter::dump(const std::string
429       // Temp storage to gather node IDs       // Temp storage to gather node IDs
430       int *Points_Nodes = TMPMEMALLOC(num_Points,int);       int *Points_Nodes = TMPMEMALLOC(num_Points,int);
431    
      // Points ReferenceElement->ElementTypeId  
      if (!dataFile.add_att("Points_TypeId", mesh->Points->ReferenceElement->Type->TypeId) )  
         throw DataException("Error - MeshAdapter::dump: appending Points_TypeId to NetCDF file failed: " + *newFileName);  
   
432       // Points_Id       // Points_Id
433       if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )       if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )
434          throw DataException("Error - MeshAdapter::dump: appending Points_Id to netCDF file failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: appending Points_Id to netCDF file failed: " + *newFileName);
# Line 436  void MeshAdapter::dump(const std::string Line 466  void MeshAdapter::dump(const std::string
466       if (! (ids->put(&(Points_Nodes[0]), num_Points)) )       if (! (ids->put(&(Points_Nodes[0]), num_Points)) )
467          throw DataException("Error - MeshAdapter::dump: copy Points_Nodes to netCDF buffer failed: " + *newFileName);          throw DataException("Error - MeshAdapter::dump: copy Points_Nodes to netCDF buffer failed: " + *newFileName);
468    
469         TMPMEMFREE(Points_Nodes);
470    
471     }     }
472    
473     // // // // // TagMap // // // // //     // // // // // TagMap // // // // //
474    
475       fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump does not save the TagMap yet\n\n\n");     if (num_Tags>0) {
476    
477         // Temp storage to gather node IDs
478         int *Tags_keys = TMPMEMALLOC(num_Tags, int);
479         char name_temp[4096];
480    
481         /* Copy tag data into temp arrays */
482         tag_map = mesh->TagMap;
483         if (tag_map) {
484           int i = 0;
485           while (tag_map) {
486        Tags_keys[i++] = tag_map->tag_key;
487            tag_map=tag_map->next;
488           }
489         }
490    
491         // Tags_keys
492         if (! ( ids = dataFile.add_var("Tags_keys", ncInt, ncdims[10])) )
493            throw DataException("Error - MeshAdapter::dump: appending Tags_keys to netCDF file failed: " + *newFileName);
494         int_ptr = &Tags_keys[0];
495         if (! (ids->put(int_ptr, num_Tags)) )
496            throw DataException("Error - MeshAdapter::dump: copy Tags_keys to netCDF buffer failed: " + *newFileName);
497    
498         // Tags_names_*
499         // This is an array of strings, it should be stored as an array but instead I have hacked in one attribute per string
500         // because the NetCDF manual doesn't tell how to do an array of strings
501         tag_map = mesh->TagMap;
502         if (tag_map) {
503           int i = 0;
504           while (tag_map) {
505             sprintf(name_temp, "Tags_name_%d", i);
506             if (!dataFile.add_att(name_temp, tag_map->name) )
507               throw DataException("Error - MeshAdapter::dump: appending Tags_names_ to NetCDF file failed: " + *newFileName);
508             tag_map=tag_map->next;
509         i++;
510           }
511         }
512    
513         TMPMEMFREE(Tags_keys);
514    
515       }
516    
517    
518     // NetCDF file is closed by destructor of NcFile object     // NetCDF file is closed by destructor of NcFile object
519  #else  #else
# Line 738  void MeshAdapter::addPDEToRHS( escript:: Line 811  void MeshAdapter::addPDEToRHS( escript::
811     Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, 0, &_rhs , 0, 0, 0, 0, 0, &_y_contact );     Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, 0, &_rhs , 0, 0, 0, 0, 0, &_y_contact );
812     checkFinleyError();     checkFinleyError();
813  }  }
814    //
815    // adds PDE of second order into a transport problem
816    //
817    void MeshAdapter::addPDEToTransportProblem(
818                         TransportProblemAdapter& tp, escript::Data& source, const escript::Data& M,
819                         const escript::Data& A, const escript::Data& B, const escript::Data& C,
820                         const  escript::Data& D,const  escript::Data& X,const  escript::Data& Y,
821                         const escript::Data& d, const escript::Data& y,
822                         const escript::Data& d_contact,const escript::Data& y_contact) const
823    {
824       DataArrayView::ShapeType shape;
825       source.expand();
826       escriptDataC _source=source.getDataC();
827       escriptDataC _M=M.getDataC();
828       escriptDataC _A=A.getDataC();
829       escriptDataC _B=B.getDataC();
830       escriptDataC _C=C.getDataC();
831       escriptDataC _D=D.getDataC();
832       escriptDataC _X=X.getDataC();
833       escriptDataC _Y=Y.getDataC();
834       escriptDataC _d=d.getDataC();
835       escriptDataC _y=y.getDataC();
836       escriptDataC _d_contact=d_contact.getDataC();
837       escriptDataC _y_contact=y_contact.getDataC();
838    
839       Finley_Mesh* mesh=m_finleyMesh.get();
840       Paso_FCTransportProblem* _tp = tp.getPaso_FCTransportProblem();
841      
842       Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,_tp->mass_matrix, &_source, 0, 0, 0, &_M, 0, 0 );
843       checkFinleyError();
844    
845       Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,_tp->transport_matrix, &_source, &_A, &_B, &_C, &_D, &_X, &_Y );
846       checkFinleyError();
847    
848       Finley_Assemble_PDE(mesh->Nodes,mesh->FaceElements, _tp->transport_matrix, &_source, 0, 0, 0, &_d, 0, &_y );
849       checkFinleyError();
850    
851       Finley_Assemble_PDE(mesh->Nodes,mesh->ContactElements, _tp->transport_matrix, &_source , 0, 0, 0, &_d_contact, 0, &_y_contact );
852       checkFinleyError();
853    }
854    
855  //  //
856  // interpolates data between different function spaces:  // interpolates data between different function spaces:
# Line 846  void MeshAdapter::interpolateOnDomain(es Line 959  void MeshAdapter::interpolateOnDomain(es
959             Finley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);             Finley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);
960          } else {          } else {
961             throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");             throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");
962         }          }
963         break;          break;
964       case(ReducedFaceElements):       case(ReducedFaceElements):
965          if (target.getFunctionSpace().getTypeCode()==FaceElements) {          if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
966             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
967          } else {          } else {
968             throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");             throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");
# Line 870  void MeshAdapter::interpolateOnDomain(es Line 983  void MeshAdapter::interpolateOnDomain(es
983             Finley_Assemble_AverageElementData(mesh->ContactElements,&_target,&_in);             Finley_Assemble_AverageElementData(mesh->ContactElements,&_target,&_in);
984          } else {          } else {
985             throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");             throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");
            break;  
986          }          }
987          break;          break;
988       case(ReducedContactElementsZero):       case(ReducedContactElementsZero):
# Line 879  void MeshAdapter::interpolateOnDomain(es Line 991  void MeshAdapter::interpolateOnDomain(es
991             Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);             Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);
992          } else {          } else {
993             throw FinleyAdapterException("Error - No interpolation with data on contact elements with reduced integration order possible.");             throw FinleyAdapterException("Error - No interpolation with data on contact elements with reduced integration order possible.");
            break;  
994          }          }
995          break;          break;
996       case(DegreesOfFreedom):             case(DegreesOfFreedom):      
# Line 1334  void MeshAdapter::setNewX(const escript: Line 1445  void MeshAdapter::setNewX(const escript:
1445  // saves a data array in openDX format:  // saves a data array in openDX format:
1446  void MeshAdapter::saveDX(const std::string& filename,const boost::python::dict& arg) const  void MeshAdapter::saveDX(const std::string& filename,const boost::python::dict& arg) const
1447  {  {
1448      int MAX_namelength=256;      unsigned int MAX_namelength=IS_THERE_A_REASON_FOR_THIS_MAGIC_NAME_LENGTH;
1449      const int num_data=boost::python::extract<int>(arg.attr("__len__")());      const int num_data=boost::python::extract<int>(arg.attr("__len__")());
1450    /* win32 refactor */    /* win32 refactor */
1451    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
# Line 1382  void MeshAdapter::saveDX(const std::stri Line 1493  void MeshAdapter::saveDX(const std::stri
1493  // saves a data array in openVTK format:  // saves a data array in openVTK format:
1494  void MeshAdapter::saveVTK(const std::string& filename,const boost::python::dict& arg) const  void MeshAdapter::saveVTK(const std::string& filename,const boost::python::dict& arg) const
1495  {  {
1496      int MAX_namelength=256;      unsigned int MAX_namelength=IS_THERE_A_REASON_FOR_THIS_MAGIC_NAME_LENGTH;
1497      const int num_data=boost::python::extract<int>(arg.attr("__len__")());      const int num_data=boost::python::extract<int>(arg.attr("__len__")());
1498    /* win32 refactor */    /* win32 refactor */
1499    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;    char* *names = (num_data>0) ? TMPMEMALLOC(num_data,char*) : (char**)NULL;
# Line 1478  SystemMatrixAdapter MeshAdapter::newSyst Line 1589  SystemMatrixAdapter MeshAdapter::newSyst
1589      Paso_SystemMatrixPattern_free(fsystemMatrixPattern);      Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
1590      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);
1591  }  }
1592    // creates a TransportProblemAdapter
1593    TransportProblemAdapter MeshAdapter::newTransportProblem(
1594                          const double theta,
1595                          const int blocksize,
1596                          const escript::FunctionSpace& functionspace,
1597                          const int type) const
1598    {
1599        int reduceOrder=0;
1600        // is the domain right?
1601        const MeshAdapter& domain=dynamic_cast<const MeshAdapter&>(functionspace.getDomain());
1602        if (domain!=*this)
1603              throw FinleyAdapterException("Error - domain of function space does not match the domain of transport problem generator.");
1604        // is the function space type right
1605        if (functionspace.getTypeCode()==DegreesOfFreedom) {
1606            reduceOrder=0;
1607        } else if (functionspace.getTypeCode()==ReducedDegreesOfFreedom) {
1608            reduceOrder=1;
1609        } else {
1610            throw FinleyAdapterException("Error - illegal function space type for system matrix rows.");
1611        }
1612        // generate matrix:
1613        
1614        Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceOrder,reduceOrder);
1615        checkFinleyError();
1616        Paso_FCTransportProblem* transportProblem;
1617        transportProblem=Paso_FCTransportProblem_alloc(theta,fsystemMatrixPattern,blocksize);
1618        checkPasoError();
1619        Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
1620        return TransportProblemAdapter(transportProblem,theta,blocksize,functionspace);
1621    }
1622    
1623  //  //
1624  // vtkObject MeshAdapter::createVtkObject() const  // vtkObject MeshAdapter::createVtkObject() const
# Line 1712  escript::Data MeshAdapter::getSize() con Line 1853  escript::Data MeshAdapter::getSize() con
1853    
1854  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const
1855  {  {
1856    int *out=0,i;    int *out = NULL;
1857    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
1858    switch (functionSpaceType) {    switch (functionSpaceType) {
1859      case(Nodes):      case(Nodes):

Legend:
Removed from v.1343  
changed lines
  Added in v.1455

  ViewVC Help
Powered by ViewVC 1.1.26