/[escript]/trunk/finley/src/CPPAdapter/MeshAdapter.cpp
ViewVC logotype

Diff of /trunk/finley/src/CPPAdapter/MeshAdapter.cpp

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

revision 1748 by ksteube, Wed Sep 3 06:10:39 2008 UTC revision 2100 by gross, Wed Nov 26 08:13:00 2008 UTC
# Line 1  Line 1 
1    
 /* $Id$ */  
   
2  /*******************************************************  /*******************************************************
3   *  *
4   *           Copyright 2003-2007 by ACceSS MNRF  * Copyright (c) 2003-2008 by University of Queensland
5   *       Copyright 2007 by University of Queensland  * Earth Systems Science Computational Center (ESSCC)
6   *  * http://www.uq.edu.au/esscc
7   *                http://esscc.uq.edu.au  *
8   *        Primary Business: Queensland, Australia  * Primary Business: Queensland, Australia
9   *  Licensed under the Open Software License version 3.0  * Licensed under the Open Software License version 3.0
10   *     http://www.opensource.org/licenses/osl-3.0.php  * http://www.opensource.org/licenses/osl-3.0.php
11   *  *
12   *******************************************************/  *******************************************************/
13    
14    
15  #include "MeshAdapter.h"  #include "MeshAdapter.h"
16  #include "escript/Data.h"  #include "escript/Data.h"
# Line 19  Line 18 
18  #ifdef USE_NETCDF  #ifdef USE_NETCDF
19  #include <netcdfcpp.h>  #include <netcdfcpp.h>
20  #endif  #endif
21    #ifdef PASO_MPI
22    #include <mpi.h>
23    #include "paso/Paso_MPI.h"
24    #endif
25  extern "C" {  extern "C" {
26  #include "escript/blocktimer.h"  #include "esysUtils/blocktimer.h"
27  }  }
28  #include <vector>  #include <vector>
29    
# Line 83  int MeshAdapter::getMPIRank() const Line 86  int MeshAdapter::getMPIRank() const
86  {  {
87     return m_finleyMesh.get()->MPIInfo->rank;     return m_finleyMesh.get()->MPIInfo->rank;
88  }  }
89    void MeshAdapter::MPIBarrier() const
90    {
91    #ifdef PASO_MPI
92       MPI_Barrier(m_finleyMesh.get()->MPIInfo->comm);
93    #endif
94       return;
95    }
96    bool MeshAdapter::onMasterProcessor() const
97    {
98       return m_finleyMesh.get()->MPIInfo->rank == 0;
99    }
100    
101    
102  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {
# Line 106  void MeshAdapter::Print_Mesh_Info(const Line 120  void MeshAdapter::Print_Mesh_Info(const
120  void MeshAdapter::dump(const std::string& fileName) const  void MeshAdapter::dump(const std::string& fileName) const
121  {  {
122  #ifdef USE_NETCDF  #ifdef USE_NETCDF
123     const NcDim* ncdims[12];     const NcDim* ncdims[12] = {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
124     NcVar *ids;     NcVar *ids;
125     int *int_ptr;     int *int_ptr;
126     Finley_Mesh *mesh = m_finleyMesh.get();     Finley_Mesh *mesh = m_finleyMesh.get();
# Line 123  void MeshAdapter::dump(const std::string Line 137  void MeshAdapter::dump(const std::string
137     int num_Elements_numNodes        = mesh->Elements->numNodes;     int num_Elements_numNodes        = mesh->Elements->numNodes;
138     int num_FaceElements_numNodes    = mesh->FaceElements->numNodes;     int num_FaceElements_numNodes    = mesh->FaceElements->numNodes;
139     int num_ContactElements_numNodes = mesh->ContactElements->numNodes;     int num_ContactElements_numNodes = mesh->ContactElements->numNodes;
140    #ifdef PASO_MPI
141       MPI_Status status;
142    #endif
143    
144    /* Incoming token indicates it's my turn to write */
145    #ifdef PASO_MPI
146       if (mpi_rank>0) MPI_Recv(&num_Tags, 0, MPI_INT, mpi_rank-1, 81800, mesh->MPIInfo->comm, &status);
147    #endif
148    
149     char *newFileName = Paso_MPI_appendRankToFileName(fileName.c_str(),     char *newFileName = Paso_MPI_appendRankToFileName(fileName.c_str(),
150                                                       mpi_size, mpi_rank);                                                       mpi_size, mpi_rank);
151    
152     /* Figure out how much storage is required for tags */     /* Figure out how much storage is required for tags */
153     tag_map = mesh->TagMap;     tag_map = mesh->TagMap;
154       num_Tags = 0;
155     if (tag_map) {     if (tag_map) {
156        while (tag_map) {        while (tag_map) {
157           num_Tags++;           num_Tags++;
# Line 276  void MeshAdapter::dump(const std::string Line 299  void MeshAdapter::dump(const std::string
299        if (! (ids->put(int_ptr, mpi_size+1)) )        if (! (ids->put(int_ptr, mpi_size+1)) )
300           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);
301    
302          // Nodes nodeDistribution
303          if (! ( ids = dataFile.add_var("Nodes_NodeDistribution", ncInt, ncdims[2])) )
304             throw DataException("Error - MeshAdapter::dump: appending Nodes_NodeDistribution to netCDF file failed: " + *newFileName);
305          int_ptr = &mesh->Nodes->nodesDistribution->first_component[0];
306          if (! (ids->put(int_ptr, mpi_size+1)) )
307             throw DataException("Error - MeshAdapter::dump: copy Nodes_NodeDistribution to netCDF buffer failed: " + *newFileName);
308    
309     }     }
310    
311     // // // // // Elements // // // // //     // // // // // Elements // // // // //
312    
313     if (num_Elements>0) {     if (num_Elements>0) {
314    
       // Temp storage to gather node IDs  
       int *Elements_Nodes = TMPMEMALLOC(num_Elements*num_Elements_numNodes,int);  
   
315        // Elements_Id        // Elements_Id
316        if (! ( ids = dataFile.add_var("Elements_Id", ncInt, ncdims[3])) )        if (! ( ids = dataFile.add_var("Elements_Id", ncInt, ncdims[3])) )
317           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 314  void MeshAdapter::dump(const std::string Line 341  void MeshAdapter::dump(const std::string
341           throw DataException("Error - MeshAdapter::dump: copy Elements_Color to netCDF buffer failed: " + *newFileName);           throw DataException("Error - MeshAdapter::dump: copy Elements_Color to netCDF buffer failed: " + *newFileName);
342    
343        // Elements_Nodes        // Elements_Nodes
       for (int i=0; i<num_Elements; i++)  
          for (int j=0; j<num_Elements_numNodes; j++)  
             Elements_Nodes[INDEX2(j,i,num_Elements_numNodes)] = mesh->Nodes->Id[mesh->Elements->Nodes[INDEX2(j,i,num_Elements_numNodes)]];  
344        if (! ( ids = dataFile.add_var("Elements_Nodes", ncInt, ncdims[3], ncdims[7]) ) )        if (! ( ids = dataFile.add_var("Elements_Nodes", ncInt, ncdims[3], ncdims[7]) ) )
345           throw DataException("Error - MeshAdapter::dump: appending Elements_Nodes to netCDF file failed: " + *newFileName);           throw DataException("Error - MeshAdapter::dump: appending Elements_Nodes to netCDF file failed: " + *newFileName);
346        if (! (ids->put(&(Elements_Nodes[0]), num_Elements, num_Elements_numNodes)) )        if (! (ids->put(&(mesh->Elements->Nodes[0]), num_Elements, num_Elements_numNodes)) )
347           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);
348    
       TMPMEMFREE(Elements_Nodes);  
   
349     }     }
350    
351     // // // // // Face_Elements // // // // //     // // // // // Face_Elements // // // // //
352    
353     if (num_FaceElements>0) {     if (num_FaceElements>0) {
354    
       // Temp storage to gather node IDs  
       int *FaceElements_Nodes = TMPMEMALLOC(num_FaceElements*num_FaceElements_numNodes,int);  
   
355        // FaceElements_Id        // FaceElements_Id
356        if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )        if (! ( ids = dataFile.add_var("FaceElements_Id", ncInt, ncdims[4])) )
357           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 362  void MeshAdapter::dump(const std::string Line 381  void MeshAdapter::dump(const std::string
381           throw DataException("Error - MeshAdapter::dump: copy FaceElements_Color to netCDF buffer failed: " + *newFileName);           throw DataException("Error - MeshAdapter::dump: copy FaceElements_Color to netCDF buffer failed: " + *newFileName);
382    
383        // FaceElements_Nodes        // FaceElements_Nodes
       for (int i=0; i<num_FaceElements; i++)  
          for (int j=0; j<num_FaceElements_numNodes; j++)  
             FaceElements_Nodes[INDEX2(j,i,num_FaceElements_numNodes)] = mesh->Nodes->Id[mesh->FaceElements->Nodes[INDEX2(j,i,num_FaceElements_numNodes)]];  
384        if (! ( ids = dataFile.add_var("FaceElements_Nodes", ncInt, ncdims[4], ncdims[8]) ) )        if (! ( ids = dataFile.add_var("FaceElements_Nodes", ncInt, ncdims[4], ncdims[8]) ) )
385           throw DataException("Error - MeshAdapter::dump: appending FaceElements_Nodes to netCDF file failed: " + *newFileName);           throw DataException("Error - MeshAdapter::dump: appending FaceElements_Nodes to netCDF file failed: " + *newFileName);
386        if (! (ids->put(&(FaceElements_Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )        if (! (ids->put(&(mesh->FaceElements->Nodes[0]), num_FaceElements, num_FaceElements_numNodes)) )
387           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);
388    
       TMPMEMFREE(FaceElements_Nodes);  
   
389     }     }
390    
391     // // // // // Contact_Elements // // // // //     // // // // // Contact_Elements // // // // //
392    
393     if (num_ContactElements>0) {     if (num_ContactElements>0) {
394    
       // Temp storage to gather node IDs  
       int *ContactElements_Nodes = TMPMEMALLOC(num_ContactElements*num_ContactElements_numNodes,int);  
   
395        // ContactElements_Id        // ContactElements_Id
396        if (! ( ids = dataFile.add_var("ContactElements_Id", ncInt, ncdims[5])) )        if (! ( ids = dataFile.add_var("ContactElements_Id", ncInt, ncdims[5])) )
397           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 410  void MeshAdapter::dump(const std::string Line 421  void MeshAdapter::dump(const std::string
421           throw DataException("Error - MeshAdapter::dump: copy ContactElements_Color to netCDF buffer failed: " + *newFileName);           throw DataException("Error - MeshAdapter::dump: copy ContactElements_Color to netCDF buffer failed: " + *newFileName);
422    
423        // ContactElements_Nodes        // ContactElements_Nodes
       for (int i=0; i<num_ContactElements; i++)  
          for (int j=0; j<num_ContactElements_numNodes; j++)  
             ContactElements_Nodes[INDEX2(j,i,num_ContactElements_numNodes)] = mesh->Nodes->Id[mesh->ContactElements->Nodes[INDEX2(j,i,num_ContactElements_numNodes)]];  
424        if (! ( ids = dataFile.add_var("ContactElements_Nodes", ncInt, ncdims[5], ncdims[9]) ) )        if (! ( ids = dataFile.add_var("ContactElements_Nodes", ncInt, ncdims[5], ncdims[9]) ) )
425           throw DataException("Error - MeshAdapter::dump: appending ContactElements_Nodes to netCDF file failed: " + *newFileName);           throw DataException("Error - MeshAdapter::dump: appending ContactElements_Nodes to netCDF file failed: " + *newFileName);
426        if (! (ids->put(&(ContactElements_Nodes[0]), num_ContactElements, num_ContactElements_numNodes)) )        if (! (ids->put(&(mesh->ContactElements->Nodes[0]), num_ContactElements, num_ContactElements_numNodes)) )
427           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);
428    
       TMPMEMFREE(ContactElements_Nodes);  
   
429     }     }
430    
431     // // // // // Points // // // // //     // // // // // Points // // // // //
# Line 428  void MeshAdapter::dump(const std::string Line 434  void MeshAdapter::dump(const std::string
434    
435        fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump has not been tested with Point elements\n\n\n");        fprintf(stderr, "\n\n\nWARNING: MeshAdapter::dump has not been tested with Point elements\n\n\n");
436    
       // Temp storage to gather node IDs  
       int *Points_Nodes = TMPMEMALLOC(num_Points,int);  
   
437        // Points_Id        // Points_Id
438        if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )        if (! ( ids = dataFile.add_var("Points_Id", ncInt, ncdims[6])) )
439           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 461  void MeshAdapter::dump(const std::string Line 464  void MeshAdapter::dump(const std::string
464    
465        // Points_Nodes        // Points_Nodes
466        // mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]]        // mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]]
       for (int i=0; i<num_Points; i++)  
          Points_Nodes[i] = mesh->Nodes->Id[mesh->Points->Nodes[INDEX2(0,i,1)]];  
467        if (! ( ids = dataFile.add_var("Points_Nodes", ncInt, ncdims[6]) ) )        if (! ( ids = dataFile.add_var("Points_Nodes", ncInt, ncdims[6]) ) )
468           throw DataException("Error - MeshAdapter::dump: appending Points_Nodes to netCDF file failed: " + *newFileName);           throw DataException("Error - MeshAdapter::dump: appending Points_Nodes to netCDF file failed: " + *newFileName);
469        if (! (ids->put(&(Points_Nodes[0]), num_Points)) )        if (! (ids->put(&(mesh->Points->Nodes[0]), num_Points)) )
470           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);
471    
       TMPMEMFREE(Points_Nodes);  
   
472     }     }
473    
474     // // // // // TagMap // // // // //     // // // // // TagMap // // // // //
# Line 516  void MeshAdapter::dump(const std::string Line 515  void MeshAdapter::dump(const std::string
515    
516     }     }
517    
518    /* Send token to next MPI process so he can take his turn */
519    #ifdef PASO_MPI
520       if (mpi_rank<mpi_size-1) MPI_Send(&num_Tags, 0, MPI_INT, mpi_rank+1, 81800, mesh->MPIInfo->comm);
521    #endif
522    
523     // NetCDF file is closed by destructor of NcFile object     // NetCDF file is closed by destructor of NcFile object
524    
525  #else  #else
526     Finley_setError(IO_ERROR, "MeshAdapter::dump: not configured with NetCDF. Please contact your installation manager.");     Finley_setError(IO_ERROR, "MeshAdapter::dump: not configured with NetCDF. Please contact your installation manager.");
527  #endif  /* USE_NETCDF */  #endif  /* USE_NETCDF */
# Line 642  int MeshAdapter::getDiracDeltaFunctionCo Line 646  int MeshAdapter::getDiracDeltaFunctionCo
646  //  //
647  int MeshAdapter::getDim() const  int MeshAdapter::getDim() const
648  {  {
649     int numDim=Finley_Mesh_getDim(m_finleyMesh.get());     Finley_Mesh* mesh=m_finleyMesh.get();
650       int numDim=Finley_Mesh_getDim(mesh);
651     checkFinleyError();     checkFinleyError();
652     return numDim;     return numDim;
653  }  }
654    
655  //  //
656    // Return the number of data points summed across all MPI processes
657    //
658    int MeshAdapter::getNumDataPointsGlobal() const
659    {
660       return Finley_NodeFile_getGlobalNumNodes(m_finleyMesh.get()->Nodes);
661    }
662    
663    //
664  // return the number of data points per sample and the number of samples  // return the number of data points per sample and the number of samples
665  // needed to represent data on a parts of the mesh.  // needed to represent data on a parts of the mesh.
666  //  //
# Line 823  void MeshAdapter::addPDEToTransportProbl Line 836  void MeshAdapter::addPDEToTransportProbl
836                                             const escript::Data& d, const escript::Data& y,                                             const escript::Data& d, const escript::Data& y,
837                                             const escript::Data& d_contact,const escript::Data& y_contact) const                                             const escript::Data& d_contact,const escript::Data& y_contact) const
838  {  {
839     DataArrayView::ShapeType shape;     DataTypes::ShapeType shape;
840     source.expand();     source.expand();
841     escriptDataC _source=source.getDataC();     escriptDataC _source=source.getDataC();
842     escriptDataC _M=M.getDataC();     escriptDataC _M=M.getDataC();
# Line 859  void MeshAdapter::addPDEToTransportProbl Line 872  void MeshAdapter::addPDEToTransportProbl
872  //  //
873  void MeshAdapter::interpolateOnDomain(escript::Data& target,const escript::Data& in) const  void MeshAdapter::interpolateOnDomain(escript::Data& target,const escript::Data& in) const
874  {  {
875     const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(in.getFunctionSpace().getDomain());     const MeshAdapter& inDomain=dynamic_cast<const MeshAdapter&>(*(in.getFunctionSpace().getDomain()));
876     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(*(target.getFunctionSpace().getDomain()));
877     if (inDomain!=*this)       if (inDomain!=*this)  
878        throw FinleyAdapterException("Error - Illegal domain of interpolant.");        throw FinleyAdapterException("Error - Illegal domain of interpolant.");
879     if (targetDomain!=*this)     if (targetDomain!=*this)
# Line 1144  void MeshAdapter::interpolateOnDomain(es Line 1157  void MeshAdapter::interpolateOnDomain(es
1157  //  //
1158  void MeshAdapter::setToX(escript::Data& arg) const  void MeshAdapter::setToX(escript::Data& arg) const
1159  {  {
1160     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1161     if (argDomain!=*this)     if (argDomain!=*this)
1162        throw FinleyAdapterException("Error - Illegal domain of data point locations");        throw FinleyAdapterException("Error - Illegal domain of data point locations");
1163     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
# Line 1167  void MeshAdapter::setToX(escript::Data& Line 1180  void MeshAdapter::setToX(escript::Data&
1180  //  //
1181  void MeshAdapter::setToNormal(escript::Data& normal) const  void MeshAdapter::setToNormal(escript::Data& normal) const
1182  {  {
1183     const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());  /*   const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(normal.getFunctionSpace().getDomain());*/
1184       const MeshAdapter& normalDomain=dynamic_cast<const MeshAdapter&>(*(normal.getFunctionSpace().getDomain()));
1185     if (normalDomain!=*this)     if (normalDomain!=*this)
1186        throw FinleyAdapterException("Error - Illegal domain of normal locations");        throw FinleyAdapterException("Error - Illegal domain of normal locations");
1187     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
# Line 1222  void MeshAdapter::setToNormal(escript::D Line 1236  void MeshAdapter::setToNormal(escript::D
1236  //  //
1237  void MeshAdapter::interpolateACross(escript::Data& target,const escript::Data& source) const  void MeshAdapter::interpolateACross(escript::Data& target,const escript::Data& source) const
1238  {  {
1239     const MeshAdapter& targetDomain=dynamic_cast<const MeshAdapter&>(target.getFunctionSpace().getDomain());     const_Domain_ptr targetDomain_p=target.getFunctionSpace().getDomain();
1240     if (targetDomain!=*this)     const MeshAdapter* targetDomain=dynamic_cast<const MeshAdapter*>(targetDomain_p.get());
1241       if (targetDomain!=this)
1242        throw FinleyAdapterException("Error - Illegal domain of interpolation target");        throw FinleyAdapterException("Error - Illegal domain of interpolation target");
1243    
1244     throw FinleyAdapterException("Error - Finley does not allow interpolation across domains yet.");     throw FinleyAdapterException("Error - Finley does not allow interpolation across domains yet.");
# Line 1234  void MeshAdapter::interpolateACross(escr Line 1249  void MeshAdapter::interpolateACross(escr
1249  //  //
1250  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const  void MeshAdapter::setToIntegrals(std::vector<double>& integrals,const escript::Data& arg) const
1251  {  {
1252     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1253     if (argDomain!=*this)     if (argDomain!=*this)
1254        throw FinleyAdapterException("Error - Illegal domain of integration kernel");        throw FinleyAdapterException("Error - Illegal domain of integration kernel");
1255    
# Line 1245  void MeshAdapter::setToIntegrals(std::ve Line 1260  void MeshAdapter::setToIntegrals(std::ve
1260     escriptDataC _arg=arg.getDataC();     escriptDataC _arg=arg.getDataC();
1261     switch(arg.getFunctionSpace().getTypeCode()) {     switch(arg.getFunctionSpace().getTypeCode()) {
1262     case(Nodes):     case(Nodes):
1263     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1264     _temp=temp.getDataC();     _temp=temp.getDataC();
1265     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1266     break;     break;
1267     case(ReducedNodes):     case(ReducedNodes):
1268     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1269     _temp=temp.getDataC();     _temp=temp.getDataC();
1270     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1271     break;     break;
# Line 1282  void MeshAdapter::setToIntegrals(std::ve Line 1297  void MeshAdapter::setToIntegrals(std::ve
1297     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&_arg,&integrals[0]);
1298     break;     break;
1299     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1300     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1301     _temp=temp.getDataC();     _temp=temp.getDataC();
1302     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1303     break;     break;
1304     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1305     temp=escript::Data( arg, function(asAbstractContinuousDomain()) );     temp=escript::Data( arg, escript::function(asAbstractContinuousDomain()) );
1306     _temp=temp.getDataC();     _temp=temp.getDataC();
1307     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);     Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&_temp,&integrals[0]);
1308     break;     break;
# Line 1306  void MeshAdapter::setToIntegrals(std::ve Line 1321  void MeshAdapter::setToIntegrals(std::ve
1321  //  //
1322  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const  void MeshAdapter::setToGradient(escript::Data& grad,const escript::Data& arg) const
1323  {  {
1324     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(arg.getFunctionSpace().getDomain());     const MeshAdapter& argDomain=dynamic_cast<const MeshAdapter&>(*(arg.getFunctionSpace().getDomain()));
1325     if (argDomain!=*this)     if (argDomain!=*this)
1326        throw FinleyAdapterException("Error - Illegal domain of gradient argument");        throw FinleyAdapterException("Error - Illegal domain of gradient argument");
1327     const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(grad.getFunctionSpace().getDomain());     const MeshAdapter& gradDomain=dynamic_cast<const MeshAdapter&>(*(grad.getFunctionSpace().getDomain()));
1328     if (gradDomain!=*this)     if (gradDomain!=*this)
1329        throw FinleyAdapterException("Error - Illegal domain of gradient");        throw FinleyAdapterException("Error - Illegal domain of gradient");
1330    
# Line 1436  void MeshAdapter::setNewX(const escript: Line 1451  void MeshAdapter::setNewX(const escript:
1451  {  {
1452     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
1453     escriptDataC tmp;     escriptDataC tmp;
1454     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(new_x.getFunctionSpace().getDomain());     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));
1455     if (newDomain!=*this)     if (newDomain!=*this)
1456        throw FinleyAdapterException("Error - Illegal domain of new point locations");        throw FinleyAdapterException("Error - Illegal domain of new point locations");
1457     tmp = new_x.getDataC();     tmp = new_x.getDataC();
# Line 1463  void MeshAdapter::saveDX(const std::stri Line 1478  void MeshAdapter::saveDX(const std::stri
1478     for (int i=0;i<num_data;++i) {     for (int i=0;i<num_data;++i) {
1479        std::string n=boost::python::extract<std::string>(keys[i]);        std::string n=boost::python::extract<std::string>(keys[i]);
1480        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1481        if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)        if (dynamic_cast<const MeshAdapter&>(*(d.getFunctionSpace().getDomain())) !=*this)
1482           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1483        data[i]=d.getDataC();        data[i]=d.getDataC();
1484        ptr_data[i]= &(data[i]);        ptr_data[i]= &(data[i]);
# Line 1508  void MeshAdapter::saveVTK(const std::str Line 1523  void MeshAdapter::saveVTK(const std::str
1523     for (int i=0;i<num_data;++i) {     for (int i=0;i<num_data;++i) {
1524        std::string n=boost::python::extract<std::string>(keys[i]);        std::string n=boost::python::extract<std::string>(keys[i]);
1525        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);        escript::Data& d=boost::python::extract<escript::Data&>(arg[keys[i]]);
1526        if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)        if (dynamic_cast<const MeshAdapter&>(*(d.getFunctionSpace().getDomain())) !=*this)
1527           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");           throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
1528        data[i]=d.getDataC();        data[i]=d.getDataC();
1529        ptr_data[i]=&(data[i]);        ptr_data[i]=&(data[i]);
# Line 1546  SystemMatrixAdapter MeshAdapter::newSyst Line 1561  SystemMatrixAdapter MeshAdapter::newSyst
1561     int reduceRowOrder=0;     int reduceRowOrder=0;
1562     int reduceColOrder=0;     int reduceColOrder=0;
1563     // is the domain right?     // is the domain right?
1564     const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(row_functionspace.getDomain());     const MeshAdapter& row_domain=dynamic_cast<const MeshAdapter&>(*(row_functionspace.getDomain()));
1565     if (row_domain!=*this)     if (row_domain!=*this)
1566        throw FinleyAdapterException("Error - domain of row function space does not match the domain of matrix generator.");        throw FinleyAdapterException("Error - domain of row function space does not match the domain of matrix generator.");
1567     const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(column_functionspace.getDomain());     const MeshAdapter& col_domain=dynamic_cast<const MeshAdapter&>(*(column_functionspace.getDomain()));
1568     if (col_domain!=*this)     if (col_domain!=*this)
1569        throw FinleyAdapterException("Error - domain of columnn function space does not match the domain of matrix generator.");        throw FinleyAdapterException("Error - domain of columnn function space does not match the domain of matrix generator.");
1570     // is the function space type right     // is the function space type right
# Line 1594  TransportProblemAdapter MeshAdapter::new Line 1609  TransportProblemAdapter MeshAdapter::new
1609  {  {
1610     int reduceOrder=0;     int reduceOrder=0;
1611     // is the domain right?     // is the domain right?
1612     const MeshAdapter& domain=dynamic_cast<const MeshAdapter&>(functionspace.getDomain());     const MeshAdapter& domain=dynamic_cast<const MeshAdapter&>(*(functionspace.getDomain()));
1613     if (domain!=*this)     if (domain!=*this)
1614        throw FinleyAdapterException("Error - domain of function space does not match the domain of transport problem generator.");        throw FinleyAdapterException("Error - domain of function space does not match the domain of transport problem generator.");
1615     // is the function space type right     // is the function space type right
# Line 1825  bool MeshAdapter::operator!=(const Abstr Line 1840  bool MeshAdapter::operator!=(const Abstr
1840     return !(operator==(other));     return !(operator==(other));
1841  }  }
1842    
1843  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const
1844  {  {
1845     int out=Paso_SystemMatrix_getSystemMatrixTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0);     int out=Paso_SystemMatrix_getSystemMatrixTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(preconditioner), SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0);
1846       checkPasoError();
1847       return out;
1848    }
1849    int MeshAdapter::getTransportTypeId(const int solver, const int preconditioner, const int package, const bool symmetry) const
1850    {
1851       int out=Paso_FCTransportProblem_getTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(preconditioner), SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0);
1852     checkPasoError();     checkPasoError();
1853     return out;     return out;
1854  }  }
# Line 1844  escript::Data MeshAdapter::getNormal() c Line 1865  escript::Data MeshAdapter::getNormal() c
1865    
1866  escript::Data MeshAdapter::getSize() const  escript::Data MeshAdapter::getSize() const
1867  {  {
1868     return function(asAbstractContinuousDomain()).getSize();     return escript::function(asAbstractContinuousDomain()).getSize();
1869  }  }
1870    
1871  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const
# Line 2127  int* MeshAdapter::borrowListOfTagsInUse( Line 2148  int* MeshAdapter::borrowListOfTagsInUse(
2148  }  }
2149    
2150    
2151    bool MeshAdapter::canTag(int functionSpaceCode) const
2152    {
2153      switch(functionSpaceCode) {
2154       case(Nodes):
2155       case(Elements):
2156       case(ReducedElements):
2157       case(FaceElements):
2158       case(ReducedFaceElements):
2159       case(Points):
2160       case(ContactElementsZero):
2161       case(ReducedContactElementsZero):
2162       case(ContactElementsOne):
2163       case(ReducedContactElementsOne):
2164              return true;
2165       case(ReducedNodes):
2166       case(DegreesOfFreedom):
2167       case(ReducedDegreesOfFreedom):
2168          return false;
2169       default:
2170        return false;
2171      }
2172    }
2173    
2174    
2175  }  // end of namespace  }  // end of namespace

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

  ViewVC Help
Powered by ViewVC 1.1.26