/[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 2315 by gross, Wed Mar 18 00:38:48 2009 UTC revision 2642 by jfenwick, Tue Sep 1 04:15:50 2009 UTC
# Line 1  Line 1 
1    
2  /*******************************************************  /*******************************************************
3  *  *
4  * Copyright (c) 2003-2008 by University of Queensland  * Copyright (c) 2003-2009 by University of Queensland
5  * Earth Systems Science Computational Center (ESSCC)  * Earth Systems Science Computational Center (ESSCC)
6  * http://www.uq.edu.au/esscc  * http://www.uq.edu.au/esscc
7  *  *
# Line 96  bool MeshAdapter::onMasterProcessor() co Line 96  bool MeshAdapter::onMasterProcessor() co
96  }  }
97    
98    
99    #ifdef PASO_MPI
100      MPI_Comm
101    #else
102      unsigned int
103    #endif
104    MeshAdapter::getMPIComm() const
105    {
106    #ifdef PASO_MPI
107        return m_finleyMesh->MPIInfo->comm;
108    #else
109        return 0;
110    #endif
111    }
112    
113    
114  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {  Finley_Mesh* MeshAdapter::getFinley_Mesh() const {
115     return m_finleyMesh.get();     return m_finleyMesh.get();
116  }  }
# Line 109  void MeshAdapter::write(const std::strin Line 124  void MeshAdapter::write(const std::strin
124     TMPMEMFREE(fName);     TMPMEMFREE(fName);
125  }  }
126    
127  void MeshAdapter::Print_Mesh_Info(const bool full=false) const  void MeshAdapter::Print_Mesh_Info(const bool full) const
128  {  {
129     Finley_PrintMesh_Info(m_finleyMesh.get(), full);     Finley_PrintMesh_Info(m_finleyMesh.get(), full);
130  }  }
# Line 881  void MeshAdapter::interpolateOnDomain(es Line 896  void MeshAdapter::interpolateOnDomain(es
896     escriptDataC _in=in.getDataC();     escriptDataC _in=in.getDataC();
897     switch(in.getFunctionSpace().getTypeCode()) {     switch(in.getFunctionSpace().getTypeCode()) {
898     case(Nodes):     case(Nodes):
899     switch(target.getFunctionSpace().getTypeCode()) {        switch(target.getFunctionSpace().getTypeCode()) {
900     case(Nodes):        case(Nodes):
901     case(ReducedNodes):        case(ReducedNodes):
902     case(DegreesOfFreedom):        case(DegreesOfFreedom):
903     case(ReducedDegreesOfFreedom):        case(ReducedDegreesOfFreedom):
904     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
    break;  
    case(Elements):  
    case(ReducedElements):  
    Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);  
    break;  
    case(FaceElements):  
    case(ReducedFaceElements):  
    Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);  
    break;  
    case(Points):  
    Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);  
    break;  
    case(ContactElementsZero):  
    case(ReducedContactElementsZero):  
    Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);  
    break;  
    case(ContactElementsOne):  
    case(ReducedContactElementsOne):  
    Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);  
    break;  
    default:  
       stringstream temp;  
       temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();  
       throw FinleyAdapterException(temp.str());  
905        break;        break;
906     }        case(Elements):
907     break;        case(ReducedElements):
908     case(ReducedNodes):        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
909     switch(target.getFunctionSpace().getTypeCode()) {        break;
910     case(Nodes):        case(FaceElements):
911     case(ReducedNodes):        case(ReducedFaceElements):
912     case(DegreesOfFreedom):        Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
913     case(ReducedDegreesOfFreedom):        break;
914     Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);        case(Points):
915     break;        Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
916     case(Elements):        break;
917     case(ReducedElements):        case(ContactElementsZero):
918     Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);        case(ReducedContactElementsZero):
919     break;        Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
920     case(FaceElements):        break;
921     case(ReducedFaceElements):        case(ContactElementsOne):
922     Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);        case(ReducedContactElementsOne):
923     break;        Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
924     case(Points):        break;
925     Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);        default:
926     break;           stringstream temp;
927     case(ContactElementsZero):           temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
928     case(ReducedContactElementsZero):           throw FinleyAdapterException(temp.str());
929     Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);           break;
930     break;        }
    case(ContactElementsOne):  
    case(ReducedContactElementsOne):  
    Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);  
    break;  
    default:  
       stringstream temp;  
       temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();  
       throw FinleyAdapterException(temp.str());  
931        break;        break;
    }  
    break;  
    case(Elements):  
    if (target.getFunctionSpace().getTypeCode()==Elements) {  
       Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);  
    } else if (target.getFunctionSpace().getTypeCode()==ReducedElements) {  
       Finley_Assemble_AverageElementData(mesh->Elements,&_target,&_in);  
    } else {  
       throw FinleyAdapterException("Error - No interpolation with data on elements possible.");  
    }  
    break;  
    case(ReducedElements):  
    if (target.getFunctionSpace().getTypeCode()==ReducedElements) {  
       Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);  
    } else {  
       throw FinleyAdapterException("Error - No interpolation with data on elements with reduced integration order possible.");  
    }  
    break;  
    case(FaceElements):  
    if (target.getFunctionSpace().getTypeCode()==FaceElements) {  
       Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);  
    } else if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {  
       Finley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);  
    } else {  
       throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");  
    }  
    break;  
    case(ReducedFaceElements):  
    if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {  
       Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);  
    } else {  
       throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");  
    }  
    break;  
    case(Points):  
    if (target.getFunctionSpace().getTypeCode()==Points) {  
       Finley_Assemble_CopyElementData(mesh->Points,&_target,&_in);  
    } else {  
       throw FinleyAdapterException("Error - No interpolation with data on points possible.");  
    }  
    break;  
    case(ContactElementsZero):  
    case(ContactElementsOne):  
    if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {  
       Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);  
    } else if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {  
       Finley_Assemble_AverageElementData(mesh->ContactElements,&_target,&_in);  
    } else {  
       throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");  
    }  
    break;  
    case(ReducedContactElementsZero):  
    case(ReducedContactElementsOne):  
    if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {  
       Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);  
    } else {  
       throw FinleyAdapterException("Error - No interpolation with data on contact elements with reduced integration order possible.");  
    }  
    break;  
    case(DegreesOfFreedom):        
    switch(target.getFunctionSpace().getTypeCode()) {  
    case(ReducedDegreesOfFreedom):  
    case(DegreesOfFreedom):  
    Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);  
    break;  
   
    case(Nodes):  
932     case(ReducedNodes):     case(ReducedNodes):
933     if (getMPISize()>1) {        switch(target.getFunctionSpace().getTypeCode()) {
934        escript::Data temp=escript::Data(in);        case(Nodes):
935        temp.expand();        case(ReducedNodes):
936        escriptDataC _in2 = temp.getDataC();        case(DegreesOfFreedom):
937        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);        case(ReducedDegreesOfFreedom):
    } else {  
938        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
939     }        break;
940     break;        case(Elements):
941     case(Elements):        case(ReducedElements):
    case(ReducedElements):  
    if (getMPISize()>1) {  
       escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );  
       escriptDataC _in2 = temp.getDataC();  
       Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);  
    } else {  
942        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
943     }        break;
944     break;        case(FaceElements):
945     case(FaceElements):        case(ReducedFaceElements):
    case(ReducedFaceElements):  
    if (getMPISize()>1) {  
       escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );  
       escriptDataC _in2 = temp.getDataC();  
       Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);  
   
    } else {  
946        Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);        Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
947     }        break;
948     break;        case(Points):
    case(Points):  
    if (getMPISize()>1) {  
       escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );  
       escriptDataC _in2 = temp.getDataC();  
    } else {  
949        Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);        Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
950     }        break;
951     break;        case(ContactElementsZero):
952     case(ContactElementsZero):        case(ReducedContactElementsZero):
    case(ContactElementsOne):  
    case(ReducedContactElementsZero):  
    case(ReducedContactElementsOne):  
    if (getMPISize()>1) {  
       escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );  
       escriptDataC _in2 = temp.getDataC();  
       Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);  
    } else {  
953        Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);        Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
    }  
    break;  
    default:  
       stringstream temp;  
       temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();  
       throw FinleyAdapterException(temp.str());  
954        break;        break;
955     }        case(ContactElementsOne):
956     break;        case(ReducedContactElementsOne):
957     case(ReducedDegreesOfFreedom):        Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
958     switch(target.getFunctionSpace().getTypeCode()) {        break;
959     case(Nodes):        default:
960     throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");           stringstream temp;
961     break;           temp << "Error - Interpolation on Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
962     case(ReducedNodes):           throw FinleyAdapterException(temp.str());
963     if (getMPISize()>1) {           break;
964        escript::Data temp=escript::Data(in);        }
965        temp.expand();        break;
       escriptDataC _in2 = temp.getDataC();  
       Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);  
    } else {  
       Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);  
    }  
    break;  
    case(DegreesOfFreedom):  
    throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");  
    break;  
    case(ReducedDegreesOfFreedom):  
    Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);  
    break;  
966     case(Elements):     case(Elements):
967          if (target.getFunctionSpace().getTypeCode()==Elements) {
968             Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
969          } else if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
970             Finley_Assemble_AverageElementData(mesh->Elements,&_target,&_in);
971          } else {
972             throw FinleyAdapterException("Error - No interpolation with data on elements possible.");
973          }
974          break;
975     case(ReducedElements):     case(ReducedElements):
976     if (getMPISize()>1) {        if (target.getFunctionSpace().getTypeCode()==ReducedElements) {
977        escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );           Finley_Assemble_CopyElementData(mesh->Elements,&_target,&_in);
978        escriptDataC _in2 = temp.getDataC();        } else {
979        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);           throw FinleyAdapterException("Error - No interpolation with data on elements with reduced integration order possible.");
980     } else {        }
981        Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);        break;
    }  
    break;  
982     case(FaceElements):     case(FaceElements):
983          if (target.getFunctionSpace().getTypeCode()==FaceElements) {
984             Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
985          } else if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
986             Finley_Assemble_AverageElementData(mesh->FaceElements,&_target,&_in);
987          } else {
988             throw FinleyAdapterException("Error - No interpolation with data on face elements possible.");
989          }
990          break;
991     case(ReducedFaceElements):     case(ReducedFaceElements):
992     if (getMPISize()>1) {        if (target.getFunctionSpace().getTypeCode()==ReducedFaceElements) {
993        escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );           Finley_Assemble_CopyElementData(mesh->FaceElements,&_target,&_in);
994        escriptDataC _in2 = temp.getDataC();        } else {
995        Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);           throw FinleyAdapterException("Error - No interpolation with data on face elements with reduced integration order possible.");
996     } else {        }
997        Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);        break;
    }  
    break;  
998     case(Points):     case(Points):
999     if (getMPISize()>1) {        if (target.getFunctionSpace().getTypeCode()==Points) {
1000        escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );           Finley_Assemble_CopyElementData(mesh->Points,&_target,&_in);
1001        escriptDataC _in2 = temp.getDataC();        } else {
1002        Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);           throw FinleyAdapterException("Error - No interpolation with data on points possible.");
1003     } else {        }
1004        Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);        break;
    }  
    break;  
1005     case(ContactElementsZero):     case(ContactElementsZero):
1006     case(ContactElementsOne):     case(ContactElementsOne):
1007          if (target.getFunctionSpace().getTypeCode()==ContactElementsZero || target.getFunctionSpace().getTypeCode()==ContactElementsOne) {
1008             Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);
1009          } else if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {
1010             Finley_Assemble_AverageElementData(mesh->ContactElements,&_target,&_in);
1011          } else {
1012             throw FinleyAdapterException("Error - No interpolation with data on contact elements possible.");
1013          }
1014          break;
1015     case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1016     case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1017     if (getMPISize()>1) {        if (target.getFunctionSpace().getTypeCode()==ReducedContactElementsZero || target.getFunctionSpace().getTypeCode()==ReducedContactElementsOne) {
1018        escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );           Finley_Assemble_CopyElementData(mesh->ContactElements,&_target,&_in);
1019        escriptDataC _in2 = temp.getDataC();        } else {
1020        Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);           throw FinleyAdapterException("Error - No interpolation with data on contact elements with reduced integration order possible.");
1021     } else {        }
1022        Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);        break;
1023     }     case(DegreesOfFreedom):      
1024     break;        switch(target.getFunctionSpace().getTypeCode()) {
1025     default:        case(ReducedDegreesOfFreedom):
1026        stringstream temp;        case(DegreesOfFreedom):
1027        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();        Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
1028        throw FinleyAdapterException(temp.str());        break;
1029      
1030          case(Nodes):
1031          case(ReducedNodes):
1032          if (getMPISize()>1) {
1033             escript::Data temp=escript::Data(in);
1034             temp.expand();
1035             escriptDataC _in2 = temp.getDataC();
1036             Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
1037          } else {
1038             Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
1039          }
1040          break;
1041          case(Elements):
1042          case(ReducedElements):
1043          if (getMPISize()>1) {
1044             escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1045             escriptDataC _in2 = temp.getDataC();
1046             Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
1047          } else {
1048             Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
1049          }
1050          break;
1051          case(FaceElements):
1052          case(ReducedFaceElements):
1053          if (getMPISize()>1) {
1054             escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1055             escriptDataC _in2 = temp.getDataC();
1056             Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
1057      
1058          } else {
1059             Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
1060          }
1061          break;
1062          case(Points):
1063          if (getMPISize()>1) {
1064             escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1065             escriptDataC _in2 = temp.getDataC();
1066          } else {
1067             Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
1068          }
1069          break;
1070          case(ContactElementsZero):
1071          case(ContactElementsOne):
1072          case(ReducedContactElementsZero):
1073          case(ReducedContactElementsOne):
1074          if (getMPISize()>1) {
1075             escript::Data temp=escript::Data( in,  continuousFunction(asAbstractContinuousDomain()) );
1076             escriptDataC _in2 = temp.getDataC();
1077             Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
1078          } else {
1079             Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
1080          }
1081          break;
1082          default:
1083             stringstream temp;
1084             temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
1085             throw FinleyAdapterException(temp.str());
1086             break;
1087          }
1088          break;
1089       case(ReducedDegreesOfFreedom):
1090          switch(target.getFunctionSpace().getTypeCode()) {
1091          case(Nodes):
1092          throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to mesh nodes.");
1093          break;
1094          case(ReducedNodes):
1095          if (getMPISize()>1) {
1096             escript::Data temp=escript::Data(in);
1097             temp.expand();
1098             escriptDataC _in2 = temp.getDataC();
1099             Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in2);
1100          } else {
1101             Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
1102          }
1103          break;
1104          case(DegreesOfFreedom):
1105          throw FinleyAdapterException("Error - Finley does not support interpolation from reduced degrees of freedom to degrees of freedom");
1106          break;
1107          case(ReducedDegreesOfFreedom):
1108          Finley_Assemble_CopyNodalData(mesh->Nodes,&_target,&_in);
1109          break;
1110          case(Elements):
1111          case(ReducedElements):
1112          if (getMPISize()>1) {
1113             escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1114             escriptDataC _in2 = temp.getDataC();
1115             Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in2,&_target);
1116          } else {
1117             Finley_Assemble_interpolate(mesh->Nodes,mesh->Elements,&_in,&_target);
1118          }
1119          break;
1120          case(FaceElements):
1121          case(ReducedFaceElements):
1122          if (getMPISize()>1) {
1123             escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1124             escriptDataC _in2 = temp.getDataC();
1125             Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in2,&_target);
1126          } else {
1127             Finley_Assemble_interpolate(mesh->Nodes,mesh->FaceElements,&_in,&_target);
1128          }
1129          break;
1130          case(Points):
1131          if (getMPISize()>1) {
1132             escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1133             escriptDataC _in2 = temp.getDataC();
1134             Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in2,&_target);
1135          } else {
1136             Finley_Assemble_interpolate(mesh->Nodes,mesh->Points,&_in,&_target);
1137          }
1138          break;
1139          case(ContactElementsZero):
1140          case(ContactElementsOne):
1141          case(ReducedContactElementsZero):
1142          case(ReducedContactElementsOne):
1143          if (getMPISize()>1) {
1144             escript::Data temp=escript::Data( in,  reducedContinuousFunction(asAbstractContinuousDomain()) );
1145             escriptDataC _in2 = temp.getDataC();
1146             Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in2,&_target);
1147          } else {
1148             Finley_Assemble_interpolate(mesh->Nodes,mesh->ContactElements,&_in,&_target);
1149          }
1150          break;
1151          default:
1152             stringstream temp;
1153             temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << target.getFunctionSpace().getTypeCode();
1154             throw FinleyAdapterException(temp.str());
1155             break;
1156          }
1157        break;        break;
    }  
    break;  
1158     default:     default:
1159        stringstream temp;        stringstream temp;
1160        temp << "Error - 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();
# Line 1453  void MeshAdapter::setNewX(const escript: Line 1468  void MeshAdapter::setNewX(const escript:
1468     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));     const MeshAdapter& newDomain=dynamic_cast<const MeshAdapter&>(*(new_x.getFunctionSpace().getDomain()));
1469     if (newDomain!=*this)     if (newDomain!=*this)
1470        throw FinleyAdapterException("Error - Illegal domain of new point locations");        throw FinleyAdapterException("Error - Illegal domain of new point locations");
1471     tmp = new_x.getDataC();     if ( new_x.getFunctionSpace() == continuousFunction(asAbstractContinuousDomain()) ) {
1472     Finley_Mesh_setCoordinates(mesh,&tmp);         tmp = new_x.getDataC();
1473           Finley_Mesh_setCoordinates(mesh,&tmp);
1474       } else {
1475           escript::Data new_x_inter=escript::Data( new_x,  continuousFunction(asAbstractContinuousDomain()) );
1476           tmp = new_x_inter.getDataC();
1477           Finley_Mesh_setCoordinates(mesh,&tmp);
1478       }
1479     checkFinleyError();     checkFinleyError();
1480  }  }
1481    
# Line 1512  void MeshAdapter::saveDX(const std::stri Line 1533  void MeshAdapter::saveDX(const std::stri
1533  //  //
1534  // saves mesh and optionally data arrays in VTK format  // saves mesh and optionally data arrays in VTK format
1535  //  //
1536  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 std::string& metadata, const std::string& metadata_schema) const
1537  {  {
1538     int num_data;     int num_data;
1539     char **names;     char **names;
# Line 1520  void MeshAdapter::saveVTK(const std::str Line 1541  void MeshAdapter::saveVTK(const std::str
1541     escriptDataC **ptr_data;     escriptDataC **ptr_data;
1542    
1543     extractArgsFromDict(arg, num_data, names, data, ptr_data);     extractArgsFromDict(arg, num_data, names, data, ptr_data);
1544     Finley_Mesh_saveVTK(filename.c_str(), m_finleyMesh.get(), num_data, names, ptr_data);     Finley_Mesh_saveVTK(filename.c_str(), m_finleyMesh.get(), num_data, names, ptr_data, metadata.c_str(), metadata_schema.c_str());
1545     checkFinleyError();     checkFinleyError();
1546    
1547     /* win32 refactor */     /* win32 refactor */
# Line 1533  void MeshAdapter::saveVTK(const std::str Line 1554  void MeshAdapter::saveVTK(const std::str
1554     TMPMEMFREE(names);     TMPMEMFREE(names);
1555  }  }
1556    
1557    bool MeshAdapter::ownSample(int fs_code, index_t id) const
1558    {
1559        index_t myFirstNode=0, myLastNode=0, k=0;
1560        index_t* globalNodeIndex=0;
1561        Finley_Mesh* mesh_p=m_finleyMesh.get();
1562        if (fs_code == FINLEY_REDUCED_NODES)
1563        {
1564        myFirstNode = Finley_NodeFile_getFirstReducedNode(mesh_p->Nodes);
1565        myLastNode = Finley_NodeFile_getLastReducedNode(mesh_p->Nodes);
1566        globalNodeIndex = Finley_NodeFile_borrowGlobalReducedNodesIndex(mesh_p->Nodes);
1567        }
1568        else
1569        {
1570        myFirstNode = Finley_NodeFile_getFirstNode(mesh_p->Nodes);
1571        myLastNode = Finley_NodeFile_getLastNode(mesh_p->Nodes);
1572        globalNodeIndex = Finley_NodeFile_borrowGlobalNodesIndex(mesh_p->Nodes);
1573        }
1574        k=globalNodeIndex[id];
1575        return static_cast<bool>( (myFirstNode <= k) && (k < myLastNode) );
1576    }
1577    
1578    
1579    
1580  //  //
1581  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros  // creates a SystemMatrixAdapter stiffness matrix an initializes it with zeros
1582  //  //
# Line 1579  SystemMatrixAdapter MeshAdapter::newSyst Line 1623  SystemMatrixAdapter MeshAdapter::newSyst
1623  #endif  #endif
1624     }     }
1625     else {     else {
1626        fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize);        fsystemMatrix=Paso_SystemMatrix_alloc(type,fsystemMatrixPattern,row_blocksize,column_blocksize,FALSE);
1627     }     }
1628     checkPasoError();     checkPasoError();
1629     Paso_SystemMatrixPattern_free(fsystemMatrixPattern);     Paso_SystemMatrixPattern_free(fsystemMatrixPattern);
# Line 1655  bool MeshAdapter::isCellOriented(int fun Line 1699  bool MeshAdapter::isCellOriented(int fun
1699     return false;     return false;
1700  }  }
1701    
1702    bool
1703    MeshAdapter::commonFunctionSpace(const std::vector<int>& fs, int& resultcode) const
1704    {
1705       /* The idea is to use equivalence classes. [Types which can be interpolated back and forth]
1706        class 1: DOF <-> Nodes
1707        class 2: ReducedDOF <-> ReducedNodes
1708        class 3: Points
1709        class 4: Elements
1710        class 5: ReducedElements
1711        class 6: FaceElements
1712        class 7: ReducedFaceElements
1713        class 8: ContactElementZero <-> ContactElementOne
1714        class 9: ReducedContactElementZero <-> ReducedContactElementOne
1715    
1716       There is also a set of lines. Interpolation is possible down a line but not between lines.
1717       class 1 and 2 belong to all lines so aren't considered.
1718        line 0: class 3
1719        line 1: class 4,5
1720        line 2: class 6,7
1721        line 3: class 8,9
1722    
1723       For classes with multiple members (eg class 2) we have vars to record if there is at least one instance.
1724       eg hasnodes is true if we have at least one instance of Nodes.
1725       */
1726        if (fs.size()==0)
1727        {
1728        return false;
1729        }
1730        std::vector<int> hasclass(10);
1731        std::vector<int> hasline(4);    
1732        bool hasnodes=false;
1733        bool hasrednodes=false;
1734        bool hascez=false;
1735        bool hasrcez=false;
1736        for (int i=0;i<fs.size();++i)
1737        {
1738        switch(fs[i])
1739        {
1740        case(Nodes):   hasnodes=true;   // no break is deliberate
1741        case(DegreesOfFreedom):
1742            hasclass[1]=1;
1743            break;
1744        case(ReducedNodes):    hasrednodes=true;    // no break is deliberate
1745        case(ReducedDegreesOfFreedom):
1746            hasclass[2]=1;
1747            break;
1748        case(Points):
1749            hasline[0]=1;
1750            hasclass[3]=1;
1751            break;
1752        case(Elements):
1753            hasclass[4]=1;
1754            hasline[1]=1;
1755            break;
1756        case(ReducedElements):
1757            hasclass[5]=1;
1758            hasline[1]=1;
1759            break;
1760        case(FaceElements):
1761            hasclass[6]=1;
1762            hasline[2]=1;
1763            break;
1764        case(ReducedFaceElements):
1765            hasclass[7]=1;
1766            hasline[2]=1;
1767            break;
1768        case(ContactElementsZero):  hascez=true;    // no break is deliberate
1769        case(ContactElementsOne):
1770            hasclass[8]=1;
1771            hasline[3]=1;
1772            break;
1773        case(ReducedContactElementsZero):   hasrcez=true;   // no break is deliberate
1774        case(ReducedContactElementsOne):
1775            hasclass[9]=1;
1776            hasline[3]=1;
1777            break;
1778        default:
1779            return false;
1780        }
1781        }
1782        int totlines=hasline[0]+hasline[1]+hasline[2]+hasline[3];
1783        // fail if we have more than one leaf group
1784    
1785        if (totlines>1)
1786        {
1787        return false;   // there are at least two branches we can't interpolate between
1788        }
1789        else if (totlines==1)
1790        {
1791        if (hasline[0]==1)      // we have points
1792        {
1793            resultcode=Points;
1794        }
1795        else if (hasline[1]==1)
1796        {
1797            if (hasclass[5]==1)
1798            {
1799            resultcode=ReducedElements;
1800            }
1801            else
1802            {
1803            resultcode=Elements;
1804            }
1805        }
1806        else if (hasline[2]==1)
1807        {
1808            if (hasclass[7]==ReducedFaceElements)
1809            {
1810            resultcode=ReducedFaceElements;
1811            }
1812            else
1813            {
1814            resultcode=FaceElements;
1815            }
1816        }
1817        else    // so we must be in line3
1818        {
1819            if (hasclass[9]==1)
1820            {
1821            // need something from class 9
1822            resultcode=(hasrcez?ReducedContactElementsZero:ReducedContactElementsOne);
1823            }
1824            else
1825            {
1826            // something from class 8
1827            resultcode=(hascez?ContactElementsZero:ContactElementsOne);
1828            }
1829        }
1830        }
1831        else    // totlines==0
1832        {
1833        if (hasclass[2]==1)
1834        {
1835            // something from class 2
1836            resultcode=(hasrednodes?ReducedNodes:ReducedDegreesOfFreedom);
1837        }
1838        else
1839        {   // something from class 1
1840            resultcode=(hasnodes?Nodes:DegreesOfFreedom);
1841        }
1842        }
1843        return true;
1844    }
1845    
1846  bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const  bool MeshAdapter::probeInterpolationOnDomain(int functionSpaceType_source,int functionSpaceType_target) const
1847  {  {
1848     switch(functionSpaceType_source) {     switch(functionSpaceType_source) {
1849     case(Nodes):     case(Nodes):
1850     switch(functionSpaceType_target) {      switch(functionSpaceType_target) {
1851     case(Nodes):      case(Nodes):
1852     case(ReducedNodes):      case(ReducedNodes):
1853     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1854     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1855     case(Elements):      case(Elements):
1856     case(ReducedElements):      case(ReducedElements):
1857     case(FaceElements):      case(FaceElements):
1858     case(ReducedFaceElements):      case(ReducedFaceElements):
1859     case(Points):      case(Points):
1860     case(ContactElementsZero):      case(ContactElementsZero):
1861     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1862     case(ContactElementsOne):      case(ContactElementsOne):
1863     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1864     return true;      return true;
1865     default:      default:
1866        stringstream temp;            stringstream temp;
1867        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;            temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1868        throw FinleyAdapterException(temp.str());            throw FinleyAdapterException(temp.str());
1869     }     }
1870     break;     break;
1871     case(ReducedNodes):     case(ReducedNodes):
1872     switch(functionSpaceType_target) {      switch(functionSpaceType_target) {
1873     case(ReducedNodes):      case(ReducedNodes):
1874     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1875     case(Elements):      case(Elements):
1876     case(ReducedElements):      case(ReducedElements):
1877     case(FaceElements):      case(FaceElements):
1878     case(ReducedFaceElements):      case(ReducedFaceElements):
1879     case(Points):      case(Points):
1880     case(ContactElementsZero):      case(ContactElementsZero):
1881     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1882     case(ContactElementsOne):      case(ContactElementsOne):
1883     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1884     return true;      return true;
1885     case(Nodes):      case(Nodes):
1886     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1887     return false;      return false;
1888     default:      default:
1889        stringstream temp;          stringstream temp;
1890        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1891        throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
1892     }     }
1893     break;     break;
1894     case(Elements):     case(Elements):
1895     if (functionSpaceType_target==Elements) {      if (functionSpaceType_target==Elements) {
1896        return true;        return true;
1897     } else if (functionSpaceType_target==ReducedElements) {      } else if (functionSpaceType_target==ReducedElements) {
1898        return true;        return true;
1899     } else {          } else {
1900        return false;            return false;
1901     }          }
1902     case(ReducedElements):     case(ReducedElements):
1903     if (functionSpaceType_target==ReducedElements) {      if (functionSpaceType_target==ReducedElements) {
1904        return true;        return true;
1905     } else {      } else {
1906        return false;            return false;
1907     }      }
1908     case(FaceElements):     case(FaceElements):
1909     if (functionSpaceType_target==FaceElements) {      if (functionSpaceType_target==FaceElements) {
1910        return true;              return true;
1911     } else if (functionSpaceType_target==ReducedFaceElements) {      } else if (functionSpaceType_target==ReducedFaceElements) {
1912        return true;              return true;
1913     } else {      } else {
1914        return false;              return false;
1915     }      }
1916     case(ReducedFaceElements):     case(ReducedFaceElements):
1917     if (functionSpaceType_target==ReducedFaceElements) {      if (functionSpaceType_target==ReducedFaceElements) {
1918        return true;              return true;
1919     } else {      } else {
1920        return false;          return false;
1921     }      }
1922     case(Points):     case(Points):
1923     if (functionSpaceType_target==Points) {      if (functionSpaceType_target==Points) {
1924        return true;              return true;
1925     } else {      } else {
1926        return false;              return false;
1927     }      }
1928     case(ContactElementsZero):     case(ContactElementsZero):
1929     case(ContactElementsOne):     case(ContactElementsOne):
1930     if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {      if (functionSpaceType_target==ContactElementsZero || functionSpaceType_target==ContactElementsOne) {
1931        return true;              return true;
1932     } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {      } else if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1933        return true;              return true;
1934     } else {      } else {
1935        return false;              return false;
1936     }      }
1937     case(ReducedContactElementsZero):     case(ReducedContactElementsZero):
1938     case(ReducedContactElementsOne):     case(ReducedContactElementsOne):
1939     if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {      if (functionSpaceType_target==ReducedContactElementsZero || functionSpaceType_target==ReducedContactElementsOne) {
1940        return true;              return true;
1941     } else {      } else {
1942        return false;              return false;
1943     }      }
1944     case(DegreesOfFreedom):     case(DegreesOfFreedom):
1945     switch(functionSpaceType_target) {      switch(functionSpaceType_target) {
1946     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1947     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1948     case(Nodes):      case(Nodes):
1949     case(ReducedNodes):      case(ReducedNodes):
1950     case(Elements):      case(Elements):
1951     case(ReducedElements):      case(ReducedElements):
1952     case(Points):      case(Points):
1953     case(FaceElements):      case(FaceElements):
1954     case(ReducedFaceElements):      case(ReducedFaceElements):
1955     case(ContactElementsZero):      case(ContactElementsZero):
1956     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1957     case(ContactElementsOne):      case(ContactElementsOne):
1958     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1959     return true;      return true;
1960     default:      default:
1961        stringstream temp;          stringstream temp;
1962        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1963        throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
1964     }      }
1965     break;      break;
1966     case(ReducedDegreesOfFreedom):     case(ReducedDegreesOfFreedom):
1967     switch(functionSpaceType_target) {     switch(functionSpaceType_target) {
1968     case(ReducedDegreesOfFreedom):      case(ReducedDegreesOfFreedom):
1969     case(ReducedNodes):      case(ReducedNodes):
1970     case(Elements):      case(Elements):
1971     case(ReducedElements):      case(ReducedElements):
1972     case(FaceElements):      case(FaceElements):
1973     case(ReducedFaceElements):      case(ReducedFaceElements):
1974     case(Points):      case(Points):
1975     case(ContactElementsZero):      case(ContactElementsZero):
1976     case(ReducedContactElementsZero):      case(ReducedContactElementsZero):
1977     case(ContactElementsOne):      case(ContactElementsOne):
1978     case(ReducedContactElementsOne):      case(ReducedContactElementsOne):
1979     return true;      return true;
1980     case(Nodes):      case(Nodes):
1981     case(DegreesOfFreedom):      case(DegreesOfFreedom):
1982     return false;      return false;
1983     default:      default:
1984        stringstream temp;          stringstream temp;
1985        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;          temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_target;
1986        throw FinleyAdapterException(temp.str());          throw FinleyAdapterException(temp.str());
1987     }      }
1988     break;      break;
1989     default:     default:
1990        stringstream temp;        stringstream temp;
1991        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_source;        temp << "Error - Interpolation On Domain: Finley does not know anything about function space type " << functionSpaceType_source;
# Line 1858  escript::Data MeshAdapter::getSize() con Line 2046  escript::Data MeshAdapter::getSize() con
2046     return escript::function(asAbstractContinuousDomain()).getSize();     return escript::function(asAbstractContinuousDomain()).getSize();
2047  }  }
2048    
2049  int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const  const int* MeshAdapter::borrowSampleReferenceIDs(int functionSpaceType) const
2050  {  {
2051     int *out = NULL;     int *out = NULL;
2052     Finley_Mesh* mesh=m_finleyMesh.get();     Finley_Mesh* mesh=m_finleyMesh.get();
# Line 2095  int MeshAdapter::getNumberOfTagsInUse(in Line 2283  int MeshAdapter::getNumberOfTagsInUse(in
2283    }    }
2284    return numTags;    return numTags;
2285  }  }
2286  int* MeshAdapter::borrowListOfTagsInUse(int functionSpaceCode) const  
2287    const int* MeshAdapter::borrowListOfTagsInUse(int functionSpaceCode) const
2288  {  {
2289    Finley_Mesh* mesh=m_finleyMesh.get();    Finley_Mesh* mesh=m_finleyMesh.get();
2290    index_t* tags=NULL;    index_t* tags=NULL;
# Line 2161  bool MeshAdapter::canTag(int functionSpa Line 2350  bool MeshAdapter::canTag(int functionSpa
2350    }    }
2351  }  }
2352    
2353    AbstractDomain::StatusType MeshAdapter::getStatus() const
2354    {
2355      Finley_Mesh* mesh=m_finleyMesh.get();
2356      return Finley_Mesh_getStatus(mesh);
2357    }
2358    
2359    
2360    
2361  }  // end of namespace  }  // end of namespace

Legend:
Removed from v.2315  
changed lines
  Added in v.2642

  ViewVC Help
Powered by ViewVC 1.1.26