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

trunk/esys2/finley/src/CPPAdapter/MeshAdapter.cpp revision 149 by jgs, Thu Sep 1 03:31:39 2005 UTC trunk/finley/src/CPPAdapter/MeshAdapter.cpp revision 472 by jgs, Fri Jan 27 01:50:59 2006 UTC
# Line 12  Line 12 
12   *                                                                            *   *                                                                            *
13   ******************************************************************************   ******************************************************************************
14  */  */
15  extern "C" {  
16  #include "finley/finleyC/Finley.h"  #include "MeshAdapter.h"
 #include "finley/finleyC/Assemble.h"  
 #include "finley/finleyC/Mesh.h"  
 #include "finley/finleyC/Finley.h"  
 #include "finley/finleyC/System.h"  
 }  
 #include "finley/CPPAdapter/SystemMatrixAdapter.h"  
 #include "finley/CPPAdapter/MeshAdapter.h"  
 #include "finley/CPPAdapter/FinleyError.h"  
 #include "finley/CPPAdapter/FinleyAdapterException.h"  
 #include "escript/Data/FunctionSpaceFactory.h"  
 #include "escript/Data/Data.h"  
 #include "escript/Data/DataArrayView.h"  
 #include "escript/Data/FunctionSpace.h"  
 #include "escript/Data/DataFactory.h"  
   
 #include <iostream>  
 #include <vector>  
 #include <sstream>  
17    
18  using namespace std;  using namespace std;
19  using namespace escript;  using namespace escript;
# Line 241  void MeshAdapter::getTagList(int functio Line 223  void MeshAdapter::getTagList(int functio
223      break;      break;
224    default:    default:
225      stringstream temp;      stringstream temp;
226      temp << "Error - Invalid function space type: "      temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
      << functionSpaceType << " for domain: " << getDescription();  
227      throw FinleyAdapterException(temp.str());      throw FinleyAdapterException(temp.str());
228      break;      break;
229    }    }
# Line 314  void MeshAdapter::getReferenceNoList(int Line 295  void MeshAdapter::getReferenceNoList(int
295      break;      break;
296    default:    default:
297      stringstream temp;      stringstream temp;
298      temp << "Error - Invalid function space type: "      temp << "Error - Invalid function space type: " << functionSpaceType << " for domain: " << getDescription();
      << functionSpaceType << " for domain: " << getDescription();  
299      throw FinleyAdapterException(temp.str());      throw FinleyAdapterException(temp.str());
300      break;      break;
301    }    }
# Line 395  pair<int,int> MeshAdapter::getDataShape( Line 375  pair<int,int> MeshAdapter::getDataShape(
375             break;             break;
376        default:        default:
377          stringstream temp;          stringstream temp;
378          temp << "Error - Invalid function space type: "          temp << "Error - Invalid function space type: " << functionSpaceCode << " for domain: " << getDescription();
          << functionSpaceCode << " for domain: " << getDescription();  
379          throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
380          break;          break;
381        }        }
# Line 413  void MeshAdapter::addPDEToSystem( Line 392  void MeshAdapter::addPDEToSystem(
392                       const Data& d_contact,const Data& y_contact) const                       const Data& d_contact,const Data& y_contact) const
393  {  {
394     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
395     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,mat.getFinley_SystemMatrix(),&(rhs.getDataC()),     Finley_Assemble_PDE(mesh->Nodes,mesh->Elements,mat.getPaso_SystemMatrix(),&(rhs.getDataC()),
396                         &(A.getDataC()),&(B.getDataC()),&(C.getDataC()),&(D.getDataC()),&(X.getDataC()),&(Y.getDataC()));                         &(A.getDataC()),&(B.getDataC()),&(C.getDataC()),&(D.getDataC()),&(X.getDataC()),&(Y.getDataC()));
397     checkFinleyError();     checkFinleyError();
398     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->FaceElements,
399                    mat.getFinley_SystemMatrix(),                    mat.getPaso_SystemMatrix(),
400                    &(rhs.getDataC()),                    &(rhs.getDataC()),
401                                    &(d.getDataC()),&(y.getDataC()),                                    &(d.getDataC()),&(y.getDataC()),
402                                    Finley_Assemble_handelShapeMissMatch_Mean_out);                                    Finley_Assemble_handelShapeMissMatch_Mean_out);
403     checkFinleyError();     checkFinleyError();
404     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->ContactElements,     Finley_Assemble_RobinCondition(mesh->Nodes,mesh->ContactElements,
405                    mat.getFinley_SystemMatrix(),                    mat.getPaso_SystemMatrix(),
406                    &(rhs.getDataC()),                    &(rhs.getDataC()),
407                                    &(d_contact.getDataC()),                                    &(d_contact.getDataC()),
408                    &(y_contact.getDataC()),                    &(y_contact.getDataC()),
# Line 489  void MeshAdapter::interpolateOnDomain(Da Line 468  void MeshAdapter::interpolateOnDomain(Da
468                 Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));                 Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));
469                 break;                 break;
470             default:             default:
471                 Finley_ErrorCode=TYPE_ERROR;                 stringstream temp;
472                 sprintf(Finley_ErrorMsg,"Interpolation on Domain: Finley does not know anything about function space type %d",target.getFunctionSpace().getTypeCode());                 temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
473                   throw FinleyAdapterException(temp.str());
474                 break;                 break;
475          }          }
476          break;          break;
# Line 498  void MeshAdapter::interpolateOnDomain(Da Line 478  void MeshAdapter::interpolateOnDomain(Da
478          if (target.getFunctionSpace().getTypeCode()==Elements) {          if (target.getFunctionSpace().getTypeCode()==Elements) {
479             Finley_Assemble_CopyElementData(mesh->Elements,&(target.getDataC()),&(in.getDataC()));             Finley_Assemble_CopyElementData(mesh->Elements,&(target.getDataC()),&(in.getDataC()));
480          } else {          } else {
481             Finley_ErrorCode=TYPE_ERROR;             throw FinleyAdapterException("Error - No interpolation with data on elements possible.");
            sprintf(Finley_ErrorMsg,"No interpolation with data on elements possible.");  
482          }          }
483          break;          break;
484       case(FaceElements):       case(FaceElements):
485          if (target.getFunctionSpace().getTypeCode()==FaceElements) {          if (target.getFunctionSpace().getTypeCode()==FaceElements) {
486             Finley_Assemble_CopyElementData(mesh->FaceElements,&(target.getDataC()),&(in.getDataC()));             Finley_Assemble_CopyElementData(mesh->FaceElements,&(target.getDataC()),&(in.getDataC()));
487          } else {          } else {
488             Finley_ErrorCode=TYPE_ERROR;             throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");
            sprintf(Finley_ErrorMsg,"No interpolation with data on face elements possible.");  
489             break;             break;
490         }         }
491       case(Points):       case(Points):
492          if (target.getFunctionSpace().getTypeCode()==Points) {          if (target.getFunctionSpace().getTypeCode()==Points) {
493             Finley_Assemble_CopyElementData(mesh->Points,&(target.getDataC()),&(in.getDataC()));             Finley_Assemble_CopyElementData(mesh->Points,&(target.getDataC()),&(in.getDataC()));
494          } else {          } else {
495             Finley_ErrorCode=TYPE_ERROR;             throw FinleyAdapterException("Error - No interpolation with data on points possible.");
            sprintf(Finley_ErrorMsg,"No interpolation with data on points possible.");  
496             break;             break;
497          }          }
498          break;          break;
# Line 524  void MeshAdapter::interpolateOnDomain(Da Line 501  void MeshAdapter::interpolateOnDomain(Da
501          if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {          if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {
502             Finley_Assemble_CopyElementData(mesh->ContactElements,&(target.getDataC()),&(in.getDataC()));             Finley_Assemble_CopyElementData(mesh->ContactElements,&(target.getDataC()),&(in.getDataC()));
503          } else {          } else {
504             Finley_ErrorCode=TYPE_ERROR;             throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");
            sprintf(Finley_ErrorMsg,"No interpolation with data on contact elements possible.");  
505             break;             break;
506          }          }
507          break;          break;
# Line 550  void MeshAdapter::interpolateOnDomain(Da Line 526  void MeshAdapter::interpolateOnDomain(Da
526                Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));                Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));
527               break;               break;
528             default:             default:
529               Finley_ErrorCode=TYPE_ERROR;               stringstream temp;
530               sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",target.getFunctionSpace().getTypeCode());               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
531                 throw FinleyAdapterException(temp.str());
532               break;               break;
533          }          }
534          break;          break;
# Line 574  void MeshAdapter::interpolateOnDomain(Da Line 551  void MeshAdapter::interpolateOnDomain(Da
551               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));               Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&(in.getDataC()),&(target.getDataC()));
552               break;               break;
553            case(Nodes):            case(Nodes):
554               Finley_ErrorCode=TYPE_ERROR;               throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");
              sprintf(Finley_ErrorMsg,"Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");  
555               break;               break;
556            case(DegreesOfFreedom):            case(DegreesOfFreedom):
557               Finley_ErrorCode=TYPE_ERROR;               throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");
              sprintf(Finley_ErrorMsg,"Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");  
558               break;               break;
559            default:            default:
560               Finley_ErrorCode=TYPE_ERROR;               stringstream temp;
561               sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",target.getFunctionSpace().getTypeCode());               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
562                 throw FinleyAdapterException(temp.str());
563               break;               break;
564         }         }
565         break;         break;
566       default:       default:
567          Finley_ErrorCode=TYPE_ERROR;          stringstream temp;
568          sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",in.getFunctionSpace().getTypeCode());          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type %d" << in.getFunctionSpace().getTypeCode();
569            throw FinleyAdapterException(temp.str());
570          break;          break;
571    }    }
572    checkFinleyError();    checkFinleyError();
# Line 627  void MeshAdapter::setToNormal(Data& norm Line 604  void MeshAdapter::setToNormal(Data& norm
604    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
605    switch(normal.getFunctionSpace().getTypeCode()) {    switch(normal.getFunctionSpace().getTypeCode()) {
606      case(Nodes):      case(Nodes):
607        Finley_ErrorCode=TYPE_ERROR;        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for nodes");
       sprintf(Finley_ErrorMsg,"Finley does not support surface normal vectors for nodes");  
608        break;        break;
609      case(Elements):      case(Elements):
610        Finley_ErrorCode=TYPE_ERROR;        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for elements");
       sprintf(Finley_ErrorMsg,"Finley does not support surface normal vectors for elements");  
611        break;        break;
612      case (FaceElements):      case (FaceElements):
613        Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&(normal.getDataC()));        Finley_Assemble_setNormal(mesh->Nodes,mesh->FaceElements,&(normal.getDataC()));
614        break;        break;
615      case(Points):      case(Points):
616        Finley_ErrorCode=TYPE_ERROR;        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for point elements");
       sprintf(Finley_ErrorMsg,"Finley does not support surface normal vectors for point elements");  
617        break;        break;
618      case (ContactElementsOne):      case (ContactElementsOne):
619      case (ContactElementsZero):      case (ContactElementsZero):
620        Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&(normal.getDataC()));        Finley_Assemble_setNormal(mesh->Nodes,mesh->ContactElements,&(normal.getDataC()));
621        break;        break;
622      case(DegreesOfFreedom):      case(DegreesOfFreedom):
623        Finley_ErrorCode=TYPE_ERROR;        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for degrees of freedom.");
       sprintf(Finley_ErrorMsg,"Finley does not support surface normal vectors for degrees of freedom.");  
624        break;        break;
625      case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
626        Finley_ErrorCode=TYPE_ERROR;        throw FinleyAdapterException("Error - Finley does not support surface normal vectors for reduced degrees of freedom.");
       sprintf(Finley_ErrorMsg,"Finley does not support surface normal vectors for reduced degrees of freedom.");  
627        break;        break;
628      default:      default:
629        Finley_ErrorCode=TYPE_ERROR;        stringstream temp;
630        sprintf(Finley_ErrorMsg,"Normal Vectors: Finley does not know anything about function space type %d",normal.getFunctionSpace().getTypeCode());        temp << "Error - Normal Vectors: Finley does not know anything about function space type " << normal.getFunctionSpace().getTypeCode();
631          throw FinleyAdapterException(temp.str());
632        break;        break;
633    }    }
634    checkFinleyError();    checkFinleyError();
# Line 670  void MeshAdapter::interpolateACross(Data Line 643  void MeshAdapter::interpolateACross(Data
643    if (targetDomain!=*this)    if (targetDomain!=*this)
644       throw FinleyAdapterException("Error - Illegal domain of interpolation target");       throw FinleyAdapterException("Error - Illegal domain of interpolation target");
645    
646    Finley_ErrorCode=SYSTEM_ERROR;    throw FinleyAdapterException("Error - Finley does not allow interpolation across domains yet.");
   sprintf(Finley_ErrorMsg,"Finley does not allow interpolation across domains yet.");  
   checkFinleyError();  
647  }  }
648    
649  //  //
# Line 687  void MeshAdapter::setToIntegrals(std::ve Line 658  void MeshAdapter::setToIntegrals(std::ve
658    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
659    switch(arg.getFunctionSpace().getTypeCode()) {    switch(arg.getFunctionSpace().getTypeCode()) {
660       case(Nodes):       case(Nodes):
661          Finley_ErrorCode=TYPE_ERROR;          throw FinleyAdapterException("Error - Integral of data on nodes is not supported.");
         sprintf(Finley_ErrorMsg,"Integral of data on nodes is not supported.");  
662          break;          break;
663       case(Elements):       case(Elements):
664          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->Elements,&(arg.getDataC()),&integrals[0]);
# Line 697  void MeshAdapter::setToIntegrals(std::ve Line 667  void MeshAdapter::setToIntegrals(std::ve
667          Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->FaceElements,&(arg.getDataC()),&integrals[0]);
668          break;          break;
669       case(Points):       case(Points):
670          Finley_ErrorCode=TYPE_ERROR;          throw FinleyAdapterException("Error - Integral of data on points is not supported.");
         sprintf(Finley_ErrorMsg,"Integral of data on points is not supported.");  
671          break;          break;
672       case(ContactElementsZero):       case(ContactElementsZero):
673          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&(arg.getDataC()),&integrals[0]);
# Line 707  void MeshAdapter::setToIntegrals(std::ve Line 676  void MeshAdapter::setToIntegrals(std::ve
676          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&(arg.getDataC()),&integrals[0]);          Finley_Assemble_integrate(mesh->Nodes,mesh->ContactElements,&(arg.getDataC()),&integrals[0]);
677          break;          break;
678       case(DegreesOfFreedom):       case(DegreesOfFreedom):
679          Finley_ErrorCode=TYPE_ERROR;          throw FinleyAdapterException("Error - Integral of data on degrees of freedom is not supported.");
         sprintf(Finley_ErrorMsg,"Integral of data on degrees of freedom is not supported.");  
680          break;          break;
681       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
682          Finley_ErrorCode=TYPE_ERROR;          throw FinleyAdapterException("Error - Integral of data on reduced degrees of freedom is not supported.");
         sprintf(Finley_ErrorMsg,"Integral of data on reduced degrees of freedom is not supported.");  
683          break;          break;
684       default:       default:
685          Finley_ErrorCode=TYPE_ERROR;          stringstream temp;
686          sprintf(Finley_ErrorMsg,"Integrals: Finley does not know anything about function space type %d",arg.getFunctionSpace().getTypeCode());          temp << "Error - Integrals: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();
687            throw FinleyAdapterException(temp.str());
688          break;          break;
689    }    }
690    checkFinleyError();    checkFinleyError();
# Line 737  void MeshAdapter::setToGradient(Data& gr Line 705  void MeshAdapter::setToGradient(Data& gr
705    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
706    switch(grad.getFunctionSpace().getTypeCode()) {    switch(grad.getFunctionSpace().getTypeCode()) {
707         case(Nodes):         case(Nodes):
708            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Gradient at nodes is not supported.");
           sprintf(Finley_ErrorMsg,"Gradient at nodes is not supported.");  
709            break;            break;
710         case(Elements):         case(Elements):
711            Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&(grad.getDataC()),&(arg.getDataC()));            Finley_Assemble_gradient(mesh->Nodes,mesh->Elements,&(grad.getDataC()),&(arg.getDataC()));
# Line 747  void MeshAdapter::setToGradient(Data& gr Line 714  void MeshAdapter::setToGradient(Data& gr
714            Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&(grad.getDataC()),&(arg.getDataC()));            Finley_Assemble_gradient(mesh->Nodes,mesh->FaceElements,&(grad.getDataC()),&(arg.getDataC()));
715            break;            break;
716         case(Points):         case(Points):
717            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Gradient at points is not supported.");
           sprintf(Finley_ErrorMsg,"Gradient at points is not supported.");  
718            break;            break;
719         case(ContactElementsZero):         case(ContactElementsZero):
720            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&(grad.getDataC()),&(arg.getDataC()));            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&(grad.getDataC()),&(arg.getDataC()));
# Line 757  void MeshAdapter::setToGradient(Data& gr Line 723  void MeshAdapter::setToGradient(Data& gr
723            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&(grad.getDataC()),&(arg.getDataC()));            Finley_Assemble_gradient(mesh->Nodes,mesh->ContactElements,&(grad.getDataC()),&(arg.getDataC()));
724            break;            break;
725         case(DegreesOfFreedom):         case(DegreesOfFreedom):
726            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Gradient at degrees of freedom is not supported.");
           sprintf(Finley_ErrorMsg,"Gradient at degrees of freedom is not supported.");  
727            break;            break;
728         case(ReducedDegreesOfFreedom):         case(ReducedDegreesOfFreedom):
729            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Gradient at reduced degrees of freedom is not supported.");
           sprintf(Finley_ErrorMsg,"Gradient at reduced degrees of freedom is not supported.");  
730            break;            break;
731         default:         default:
732            Finley_ErrorCode=TYPE_ERROR;            stringstream temp;
733            sprintf(Finley_ErrorMsg,"Gradient: Finley does not know anything about function space type %d",arg.getFunctionSpace().getTypeCode());            temp << "Error - Gradient: Finley does not know anything about function space type " << arg.getFunctionSpace().getTypeCode();
734              throw FinleyAdapterException(temp.str());
735            break;            break;
736    }    }
737    checkFinleyError();    checkFinleyError();
# Line 781  void MeshAdapter::setToSize(Data& size) Line 746  void MeshAdapter::setToSize(Data& size)
746    escriptDataC tmp=size.getDataC();    escriptDataC tmp=size.getDataC();
747    switch(size.getFunctionSpace().getTypeCode()) {    switch(size.getFunctionSpace().getTypeCode()) {
748         case(Nodes):         case(Nodes):
749            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Size of nodes is not supported.");
           sprintf(Finley_ErrorMsg,"Size of nodes is not supported.");  
750            break;            break;
751         case(Elements):         case(Elements):
752            Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);            Finley_Assemble_getSize(mesh->Nodes,mesh->Elements,&tmp);
# Line 791  void MeshAdapter::setToSize(Data& size) Line 755  void MeshAdapter::setToSize(Data& size)
755            Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);            Finley_Assemble_getSize(mesh->Nodes,mesh->FaceElements,&tmp);
756            break;            break;
757         case(Points):         case(Points):
758            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Size of point elements is not supported.");
           sprintf(Finley_ErrorMsg,"Size of point elements is not supported.");  
759            break;            break;
760         case(ContactElementsZero):         case(ContactElementsZero):
761         case(ContactElementsOne):         case(ContactElementsOne):
762            Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);            Finley_Assemble_getSize(mesh->Nodes,mesh->ContactElements,&tmp);
763            break;            break;
764         case(DegreesOfFreedom):         case(DegreesOfFreedom):
765            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Size of degrees of freedom is not supported.");
           sprintf(Finley_ErrorMsg,"Size of degrees of freedom is not supported.");  
766            break;            break;
767         case(ReducedDegreesOfFreedom):         case(ReducedDegreesOfFreedom):
768            Finley_ErrorCode=TYPE_ERROR;            throw FinleyAdapterException("Error - Size of reduced degrees of freedom is not supported.");
           sprintf(Finley_ErrorMsg,"Size of reduced degrees of freedom is not supported.");  
769            break;            break;
770         default:         default:
771            Finley_ErrorCode=TYPE_ERROR;            stringstream temp;
772            sprintf(Finley_ErrorMsg,"Element size: Finley does not know anything about function space type %d",size.getFunctionSpace().getTypeCode());            temp << "Error - Element size: Finley does not know anything about function space type " << size.getFunctionSpace().getTypeCode();
773              throw FinleyAdapterException(temp.str());
774            break;            break;
775    }    }
776    checkFinleyError();    checkFinleyError();
# Line 826  void MeshAdapter::setNewX(const Data& ne Line 788  void MeshAdapter::setNewX(const Data& ne
788  }  }
789    
790  // saves a data array in openDX format:  // saves a data array in openDX format:
791  void MeshAdapter::saveDX(const std::string& filename,const Data& arg) const  void MeshAdapter::saveDX(const std::string& filename,const boost::python::dict& arg) const
792  {  {
793    Finley_Mesh_saveDX(filename.c_str(),m_finleyMesh.get(),&(arg.getDataC()));      int MAX_namelength=256;
794    checkFinleyError();      const int num_data=boost::python::extract<int>(arg.attr("__len__")());
795        char names[num_data][MAX_namelength];
796        char* c_names[num_data];
797        escriptDataC data[num_data];
798        escriptDataC* ptr_data[num_data];
799    
800        boost::python::list keys=arg.keys();
801        for (int i=0;i<num_data;++i) {
802             Data& d=boost::python::extract<Data&>(arg[keys[i]]);
803             if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
804                 throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
805             data[i]=d.getDataC();
806             ptr_data[i]=&(data[i]);
807             std::string n=boost::python::extract<std::string>(keys[i]);
808             c_names[i]=&(names[i][0]);
809             if (n.length()>MAX_namelength-1) {
810                strncpy(c_names[i],n.c_str(),MAX_namelength-1);
811                c_names[i][MAX_namelength-1]='\0';
812             } else {
813                strcpy(c_names[i],n.c_str());
814             }
815        }
816        Finley_Mesh_saveDX(filename.c_str(),m_finleyMesh.get(),num_data,c_names,ptr_data);
817        checkFinleyError();
818        return;
819  }  }
820    
821  // saves a data array in openVTK format:  // saves a data array in openVTK format:
822  void MeshAdapter::saveVTK(const std::string& filename,const Data& arg) const  void MeshAdapter::saveVTK(const std::string& filename,const boost::python::dict& arg) const
823  {  {
824    Finley_Mesh_saveVTK(filename.c_str(),m_finleyMesh.get(),&(arg.getDataC()));      int MAX_namelength=256;
825    checkFinleyError();      const int num_data=boost::python::extract<int>(arg.attr("__len__")());
826        char names[num_data][MAX_namelength];
827        char* c_names[num_data];
828        escriptDataC data[num_data];
829        escriptDataC* ptr_data[num_data];
830    
831        boost::python::list keys=arg.keys();
832        for (int i=0;i<num_data;++i) {
833             Data& d=boost::python::extract<Data&>(arg[keys[i]]);
834             if (dynamic_cast<const MeshAdapter&>(d.getFunctionSpace().getDomain()) !=*this)
835                 throw FinleyAdapterException("Error  in saveVTK: Data must be defined on same Domain");
836             data[i]=d.getDataC();
837             ptr_data[i]=&(data[i]);
838             std::string n=boost::python::extract<std::string>(keys[i]);
839             c_names[i]=&(names[i][0]);
840             if (n.length()>MAX_namelength-1) {
841                strncpy(c_names[i],n.c_str(),MAX_namelength-1);
842                c_names[i][MAX_namelength-1]='\0';
843             } else {
844                strcpy(c_names[i],n.c_str());
845             }
846        }
847        Finley_Mesh_saveVTK(filename.c_str(),m_finleyMesh.get(),num_data,c_names,ptr_data);
848        checkFinleyError();
849        return;
850  }  }
851                                                                                                                                                                            
852                                                                                                                                                                            
853  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros:
854  SystemMatrixAdapter MeshAdapter::newSystemMatrix(  SystemMatrixAdapter MeshAdapter::newSystemMatrix(
855                        const int row_blocksize,                        const int row_blocksize,
# Line 873  SystemMatrixAdapter MeshAdapter::newSyst Line 884  SystemMatrixAdapter MeshAdapter::newSyst
884      }      }
885      // generate matrix:      // generate matrix:
886            
887      Finley_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);      Paso_SystemMatrixPattern* fsystemMatrixPattern=Finley_getPattern(getFinley_Mesh(),reduceRowOrder,reduceColOrder);
888      checkFinleyError();      checkFinleyError();
889      Finley_SystemMatrix* fsystemMatrix=Finley_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);      Paso_SystemMatrix* fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);
890      checkFinleyError();      checkPasoError();
891      Finley_SystemMatrixPattern_dealloc(fsystemMatrixPattern);      Paso_SystemMatrixPattern_dealloc(fsystemMatrixPattern);
892      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);      return SystemMatrixAdapter(fsystemMatrix,row_blocksize,row_functionspace,column_blocksize,column_functionspace);
893  }  }
894    
# Line 904  bool MeshAdapter::isCellOriented(int fun Line 915  bool MeshAdapter::isCellOriented(int fun
915            return true;            return true;
916            break;            break;
917         default:         default:
918            Finley_ErrorCode=TYPE_ERROR;            stringstream temp;
919            sprintf(Finley_ErrorMsg,"Cell: Finley does not know anything about function space type %d",functionSpaceCode);            temp << "Error - Cell: Finley does not know anything about function space type " << functionSpaceCode;
920              throw FinleyAdapterException(temp.str());
921            break;            break;
922    }    }
923    checkFinleyError();    checkFinleyError();
# Line 927  bool MeshAdapter::probeInterpolationOnDo Line 939  bool MeshAdapter::probeInterpolationOnDo
939             case(ContactElementsOne):             case(ContactElementsOne):
940                 return true;                 return true;
941             default:             default:
942                 Finley_ErrorCode=TYPE_ERROR;                 stringstream temp;
943                 sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",functionSpaceType_target);                 temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
944                   throw FinleyAdapterException(temp.str());
945          }          }
946          break;          break;
947       case(Elements):       case(Elements):
# Line 968  bool MeshAdapter::probeInterpolationOnDo Line 981  bool MeshAdapter::probeInterpolationOnDo
981             case(ContactElementsOne):             case(ContactElementsOne):
982                return true;                return true;
983             default:             default:
984               Finley_ErrorCode=TYPE_ERROR;               stringstream temp;
985               sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",functionSpaceType_target);               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
986                 throw FinleyAdapterException(temp.str());
987          }          }
988          break;          break;
989       case(ReducedDegreesOfFreedom):       case(ReducedDegreesOfFreedom):
# Line 985  bool MeshAdapter::probeInterpolationOnDo Line 999  bool MeshAdapter::probeInterpolationOnDo
999            case(DegreesOfFreedom):            case(DegreesOfFreedom):
1000               return false;               return false;
1001            default:            default:
1002               Finley_ErrorCode=TYPE_ERROR;               stringstream temp;
1003               sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",functionSpaceType_target);               temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1004                 throw FinleyAdapterException(temp.str());
1005         }         }
1006         break;         break;
1007       default:       default:
1008          Finley_ErrorCode=TYPE_ERROR;          stringstream temp;
1009          sprintf(Finley_ErrorMsg,"Interpolation On Domain: Finley does not know anything about function space type %d",functionSpaceType_source);          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_source;
1010            throw FinleyAdapterException(temp.str());
1011          break;          break;
1012    }    }
1013    checkFinleyError();    checkFinleyError();
# Line 1018  bool MeshAdapter::operator!=(const Abstr Line 1034  bool MeshAdapter::operator!=(const Abstr
1034    return !(operator==(other));    return !(operator==(other));
1035  }  }
1036    
1037  int MeshAdapter::getSystemMatrixTypeId(const int solver, const bool symmetry) const  int MeshAdapter::getSystemMatrixTypeId(const int solver, const int package, const bool symmetry) const
1038  {  {
1039     int out=Finley_SystemMatrix_getSystemMatrixTypeId(solver,symmetry?1:0);     int out=Paso_SystemMatrix_getSystemMatrixTypeId(SystemMatrixAdapter::mapOptionToPaso(solver),SystemMatrixAdapter::mapOptionToPaso(package),symmetry?1:0);
1040     checkFinleyError();     checkPasoError();
1041     return out;     return out;
1042  }  }
1043    

Legend:
Removed from v.149  
changed lines
  Added in v.472

  ViewVC Help
Powered by ViewVC 1.1.26