Changeset 16304


Ignore:
Timestamp:
10/07/13 08:24:10 (11 years ago)
Author:
Mathieu Morlighem
Message:

CHG: reverting to version 16296

Location:
issm/trunk-jpl
Files:
9 deleted
18 edited
4 copied

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Makefile.am

    r16301 r16304  
    542542
    543543#}}}
    544 #Responses sources  {{{
    545 responses_sources =  ./classes/Massfluxatgate.h \
    546                                          ./modules/ModelProcessorx/CreateOutputDefinitions.cpp
    547 #}}}
    548544#Damage sources  {{{
    549545damage_sources =  ./analyses/damage_core.cpp\
     
    882878endif
    883879
    884 if RESPONSES
    885 issm_sources  +=  $(responses_sources)
    886 endif
    887 
    888880if PETSC
    889881issm_sources  +=  $(petsc_sources)
  • issm/trunk-jpl/src/c/classes/IoModel.cpp

    r16301 r16304  
    891891}
    892892/*}}}*/
    893 /*FUNCTION IoModel::FetchMultipleData(char***       pstrings,int* pnumstrings,int data_enum){{{*/
    894 void  IoModel::FetchMultipleData(char*** pstrings,int* pnumstrings,int data_enum){
    895 
    896         int my_rank;
    897 
    898         int i;
    899         int num_instances;
    900 
    901         /*output: */
    902         int   numstrings=0;
    903         char** strings=NULL;
    904 
    905         /*intermediary: */
    906         char* string=NULL;
    907         int   string_size;
    908         int*   code=NULL;
    909         FILE** file_instances=NULL;
    910         FILE* file_id=NULL;
    911 
    912         /*recover my_rank:*/
    913         my_rank=IssmComm::GetRank();
    914 
    915         /*Get file pointers to beginning of the data (multiple instances of it): */
    916         file_instances=this->SetFilePointerToData(&codes,NULL,&num_instances,data_enum);
    917 
    918         if(num_instances){
    919 
    920                 strings=xNew<char*>(num_instances);
    921 
    922                 for(i=0;i<num_instances;i++){
    923 
    924                         file_id=file_instances[i];
    925 
    926                         /*check we are indeed finding a string, not something else: */
    927                         if(codes[i]!=4)_error_("expecting a string for enum " << EnumToStringx(data_enum));
    928 
    929                         /*We have to read a string from disk. First read the dimensions of the string, then the string: */
    930                         if(my_rank==0){ 
    931                                 if(fread(&string_size,sizeof(int),1,file_id)!=1) _error_("could not read length of string ");
    932                         }
    933 
    934                         ISSM_MPI_Bcast(&string_size,1,ISSM_MPI_INT,0,IssmComm::GetComm());
    935 
    936                         /*Now allocate string: */
    937                         if(string_size){
    938                                 string=xNew<char>((string_size+1));
    939                                 string[string_size]='\0';
    940 
    941                                 /*Read string on node 0, then broadcast: */
    942                                 if(my_rank==0){ 
    943                                         if(fread(string,string_size*sizeof(char),1,file_id)!=1)_error_(" could not read string ");
    944                                 }
    945                                 ISSM_MPI_Bcast(string,string_size,ISSM_MPI_CHAR,0,IssmComm::GetComm());
    946                         }
    947                         else{
    948                                 string=xNew<char>(1);
    949                                 string[0]='\0';
    950                         }
    951                         strings[i]=string;
    952                 }
    953         }
    954        
    955         /*Assign output pointers: */
    956         *pstrings=strings;
    957         *pnumstrings=num_instances;
    958 }
    959 /*}}}*/
    960893/*FUNCTION IoModel::FetchData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pM,int data_enum){{{*/
    961894void  IoModel::FetchData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){
     
    1042975        *pndims=ndims;
    1043976        *pnumrecords=numrecords;
    1044 }
    1045 /*}}}*/
    1046 /*FUNCTION IoModel::FetchMultipleData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pM,int data_enum){{{*/
    1047 void  IoModel::FetchMultipleData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){
    1048 
    1049         int i;
    1050         int num_instances;
    1051         int my_rank;
    1052        
    1053         FILE** file_instances=NULL;
    1054         FILE* file_id=NULL;
    1055 
    1056         /*output: */
    1057         IssmDouble** matrices=NULL;
    1058         int*     mdims=NULL;
    1059         int*     ndims=NULL;
    1060         int      numrecords=0;
    1061 
    1062         /*intermediary: */
    1063         int     M, N;
    1064         IssmPDouble *pmatrix = NULL;
    1065         IssmDouble *matrix = NULL;
    1066         int     code;
    1067 
    1068         /*recover my_rank:*/
    1069         my_rank=IssmComm::GetRank();
    1070        
    1071         /*Get file pointers to beginning of the data (multiple instances of it): */
    1072         file_instances=this->SetFilePointerToData(&codes,NULL,&num_instances,data_enum);
    1073 
    1074         if(num_instances){
    1075 
    1076                 /*Allocate matrices :*/
    1077                 matrices=xNew<IssmDouble*>(numrecords);
    1078                 mdims=xNew<int>(numrecords);
    1079                 ndims=xNew<int>(numrecords);
    1080 
    1081                 for(i=0;i<num_instances;i++){
    1082 
    1083                         file_id=file_instances[i];
    1084                         code=codes[i];
    1085 
    1086                         if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(data_enum));
    1087                        
    1088                         /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */
    1089                         /*numberofelements: */
    1090                         if(my_rank==0){ 
    1091                                 if(fread(&M,sizeof(int),1,file_id)!=1) _error_("could not read number of rows for matrix ");
    1092                         }
    1093                         ISSM_MPI_Bcast(&M,1,ISSM_MPI_INT,0,IssmComm::GetComm());
    1094 
    1095                         if(my_rank==0){ 
    1096                                 if(fread(&N,sizeof(int),1,file_id)!=1) _error_("could not read number of columns for matrix ");
    1097                         }
    1098                         ISSM_MPI_Bcast(&N,1,ISSM_MPI_INT,0,IssmComm::GetComm());
    1099 
    1100                         /*Now allocate matrix: */
    1101                         if(M*N){
    1102                                 pmatrix=xNew<IssmPDouble>(M*N);
    1103 
    1104                                 /*Read matrix on node 0, then broadcast: */
    1105                                 if(my_rank==0){ 
    1106                                         if(fread(pmatrix,M*N*sizeof(IssmPDouble),1,file_id)!=1) _error_("could not read matrix ");
    1107                                 }
    1108                                 ISSM_MPI_Bcast(pmatrix,M*N,ISSM_MPI_PDOUBLE,0,IssmComm::GetComm());
    1109 
    1110                                 _assert_(this->independents);
    1111                                 if (this->independents[data_enum]){
    1112                                         /*this data has already been checked out! So cancel all that we've done here, and return
    1113                                          * the data[data_enum] directly: */
    1114                                         matrix=this->data[data_enum];
    1115                                 }
    1116                                 else{
    1117                                         matrix=xNew<IssmDouble>(M*N);
    1118                                         for (int i=0;i<M*N;++i) matrix[i]=pmatrix[i];
    1119                                 }
    1120                                 xDelete<IssmPDouble>(matrix);
    1121                         }
    1122                         else
    1123                                 matrix=NULL;
    1124                        
    1125                         /*Assign: */
    1126                         mdims[i]=M;
    1127                         matrices[i]=matrix;
    1128                         ndims[i]=N;
    1129                 }
    1130         }
    1131 
    1132         /*Assign output pointers: */
    1133         *pmatrices=matrices;
    1134         *pmdims=mdims;
    1135         *pndims=ndims;
    1136         *pnumrecords=num_instances;
    1137977}
    1138978/*}}}*/
     
    14171257        ISSM_MPI_Bcast(&record_code,1,ISSM_MPI_INT,0,IssmComm::GetComm());
    14181258        ISSM_MPI_Bcast(&vector_type,1,ISSM_MPI_INT,0,IssmComm::GetComm());
     1259        if(record_code==5) ISSM_MPI_Bcast(&vector_type,1,ISSM_MPI_INT,0,IssmComm::GetComm());
    14191260
    14201261        /*Assign output pointers:*/
     
    14251266}
    14261267/*}}}*/
    1427 /*FUNCTION IoModel::SetFilePointersToData{{{*/
    1428 FILE** IoModel::SetFilePointersToData(int** pcodes,int** pvector_types, int* pnum_instances, int data_enum){
    1429 
    1430         int  my_rank;
    1431         int  found         = 0;
    1432         int  record_enum;
    1433         int  record_length;
    1434         int  record_code;       //1 to 7 number
    1435         int  vector_type;       //1 to 7 number
    1436         int* vector_types   = NULL;
    1437         int* codes= NULL;
    1438         int  num_instances  = 0;
    1439         int  counter;
    1440         FILE** file_instances =NULL;
    1441 
    1442         /*recover my_rank:*/
    1443         my_rank=IssmComm::GetRank();
    1444 
    1445         /*Go find in the binary file, the data we want to fetch and count the number of
    1446          * instances it appears: */
    1447         if(my_rank==0){
    1448 
    1449                 /*First set FILE* position to the beginning of the file: */
    1450                 fseek(fid,0,SEEK_SET);
    1451 
    1452                 /*Now march through file looking for the correct data identifier: */
    1453                 for(;;){
    1454                         /*Read enum for this size of first string name: */
    1455                         if(fread(&record_enum,sizeof(int),1,fid)==0){
    1456                                 /*Ok, we have reached the end of the file. break: */
    1457                                 break;
    1458                         }
    1459 
    1460                         /*Is this the record sought for? : */
    1461                         if (data_enum==record_enum) num_instances++;
    1462 
    1463                         /*Read the record length, and use it to skip the record: */
    1464                         if(fread(&record_length,sizeof(int),1,fid)!=1) _error_("Could not read record_length");
    1465                         fseek(fid,record_length,SEEK_CUR);
    1466                 }
    1467 
    1468                 /*Ok, initialize the number of file handles we are going to return: */
    1469                 if(num_instances){
    1470                         file_instances = xNew<FILE*>(num_instances);
    1471                         codes = xNew<int>(num_instances);
    1472                         vector_types = xNew<int>(num_instances);
    1473                 }
    1474 
    1475        
    1476                 /*Reset FILE* position to the beginning of the file, and start again, this time saving the data information
    1477                  * as we find it: */
    1478                 counter=0;
    1479                 fseek(fid,0,SEEK_SET);
    1480 
    1481                 for(;;){
    1482                         /*Read enum for this size of first string name: */
    1483                         if(fread(&record_enum,sizeof(int),1,fid)==0){
    1484                                 /*Ok, we have reached the end of the file. break: */
    1485                                 break;
    1486                         }
    1487 
    1488                         /*Is this the record sought for? : */
    1489                         if (data_enum==record_enum){
    1490                                 /*Ok, we have found the correct string. Pass the record length, and read data type code: */
    1491                                 fseek(fid,sizeof(int),SEEK_CUR);
    1492                                 if(fread(&record_code,sizeof(int),1,fid)!=1) _error_("Could not read record_code");
    1493 
    1494                                 /*if record_code points to a vector, get its type (nodal or elementary): */
    1495                                 if(5<=record_code && record_code<=7){
    1496                                         if(fread(&vector_type,sizeof(int),1,fid)!=1) _error_("Could not read vector_type");
    1497                                 }
    1498                                 codes[counter]=record_code;
    1499                                 vector_types[counter]=vector_type;
    1500                                 file_instances[counter]=fid;
    1501                                 counter++;
    1502                                 break;
    1503                         }
    1504                         else{
    1505                                 /*This is not the correct string, read the record length, and use it to skip this record: */
    1506                                 if(fread(&record_length,sizeof(int),1,fid)!=1) _error_("Could not read record_length");
    1507                                 /*skip: */
    1508                                 fseek(fid,record_length,SEEK_CUR);
    1509                         }
    1510                 }
    1511         }
    1512 
    1513         /*Broadcast data: */
    1514         ISSM_MPI_Bcast(&num_instances,1,ISSM_MPI_INT,0,IssmComm::GetComm());
    1515         ISSM_MPI_Bcast(codes,num_instances,ISSM_MPI_INT,0,IssmComm::GetComm());
    1516         ISSM_MPI_Bcast(vector_types,num_instances,ISSM_MPI_INT,0,IssmComm::GetComm());
    1517 
    1518         /*Assign output pointers:*/
    1519         *pcodes=codes;
    1520         *pnum_instances=num_instances;
    1521         if(pvector_types)*pvector_types=vector_types;
    1522         return file_instances;
    1523 }
    1524 /*}}}*/
  • issm/trunk-jpl/src/c/classes/IoModel.h

    r16301 r16304  
    7676                void        FetchData(char***   pstringarray,int* pnumstrings,int data_enum);
    7777                void        FetchData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
    78                 void        FetchMultipleData(char***   pstringarray,int* pnumstrings,int data_enum);
    79                 void        FetchMultipleData(IssmDouble*** pmatrixarray,int** pmdims,int** pndims, int* pnumrecords,int data_enum);
    8078                void        FetchData(Option **poption,int data_enum);
    8179                void        FetchData(int num,...);
     
    8381                void        FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value);
    8482                void        LastIndex(int *pindex);
    85                 FILE**      SetFilePointersToData(int** pcodes,int** pvector_types, int data_enum);
    8683                FILE*       SetFilePointerToData(int* pcode,int* pvector_type, int data_enum);
    8784                void        DeclareIndependents(void);
  • issm/trunk-jpl/src/c/classes/classes.h

    r16301 r16304  
    1717#include "./IndependentObject.h"
    1818#include "./Segment.h"
    19 #include "./Massfluxatgate.h"
    2019
    2120/*Constraints: */
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp

    r16301 r16304  
    2424        IssmDouble  time;
    2525        bool        ispdd,isdelta18o;
     26
     27        /*parameters for mass flux: {{{*/
     28        int          mass_flux_num_profiles     = 0;
     29        bool         qmu_mass_flux_present      = false;
     30        bool         autodiff_mass_flux_present = false;
     31        bool         mass_flux_present          = false;
     32        IssmDouble **array                      = NULL;
     33        int         *mdims_array                = NULL;
     34        int         *ndims_array                = NULL;
     35        IssmDouble  *temp_matrix                = NULL;
     36        int          temp_m,temp_n;
     37        IssmDouble  *matrix                     = NULL;
     38        int          count;
     39        /*}}}*/
    2640
    2741        if(*pparameters)return; //do not create parameters twice!
     
    137151        iomodel->DeleteData(requestedoutputs,MasstransportRequestedOutputsEnum);
    138152
    139         /*Output definitions dataset: */
    140         CreateOutputDefinitions(&parameters,iomodel);
     153        /*Deal with mass flux segments: {{{*/
     154        iomodel->FetchData(&qmu_mass_flux_present,QmuMassFluxSegmentsPresentEnum);
     155        iomodel->FetchData(&autodiff_mass_flux_present,AutodiffMassFluxSegmentsPresentEnum);
     156
     157        if(qmu_mass_flux_present || autodiff_mass_flux_present)mass_flux_present=true;
     158        else mass_flux_present=false;
     159        parameters->AddObject(new BoolParam(MassFluxSegmentsPresentEnum,mass_flux_present));
     160
     161        if(mass_flux_present){
     162
     163                /*Fetch the mass flux segments necessary to compute the mass fluxes.  Build a DoubleMatArrayParam object out of them: */
     164                iomodel->FetchData(&array,&mdims_array,&ndims_array,&mass_flux_num_profiles,MassFluxSegmentsEnum);
     165                if(mass_flux_num_profiles==0)_error_("mass_flux_num_profiles is 0, when MassFlux computations were requested!");
     166
     167                /*Go through segments, and extract those that belong to this cpu: */
     168                for(i=0;i<mass_flux_num_profiles;i++){
     169                        temp_matrix=array[i];
     170                        temp_m=mdims_array[i];
     171                        temp_n=ndims_array[i];
     172                        _assert_(temp_n==5);
     173
     174                        m=0;
     175                        for(j=0;j<temp_m;j++){
     176                                if (  iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1] )m++;
     177                        }
     178                        if(m){
     179                                matrix=xNewZeroInit<IssmDouble>(5*m);
     180                                count=0;
     181                                for(j=0;j<temp_m;j++){
     182                                        if (iomodel->my_elements[reCast<int>(*(temp_matrix+5*j+4))-1]){
     183                                                for(k=0;k<5;k++)*(matrix+5*count+k)=*(temp_matrix+5*j+k);
     184                                                count++;
     185                                        }
     186                                }
     187                        }
     188                        else{
     189                                matrix=NULL;
     190                        }
     191
     192                        /*Assign: */
     193                        array[i]=matrix;
     194                        mdims_array[i]=m;
     195                        ndims_array[i]=5;
     196
     197                        /*Free temporary matrix: */
     198                        xDelete<IssmDouble>(temp_matrix);
     199                }
     200
     201                /*Ok, we have an array of segments, different on every cpu. Create a DoubleMatArrayParam object with it: */
     202                parameters->AddObject(new DoubleMatArrayParam(MassFluxSegmentsEnum,array,mass_flux_num_profiles,mdims_array,ndims_array));
     203
     204                /*Free data: */
     205                for(i=0;i<mass_flux_num_profiles;i++){
     206                        IssmDouble* matrix=array[i];
     207                        xDelete<IssmDouble>(matrix);
     208                }
     209                xDelete<int>(mdims_array);
     210                xDelete<int>(ndims_array);
     211                xDelete<IssmDouble*>(array);
     212        }
     213        /*}}}*/
    141214
    142215        /*Solution specific parameters*/
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h

    r16301 r16304  
    160160void DistributeNumDofs(DofIndexing* index,int analysis_type,int node_type);
    161161
    162 #ifdef _HAVE_RESPONSES_
    163 void CreateParametersOutputDefinitions(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type);
    164162#endif
    165 
    166 #endif
  • issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h

    r16301 r16304  
    2727        AutodiffFovForwardIndicesEnum,
    2828        AutodiffFosReverseIndexEnum,
     29        AutodiffMassFluxSegmentsPresentEnum,
    2930        AutodiffKeepEnum,
    3031        AutodiffObufsizeEnum,
     
    213214        MasstransportRequestedOutputsEnum,
    214215        QmuIsdakotaEnum,
     216        MassFluxSegmentsEnum,
     217        MassFluxSegmentsPresentEnum,
     218        QmuMassFluxSegmentsPresentEnum,
    215219        QmuNumberofpartitionsEnum,
    216220        QmuNumberofresponsesEnum,
     
    539543        WaterColumnOldEnum,
    540544        /*}}}*/
    541         /*Output Definitions{{{*/
    542         OutputdefinitionEnum,
    543         OutputdefinitionEnumsEnum,
    544         MassfluxatgateEnum,
    545         MassfluxatgateNameEnum,
    546         MassfluxatgateSegmentsEnum,
    547         /*}}}*/
    548545        /*Responses{{{*/
    549546        MinVelEnum,
  • issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp

    r16301 r16304  
    3535                case AutodiffFovForwardIndicesEnum : return "AutodiffFovForwardIndices";
    3636                case AutodiffFosReverseIndexEnum : return "AutodiffFosReverseIndex";
     37                case AutodiffMassFluxSegmentsPresentEnum : return "AutodiffMassFluxSegmentsPresent";
    3738                case AutodiffKeepEnum : return "AutodiffKeep";
    3839                case AutodiffObufsizeEnum : return "AutodiffObufsize";
     
    221222                case MasstransportRequestedOutputsEnum : return "MasstransportRequestedOutputs";
    222223                case QmuIsdakotaEnum : return "QmuIsdakota";
     224                case MassFluxSegmentsEnum : return "MassFluxSegments";
     225                case MassFluxSegmentsPresentEnum : return "MassFluxSegmentsPresent";
     226                case QmuMassFluxSegmentsPresentEnum : return "QmuMassFluxSegmentsPresent";
    223227                case QmuNumberofpartitionsEnum : return "QmuNumberofpartitions";
    224228                case QmuNumberofresponsesEnum : return "QmuNumberofresponses";
     
    528532                case TriaP1ElementResultEnum : return "TriaP1ElementResult";
    529533                case WaterColumnOldEnum : return "WaterColumnOld";
    530                 case OutputdefinitionEnum : return "Outputdefinition";
    531                 case OutputdefinitionEnumsEnum : return "OutputdefinitionEnums";
    532                 case MassfluxatgateEnum : return "Massfluxatgate";
    533                 case MassfluxatgateNameEnum : return "MassfluxatgateName";
    534                 case MassfluxatgateSegmentsEnum : return "MassfluxatgateSegments";
    535534                case MinVelEnum : return "MinVel";
    536535                case MaxVelEnum : return "MaxVel";
  • issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp

    r16301 r16304  
    3535              else if (strcmp(name,"AutodiffFovForwardIndices")==0) return AutodiffFovForwardIndicesEnum;
    3636              else if (strcmp(name,"AutodiffFosReverseIndex")==0) return AutodiffFosReverseIndexEnum;
     37              else if (strcmp(name,"AutodiffMassFluxSegmentsPresent")==0) return AutodiffMassFluxSegmentsPresentEnum;
    3738              else if (strcmp(name,"AutodiffKeep")==0) return AutodiffKeepEnum;
    3839              else if (strcmp(name,"AutodiffObufsize")==0) return AutodiffObufsizeEnum;
     
    136137              else if (strcmp(name,"InversionCostFunctionsCoefficients")==0) return InversionCostFunctionsCoefficientsEnum;
    137138              else if (strcmp(name,"InversionCostFunctions")==0) return InversionCostFunctionsEnum;
    138               else if (strcmp(name,"InversionGradientScaling")==0) return InversionGradientScalingEnum;
    139139         else stage=2;
    140140   }
    141141   if(stage==2){
    142               if (strcmp(name,"InversionIscontrol")==0) return InversionIscontrolEnum;
     142              if (strcmp(name,"InversionGradientScaling")==0) return InversionGradientScalingEnum;
     143              else if (strcmp(name,"InversionIscontrol")==0) return InversionIscontrolEnum;
    143144              else if (strcmp(name,"InversionTao")==0) return InversionTaoEnum;
    144145              else if (strcmp(name,"InversionIncompleteAdjoint")==0) return InversionIncompleteAdjointEnum;
     
    224225              else if (strcmp(name,"MasstransportRequestedOutputs")==0) return MasstransportRequestedOutputsEnum;
    225226              else if (strcmp(name,"QmuIsdakota")==0) return QmuIsdakotaEnum;
     227              else if (strcmp(name,"MassFluxSegments")==0) return MassFluxSegmentsEnum;
     228              else if (strcmp(name,"MassFluxSegmentsPresent")==0) return MassFluxSegmentsPresentEnum;
     229              else if (strcmp(name,"QmuMassFluxSegmentsPresent")==0) return QmuMassFluxSegmentsPresentEnum;
    226230              else if (strcmp(name,"QmuNumberofpartitions")==0) return QmuNumberofpartitionsEnum;
    227231              else if (strcmp(name,"QmuNumberofresponses")==0) return QmuNumberofresponsesEnum;
     
    256260              else if (strcmp(name,"SurfaceforcingsMassBalance")==0) return SurfaceforcingsMassBalanceEnum;
    257261              else if (strcmp(name,"SurfaceforcingsIspdd")==0) return SurfaceforcingsIspddEnum;
    258               else if (strcmp(name,"SurfaceforcingsDesfac")==0) return SurfaceforcingsDesfacEnum;
     262         else stage=3;
     263   }
     264   if(stage==3){
     265              if (strcmp(name,"SurfaceforcingsDesfac")==0) return SurfaceforcingsDesfacEnum;
    259266              else if (strcmp(name,"SurfaceforcingsS0p")==0) return SurfaceforcingsS0pEnum;
    260267              else if (strcmp(name,"SurfaceforcingsIssmbgradients")==0) return SurfaceforcingsIssmbgradientsEnum;
    261268              else if (strcmp(name,"SurfaceforcingsMonthlytemperatures")==0) return SurfaceforcingsMonthlytemperaturesEnum;
    262          else stage=3;
    263    }
    264    if(stage==3){
    265               if (strcmp(name,"SurfaceforcingsHref")==0) return SurfaceforcingsHrefEnum;
     269              else if (strcmp(name,"SurfaceforcingsHref")==0) return SurfaceforcingsHrefEnum;
    266270              else if (strcmp(name,"SurfaceforcingsSmbref")==0) return SurfaceforcingsSmbrefEnum;
    267271              else if (strcmp(name,"SurfaceforcingsBPos")==0) return SurfaceforcingsBPosEnum;
     
    379383              else if (strcmp(name,"Input")==0) return InputEnum;
    380384              else if (strcmp(name,"IntInput")==0) return IntInputEnum;
    381               else if (strcmp(name,"IntParam")==0) return IntParamEnum;
     385         else stage=4;
     386   }
     387   if(stage==4){
     388              if (strcmp(name,"IntParam")==0) return IntParamEnum;
    382389              else if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum;
    383390              else if (strcmp(name,"TransientParam")==0) return TransientParamEnum;
    384391              else if (strcmp(name,"Matice")==0) return MaticeEnum;
    385          else stage=4;
    386    }
    387    if(stage==4){
    388               if (strcmp(name,"Matpar")==0) return MatparEnum;
     392              else if (strcmp(name,"Matpar")==0) return MatparEnum;
    389393              else if (strcmp(name,"Node")==0) return NodeEnum;
    390394              else if (strcmp(name,"Numericalflux")==0) return NumericalfluxEnum;
     
    502506              else if (strcmp(name,"StressTensorxz")==0) return StressTensorxzEnum;
    503507              else if (strcmp(name,"StressTensoryy")==0) return StressTensoryyEnum;
    504               else if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum;
     508         else stage=5;
     509   }
     510   if(stage==5){
     511              if (strcmp(name,"StressTensoryz")==0) return StressTensoryzEnum;
    505512              else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum;
    506513              else if (strcmp(name,"GiaCrossSectionShape")==0) return GiaCrossSectionShapeEnum;
    507514              else if (strcmp(name,"GiadWdt")==0) return GiadWdtEnum;
    508          else stage=5;
    509    }
    510    if(stage==5){
    511               if (strcmp(name,"GiaW")==0) return GiaWEnum;
     515              else if (strcmp(name,"GiaW")==0) return GiaWEnum;
    512516              else if (strcmp(name,"P0")==0) return P0Enum;
    513517              else if (strcmp(name,"P1")==0) return P1Enum;
     
    540544              else if (strcmp(name,"TriaP1ElementResult")==0) return TriaP1ElementResultEnum;
    541545              else if (strcmp(name,"WaterColumnOld")==0) return WaterColumnOldEnum;
    542               else if (strcmp(name,"Outputdefinition")==0) return OutputdefinitionEnum;
    543               else if (strcmp(name,"OutputdefinitionEnums")==0) return OutputdefinitionEnumsEnum;
    544               else if (strcmp(name,"Massfluxatgate")==0) return MassfluxatgateEnum;
    545               else if (strcmp(name,"MassfluxatgateName")==0) return MassfluxatgateNameEnum;
    546               else if (strcmp(name,"MassfluxatgateSegments")==0) return MassfluxatgateSegmentsEnum;
    547546              else if (strcmp(name,"MinVel")==0) return MinVelEnum;
    548547              else if (strcmp(name,"MaxVel")==0) return MaxVelEnum;
  • issm/trunk-jpl/src/m/classes/autodiff.m

    r16298 r16304  
    8383                        %early return
    8484                        if ~obj.isautodiff,
     85                                WriteData(fid,'data',false,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean');
    8586                                WriteData(fid,'data',false,'enum',AutodiffKeepEnum(),'format','Boolean');
    8687                                return;
     
    197198                        end
    198199                        %}}}
     200                        %deal with mass fluxes:  {{{
     201                        mass_flux_segments=cell(0,1);
     202                        for i=1:num_dependent_objects,
     203                                dep=obj.dependents{i};
     204                                if strcmpi(dep.name,'MassFlux'),
     205                                        mass_flux_segments{end+1,1}=dep.segments;
     206                                end
     207                        end
     208                        if ~isempty(mass_flux_segments),
     209                                WriteData(fid,'data',mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray');
     210                                flag=true;
     211                        else
     212                                flag=false;
     213                        end
     214                        WriteData(fid,'data',flag,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean');
     215                        %}}}
    199216                        %deal with trace keep on: {{{
    200217                        keep=false;
  • issm/trunk-jpl/src/m/classes/autodiff.py

    r16298 r16304  
    8686                #early return
    8787                if not self.isautodiff:
     88                        WriteData(fid,'data',False,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean')
    8889                        WriteData(fid,'data',False,'enum',AutodiffKeepEnum(),'format','Boolean')
    8990                        return
     
    181182                        WriteData(fid,'data',indices,'enum',AutodiffFovForwardIndicesEnum(),'format','IntMat','mattype',3)
    182183                #}}}
     184                #deal with mass fluxes:  {{{
     185                mass_flux_segments=[dep.segments for dep in self.dependents if strcmpi(dep.name,'MassFlux')]
     186
     187                if mass_flux_segments:
     188                        WriteData(fid,'data',mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray')
     189                        flag=True
     190                else:
     191                        flag=False
     192                WriteData(fid,'data',flag,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean')
     193                #}}}
    183194                #deal with trace keep on: {{{
    184195                keep=False
  • issm/trunk-jpl/src/m/classes/damage.m

    r16299 r16304  
    110110                        disp(sprintf('   Damage:\n'));
    111111
    112                         fielddisplay(obj,'D','damage tensor (vector)');
     112                        fielddisplay(obj,'D','damage tensor (scalar)');
    113113                        fielddisplay(obj,'law','damage law (string) from {''undamaged'',''pralong''}');
    114114                        fielddisplay(obj,'spcdamage','damage constraints (NaN means no constraint)');
  • issm/trunk-jpl/src/m/classes/model.m

    r16297 r16304  
    4545
    4646                results          = 0;
    47                 outputdefinition = 0;
    4847                radaroverlay     = 0;
    4948                miscellaneous    = 0;
     
    10721071                        md.radaroverlay     = radaroverlay();
    10731072                        md.results          = struct();
    1074                         md.outputdefinition = outputdefinition();
    10751073                        md.miscellaneous    = miscellaneous();
    10761074                        md.private          = private();
     
    11091107                        disp(sprintf('%19s: %-22s -- %s','inversion'       ,['[1x1 ' class(obj.inversion) ']'],'parameters for inverse methods'));
    11101108                        disp(sprintf('%19s: %-22s -- %s','qmu'             ,['[1x1 ' class(obj.qmu) ']'],'dakota properties'));
    1111                         disp(sprintf('%19s: %-22s -- %s','outputdefinition',['[1x1 ' class(obj.outputdefinition) ']'],'output definition'));
    11121109                        disp(sprintf('%19s: %-22s -- %s','results'         ,['[1x1 ' class(obj.results) ']'],'model results'));
    11131110                        disp(sprintf('%19s: %-22s -- %s','radaroverlay'    ,['[1x1 ' class(obj.radaroverlay) ']'],'radar image for plot overlay'));
  • issm/trunk-jpl/src/m/classes/qmu.m

    r16297 r16304  
    1717                variabledescriptors         = {};
    1818                responsedescriptors         = {};
     19                mass_flux_profile_directory = NaN;
     20                mass_flux_profiles          = NaN;
     21                mass_flux_segments          = {};
    1922                adjacency                   = NaN;
    2023                vertex_weight               = NaN;
     
    130133                        fielddisplay(obj,'responsedescriptors','');
    131134                        fielddisplay(obj,'method','array of dakota_method class');
     135                        fielddisplay(obj,'mass_flux_profile_directory','directory for mass flux profiles');
     136                        fielddisplay(obj,'mass_flux_profiles','list of mass_flux profiles');
     137                        fielddisplay(obj,'mass_flux_segments','');
    132138                        fielddisplay(obj,'adjacency','');
    133139                        fielddisplay(obj,'vertex_weight','weight applied to each mesh vertex');
     
    145151                        WriteData(fid,'object',obj,'fieldname','variabledescriptors','format','StringArray');
    146152                        WriteData(fid,'object',obj,'fieldname','responsedescriptors','format','StringArray');
     153                        if ~isempty(obj.mass_flux_segments),
     154                                WriteData(fid,'data',obj.mass_flux_segments,'enum',MassFluxSegmentsEnum,'format','MatArray');
     155                                flag=true;
     156                        else
     157                                flag=false;
     158                        end
     159                        WriteData(fid,'data',flag,'enum',QmuMassFluxSegmentsPresentEnum,'format','Boolean');
    147160                end % }}}
    148161        end
  • issm/trunk-jpl/src/m/classes/qmu.py

    r16297 r16304  
    2727                self.variabledescriptors         = []
    2828                self.responsedescriptors         = []
     29                self.mass_flux_profile_directory = float('NaN')
     30                self.mass_flux_profiles          = float('NaN')
     31                self.mass_flux_segments          = []
    2932                self.adjacency                   = float('NaN')
    3033                self.vertex_weight               = float('NaN')
     
    123126                s+="%s\n" % fielddisplay(self,'responsedescriptors','')
    124127                s+="%s\n" % fielddisplay(self,'method','array of dakota_method class')
     128                s+="%s\n" % fielddisplay(self,'mass_flux_profile_directory','directory for mass flux profiles')
     129                s+="%s\n" % fielddisplay(self,'mass_flux_profiles','list of mass_flux profiles')
     130                s+="%s\n" % fielddisplay(self,'mass_flux_segments','')
    125131                s+="%s\n" % fielddisplay(self,'adjacency','')
    126132                s+="%s\n" % fielddisplay(self,'vertex_weight','weight applied to each mesh vertex')
     
    138144                WriteData(fid,'object',self,'fieldname','variabledescriptors','format','StringArray')
    139145                WriteData(fid,'object',self,'fieldname','responsedescriptors','format','StringArray')
     146                if not self.mass_flux_segments:
     147                        WriteData(fid,'data',self.mass_flux_segments,'enum',MassFluxSegmentsEnum(),'format','MatArray');
     148                        flag=True;
     149                else:
     150                        flag=False;
     151                WriteData(fid,'data',flag,'enum',QmuMassFluxSegmentsPresentEnum(),'format','Boolean');
    140152        # }}}
  • issm/trunk-jpl/src/m/contrib/paraview/exportVTK.m

    r16303 r16304  
    1 function exportVTK(filename,model)
     1function exportVTK(filename,model,Solution)
    22% vtk export
    33% function exportVTK(filename,model,Solution)
     
    1919mkdir(filename);
    2020
    21 %get the element related variables
    2221points=[model.mesh.x model.mesh.y model.mesh.z];
    2322[num_of_points,dim]=size(points);
    2423[num_of_elt]=size(model.mesh.elements,1);
    2524[point_per_elt]=size(model.mesh.elements,2);
     25sol_enum=EnumToString(Solution);
     26
     27sol_struct=model.results.(sol_enum);
    2628
    2729%Select the type of element function of the number of nodes per elements
     
    3436end
    3537
    36 %sol_enum=EnumToString(Solution);
     38%looking for multiple time steps
     39num_of_timesteps=size(sol_struct,2);
    3740
    38 %this is the result structure
    39 res_struct=model.results;
     41%getting the number of fields in the solution
     42fieldnames=fields(sol_struct(1));
     43num_of_fields=length(fieldnames);
    4044
    41 %Getting all the solutions of the model
    42 solnames=fields(res_struct);
    43 num_of_sols=length(solnames);
     45if num_of_timesteps==1; %just one timestep only write one file
    4446
    45 %building solution structure
    46 for i=1:num_of_sols
    47         sol_struct{i}=res_struct.(solnames{i});
    48 end
    49 
    50 %looking for multiple time steps
    51 num_of_timesteps=size(sol_struct{1},2);
    52 
    53 for i=1:num_of_timesteps;
    54         %by default, we take the timestep from the first solution sturcture
    55         timestep=sol_struct{1}(i).step;
    56        
    57         FID = fopen(strcat(path,filesep,name,filesep,name,'.vtk',int2str(timestep),'.vtk'),'w+');
     47        FID = fopen(strcat(path,filesep,name,filesep,name,'.vtk'),'w+');
    5848        fprintf(FID,'# vtk DataFile Version 2.0 \n');
    5949        fprintf(FID,'Data for run %s \n',model.miscellaneous.name);
    6050        fprintf(FID,'ASCII \n');
    6151        fprintf(FID,'DATASET UNSTRUCTURED_GRID \n');
    62        
     52
    6353        fprintf(FID,'POINTS %d float\n',num_of_points);
    6454        if(dim==3);
     
    6959        P=[points zeros(num_of_points,3-dim)];
    7060        fprintf(FID,s,P');
    71  
     61
    7262        fprintf(FID,'CELLS %d %d\n',num_of_elt,num_of_elt*(point_per_elt+1));
    7363        s='%d';
    7464        for k=1:point_per_elt
    75                 s=horzcat(s,{' %d'});
     65    s=horzcat(s,{' %d'});
    7666  end
    7767        s=cell2mat(horzcat(s,{'\n'}));
    7868        fprintf(FID,s,[(point_per_elt)*ones(num_of_elt,1) model.mesh.elements-1]');
    79  
     69
    8070        fprintf(FID,'CELL_TYPES %d\n',num_of_elt);
    8171        s='%d\n';
    8272        fprintf(FID,s,celltype*ones(num_of_elt,1));
    83        
    84         %loop over the different solution structures
    85         for j=1:num_of_sols
    8673
    87                 %getting the number of fields in the solution
    88                 fieldnames=fields(sol_struct{j}(i));
    89                 num_of_fields=length(fieldnames);
    90                
     74        %check which field is a real result and print   
     75        fprintf(FID,'POINT_DATA %s \n',num2str(num_of_points));
     76        for j=1:num_of_fields
     77
     78                if (length(sol_struct(1).(fieldnames{j}))==num_of_points);
     79                        fprintf(FID,'SCALARS %s float 1 \n',fieldnames{j});
     80                        fprintf(FID,'LOOKUP_TABLE default\n');
     81                        s='%e\n';
     82                        fprintf(FID,s,sol_struct.(fieldnames{j}));
     83          end
     84  end
     85                fclose(FID);
     86else
     87        for i=1:num_of_timesteps;
     88                timestep=sol_struct(i).step;
     89                FID = fopen(strcat(path,filesep,name,filesep,name,'.vtk',int2str(timestep),'.vtk'),'w+');
     90                fprintf(FID,'# vtk DataFile Version 2.0 \n');
     91                fprintf(FID,'Data for run %s \n',model.miscellaneous.name);
     92                fprintf(FID,'ASCII \n');
     93                fprintf(FID,'DATASET UNSTRUCTURED_GRID \n');
     94
     95                fprintf(FID,'POINTS %d float\n',num_of_points);
     96                if(dim==3);
     97                        s='%f %f %f \n';
     98                elseif(dim==2);
     99                        s='%f %f \n';
     100   end
     101                P=[points zeros(num_of_points,3-dim)];
     102                fprintf(FID,s,P');
     103
     104                fprintf(FID,'CELLS %d %d\n',num_of_elt,num_of_elt*(point_per_elt+1));
     105                s='%d';
     106                for k=1:point_per_elt
     107                        s=horzcat(s,{' %d'});
     108        end
     109                s=cell2mat(horzcat(s,{'\n'}));
     110                fprintf(FID,s,[(point_per_elt)*ones(num_of_elt,1) model.mesh.elements-1]');
     111
     112                fprintf(FID,'CELL_TYPES %d\n',num_of_elt);
     113                s='%d\n';
     114                fprintf(FID,s,celltype*ones(num_of_elt,1));
     115
    91116                %check which field is a real result and print
    92117                fprintf(FID,'POINT_DATA %s \n',num2str(num_of_points));
    93                 for k=1:num_of_fields
    94                        
    95                         if ((length(sol_struct{j}(i).(fieldnames{k})))==num_of_points);
    96                                 fprintf(FID,'SCALARS %s float 1 \n',fieldnames{k});
     118                for j=1:num_of_fields
     119
     120                        if (length(sol_struct(1).(fieldnames{j}))==num_of_points);
     121                                fprintf(FID,'SCALARS %s float 1 \n',fieldnames{j});
    97122                                fprintf(FID,'LOOKUP_TABLE default\n');
    98123                                s='%e\n';
    99                                 fprintf(FID,s,sol_struct{j}(i).(fieldnames{k}));
     124                                fprintf(FID,s,sol_struct(i).(fieldnames{j}));
    100125            end         
    101      end
    102          end
    103          fclose(FID);
     126    end
     127                fclose(FID);
    104128  end
    105129end
  • issm/trunk-jpl/src/m/enum/EnumDefinitions.py

    r16301 r16304  
    2727def AutodiffFovForwardIndicesEnum(): return StringToEnum("AutodiffFovForwardIndices")[0]
    2828def AutodiffFosReverseIndexEnum(): return StringToEnum("AutodiffFosReverseIndex")[0]
     29def AutodiffMassFluxSegmentsPresentEnum(): return StringToEnum("AutodiffMassFluxSegmentsPresent")[0]
    2930def AutodiffKeepEnum(): return StringToEnum("AutodiffKeep")[0]
    3031def AutodiffObufsizeEnum(): return StringToEnum("AutodiffObufsize")[0]
     
    213214def MasstransportRequestedOutputsEnum(): return StringToEnum("MasstransportRequestedOutputs")[0]
    214215def QmuIsdakotaEnum(): return StringToEnum("QmuIsdakota")[0]
     216def MassFluxSegmentsEnum(): return StringToEnum("MassFluxSegments")[0]
     217def MassFluxSegmentsPresentEnum(): return StringToEnum("MassFluxSegmentsPresent")[0]
     218def QmuMassFluxSegmentsPresentEnum(): return StringToEnum("QmuMassFluxSegmentsPresent")[0]
    215219def QmuNumberofpartitionsEnum(): return StringToEnum("QmuNumberofpartitions")[0]
    216220def QmuNumberofresponsesEnum(): return StringToEnum("QmuNumberofresponses")[0]
     
    520524def TriaP1ElementResultEnum(): return StringToEnum("TriaP1ElementResult")[0]
    521525def WaterColumnOldEnum(): return StringToEnum("WaterColumnOld")[0]
    522 def OutputdefinitionEnum(): return StringToEnum("Outputdefinition")[0]
    523 def OutputdefinitionEnumsEnum(): return StringToEnum("OutputdefinitionEnums")[0]
    524 def MassfluxatgateEnum(): return StringToEnum("Massfluxatgate")[0]
    525 def MassfluxatgateNameEnum(): return StringToEnum("MassfluxatgateName")[0]
    526 def MassfluxatgateSegmentsEnum(): return StringToEnum("MassfluxatgateSegments")[0]
    527526def MinVelEnum(): return StringToEnum("MinVel")[0]
    528527def MaxVelEnum(): return StringToEnum("MaxVel")[0]
  • issm/trunk-jpl/test/NightlyRun/test234.m

    r16302 r16304  
    2828md.qmu.responses.MaxVel=response_function('MaxVel',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
    2929md.qmu.responses.IceVolume=response_function('IceVolume',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
    30 md.qmu.responses.MassFlux1=response_function('MassFlux1',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
    31 md.qmu.responses.MassFlux2=response_function('MassFlux2',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
    32 md.qmu.responses.MassFlux3=response_function('MassFlux3',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
    33 md.qmu.responses.MassFlux4=response_function('MassFlux4',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
    34 md.qmu.responses.MassFlux5=response_function('MassFlux5',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
    35 md.qmu.responses.massFlux6=response_function('MassFlux6',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
     30md.qmu.responses.MassFlux1=response_function('indexed_MassFlux_1',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
     31md.qmu.responses.MassFlux2=response_function('indexed_MassFlux_2',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
     32md.qmu.responses.MassFlux3=response_function('indexed_MassFlux_3',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
     33md.qmu.responses.MassFlux4=response_function('indexed_MassFlux_4',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
     34md.qmu.responses.MassFlux5=response_function('indexed_MassFlux_5',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
     35md.qmu.responses.massFlux6=response_function('indexed_MassFlux_6',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]);
    3636
    37 md.outputdefinition.definitions={...
    38                 massfluxatgate('MassFlux1',[pwd '/../Exp/MassFlux1.exp']),...
    39                 massfluxatgate('MassFlux2',[pwd '/../Exp/MassFlux2.exp']),...
    40                 massfluxatgate('MassFlux3',[pwd '/../Exp/MassFlux3.exp']),...
    41                 massfluxatgate('MassFlux4',[pwd '/../Exp/MassFlux4.exp']),...
    42                 massfluxatgate('MassFlux5',[pwd '/../Exp/MassFlux5.exp']),...
    43                 massfluxatgate('MassFlux6',[pwd '/../Exp/MassFlux6.exp'])...
    44         };
    45 
     37%mass flux profiles
     38md.qmu.mass_flux_profiles={'../Exp/MassFlux1.exp','../Exp/MassFlux2.exp','../Exp/MassFlux3.exp','../Exp/MassFlux4.exp','../Exp/MassFlux5.exp','../Exp/MassFlux6.exp'};
     39md.qmu.mass_flux_profile_directory=pwd;
    4640
    4741%%  nond_sampling study
Note: See TracChangeset for help on using the changeset viewer.