Changeset 23504


Ignore:
Timestamp:
12/05/18 14:35:58 (6 years ago)
Author:
Mathieu Morlighem
Message:

CHG: cosmetics

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp

    r20980 r23504  
    1717void  ElementsAndVerticesPartitioning(bool** pmy_elements, int** pmy_vertices, IoModel* iomodel){
    1818
    19         int i,j;
    20 
    21         const int RIFTINFOSIZE = 12;
    2219        int numberofelements2d;
    2320        int numberofvertices2d;
    2421        int numlayers;
    25         int numrifts;
    2622        int numvertex_pairing;
    27 
    28         /*output: */
    29         bool *my_elements = NULL;
    30         int  *my_vertices = NULL;
    3123
    3224        /*intermediary: */
     
    3628        int         el1,el2;
    3729        int        *elements2d     = NULL;
    38         int        *vertex_pairing = NULL;
    39         IssmDouble *riftinfo       = NULL;
    4030
    4131        /*Get my_rank:*/
     
    4333        int num_procs = IssmComm::GetSize();
    4434
    45         /*Fetch parameters: */
    46         iomodel->FindConstant(&numrifts,"md.rifts.numrifts");
    47 
    4835        /*First, check that partitioning has not yet been carryed out. Just check whether my_elements pointers is not already assigned a value: */
    49         if(*pmy_elements)return;
     36        if(*pmy_elements) return;
    5037
    5138        /*Number of vertices per elements, needed to correctly retrieve data: */
     
    7562        }
    7663
     64        /*Partition and free resouces*/
    7765        MeshPartitionx(&epart,&npart,iomodel->numberofelements,iomodel->numberofvertices,iomodel->elements,numberofelements2d,numberofvertices2d,elements2d,numlayers,elements_width,iomodel->meshelementtype,num_procs);
    78 
    79         /*Free elements2d: */
    8066        xDelete<int>(elements2d);
     67        xDelete<int>(npart);
    8168
    8269        /*Deal with rifts, they have to be included into one partition only, not several: */
     70        int numrifts;
     71        iomodel->FindConstant(&numrifts,"md.rifts.numrifts");
    8372        if(numrifts){
     73                IssmDouble *riftinfo = NULL;
    8474                iomodel->FetchData(&riftinfo,&numrifts,NULL,"md.rifts.riftstruct");
    85                 for(i=0;i<numrifts;i++){
     75                for(int i=0;i<numrifts;i++){
     76                        const int RIFTINFOSIZE = 12;
    8677                        el1=reCast<int>(*(riftinfo+RIFTINFOSIZE*i+2))-1; //matlab indexing to c indexing
    8778                        el2=reCast<int>(*(riftinfo+RIFTINFOSIZE*i+3))-1; //matlab indexing to c indexing
     
    9182        }
    9283
    93         /*Used later on: */
    94         my_vertices=xNewZeroInit<int>(iomodel->numberofvertices);
    95         my_elements=xNewZeroInit<bool>(iomodel->numberofelements);
     84        /*Create my_vertices and my_elements, used by each partition */
     85        bool *my_elements = xNewZeroInit<bool>(iomodel->numberofelements);
     86        int  *my_vertices = xNewZeroInit<int>(iomodel->numberofvertices);
    9687
    9788        /*Start figuring out, out of the partition, which elements belong to this cpu: */
    98         for(i=0;i<iomodel->numberofelements;i++){
     89        for(int i=0;i<iomodel->numberofelements;i++){
    9990
    10091                /*!All elements have been partitioned above, only deal with elements for this cpu: */
     
    10596                         into the vertices coordinates. If we start plugging 1 into my_vertices for each index[n][i] (i=0:2), then my_vertices
    10697                         will hold which vertices belong to this partition*/
    107                         for(j=0;j<elements_width;j++){
     98                        for(int j=0;j<elements_width;j++){
    10899                                my_vertices[iomodel->elements[elements_width*i+j]-1]=1;
    109100                        }
     
    114105         * penpair has 2 nodes that are poointing toward 2 vertices.
    115106         * The 2 vertices must be in the same cpu as the penpair*/
     107        int *vertex_pairing = NULL;
    116108        iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,"md.stressbalance.vertex_pairing");
    117         for(i=0;i<numvertex_pairing;i++){
     109        for(int i=0;i<numvertex_pairing;i++){
    118110                if(my_vertices[vertex_pairing[2*i+0]-1] && !my_vertices[vertex_pairing[2*i+1]-1]){
    119111                        my_vertices[vertex_pairing[2*i+1]-1]=2; //to know that these elements are not on the partition
     
    122114        xDelete<int>(vertex_pairing);
    123115        iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,"md.masstransport.vertex_pairing");
    124         for(i=0;i<numvertex_pairing;i++){
     116        for(int i=0;i<numvertex_pairing;i++){
    125117                if(my_vertices[vertex_pairing[2*i+0]-1] && !my_vertices[vertex_pairing[2*i+1]-1]){
    126118                        my_vertices[vertex_pairing[2*i+1]-1]=2; //to know that these elements are not on the partition
     
    129121        xDelete<int>(vertex_pairing);
    130122
    131         /*Free ressources:*/
    132         xDelete<int>(npart);
     123        /*cleanup and assign output pointer*/
    133124        xDelete<int>(epart);
    134 
    135         /*Assign output pointers:*/
    136125        *pmy_elements=my_elements;
    137126        *pmy_vertices=my_vertices;
Note: See TracChangeset for help on using the changeset viewer.