Changeset 10126
- Timestamp:
- 10/06/11 09:55:17 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/modules/ModelProcessorx/DiagnosticHoriz/CreateConstraintsDiagnosticHoriz.cpp
r9734 r10126 21 21 double stokesreconditioning; 22 22 bool isstokes,ismacayealpattyn; 23 bool spcpresent=false; 24 int Mx,Nx; 25 int My,Ny; 26 int Mz,Nz; 23 27 double *spcvx = NULL; 24 28 double *spcvy = NULL; … … 30 34 double *surface = NULL; 31 35 double *z = NULL; 32 36 double *timesx=NULL; 37 double *timesy=NULL; 38 double *timesz=NULL; 39 double* values=NULL; 40 33 41 /*Output*/ 34 42 Constraints* constraints = NULL; … … 61 69 62 70 /*Constraints: fetch data: */ 63 iomodel->FetchData(&spcvx, NULL,NULL,DiagnosticSpcvxEnum);64 iomodel->FetchData(&spcvy, NULL,NULL,DiagnosticSpcvyEnum);65 iomodel->FetchData(&spcvz, NULL,NULL,DiagnosticSpcvzEnum);71 iomodel->FetchData(&spcvx,&Mx,&Nx,DiagnosticSpcvxEnum); 72 iomodel->FetchData(&spcvy,&My,&Ny,DiagnosticSpcvyEnum); 73 iomodel->FetchData(&spcvz,&Mz,&Nz,DiagnosticSpcvzEnum); 66 74 iomodel->FetchData(&nodeonmacayeal,NULL,NULL,FlowequationBordermacayealEnum); 67 75 if(dim==3)iomodel->FetchData(&nodeonpattyn,NULL,NULL,FlowequationBorderpattynEnum); … … 73 81 /*Initialize counter: */ 74 82 count=0; 75 83 84 /*figure out times: */ 85 timesx=(double*)xmalloc(Nx*sizeof(double)); 86 for(j=0;j<Nx;j++){ 87 timesx[j]=spcvx[(Mx-1)*Nx+j]; 88 } 89 /*unit conversion: */ 90 UnitConversion(timesx,Nx,ExtToIuEnum,TimeEnum); 91 /*figure out times: */ 92 timesy=(double*)xmalloc(Ny*sizeof(double)); 93 for(j=0;j<Ny;j++){ 94 timesy[j]=spcvy[(My-1)*Ny+j]; 95 } 96 /*unit conversion: */ 97 UnitConversion(timesy,Ny,ExtToIuEnum,TimeEnum); 98 /*figure out times: */ 99 timesz=(double*)xmalloc(Nz*sizeof(double)); 100 for(j=0;j<Nz;j++){ 101 timesz[j]=spcvz[(Mz-1)*Nz+j]; 102 } 103 /*unit conversion: */ 104 UnitConversion(timesz,Nz,ExtToIuEnum,TimeEnum); 105 106 76 107 /*Create spcs from x,y,z, as well as the spc values on those spcs: */ 77 108 for (i=0;i<numberofvertices;i++){ … … 195 226 /*Now add the regular spcs*/ 196 227 else{ 197 if ( !isnan(spcvx[i])){228 if (Mx==numberofvertices && !isnan(spcvx[i])){ 198 229 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,spcvx[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vx. 199 230 count++; 200 231 } 232 else if (Mx==numberofvertices+1) { 233 /*figure out times and values: */ 234 values=(double*)xmalloc(Nx*sizeof(double)); 235 spcpresent=false; 236 for(j=0;j<Nx;j++){ 237 values[j]=spcvx[i*Nx+j]/yts; 238 if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default 239 } 240 241 if(spcpresent){ 242 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,Nx,timesx,values,DiagnosticHorizAnalysisEnum)); 243 count++; 244 } 245 xfree((void**)&values); 246 } 201 247 else if (vertices_type[i]==HutterApproximationEnum){ 202 constraints->AddObject(new SpcDynamic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,DiagnosticHorizAnalysisEnum)); 203 count++; 204 } 205 206 if ( !isnan(spcvy[i])){248 constraints->AddObject(new SpcDynamic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,DiagnosticHorizAnalysisEnum)); 249 count++; 250 } 251 252 if (My==numberofvertices && !isnan(spcvy[i])){ 207 253 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,spcvy[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 1 to vy. 208 254 count++; 209 255 } 256 else if (My==numberofvertices+1){ 257 /*figure out times and values: */ 258 values=(double*)xmalloc(Ny*sizeof(double)); 259 spcpresent=false; 260 for(j=0;j<Ny;j++){ 261 values[j]=spcvy[i*Ny+j]/yts; 262 if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default 263 } 264 if(spcpresent){ 265 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,Ny,timesy,values,DiagnosticHorizAnalysisEnum)); 266 count++; 267 } 268 xfree((void**)&values); 269 } 210 270 else if (vertices_type[i]==HutterApproximationEnum){ 211 constraints->AddObject(new SpcDynamic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,DiagnosticHorizAnalysisEnum)); 212 count++; 213 } 214 215 if (!isnan(spcvz[i]) && ((int)vertices_type[i]==StokesApproximationEnum || ((int)vertices_type[i]==NoneApproximationEnum))){ 216 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvz[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy 217 count++; 271 constraints->AddObject(new SpcDynamic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,2,DiagnosticHorizAnalysisEnum)); 272 count++; 273 } 274 275 if ((int)vertices_type[i]==StokesApproximationEnum || ((int)vertices_type[i]==NoneApproximationEnum)){ 276 if (Mz==numberofvertices && !isnan(spcvz[i])){ 277 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,spcvz[i]/yts,DiagnosticHorizAnalysisEnum)); //add count'th spc, on node i+1, setting dof 2 to vy 278 count++; 279 } 280 else if (Mz==numberofvertices+1){ 281 /*figure out times and values: */ 282 values=(double*)xmalloc(Nz*sizeof(double)); 283 spcpresent=false; 284 for(j=0;j<Nz;j++){ 285 values[j]=spcvz[i*Nz+j]/yts; 286 if(!isnan(values[j]))spcpresent=true; //NaN means no spc by default 287 } 288 if(spcpresent){ 289 constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,3,Nz,timesz,values,DiagnosticHorizAnalysisEnum)); 290 count++; 291 } 292 xfree((void**)&values); 293 } 218 294 } 219 295 if ((int)vertices_type[i]==NoneApproximationEnum){ … … 221 297 count++; 222 298 } 299 223 300 } 224 301 } … … 236 313 xfree((void**)&z); 237 314 315 /*Free resources:*/ 316 xfree((void**)×x); 317 xfree((void**)×y); 318 xfree((void**)×z); 319 xfree((void**)&values); 320 238 321 /*Assign output pointer: */ 239 322 *pconstraints=constraints;
Note:
See TracChangeset
for help on using the changeset viewer.