Changeset 3418


Ignore:
Timestamp:
04/07/10 14:34:35 (15 years ago)
Author:
Mathieu Morlighem
Message:

Added Discontinuous Galerkin partitioning

File:
1 edited

Legend:

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

    r3417 r3418  
    3131
    3232        /*output: */
    33         bool*   my_elements=NULL;
    34         bool*   my_vertices=NULL;
    35         bool*   my_nodes=NULL;
     33        bool* my_elements=NULL;
     34        bool* my_vertices=NULL;
     35        bool* my_nodes=NULL;
    3636        bool* my_bordervertices=NULL;
    3737
     
    3939        int* epart=NULL; //element partitioning.
    4040        int* npart=NULL; //node partitioning.
    41         int elements_width; //size of elements
     41        int  elements_width; //number of columns in elements (2d->3, 3d->6)
    4242        Vec  bordervertices=NULL;
    4343        double* serial_bordervertices=NULL;
     
    7777                epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding grids;
    7878        }
     79
    7980        /*Free rifts: */
    8081        xfree((void**)&iomodel->riftinfo);
     
    161162        bool*   my_vertices=NULL;
    162163        bool*   my_nodes=NULL;
     164        bool*   my_nodescontinuous=NULL;
    163165        bool*   my_bordervertices=NULL;
    164166
    165167        /*Mathieu's code: */
     168        /*First: get element and vertices partitioning from Continuous Galerkin: only the nodes are partitioned differently*/
     169        ContinuousGalerkinPartitioning(&my_elements,&my_vertices,&my_nodescontinuous,&my_bordervertices,iomodel,iomodel_handle);
     170        xfree((void**)&my_nodescontinuous);
     171
     172        /*Now we must build node partitioning
     173         *  - there are three nodes per element (discontinous)
     174         *  - for each element present of each partition, its three nodes will be in this partition
     175         *  - the edges require the dofs of the 2 nodes of each elements sharing the edge.
     176         *    if the 2 elements sharing the edge are on 2 different cpus, we must duplicate
     177         *    the two nodes that are not on the cpus so that the edge can access the dofs of
     178         *    all its 4 nodes
     179         */
     180
     181        /*Allocate*/
     182        my_nodes=(int*)xcalloc(3*iomodel->numberofelements,sizeof(int));
     183
     184        /*First: add all the nodes of all the elements belonging to this cpu*/
     185        if (strcmp(iomodel->meshtype,"2d")==0){
     186                for (i=0;i<iomodel->numberofelements;i++){
     187                        if (my_elements[i]){
     188                                my_nodes[3*i+0]=1;
     189                                my_nodes[3*i+1]=1;
     190                                my_nodes[3*i+2]=1;
     191                        }
     192                }
     193        }
     194        else{
     195                ISSMERROR(exprintf("not implemented yet"));
     196        }
     197
     198        /*Second: add all missing nodes*/
     199        #ifdef _PARALLEL_
     200
     201        /*Get edges and elements*/
     202        IoModelFetchData(&iomodel->edges,&iomodel->numberofedges,NULL,iomodel_handle,"edges");
     203
     204        /*!All elements have been partitioned above, only create elements for this CPU: */
     205        for (i=0;i<iomodel->numberofedges;i++){
     206
     207                /*Get left and right elements*/
     208                e1=iomodel->edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2]
     209                e2=iomodel->edges[4*i+3]-1; //edges are [node1 node2 elem1 elem2]
     210
     211                /* 1) If the element e1 is in the current partition
     212                 * 2) and if the edge of the element is shared by another element (internal edge)
     213                 * 3) and if this element is not in the same partition:
     214                 * we must clone the nodes on this partition so that the loads (Numericalflux)
     215                 * will have access to their properties (dofs,...)*/
     216                if(my_elements[(int)e1] && !isnan(e2) && !my_elements[(int)e2]){
     217
     218                        /*1: Get vertices ids*/
     219                        i1=(int)iomodel->edges[4*i+0];
     220                        i2=(int)iomodel->edges[4*i+1];
     221
     222                        /*2: Get the column where these ids are located in the index*/
     223                        pos==UNDEF;
     224                        for(j=0;j<3;j++){
     225                                if (iomodel->elements[3*(int)e2+j]==i1) pos=j+1;
     226                        }
     227                        ISSMASSERT(pos!=UNDEF);
     228
     229                        /*3: We have the id of the elements and the position of the vertices in the index
     230                         * we can now create the corresponding nodes:*/
     231                        my_nodes[(int)e2*3+pos-1]=1;
     232                        my_nodes[(int)e2*3+((pos+1)%3)]=1;
     233                }
     234        }
     235
     236        /*Free data: */
     237        xfree((void**)&iomodel->edges);
     238        #endif
    166239
    167240        /*Assign output pointers:*/
Note: See TracChangeset for help on using the changeset viewer.