Changeset 741
- Timestamp:
- 06/03/09 09:06:27 (16 years ago)
- Location:
- issm/trunk/src/c/ModelProcessorx/DiagnosticHutter
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp
r560 r741 51 51 #ifdef _PARALLEL_ 52 52 /*keep only this partition's nodes:*/ 53 if((model-> npart[i]==1)){53 if((model->my_grids[i])){ 54 54 #endif 55 55 … … 76 76 77 77 #ifdef _PARALLEL_ 78 } //if(( npart[i]==1))78 } //if((my_grids[i])) 79 79 #endif 80 80 } -
issm/trunk/src/c/ModelProcessorx/DiagnosticHutter/CreateElementsNodesAndMaterialsDiagnosticHutter.cpp
r699 r741 97 97 int node_numdofs; 98 98 99 #ifdef _PARALLEL_ 100 /*Metis partitioning: */ 101 int range; 102 Vec gridborder=NULL; 103 int my_numgrids; 104 int* all_numgrids=NULL; 105 int gridcount; 106 int count; 107 #endif 108 99 109 /*First create the elements, nodes and material properties: */ 100 110 elements = new DataSet(ElementsEnum()); … … 134 144 xfree((void**)&model->elements2d); 135 145 136 137 #endif 138 139 /*Hutter elements can be partitioned using npart, instead of epart for more classic tria and penta elements. The reason is 140 * that each hutter elements either lies on a node (in 2d), or a pair of vertically juxtaposed nodes (in 3d): */ 146 /*Used later on: */ 147 my_grids=(int*)xcalloc(model->numberofnodes,sizeof(int)); 148 #endif 149 150 #ifdef _PARALLEL_ 151 if(strcmp(model->meshtype,"2d")==0){ 152 ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat"); 153 for (i=0;i<model->numberofelements;i++){ 154 if(my_rank==epart[i]){ 155 /*Now that we are here, we can also start building the list of grids belonging to this node partition: we use 156 *the element index to do this. For each element n, we know index[n][0:2] holds the indices (matlab indexing) 157 into the grid coordinates. If we start plugging 1 into my_grids for each index[n][i] (i=0:2), then my_grids 158 will hold which grids belong to this partition*/ 159 160 my_grids[(int)*(model->elements+elements_width*i+0)-1]=1; 161 my_grids[(int)*(model->elements+elements_width*i+1)-1]=1; 162 my_grids[(int)*(model->elements+elements_width*i+2)-1]=1; 163 } 164 } 165 } 166 else{ 167 ModelFetchData((void**)&model->elements,NULL,NULL,model_handle,"elements","Matrix","Mat"); 168 for (i=0;i<model->numberofelements;i++){ 169 if(my_rank==epart[i]){ 170 my_grids[(int)*(model->elements+elements_width*i+0)-1]=1; 171 my_grids[(int)*(model->elements+elements_width*i+1)-1]=1; 172 my_grids[(int)*(model->elements+elements_width*i+2)-1]=1; 173 my_grids[(int)*(model->elements+elements_width*i+3)-1]=1; 174 my_grids[(int)*(model->elements+elements_width*i+4)-1]=1; 175 my_grids[(int)*(model->elements+elements_width*i+5)-1]=1; 176 } 177 } 178 } 179 180 /*From the element partitioning, we can determine which grids are on the inside of this cpu's 181 *element partition, and which are on its border with other nodes:*/ 182 gridborder=NewVec(model->numberofnodes); 183 184 for (i=0;i<model->numberofnodes;i++){ 185 if(my_grids[i])VecSetValue(gridborder,i,1,ADD_VALUES); 186 } 187 VecAssemblyBegin(gridborder); 188 VecAssemblyEnd(gridborder); 189 190 #ifdef _DEBUG_ 191 VecView(gridborder,PETSC_VIEWER_STDOUT_WORLD); 192 #endif 193 194 VecToMPISerial(&my_bordergrids,gridborder); 195 196 #ifdef _DEBUG_ 197 if(my_rank==0){ 198 for (i=0;i<model->numberofnodes;i++){ 199 printf("Grid id %i Border grid %lf\n",i+1,my_bordergrids[i]); 200 } 201 } 202 #endif 203 #endif 204 205 /*Hutter elements can be partitioned using epart, even if 206 * each hutter elements either lies on a node (in 2d), or a pair of vertically juxtaposed nodes (in 3d): */ 141 207 142 208 /*Fetch data temporarily needed: */ … … 158 224 #ifdef _PARALLEL_ 159 225 /*keep only this partition's nodes:*/ 160 if(my_ rank==npart[i]){226 if(my_grids[i]){ 161 227 #endif 162 228 … … 200 266 #ifdef _PARALLEL_ 201 267 /*keep only this partition's nodes:*/ 202 if(my_ rank==npart[i]){268 if(my_grids[i]){ 203 269 #endif 204 270 … … 253 319 254 320 /*Free data: */ 321 xfree((void**)&model->elements); 255 322 xfree((void**)&model->gridonhutter); 256 323 xfree((void**)&model->thickness); … … 305 372 #ifdef _PARALLEL_ 306 373 /*keep only this partition's nodes:*/ 307 if( npart[i]==my_rank){374 if(my_grids[i]){ 308 375 #endif 309 376 310 377 node_id=i+1; //matlab indexing 311 378 312 node_partitionborder=0; 379 380 #ifdef _PARALLEL_ 381 if(my_bordergrids[i]>1.0) { //this grid belongs to a partition border 382 node_partitionborder=1; 383 } 384 else{ 385 node_partitionborder=0; 386 } 387 #else 388 node_partitionborder=0; 389 #endif 390 313 391 314 392 node_x[0]=model->x[i]; … … 368 446 369 447 /*Keep partitioning information into model*/ 370 xfree((void**)&epart); 448 model->epart=epart; 449 model->my_grids=my_grids; 450 model->my_bordergrids=my_bordergrids; 451 452 /*Keep partitioning information into model*/ 453 #ifdef _PARALLEL_ 454 xfree((void**)&all_numgrids); 455 xfree((void**)&npart); 456 VecFree(&gridborder); 457 #endif 371 458 model->npart=npart; 372 459
Note:
See TracChangeset
for help on using the changeset viewer.