Changeset 13283
- Timestamp:
- 09/06/12 16:17:49 (13 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 8 added
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/EnumDefinitions/EnumDefinitions.h
r13268 r13283 17 17 AutodiffIndependentsEnum, 18 18 AutodiffNumIndependentsEnum, 19 AutodiffJacobianEnum, 20 AutodiffXpEnum, 19 21 BalancethicknessSpcthicknessEnum, 20 22 BalancethicknessStabilizationEnum, -
issm/trunk-jpl/src/c/Makefile.am
r13268 r13283 329 329 ./modules/RequestedOutputsx/RequestedOutputsx.h\ 330 330 ./modules/RequestedOutputsx/RequestedOutputsx.cpp\ 331 ./modules/RequestedDependentsx/RequestedDependentsx.h\ 332 ./modules/RequestedDependentsx/RequestedDependentsx.cpp\ 333 ./modules/AutodiffDriversx/AutodiffDriversx.h\ 334 ./modules/AutodiffDriversx/AutodiffDriversx.cpp\ 331 335 ./modules/ResetConstraintsx/ResetConstraintsx.h\ 332 336 ./modules/ResetConstraintsx/ResetConstraintsx.cpp\ -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r13268 r13283 26 26 this->fid=NULL; 27 27 this->data=NULL; 28 this->independents=NULL; 28 29 this->constants=NULL; 29 30 … … 55 56 this->data=xNew<IssmDouble*>(MaximumNumberOfEnums); 56 57 for(int i=0;i<MaximumNumberOfEnums;i++) this->data[i]=NULL; 58 59 /*Initialize array detecting whether data[i] is an independent AD mode variable: */ 60 this->independents=xNew<bool>(MaximumNumberOfEnums); 61 for(int i=0;i<MaximumNumberOfEnums;i++) this->independents[i]=false; 57 62 58 63 /*Initialize permanent data: */ … … 85 90 86 91 xDelete<IssmDouble*>(this->data); 92 xDelete<bool>(this->independents); 87 93 xDelete<bool>(this->my_elements); 88 94 xDelete<bool>(this->my_nodes); … … 191 197 } 192 198 /*}}}*/ 193 /*FUNCTION IoModel::DeleteData {{{*/199 /*FUNCTION IoModel::DeleteData(int num,...){{{*/ 194 200 void IoModel::DeleteData(int num,...){ 195 201 … … 205 211 dataenum=va_arg(ap, int); 206 212 _assert_(dataenum<MaximumNumberOfEnums); 207 xDelete<IssmDouble>(this->data[dataenum]); 213 214 /*do not erase independent variables for the AD mode computations!: */ 215 if (!this->independents[dataenum]) xDelete<IssmDouble>(this->data[dataenum]); 208 216 } 209 217 va_end(ap); 218 } /*}}}*/ 219 /*FUNCTION IoModel::DeleteData(IssmDouble* {{{*/ 220 void IoModel::DeleteData(IssmDouble* vector, int dataenum){ 221 222 /*do not erase independent variables for the AD mode computations!: */ 223 if(vector)if (!this->independents[dataenum]) xDelete<IssmDouble>(vector); 224 210 225 } /*}}}*/ 211 226 /*FUNCTION IoModel::FetchConstants{{{*/ … … 508 523 IssmPDouble scalar; 509 524 int code; 510 525 511 526 /*Set file pointer to beginning of the data: */ 512 527 fid=this->SetFilePointerToData(&code,NULL,data_enum); … … 538 553 int string_size; 539 554 int code=0; 540 555 541 556 /*Set file pointer to beginning of the data: */ 542 557 fid=this->SetFilePointerToData(&code,NULL,data_enum); … … 591 606 int code=0; 592 607 int vector_type=0; 593 594 608 609 595 610 /*Set file pointer to beginning of the data: */ 596 611 fid=this->SetFilePointerToData(&code,&vector_type,data_enum); … … 664 679 int code=0; 665 680 int vector_type=0; 666 681 667 682 /*Set file pointer to beginning of the data: */ 668 683 fid=this->SetFilePointerToData(&code,&vector_type,data_enum); … … 698 713 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 699 714 #endif 700 *pmatrix=xNew<IssmDouble>(M*N); 701 for (int i=0;i<M*N;++i) (*pmatrix)[i]=matrix[i]; 715 716 if (this->independents[data_enum]){ 717 /*this data has already been checked out! So cancel all that we've done here, and return 718 * the data[data_enum] directly: */ 719 *pmatrix=this->data[data_enum]; 720 } 721 else{ 722 *pmatrix=xNew<IssmDouble>(M*N); 723 for (int i=0;i<M*N;++i) (*pmatrix)[i]=matrix[i]; 724 } 702 725 xDelete<IssmPDouble>(matrix); 703 726 } … … 936 959 937 960 dataenum=va_arg(ap, int); 961 962 if (this->independents[dataenum]){ 963 /*this data has already been checked out! Continue: */ 964 continue; 965 } 938 966 939 967 /*Some checks in debugging mode*/ … … 1146 1174 /*}}}*/ 1147 1175 } 1148 /*Free ressources :*/1149 xDelete<IssmDouble>(IssmDoublevector);1176 /*Free ressources. Pay attention to not freeing an AD mode independent variable though!:*/ 1177 if (!this->independents[vector_enum] && !this->independents[default_vector_enum]) xDelete<IssmDouble>(IssmDoublevector); 1150 1178 xDelete<char>(string); 1151 1179 } 1180 /*}}}*/ 1152 1181 /*FUNCTION IoModel::LastIndex{{{*/ 1153 1182 void IoModel::LastIndex(int *pindex){ … … 1185 1214 *pindex=lastindex; 1186 1215 } 1216 /*}}}*/ 1187 1217 /*FUNCTION IoModel::SetFilePointerToData{{{*/ 1188 1218 FILE* IoModel::SetFilePointerToData(int* pcode,int* pvector_type, int data_enum){ … … 1250 1280 } 1251 1281 /*}}}*/ 1282 /*FUNCTION IoModel::DeclareIndependents{{{*/ 1283 void IoModel::DeclareIndependents(void){ 1284 1285 bool autodiff=false; 1286 int dummy; 1287 int i; 1288 int num_independents; 1289 int* independents=NULL; 1290 1291 #ifdef _HAVE_ADOLC_ 1292 /*recover independent enums: */ 1293 this->Constant(&num_independents,AutodiffNumIndependentsEnum); 1294 if(num_independents){ 1295 this->FetchData(&independents,&dummy,&dummy,AutodiffIndependentsEnum); 1296 1297 /*now go fetch the independent variables for each independent enum: */ 1298 for(i=0;i<num_independents;i++){ 1299 this->FetchIndependent(independents[i]); 1300 } 1301 xDelete<int>(independents); 1302 } 1303 #else 1304 /*if we asked for AD computations, we have a problem!: */ 1305 this->Constant(&autodiff,AutodiffIsautodiffEnum); 1306 if(autodiff)_error_("Cannot carry out AD mode computations without support of ADOLC compiled in!"); 1307 #endif 1308 1309 } 1310 /*}}}*/ 1311 /*FUNCTION IoModel::FetchIndependent{{{*/ 1312 void IoModel::FetchIndependent(int independent_enum){ 1313 1314 #ifdef _HAVE_ADOLC_ //cannot come here unless you are running AD mode, from DeclaredIndependents: 1315 extern int my_rank; 1316 extern int num_procs; 1317 1318 /*output: */ 1319 int M,N; 1320 IssmPDouble* buffer=NULL; //a buffer to read the data from disk 1321 IssmDouble* matrix=NULL; //our independent variable 1322 int code=0; 1323 int vector_type=0; 1324 1325 /*Set file pointer to beginning of the data: */ 1326 fid=this->SetFilePointerToData(&code,&vector_type,independent_enum); 1327 if((code!=5) && (code!=6) && (code!=7))_error_("expecting a IssmDouble, integer or boolean matrix for enum " << EnumToStringx(independent_enum)); 1328 1329 /*Now fetch: */ 1330 1331 /*We have to read a matrix from disk. First read the dimensions of the matrix, then the whole matrix: */ 1332 /*numberofelements: */ 1333 if(my_rank==0){ 1334 if(fread(&M,sizeof(int),1,fid)!=1) _error_("could not read number of rows for matrix "); 1335 } 1336 #ifdef _HAVE_MPI_ 1337 MPI_Bcast(&M,1,MPI_INT,0,MPI_COMM_WORLD); 1338 #endif 1339 1340 if(my_rank==0){ 1341 if(fread(&N,sizeof(int),1,fid)!=1) _error_("could not read number of columns for matrix "); 1342 } 1343 #ifdef _HAVE_MPI_ 1344 MPI_Bcast(&N,1,MPI_INT,0,MPI_COMM_WORLD); 1345 #endif 1346 1347 /*Now allocate matrix: */ 1348 if(M*N){ 1349 buffer=xNew<IssmPDouble>(M*N); 1350 matrix=xNew<IssmDouble>(M*N); 1351 1352 /*Read matrix on node 0, then broadcast: */ 1353 if(my_rank==0){ 1354 if(fread(buffer,M*N*sizeof(IssmPDouble),1,fid)!=1) _error_("could not read matrix "); 1355 1356 /*Now, before we even broadcast this to other nodes, declare the whole matrix as a independent variable!: */ 1357 for (int i=0;i<M*N;++i) matrix[i]<<=buffer[i]; /*we use the <<= ADOLC overloaded operator to declare the independency*/ 1358 } 1359 #ifdef _HAVE_MPI_ 1360 MPI_Bcast(matrix,M*N,MPI_DOUBLE,0,MPI_COMM_WORLD); 1361 #endif 1362 1363 xDelete<IssmPDouble>(buffer); 1364 } 1365 else _error_("cannot declare the independent variable " << EnumToStringx(independent_enum) << "if it's empty!"); 1366 1367 /*Ok, we are almost done. Matrix is now a independent matrix. We don't want this matrix to be fetched again in the 1368 *future, which would effectively write over the independency in the ADOLC tape! So we are going to keep track of this 1369 independent matrix inthe iomodel->data[independent_enum] data slot: */ 1370 this->data[independent_enum]=matrix; 1371 this->independents[independent_enum]=true; 1372 #endif 1373 } 1374 /*}}}*/ -
issm/trunk-jpl/src/c/classes/IoModel.h
r13268 r13283 19 19 20 20 private: 21 Parameters *constants; //this dataset holds all IssmDouble, int, bool and char *parameters read in from the input file.* 22 23 public: 21 24 IssmDouble **data; //this dataset holds temporary data, memory intensive. 22 Parameters *constants; //this dataset holds all IssmDouble, int, bool and char *parameters read in from the input file.* 23 24 public: 25 25 26 /*This data needs to stay memory resident at all time, even if it's memory intensive: */ 26 27 FILE *fid; //pointer to input file … … 31 32 int *numbernodetoelementconnectivity; 32 33 34 33 35 /*Data to synchronize through low level object drivers: */ 34 36 int nodecounter; //keep track of how many nodes are being created in each analysis type 35 37 int loadcounter; //keep track of how many loads are being created in each analysis type 36 38 int constraintcounter; //keep track of how many constraints are being created in each analysis type 39 40 /*for AD mode: to keep track of our independent variables we fetch:*/ 41 bool* independents; 37 42 38 43 /*Methods*/ … … 50 55 IssmDouble *Data(int dataenum); 51 56 void DeleteData(int num,...); 57 void DeleteData(IssmDouble* vector, int dataenum); 52 58 void FetchConstants(void); 53 59 void FetchData(bool* pboolean,int data_enum); … … 64 70 void LastIndex(int *pindex); 65 71 FILE* SetFilePointerToData(int* pcode,int* pvector_type, int data_enum); 66 #ifdef _HAVE_ADOLC_ 67 void FetchIndependentVariable(IssmDouble** pscalarmatrix,int* pM,int* pN,int data_enum); 68 #endif 72 void DeclareIndependents(void); 73 void FetchIndependent(int dependent_enum); 69 74 }; 70 75 -
issm/trunk-jpl/src/c/modules/EnumToStringx/EnumToStringx.cpp
r13268 r13283 22 22 case AutodiffIndependentsEnum : return "AutodiffIndependents"; 23 23 case AutodiffNumIndependentsEnum : return "AutodiffNumIndependents"; 24 case AutodiffJacobianEnum : return "AutodiffJacobian"; 25 case AutodiffXpEnum : return "AutodiffXp"; 24 26 case BalancethicknessSpcthicknessEnum : return "BalancethicknessSpcthickness"; 25 27 case BalancethicknessStabilizationEnum : return "BalancethicknessStabilization"; -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Autodiff/CreateParametersAutodiff.cpp
r13268 r13283 14 14 void CreateParametersAutodiff(Parameters** pparameters,IoModel* iomodel,int solution_type,int analysis_type){ 15 15 16 int i ;16 int i,j; 17 17 Parameters *parameters = NULL; 18 18 bool autodiff_analysis; … … 21 21 int* independents = NULL; 22 22 int num_independents; 23 int numberofvertices; 24 IssmDouble* xp=NULL; 23 25 24 26 /*Get parameters: */ … … 27 29 /*retrieve some parameters: */ 28 30 iomodel->Constant(&autodiff_analysis,AutodiffIsautodiffEnum); 31 32 if(autodiff_analysis){ 29 33 30 if(autodiff_analysis){ 34 iomodel->Constant(&num_independents,AutodiffNumIndependentsEnum); 35 iomodel->Constant(&num_dependents,AutodiffNumDependentsEnum); 36 iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum); 31 37 32 38 /*recover dependents: */ 33 39 parameters->AddObject(iomodel->CopyConstantObject(AutodiffNumDependentsEnum)); 34 iomodel->FetchData(&dependents,NULL,&num_dependents,AutodiffDependentsEnum); 35 parameters->AddObject(new IntVecParam(AutodiffDependentsEnum,dependents,num_dependents)); 36 40 if(num_dependents){ 41 iomodel->FetchData(&dependents,NULL,&num_dependents,AutodiffDependentsEnum); 42 parameters->AddObject(new IntVecParam(AutodiffDependentsEnum,dependents,num_dependents)); 43 } 44 37 45 /*recover independents: */ 38 46 parameters->AddObject(iomodel->CopyConstantObject(AutodiffNumIndependentsEnum)); 39 iomodel->FetchData(&independents,NULL,&num_independents,AutodiffIndependentsEnum); 40 parameters->AddObject(new IntVecParam(AutodiffIndependentsEnum,independents,num_independents)); 47 if(num_independents){ 48 iomodel->FetchData(&independents,NULL,&num_independents,AutodiffIndependentsEnum); 49 parameters->AddObject(new IntVecParam(AutodiffIndependentsEnum,independents,num_independents)); 41 50 51 /*Build state vector, value at which we compute our gradients of dependent variables in adolc: the xp vector */ 52 xp=xNew<IssmDouble>(num_independents*numberofvertices); 53 for(i=0;i<num_independents;i++){ 54 IssmDouble* values=iomodel->data[independents[i]]; 55 for(j=0;j<numberofvertices;j++){ 56 xp[i*numberofvertices+j]=values[j]; 57 } 58 } 59 parameters->AddObject(new DoubleVecParam(AutodiffXpEnum,xp,num_independents*numberofvertices)); 60 } 61 62 /*Assign output pointer: */ 63 *pparameters=parameters; 42 64 } 43 44 /*Assign output pointer: */45 *pparameters=parameters;46 65 } -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Control/CreateParametersControl.cpp
r13073 r13283 64 64 65 65 xDelete<int>(control_type); 66 xDelete<IssmDouble>(cm_responses);67 xDelete<IssmDouble>(cm_jump);68 xDelete<IssmDouble>(optscal);69 xDelete<IssmDouble>(maxiter);66 iomodel->DeleteData(cm_responses,InversionCostFunctionsEnum); 67 iomodel->DeleteData(cm_jump,InversionStepThresholdEnum); 68 iomodel->DeleteData(optscal,InversionGradientScalingEnum); 69 iomodel->DeleteData(maxiter,InversionMaxiterPerStepEnum); 70 70 } 71 71 -
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateParameters.cpp
r13277 r13283 92 92 parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsIsdelta18oEnum)); 93 93 parameters->AddObject(iomodel->CopyConstantObject(SurfaceforcingsIssmbgradientsEnum)); 94 parameters->AddObject(iomodel->CopyConstantObject(AutodiffIsautodiffEnum));95 94 96 95 iomodel->Constant(&isdelta18o,SurfaceforcingsIsdelta18oEnum); … … 105 104 for(i=0;i<M;i++) temp[M+i]=yts*temp[M+i]; 106 105 parameters->AddObject(new TransientParam(SurfaceforcingsDelta18oEnum,&temp[0],&temp[M],M)); 107 xDelete<IssmDouble>(temp);106 iomodel->DeleteData(temp,SurfaceforcingsDelta18oEnum); 108 107 109 108 iomodel->FetchData(&temp,&N,&M,SurfaceforcingsDelta18oSurfaceEnum); _assert_(N==2); 110 109 for(i=0;i<M;i++) temp[M+i]=yts*temp[M+i]; 111 110 parameters->AddObject(new TransientParam(SurfaceforcingsDelta18oSurfaceEnum,&temp[0],&temp[M],M)); 112 xDelete<IssmDouble>(temp);111 iomodel->DeleteData(temp,SurfaceforcingsDelta18oSurfaceEnum); 113 112 } 114 113 … … 127 126 parameters->AddObject(new IntParam(DiagnosticNumRequestedOutputsEnum,numoutputs)); 128 127 if(numoutputs)parameters->AddObject(new IntVecParam(DiagnosticRequestedOutputsEnum,requestedoutputs,numoutputs)); 129 xDelete<IssmDouble>(requestedoutputs);128 iomodel->DeleteData(requestedoutputs,DiagnosticRequestedOutputsEnum); 130 129 iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,TransientRequestedOutputsEnum); 131 130 parameters->AddObject(new IntParam(TransientNumRequestedOutputsEnum,numoutputs)); 132 131 if(numoutputs)parameters->AddObject(new IntVecParam(TransientRequestedOutputsEnum,requestedoutputs,numoutputs)); 133 xDelete<IssmDouble>(requestedoutputs);132 iomodel->DeleteData(requestedoutputs,TransientRequestedOutputsEnum); 134 133 iomodel->FetchData(&requestedoutputs,&numoutputs,NULL,SteadystateRequestedOutputsEnum); 135 134 parameters->AddObject(new IntParam(SteadystateNumRequestedOutputsEnum,numoutputs)); 136 135 if(numoutputs)parameters->AddObject(new IntVecParam(SteadystateRequestedOutputsEnum,requestedoutputs,numoutputs)); 137 xDelete<IssmDouble>(requestedoutputs);136 iomodel->DeleteData(requestedoutputs,SteadystateRequestedOutputsEnum); 138 137 139 138 /*Before returning, create parameters in case we are running Qmu or control types runs: */ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
r13073 r13283 326 326 327 327 /*Free data: */ 328 xDelete<IssmDouble>(spcvx);329 xDelete<IssmDouble>(spcvy);330 xDelete<IssmDouble>(spcvz);331 xDelete<IssmDouble>(nodeonmacayeal);332 xDelete<IssmDouble>(nodeonpattyn);333 xDelete<IssmDouble>(nodeonstokes);334 xDelete<IssmDouble>(nodeonicesheet);335 xDelete<IssmDouble>(nodeonbed);336 xDelete<IssmDouble>(vertices_type);337 xDelete<IssmDouble>(surface);338 xDelete<IssmDouble>(z);328 iomodel->DeleteData(spcvx,DiagnosticSpcvxEnum); 329 iomodel->DeleteData(spcvy,DiagnosticSpcvyEnum); 330 iomodel->DeleteData(spcvz,DiagnosticSpcvzEnum); 331 iomodel->DeleteData(nodeonmacayeal,FlowequationBordermacayealEnum); 332 if(dim==3)iomodel->DeleteData(nodeonpattyn,FlowequationBorderpattynEnum); 333 if(dim==3)iomodel->DeleteData(nodeonstokes,FlowequationBorderstokesEnum); 334 if(dim==3)iomodel->DeleteData(nodeonbed,MeshVertexonbedEnum); 335 if(dim==3)iomodel->DeleteData(nodeonicesheet,MaskVertexongroundediceEnum); 336 iomodel->DeleteData(vertices_type,FlowequationVertexEquationEnum); 337 iomodel->DeleteData(surface,SurfaceEnum); 338 iomodel->DeleteData(z,MeshZEnum); 339 339 340 340 /*Free resources:*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateLoadsDiagnosticHoriz.cpp
r13073 r13283 129 129 /*Free data: */ 130 130 iomodel->DeleteData(3,DiagnosticIcefrontEnum,ThicknessEnum,BedEnum); 131 xDelete<IssmDouble>(elements_type); 132 xDelete<IssmDouble>(pressureload); 131 iomodel->DeleteData(elements_type,FlowequationElementEquationEnum); 132 iomodel->DeleteData(pressureload,DiagnosticIcefrontEnum); 133 133 134 134 135 /*Create Penpair for penalties: */ … … 153 154 154 155 /*free ressources: */ 155 xDelete<IssmDouble>(penalties);156 iomodel->DeleteData(penalties,DiagnosticVertexPairingEnum); 156 157 157 158 /*Create Riffront loads for rifts: */ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
r12832 r13283 76 76 77 77 /*Free elements and elements2d: */ 78 xDelete<IssmDouble>(elements);79 xDelete<IssmDouble>(elements2d);78 iomodel->DeleteData(elements,MeshElementsEnum); 79 iomodel->DeleteData(elements2d,MeshElements2dEnum); 80 80 81 81 /*Deal with rifts, they have to be included into one partition only, not several: */ … … 87 87 epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices; 88 88 } 89 xDelete<IssmDouble>(riftinfo);89 iomodel->DeleteData(riftinfo,RiftsRiftstructEnum); 90 90 } 91 91 … … 119 119 }//for (i=0;i<numberofelements;i++) 120 120 /*Free data : */ 121 xDelete<IssmDouble>(elements);121 iomodel->DeleteData(elements,MeshElementsEnum); 122 122 123 123 /*We might have vertex_pairing in which case, some vertices have to be cloned: … … 130 130 } 131 131 } 132 xDelete<IssmDouble>(vertex_pairing);132 iomodel->DeleteData(vertex_pairing,DiagnosticVertexPairingEnum); 133 133 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,PrognosticVertexPairingEnum); 134 134 for(i=0;i<numvertex_pairing;i++){ … … 137 137 } 138 138 } 139 xDelete<IssmDouble>(vertex_pairing);139 iomodel->DeleteData(vertex_pairing,PrognosticVertexPairingEnum); 140 140 141 141 /*Free ressources:*/ -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp
r13073 r13283 110 110 111 111 /*Free ressources:*/ 112 xDelete<IssmDouble>(spcvector);112 iomodel->DeleteData(spcvector,ThermalSpctemperatureEnum); 113 113 xDelete<IssmDouble>(times); 114 114 xDelete<IssmDouble>(values); -
issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.cpp
r13277 r13283 20 20 21 21 int i,analysis_type,dim,verbose; 22 bool isthermal,isprognostic,isdiagnostic,isgroundingline,isenthalpy ;22 bool isthermal,isprognostic,isdiagnostic,isgroundingline,isenthalpy,autodiff; 23 23 24 24 /*output: */ … … 43 43 iomodel->Constant(&isdiagnostic,TransientIsdiagnosticEnum); 44 44 iomodel->Constant(&isgroundingline,TransientIsgroundinglineEnum); 45 45 iomodel->Constant(&autodiff,AutodiffIsautodiffEnum); 46 47 /*If we are running in AD mode, we need to declare our independent variables now, before 48 *and prevent them from being erased during successive calls to iomodel->FetchData and 49 iomodel->DeleteData:*/ 50 if(autodiff)iomodel->DeclareIndependents(); 51 46 52 SetVerbosityLevel(verbose); 47 53 -
issm/trunk-jpl/src/c/modules/ModelProcessorx/Prognostic/CreateLoadsPrognostic.cpp
r12832 r13283 90 90 91 91 /*free ressources: */ 92 xDelete<IssmDouble>(vertex_pairing);93 xDelete<IssmDouble>(nodeonbed);92 iomodel->DeleteData(vertex_pairing,PrognosticVertexPairingEnum); 93 iomodel->DeleteData(nodeonbed,MeshVertexonbedEnum); 94 94 95 95 /*Assign output pointer: */ -
issm/trunk-jpl/src/c/modules/StringToEnumx/StringToEnumx.cpp
r13268 r13283 23 23 else if (strcmp(name,"AutodiffIndependents")==0) return AutodiffIndependentsEnum; 24 24 else if (strcmp(name,"AutodiffNumIndependents")==0) return AutodiffNumIndependentsEnum; 25 else if (strcmp(name,"AutodiffJacobian")==0) return AutodiffJacobianEnum; 26 else if (strcmp(name,"AutodiffXp")==0) return AutodiffXpEnum; 25 27 else if (strcmp(name,"BalancethicknessSpcthickness")==0) return BalancethicknessSpcthicknessEnum; 26 28 else if (strcmp(name,"BalancethicknessStabilization")==0) return BalancethicknessStabilizationEnum; … … 136 138 else if (strcmp(name,"MeshVertexonbed")==0) return MeshVertexonbedEnum; 137 139 else if (strcmp(name,"MeshVertexonsurface")==0) return MeshVertexonsurfaceEnum; 138 else if (strcmp(name,"MeshX")==0) return MeshXEnum;139 else if (strcmp(name,"MeshY")==0) return MeshYEnum;140 140 else stage=2; 141 141 } 142 142 if(stage==2){ 143 if (strcmp(name,"MeshZ")==0) return MeshZEnum; 143 if (strcmp(name,"MeshX")==0) return MeshXEnum; 144 else if (strcmp(name,"MeshY")==0) return MeshYEnum; 145 else if (strcmp(name,"MeshZ")==0) return MeshZEnum; 144 146 else if (strcmp(name,"MiscellaneousName")==0) return MiscellaneousNameEnum; 145 147 else if (strcmp(name,"PrognosticHydrostaticAdjustment")==0) return PrognosticHydrostaticAdjustmentEnum; … … 259 261 else if (strcmp(name,"Materials")==0) return MaterialsEnum; 260 262 else if (strcmp(name,"Nodes")==0) return NodesEnum; 261 else if (strcmp(name,"Parameters")==0) return ParametersEnum;262 else if (strcmp(name,"Vertices")==0) return VerticesEnum;263 263 else stage=3; 264 264 } 265 265 if(stage==3){ 266 if (strcmp(name,"Results")==0) return ResultsEnum; 266 if (strcmp(name,"Parameters")==0) return ParametersEnum; 267 else if (strcmp(name,"Vertices")==0) return VerticesEnum; 268 else if (strcmp(name,"Results")==0) return ResultsEnum; 267 269 else if (strcmp(name,"AdolcParam")==0) return AdolcParamEnum; 268 270 else if (strcmp(name,"BoolInput")==0) return BoolInputEnum; … … 382 384 else if (strcmp(name,"VzMacAyeal")==0) return VzMacAyealEnum; 383 385 else if (strcmp(name,"VzPattyn")==0) return VzPattynEnum; 384 else if (strcmp(name,"VzPicard")==0) return VzPicardEnum;385 else if (strcmp(name,"VzStokes")==0) return VzStokesEnum;386 386 else stage=4; 387 387 } 388 388 if(stage==4){ 389 if (strcmp(name,"VxMesh")==0) return VxMeshEnum; 389 if (strcmp(name,"VzPicard")==0) return VzPicardEnum; 390 else if (strcmp(name,"VzStokes")==0) return VzStokesEnum; 391 else if (strcmp(name,"VxMesh")==0) return VxMeshEnum; 390 392 else if (strcmp(name,"VyMesh")==0) return VyMeshEnum; 391 393 else if (strcmp(name,"VzMesh")==0) return VzMeshEnum; -
issm/trunk-jpl/src/c/modules/modules.h
r12927 r13283 8 8 /*Modules: */ 9 9 #include "./AddExternalResultx/AddExternalResultx.h" 10 #include "./AutodiffDriversx/AutodiffDriversx.h" 10 11 #include "./AverageFilterx/AverageFilterx.h" 11 12 #include "./AverageOntoPartitionx/AverageOntoPartitionx.h" … … 103 104 #include "./Reducevectorgtofx/Reducevectorgtofx.h" 104 105 #include "./RequestedOutputsx/RequestedOutputsx.h" 106 #include "./RequestedDependentsx/RequestedDependentsx.h" 105 107 #include "./ResetConstraintsx/ResetConstraintsx.h" 106 108 #include "./ResetCoordinateSystemx/ResetCoordinateSystemx.h" -
issm/trunk-jpl/src/c/solutions/issm.cpp
r13277 r13283 84 84 /*out of solution_type, figure out types of analyses needed in the femmodel: */ 85 85 AnalysisConfiguration(&analyses,&numanalyses,solution_type); 86 86 87 /*before we create the model, start the trace on for AD mode: */ 88 #ifdef _HAVE_ADOLC_ 89 trace_on(1); 90 #endif 91 87 92 /*Create femmodel, using input file: */ 88 93 #ifdef _HAVE_MPI_ … … 124 129 theAdolcEDF_p->GetParameterValue().myEDF_for_solverx_p=reg_ext_fct(EDF_for_solverx); 125 130 femmodel->parameters->AddObject(theAdolcEDF_p); 126 if(autodiff) trace_on(1);127 131 #else 128 132 if(autodiff) _error_("ISSM was not compiled with ADOLC support, cannot carry out autodiff analysis!"); … … 166 170 } 167 171 172 if(autodiff){ 173 trace_off(); 174 AutodiffDriversx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results); 175 } 176 168 177 169 178 #ifdef _HAVE_MPI_ … … 172 181 finish_core=(IssmPDouble)clock(); 173 182 #endif 174 183 175 184 _pprintLine_("write results to disk:"); 176 185 OutputResultsx(femmodel->elements, femmodel->nodes, femmodel->vertices, femmodel->loads, femmodel->materials, femmodel->parameters,femmodel->results); … … 179 188 #ifdef _HAVE_ADOLC_ 180 189 if(autodiff){ 181 trace_off();182 190 tapestats(1,tape_stats); //reading of tape statistics 183 191 _pprintLine_(" ADOLC statistics: "); -
issm/trunk-jpl/src/c/solutions/transient_core.cpp
r13056 r13283 152 152 } 153 153 154 RequestedDependentsx(femmodel->results,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters); 155 154 156 /*Free ressources:*/ 155 157 xDelete<int>(requested_outputs); -
issm/trunk-jpl/src/m/classes/autodiff.m
r13271 r13283 7 7 properties (SetAccess=public) 8 8 isautodiff = false; 9 dependents = { ''};10 independents = { ''};9 dependents = {}; 10 independents = {}; 11 11 end 12 12 methods … … 23 23 end % }}} 24 24 function md = checkconsistency(obj,md,solution,analyses) % {{{ 25 26 %Early return 27 if ~obj.isautodiff, return; end 28 25 29 26 30 end % }}} … … 40 44 %process dependent variables 41 45 num_dependents=numel(obj.dependents); 42 data=zeros(1,num_dependents); 43 for i=1:num_dependents, 44 data(i)=StringToEnum(obj.dependents{i}); 46 WriteData(fid,'data',num_dependents,'enum',AutodiffNumDependentsEnum(),'format','Integer'); 47 48 if(num_dependents), 49 data=zeros(1,num_dependents); 50 for i=1:num_dependents, 51 data(i)=StringToEnum(obj.dependents{i}); 52 end 53 WriteData(fid,'data',data,'enum',AutodiffDependentsEnum(),'format','DoubleMat','mattype',3); 45 54 end 46 WriteData(fid,'data',data,'enum',AutodiffDependentsEnum(),'format','DoubleMat','mattype',3);47 WriteData(fid,'data',num_dependents,'enum',AutodiffNumDependentsEnum(),'format','Integer');48 55 49 56 %process independent variables 50 57 num_independents=numel(obj.independents); 51 data=zeros(1,num_independents); 52 for i=1:num_independents, 53 data(i)=StringToEnum(obj.independents{i}); 58 WriteData(fid,'data',num_independents,'enum',AutodiffNumIndependentsEnum(),'format','Integer'); 59 60 if(num_independents) 61 data=zeros(1,num_independents); 62 for i=1:num_independents, 63 data(i)=StringToEnum(obj.independents{i}); 64 end 65 WriteData(fid,'data',data,'enum',AutodiffIndependentsEnum(),'format','DoubleMat','mattype',3); 54 66 end 55 WriteData(fid,'data',data,'enum',AutodiffIndependentsEnum(),'format','DoubleMat','mattype',3);56 WriteData(fid,'data',num_independents,'enum',AutodiffNumIndependentsEnum(),'format','Integer');57 67 58 68 end % }}} -
issm/trunk-jpl/src/m/enum/EnumDefinitions.py
r13268 r13283 59 59 return StringToEnum('AutodiffNumIndependents')[0] 60 60 61 def AutodiffJacobianEnum(): 62 """ 63 AUTODIFFJACOBIANENUM - Enum of AutodiffJacobian 64 65 Usage: 66 macro=AutodiffJacobianEnum() 67 """ 68 69 return StringToEnum('AutodiffJacobian')[0] 70 71 def AutodiffXpEnum(): 72 """ 73 AUTODIFFXPENUM - Enum of AutodiffXp 74 75 Usage: 76 macro=AutodiffXpEnum() 77 """ 78 79 return StringToEnum('AutodiffXp')[0] 80 61 81 def BalancethicknessSpcthicknessEnum(): 62 82 """ … … 4717 4737 """ 4718 4738 4719 return 47 04720 4739 return 472 4740 -
issm/trunk-jpl/src/m/enum/MaximumNumberOfEnums.m
r13268 r13283 9 9 % macro=MaximumNumberOfEnums() 10 10 11 macro=47 0;11 macro=472;
Note:
See TracChangeset
for help on using the changeset viewer.