Ignore:
Timestamp:
09/16/13 09:43:55 (12 years ago)
Author:
Mathieu Morlighem
Message:

merged trunk-jpl and trunk for revision 16135

Location:
issm/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk

  • issm/trunk/src

  • issm/trunk/src/c

    • Property svn:ignore
      •  

        old new  
        1414probe.results
        1515stXXXX*
        16 
         16.deps
         17.dirstamp
  • issm/trunk/src/c/modules/ModelProcessorx

    • Property svn:ignore set to
      .deps
      .dirstamp
  • issm/trunk/src/c/modules/ModelProcessorx/NodesPartitioning.cpp

    r15396 r16137  
    2020void  NodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel, bool continuous){
    2121
    22         /*First thing, this is a new partition for a new analysis_type, therefore, to avoid a leak, erase the nodes partition that might come through pmy_nodes: */
    23         xDelete<bool>(*pmy_nodes);
    24 
    25         /*Now, depending on whether we are running galerkin discontinous or continuous elements, carry out a different partition of the nodes: */
    2622        if(continuous==true)
    2723                ContinuousGalerkinNodesPartitioning(pmy_nodes,my_elements, my_vertices, iomodel);
     
    3228void  ContinuousGalerkinNodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel){
    3329
    34         /*as many nodes as there are vertices */
    35         int    numberofvertices;
    36 
    3730        /*output: */
    38         bool* my_nodes=NULL;
    39 
    40         /*Fetch parameters: */
    41         iomodel->Constant(&numberofvertices,MeshNumberofverticesEnum);
    42 
    43         my_nodes=xNew<bool>(numberofvertices);
    44         for(int i=0;i<numberofvertices;i++) my_nodes[i]=(bool)my_vertices[i];
     31        bool* my_nodes=xNew<bool>(iomodel->numberofvertices);
     32        for(int i=0;i<iomodel->numberofvertices;i++) my_nodes[i]=(bool)my_vertices[i];
    4533
    4634        /*Assign output pointers:*/
     
    5038void  DiscontinuousGalerkinNodesPartitioning(bool** pmy_nodes,bool* my_elements, int* my_vertices, IoModel* iomodel){
    5139
    52         int    numberofelements;
     40        /* Each element has it own nodes (as many as vertices) + additional nodes
     41         * from neighboring elements for each face. This yields to a very different
     42         * partition for the nodes and the vertices. The vertices are similar to
     43         * continuous galerkin, but the nodes partitioning involves faces, which
     44         * messes up sorting of ids. */
    5345
    54         /*Fetch parameters: */
    55         iomodel->Constant(&numberofelements,MeshNumberofelementsEnum);
    56 
    57         /*each element has it own nodes (as many as vertices) + additional nodes from neighbouring elements for each edge. This yields to a very different partition for
    58          * the nodes and the vertices. The vertices are similar to continuous galerkin, but the nodes partitioning involves edges, which mess up sorting of
    59          * ids. */
    60 
    61         int i,j;
    62         int    dim;
    63 
    64         /*output: */
    65         bool*   my_nodes=NULL;
    66 
    67         int  i1,i2;
     46        /*Intermediaries*/
     47        int  i,i1,i2;
    6848        int  cols;
    6949        int  e1,e2;
    7050        int  pos;
    71         int  numberofedges;
    72         int *edges         = NULL;
    73         int *elements      = NULL;
    7451
    75         /*Fetch parameters: */
    76         iomodel->Constant(&dim,MeshDimensionEnum);
     52        /*Get faces and elements*/
     53        CreateEdges(iomodel);
    7754
    7855        /*Build discontinuous node partitioning
    7956         *  - there are three nodes per element (discontinous)
    8057         *  - for each element present of each partition, its three nodes will be in this partition
    81          *  - the edges require the dofs of the 2 nodes of each elements sharing the edge.
    82          *    if the 2 elements sharing the edge are on 2 different cpus, we must duplicate
    83          *    the two nodes that are not on the cpus so that the edge can access the dofs of
     58         *  - the faces require the dofs of the 2 nodes of each elements sharing the face.
     59         *    if the 2 elements sharing the face are on 2 different cpus, we must duplicate
     60         *    the two nodes that are not on the cpus so that the face can access the dofs of
    8461         *    all its 4 nodes
    8562         */
    8663
    8764        /*Allocate*/
    88         my_nodes=xNewZeroInit<bool>(3*numberofelements);
     65        bool* my_nodes=xNewZeroInit<bool>(3*iomodel->numberofelements);
    8966
    9067        /*First: add all the nodes of all the elements belonging to this cpu*/
    91         if (dim==2){
    92                 for (i=0;i<numberofelements;i++){
     68        if(iomodel->dim==2){
     69                for (i=0;i<iomodel->numberofelements;i++){
    9370                        if (my_elements[i]){
    9471                                my_nodes[3*i+0]=true;
     
    10481        /*Second: add all missing nodes*/
    10582
    106         /*Get edges and elements*/
    107         iomodel->FetchData(&edges,&numberofedges,&cols,MeshEdgesEnum);
    108         iomodel->FetchData(&elements,NULL,NULL,MeshElementsEnum);
    109         if (cols!=4) _error_("field edges should have 4 columns");
     83        /*Get faces and elements*/
     84        CreateFaces(iomodel);
    11085
    11186        /*!All elements have been partitioned above, only create elements for this CPU: */
    112         for (i=0;i<numberofedges;i++){
     87        for(int i=0;i<iomodel->numberoffaces;i++){
    11388
    11489                /*Get left and right elements*/
    115                 e1=edges[4*i+2]-1; //edges are [node1 node2 elem1 elem2]
    116                 e2=edges[4*i+3]-1; //edges are [node1 node2 elem1 elem2]
     90                e1=iomodel->faces[4*i+2]-1; //faces are [node1 node2 elem1 elem2]
     91                e2=iomodel->faces[4*i+3]-1; //faces are [node1 node2 elem1 elem2]
    11792
    11893                /* 1) If the element e1 is in the current partition
    119                  * 2) and if the edge of the element is shared by another element (internal edge)
     94                 * 2) and if the face of the element is shared by another element (internal face)
    12095                 * 3) and if this element is not in the same partition:
    12196                 * we must clone the nodes on this partition so that the loads (Numericalflux)
     
    12499
    125100                        /*1: Get vertices ids*/
    126                         i1=edges[4*i+0];
    127                         i2=edges[4*i+1];
     101                        i1=iomodel->faces[4*i+0];
     102                        i2=iomodel->faces[4*i+1];
    128103
    129104                        /*2: Get the column where these ids are located in the index*/
    130105                        pos=UNDEF;
    131                         for(j=0;j<3;j++){
    132                                 if (elements[3*e2+j]==i1) pos=j;
     106                        for(int j=0;j<3;j++){
     107                                if(iomodel->elements[3*e2+j]==i1) pos=j;
    133108                        }
    134109
    135110                        /*3: We have the id of the elements and the position of the vertices in the index
    136111                         * we can now create the corresponding nodes:*/
    137                         if (pos==0){
     112                        if(pos==0){
    138113                                my_nodes[e2*3+0]=true;
    139114                                my_nodes[e2*3+2]=true;
     
    143118                                my_nodes[e2*3+0]=true;
    144119                        }
    145                         else if (pos==2){
     120                        else if(pos==2){
    146121                                my_nodes[e2*3+2]=true;
    147122                                my_nodes[e2*3+1]=true;
    148123                        }
    149124                        else{
    150                                 _error_("Problem in edges creation");
     125                                _error_("Problem in faces creation");
    151126                        }
    152127                }
    153128        }
    154129
    155         /*Free data: */
    156         xDelete<int>(elements);
    157         xDelete<int>(edges);
    158 
    159         /*Assign output pointers:*/
     130        /*Free data and assign output pointers */
    160131        *pmy_nodes=my_nodes;
    161132}
Note: See TracChangeset for help on using the changeset viewer.