Changeset 16304
- Timestamp:
- 10/07/13 08:24:10 (11 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 9 deleted
- 18 edited
- 4 copied
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r16301 r16304 542 542 543 543 #}}} 544 #Responses sources {{{545 responses_sources = ./classes/Massfluxatgate.h \546 ./modules/ModelProcessorx/CreateOutputDefinitions.cpp547 #}}}548 544 #Damage sources {{{ 549 545 damage_sources = ./analyses/damage_core.cpp\ … … 882 878 endif 883 879 884 if RESPONSES885 issm_sources += $(responses_sources)886 endif887 888 880 if PETSC 889 881 issm_sources += $(petsc_sources) -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r16301 r16304 891 891 } 892 892 /*}}}*/ 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 /*}}}*/960 893 /*FUNCTION IoModel::FetchData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pM,int data_enum){{{*/ 961 894 void IoModel::FetchData(IssmDouble*** pmatrices,int** pmdims,int** pndims, int* pnumrecords,int data_enum){ … … 1042 975 *pndims=ndims; 1043 976 *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 return1113 * 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 else1123 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;1137 977 } 1138 978 /*}}}*/ … … 1417 1257 ISSM_MPI_Bcast(&record_code,1,ISSM_MPI_INT,0,IssmComm::GetComm()); 1418 1258 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()); 1419 1260 1420 1261 /*Assign output pointers:*/ … … 1425 1266 } 1426 1267 /*}}}*/ 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 number1435 int vector_type; //1 to 7 number1436 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 of1446 * 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 information1477 * 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 76 76 void FetchData(char*** pstringarray,int* pnumstrings,int data_enum); 77 77 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);80 78 void FetchData(Option **poption,int data_enum); 81 79 void FetchData(int num,...); … … 83 81 void FetchDataToInput(Elements* elements,int vector_enum,IssmDouble default_value); 84 82 void LastIndex(int *pindex); 85 FILE** SetFilePointersToData(int** pcodes,int** pvector_types, int data_enum);86 83 FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum); 87 84 void DeclareIndependents(void); -
issm/trunk-jpl/src/c/classes/classes.h
r16301 r16304 17 17 #include "./IndependentObject.h" 18 18 #include "./Segment.h" 19 #include "./Massfluxatgate.h"20 19 21 20 /*Constraints: */ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp
r16301 r16304 24 24 IssmDouble time; 25 25 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 /*}}}*/ 26 40 27 41 if(*pparameters)return; //do not create parameters twice! … … 137 151 iomodel->DeleteData(requestedoutputs,MasstransportRequestedOutputsEnum); 138 152 139 /*Output definitions dataset: */ 140 CreateOutputDefinitions(¶meters,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 /*}}}*/ 141 214 142 215 /*Solution specific parameters*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.h
r16301 r16304 160 160 void DistributeNumDofs(DofIndexing* index,int analysis_type,int node_type); 161 161 162 #ifdef _HAVE_RESPONSES_163 void CreateParametersOutputDefinitions(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type);164 162 #endif 165 166 #endif -
issm/trunk-jpl/src/c/shared/Enum/EnumDefinitions.h
r16301 r16304 27 27 AutodiffFovForwardIndicesEnum, 28 28 AutodiffFosReverseIndexEnum, 29 AutodiffMassFluxSegmentsPresentEnum, 29 30 AutodiffKeepEnum, 30 31 AutodiffObufsizeEnum, … … 213 214 MasstransportRequestedOutputsEnum, 214 215 QmuIsdakotaEnum, 216 MassFluxSegmentsEnum, 217 MassFluxSegmentsPresentEnum, 218 QmuMassFluxSegmentsPresentEnum, 215 219 QmuNumberofpartitionsEnum, 216 220 QmuNumberofresponsesEnum, … … 539 543 WaterColumnOldEnum, 540 544 /*}}}*/ 541 /*Output Definitions{{{*/542 OutputdefinitionEnum,543 OutputdefinitionEnumsEnum,544 MassfluxatgateEnum,545 MassfluxatgateNameEnum,546 MassfluxatgateSegmentsEnum,547 /*}}}*/548 545 /*Responses{{{*/ 549 546 MinVelEnum, -
issm/trunk-jpl/src/c/shared/Enum/EnumToStringx.cpp
r16301 r16304 35 35 case AutodiffFovForwardIndicesEnum : return "AutodiffFovForwardIndices"; 36 36 case AutodiffFosReverseIndexEnum : return "AutodiffFosReverseIndex"; 37 case AutodiffMassFluxSegmentsPresentEnum : return "AutodiffMassFluxSegmentsPresent"; 37 38 case AutodiffKeepEnum : return "AutodiffKeep"; 38 39 case AutodiffObufsizeEnum : return "AutodiffObufsize"; … … 221 222 case MasstransportRequestedOutputsEnum : return "MasstransportRequestedOutputs"; 222 223 case QmuIsdakotaEnum : return "QmuIsdakota"; 224 case MassFluxSegmentsEnum : return "MassFluxSegments"; 225 case MassFluxSegmentsPresentEnum : return "MassFluxSegmentsPresent"; 226 case QmuMassFluxSegmentsPresentEnum : return "QmuMassFluxSegmentsPresent"; 223 227 case QmuNumberofpartitionsEnum : return "QmuNumberofpartitions"; 224 228 case QmuNumberofresponsesEnum : return "QmuNumberofresponses"; … … 528 532 case TriaP1ElementResultEnum : return "TriaP1ElementResult"; 529 533 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";535 534 case MinVelEnum : return "MinVel"; 536 535 case MaxVelEnum : return "MaxVel"; -
issm/trunk-jpl/src/c/shared/Enum/StringToEnumx.cpp
r16301 r16304 35 35 else if (strcmp(name,"AutodiffFovForwardIndices")==0) return AutodiffFovForwardIndicesEnum; 36 36 else if (strcmp(name,"AutodiffFosReverseIndex")==0) return AutodiffFosReverseIndexEnum; 37 else if (strcmp(name,"AutodiffMassFluxSegmentsPresent")==0) return AutodiffMassFluxSegmentsPresentEnum; 37 38 else if (strcmp(name,"AutodiffKeep")==0) return AutodiffKeepEnum; 38 39 else if (strcmp(name,"AutodiffObufsize")==0) return AutodiffObufsizeEnum; … … 136 137 else if (strcmp(name,"InversionCostFunctionsCoefficients")==0) return InversionCostFunctionsCoefficientsEnum; 137 138 else if (strcmp(name,"InversionCostFunctions")==0) return InversionCostFunctionsEnum; 138 else if (strcmp(name,"InversionGradientScaling")==0) return InversionGradientScalingEnum;139 139 else stage=2; 140 140 } 141 141 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; 143 144 else if (strcmp(name,"InversionTao")==0) return InversionTaoEnum; 144 145 else if (strcmp(name,"InversionIncompleteAdjoint")==0) return InversionIncompleteAdjointEnum; … … 224 225 else if (strcmp(name,"MasstransportRequestedOutputs")==0) return MasstransportRequestedOutputsEnum; 225 226 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; 226 230 else if (strcmp(name,"QmuNumberofpartitions")==0) return QmuNumberofpartitionsEnum; 227 231 else if (strcmp(name,"QmuNumberofresponses")==0) return QmuNumberofresponsesEnum; … … 256 260 else if (strcmp(name,"SurfaceforcingsMassBalance")==0) return SurfaceforcingsMassBalanceEnum; 257 261 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; 259 266 else if (strcmp(name,"SurfaceforcingsS0p")==0) return SurfaceforcingsS0pEnum; 260 267 else if (strcmp(name,"SurfaceforcingsIssmbgradients")==0) return SurfaceforcingsIssmbgradientsEnum; 261 268 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; 266 270 else if (strcmp(name,"SurfaceforcingsSmbref")==0) return SurfaceforcingsSmbrefEnum; 267 271 else if (strcmp(name,"SurfaceforcingsBPos")==0) return SurfaceforcingsBPosEnum; … … 379 383 else if (strcmp(name,"Input")==0) return InputEnum; 380 384 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; 382 389 else if (strcmp(name,"IntVecParam")==0) return IntVecParamEnum; 383 390 else if (strcmp(name,"TransientParam")==0) return TransientParamEnum; 384 391 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; 389 393 else if (strcmp(name,"Node")==0) return NodeEnum; 390 394 else if (strcmp(name,"Numericalflux")==0) return NumericalfluxEnum; … … 502 506 else if (strcmp(name,"StressTensorxz")==0) return StressTensorxzEnum; 503 507 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; 505 512 else if (strcmp(name,"StressTensorzz")==0) return StressTensorzzEnum; 506 513 else if (strcmp(name,"GiaCrossSectionShape")==0) return GiaCrossSectionShapeEnum; 507 514 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; 512 516 else if (strcmp(name,"P0")==0) return P0Enum; 513 517 else if (strcmp(name,"P1")==0) return P1Enum; … … 540 544 else if (strcmp(name,"TriaP1ElementResult")==0) return TriaP1ElementResultEnum; 541 545 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;547 546 else if (strcmp(name,"MinVel")==0) return MinVelEnum; 548 547 else if (strcmp(name,"MaxVel")==0) return MaxVelEnum; -
issm/trunk-jpl/src/m/classes/autodiff.m
r16298 r16304 83 83 %early return 84 84 if ~obj.isautodiff, 85 WriteData(fid,'data',false,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean'); 85 86 WriteData(fid,'data',false,'enum',AutodiffKeepEnum(),'format','Boolean'); 86 87 return; … … 197 198 end 198 199 %}}} 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 %}}} 199 216 %deal with trace keep on: {{{ 200 217 keep=false; -
issm/trunk-jpl/src/m/classes/autodiff.py
r16298 r16304 86 86 #early return 87 87 if not self.isautodiff: 88 WriteData(fid,'data',False,'enum',AutodiffMassFluxSegmentsPresentEnum(),'format','Boolean') 88 89 WriteData(fid,'data',False,'enum',AutodiffKeepEnum(),'format','Boolean') 89 90 return … … 181 182 WriteData(fid,'data',indices,'enum',AutodiffFovForwardIndicesEnum(),'format','IntMat','mattype',3) 182 183 #}}} 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 #}}} 183 194 #deal with trace keep on: {{{ 184 195 keep=False -
issm/trunk-jpl/src/m/classes/damage.m
r16299 r16304 110 110 disp(sprintf(' Damage:\n')); 111 111 112 fielddisplay(obj,'D','damage tensor ( vector)');112 fielddisplay(obj,'D','damage tensor (scalar)'); 113 113 fielddisplay(obj,'law','damage law (string) from {''undamaged'',''pralong''}'); 114 114 fielddisplay(obj,'spcdamage','damage constraints (NaN means no constraint)'); -
issm/trunk-jpl/src/m/classes/model.m
r16297 r16304 45 45 46 46 results = 0; 47 outputdefinition = 0;48 47 radaroverlay = 0; 49 48 miscellaneous = 0; … … 1072 1071 md.radaroverlay = radaroverlay(); 1073 1072 md.results = struct(); 1074 md.outputdefinition = outputdefinition();1075 1073 md.miscellaneous = miscellaneous(); 1076 1074 md.private = private(); … … 1109 1107 disp(sprintf('%19s: %-22s -- %s','inversion' ,['[1x1 ' class(obj.inversion) ']'],'parameters for inverse methods')); 1110 1108 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'));1112 1109 disp(sprintf('%19s: %-22s -- %s','results' ,['[1x1 ' class(obj.results) ']'],'model results')); 1113 1110 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 17 17 variabledescriptors = {}; 18 18 responsedescriptors = {}; 19 mass_flux_profile_directory = NaN; 20 mass_flux_profiles = NaN; 21 mass_flux_segments = {}; 19 22 adjacency = NaN; 20 23 vertex_weight = NaN; … … 130 133 fielddisplay(obj,'responsedescriptors',''); 131 134 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',''); 132 138 fielddisplay(obj,'adjacency',''); 133 139 fielddisplay(obj,'vertex_weight','weight applied to each mesh vertex'); … … 145 151 WriteData(fid,'object',obj,'fieldname','variabledescriptors','format','StringArray'); 146 152 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'); 147 160 end % }}} 148 161 end -
issm/trunk-jpl/src/m/classes/qmu.py
r16297 r16304 27 27 self.variabledescriptors = [] 28 28 self.responsedescriptors = [] 29 self.mass_flux_profile_directory = float('NaN') 30 self.mass_flux_profiles = float('NaN') 31 self.mass_flux_segments = [] 29 32 self.adjacency = float('NaN') 30 33 self.vertex_weight = float('NaN') … … 123 126 s+="%s\n" % fielddisplay(self,'responsedescriptors','') 124 127 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','') 125 131 s+="%s\n" % fielddisplay(self,'adjacency','') 126 132 s+="%s\n" % fielddisplay(self,'vertex_weight','weight applied to each mesh vertex') … … 138 144 WriteData(fid,'object',self,'fieldname','variabledescriptors','format','StringArray') 139 145 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'); 140 152 # }}} -
issm/trunk-jpl/src/m/contrib/paraview/exportVTK.m
r16303 r16304 1 function exportVTK(filename,model )1 function exportVTK(filename,model,Solution) 2 2 % vtk export 3 3 % function exportVTK(filename,model,Solution) … … 19 19 mkdir(filename); 20 20 21 %get the element related variables22 21 points=[model.mesh.x model.mesh.y model.mesh.z]; 23 22 [num_of_points,dim]=size(points); 24 23 [num_of_elt]=size(model.mesh.elements,1); 25 24 [point_per_elt]=size(model.mesh.elements,2); 25 sol_enum=EnumToString(Solution); 26 27 sol_struct=model.results.(sol_enum); 26 28 27 29 %Select the type of element function of the number of nodes per elements … … 34 36 end 35 37 36 %sol_enum=EnumToString(Solution); 38 %looking for multiple time steps 39 num_of_timesteps=size(sol_struct,2); 37 40 38 %this is the result structure 39 res_struct=model.results; 41 %getting the number of fields in the solution 42 fieldnames=fields(sol_struct(1)); 43 num_of_fields=length(fieldnames); 40 44 41 %Getting all the solutions of the model 42 solnames=fields(res_struct); 43 num_of_sols=length(solnames); 45 if num_of_timesteps==1; %just one timestep only write one file 44 46 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+'); 58 48 fprintf(FID,'# vtk DataFile Version 2.0 \n'); 59 49 fprintf(FID,'Data for run %s \n',model.miscellaneous.name); 60 50 fprintf(FID,'ASCII \n'); 61 51 fprintf(FID,'DATASET UNSTRUCTURED_GRID \n'); 62 52 63 53 fprintf(FID,'POINTS %d float\n',num_of_points); 64 54 if(dim==3); … … 69 59 P=[points zeros(num_of_points,3-dim)]; 70 60 fprintf(FID,s,P'); 71 61 72 62 fprintf(FID,'CELLS %d %d\n',num_of_elt,num_of_elt*(point_per_elt+1)); 73 63 s='%d'; 74 64 for k=1:point_per_elt 75 65 s=horzcat(s,{' %d'}); 76 66 end 77 67 s=cell2mat(horzcat(s,{'\n'})); 78 68 fprintf(FID,s,[(point_per_elt)*ones(num_of_elt,1) model.mesh.elements-1]'); 79 69 80 70 fprintf(FID,'CELL_TYPES %d\n',num_of_elt); 81 71 s='%d\n'; 82 72 fprintf(FID,s,celltype*ones(num_of_elt,1)); 83 84 %loop over the different solution structures85 for j=1:num_of_sols86 73 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); 86 else 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 91 116 %check which field is a real result and print 92 117 fprintf(FID,'POINT_DATA %s \n',num2str(num_of_points)); 93 for k=1:num_of_fields94 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}); 97 122 fprintf(FID,'LOOKUP_TABLE default\n'); 98 123 s='%e\n'; 99 fprintf(FID,s,sol_struct {j}(i).(fieldnames{k}));124 fprintf(FID,s,sol_struct(i).(fieldnames{j})); 100 125 end 101 end 102 end 103 fclose(FID); 126 end 127 fclose(FID); 104 128 end 105 129 end -
issm/trunk-jpl/src/m/enum/EnumDefinitions.py
r16301 r16304 27 27 def AutodiffFovForwardIndicesEnum(): return StringToEnum("AutodiffFovForwardIndices")[0] 28 28 def AutodiffFosReverseIndexEnum(): return StringToEnum("AutodiffFosReverseIndex")[0] 29 def AutodiffMassFluxSegmentsPresentEnum(): return StringToEnum("AutodiffMassFluxSegmentsPresent")[0] 29 30 def AutodiffKeepEnum(): return StringToEnum("AutodiffKeep")[0] 30 31 def AutodiffObufsizeEnum(): return StringToEnum("AutodiffObufsize")[0] … … 213 214 def MasstransportRequestedOutputsEnum(): return StringToEnum("MasstransportRequestedOutputs")[0] 214 215 def QmuIsdakotaEnum(): return StringToEnum("QmuIsdakota")[0] 216 def MassFluxSegmentsEnum(): return StringToEnum("MassFluxSegments")[0] 217 def MassFluxSegmentsPresentEnum(): return StringToEnum("MassFluxSegmentsPresent")[0] 218 def QmuMassFluxSegmentsPresentEnum(): return StringToEnum("QmuMassFluxSegmentsPresent")[0] 215 219 def QmuNumberofpartitionsEnum(): return StringToEnum("QmuNumberofpartitions")[0] 216 220 def QmuNumberofresponsesEnum(): return StringToEnum("QmuNumberofresponses")[0] … … 520 524 def TriaP1ElementResultEnum(): return StringToEnum("TriaP1ElementResult")[0] 521 525 def 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]527 526 def MinVelEnum(): return StringToEnum("MinVel")[0] 528 527 def MaxVelEnum(): return StringToEnum("MaxVel")[0] -
issm/trunk-jpl/test/NightlyRun/test234.m
r16302 r16304 28 28 md.qmu.responses.MaxVel=response_function('MaxVel',[],[0.0001 0.001 0.01 0.25 0.5 0.75 0.99 0.999 0.9999]); 29 29 md.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]);30 md.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]); 31 md.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]); 32 md.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]); 33 md.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]); 34 md.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]); 35 md.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]); 36 36 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 38 md.qmu.mass_flux_profiles={'../Exp/MassFlux1.exp','../Exp/MassFlux2.exp','../Exp/MassFlux3.exp','../Exp/MassFlux4.exp','../Exp/MassFlux5.exp','../Exp/MassFlux6.exp'}; 39 md.qmu.mass_flux_profile_directory=pwd; 46 40 47 41 %% nond_sampling study
Note:
See TracChangeset
for help on using the changeset viewer.