Changeset 741


Ignore:
Timestamp:
06/03/09 09:06:27 (16 years ago)
Author:
seroussi
Message:

changed hutter partitioning

Location:
issm/trunk/src/c/ModelProcessorx/DiagnosticHutter
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/ModelProcessorx/DiagnosticHutter/CreateConstraintsDiagnosticHutter.cpp

    r560 r741  
    5151        #ifdef _PARALLEL_
    5252        /*keep only this partition's nodes:*/
    53         if((model->npart[i]==1)){
     53        if((model->my_grids[i])){
    5454        #endif
    5555
     
    7676
    7777        #ifdef _PARALLEL_
    78         } //if((npart[i]==1))
     78        } //if((my_grids[i]))
    7979        #endif
    8080        }
  • issm/trunk/src/c/ModelProcessorx/DiagnosticHutter/CreateElementsNodesAndMaterialsDiagnosticHutter.cpp

    r699 r741  
    9797        int node_numdofs;
    9898
     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
    99109        /*First create the elements, nodes and material properties: */
    100110        elements  = new DataSet(ElementsEnum());
     
    134144        xfree((void**)&model->elements2d);
    135145
    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): */
    141207
    142208        /*Fetch data temporarily needed: */
     
    158224                #ifdef _PARALLEL_
    159225                /*keep only this partition's nodes:*/
    160                 if(my_rank==npart[i]){
     226                if(my_grids[i]){
    161227                #endif
    162228
     
    200266                #ifdef _PARALLEL_
    201267                /*keep only this partition's nodes:*/
    202                 if(my_rank==npart[i]){
     268                if(my_grids[i]){
    203269                #endif
    204270
     
    253319
    254320        /*Free data: */
     321        xfree((void**)&model->elements);
    255322        xfree((void**)&model->gridonhutter);
    256323        xfree((void**)&model->thickness);
     
    305372        #ifdef _PARALLEL_
    306373        /*keep only this partition's nodes:*/
    307         if(npart[i]==my_rank){
     374        if(my_grids[i]){
    308375        #endif
    309376
    310377                node_id=i+1; //matlab indexing
    311378                       
    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
    313391
    314392                node_x[0]=model->x[i];
     
    368446
    369447        /*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
    371458        model->npart=npart;
    372459
Note: See TracChangeset for help on using the changeset viewer.