Changeset 25260
- Timestamp:
- 07/10/20 19:33:36 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/InputUpdateFromDakotax/InputUpdateFromDakotax.cpp
r25259 r25260 17 17 int i,j,k,l; 18 18 19 int numberofvertices;20 int numberofelements;21 int nrows;22 int ncols;23 19 IssmDouble **variable_partitions = NULL; 24 20 IssmDouble * variable_partition = NULL; … … 42 38 femmodel->parameters->FindParam(&variable_partitions_nt,NULL,NULL,QmuVariablePartitionsNtEnum); 43 39 44 numberofvertices=femmodel->vertices->NumberOfVertices();45 numberofelements=femmodel->elements->NumberOfElements();46 40 47 41 /*Go through all dakota descriptors, ex: "rho_ice","thermal_conductivity","thickness1","thickness2", etc ..., and … … 60 54 if (strncmp(descriptor,"scaled_",7)==0){ 61 55 /*we are skipping these for now.*/ 62 variable_partition=variable_partitions[variablecount];63 56 npart=variable_partitions_npart[variablecount]; 64 57 nt=variable_partitions_nt[variablecount]; … … 75 68 76 69 else if (strncmp(descriptor,"distributed_",12)==0){ 77 78 70 if (VerboseQmu())_printf0_(" updating variable " << descriptor << "\n"); 79 71 … … 119 111 descriptor=variables_descriptors[i]; 120 112 121 122 113 /*From descriptor, figure out if the variable is scaled, indexed, distributed or just a simple variable: */ 123 114 if (strncmp(descriptor,"scaled_",7)==0){ … … 140 131 } 141 132 142 143 int inputscaling=1; 144 if(!inputscaling){ 145 /*Scale variable outside of the inputs:{{{*/ 146 147 /*Now, pick up the parameter corresponding to root: */ 148 femmodel->parameters->FindParamInDataset(¶meter,&nrows,&ncols,QmuVariableDescriptorsEnum,StringToEnumx(root)); 149 150 /*We've got the parameter, we need to update it using the partition vector, and the distributed_values. 151 In addition, the parameter can be either a static or transient (nrows+1) vector. Finally, the partition vectors can include 152 -1 (meaning, don't update). */ 153 154 //_printf_("nrows: " << nrows << " numberofvertices: " << numberofvertices << " numberofelements: " << numberofelements << "\n"); 155 156 if(ncols!=nt){ 157 /*we are trying to update a col sized transient input by scaling with a matrix of col size nt. This can only work if nt==1, otherwise, error out: */ 158 if (nt!=1) _error_("InputUpdateFromDakotax error message: transient input being updated should be the same col size as the number of time step in the qmu variable specificationi"); 159 } 160 161 if(nt==1){ 162 /*scale all the columns by the same vector:*/ 163 if (nrows==numberofvertices || nrows==(numberofvertices+1)){ 164 for(k=0;k<numberofvertices;k++){ 165 if (variable_partition[k]==-1)continue; 166 else{ 167 for(l=0;l<ncols;l++){ 168 *(parameter+ncols*k+l)=*(parameter+ncols*k+l)*distributed_values[(int)variable_partition[k]]; 169 } 170 } 171 } 172 } 173 else if (nrows==numberofelements || nrows==(numberofelements+1)){ 174 for(k=0;k<numberofelements;k++){ 175 if (variable_partition[k]==-1)continue; 176 else{ 177 for(l=0;l<ncols;l++){ 178 *(parameter+ncols*k+l)=*(parameter+ncols*k+l)*distributed_values[(int)variable_partition[k]]; 179 } 180 } 181 } 182 183 } 184 else _error_("partitioning vector should be either elements or vertex sized!"); 185 186 } 187 else{ 188 /*scale all the columns by the scalar matrix:*/ 189 if (nrows==numberofvertices || nrows==(numberofvertices+1)){ 190 for(k=0;k<numberofvertices;k++){ 191 if (variable_partition[k]==-1)continue; 192 else{ 193 for(l=0;l<ncols;l++){ 194 *(parameter+ncols*k+l)=*(parameter+ncols*k+l)*distributed_values[(int)variable_partition[k]*nt+l]; 195 } 196 } 197 } 198 } 199 else if (nrows==numberofelements || nrows==(numberofelements+1)){ 200 for(k=0;k<numberofelements;k++){ 201 if (variable_partition[k]==-1)continue; 202 else{ 203 for(l=0;l<ncols;l++){ 204 *(parameter+ncols*k+l)=*(parameter+ncols*k+l)*distributed_values[(int)variable_partition[k]*nt+l]; 205 } 206 } 207 } 208 209 } 210 else _error_("partitioning vector should be either elements or vertex sized!"); 211 } 212 213 /*Update inputs using the parameter matrix: */ 214 if(nrows==numberofvertices || (nrows==numberofvertices+1)) 215 InputUpdateFromMatrixDakotax(femmodel, parameter, nrows,ncols,StringToEnumx(root), VertexEnum); 216 else 217 InputUpdateFromMatrixDakotax(femmodel, parameter, nrows,ncols,StringToEnumx(root), ElementEnum); /*}}}*/ 218 } 219 else{ 220 /*Scale variable inside the inputs:*/ 221 InputScaleFromDakotax(femmodel, distributed_values, variable_partition,npart, nt, StringToEnumx(root)); 222 } 133 /*Scale variable inside the inputs:*/ 134 InputScaleFromDakotax(femmodel, distributed_values, variable_partition,npart, nt, StringToEnumx(root)); 223 135 224 136 /*increment i to skip the distributed values just collected: */
Note:
See TracChangeset
for help on using the changeset viewer.