Changeset 10231


Ignore:
Timestamp:
10/18/11 13:22:36 (13 years ago)
Author:
Mathieu Morlighem
Message:

Fixed MeshPartition with new model template

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/mex/MeshPartition/MeshPartition.cpp

    r8910 r10231  
    77        %Info needed from model are the following:
    88        %mesh info:
    9         numberofelements,numberofnodes,elements,elements_width
     9        numberofelements,numberofvertices,elements,elements_width
    1010        %Non-extruded 2d mesh info
    1111        nel2d,nods2d,elements2d,
     
    1313        nel2d_ext,nods2d_ext,elements2d_ext,
    1414        %Diverse
    15         numlayers,dim)
     15        numberoflayers,dim)
    1616
    1717        output:
     
    3030
    3131        /* required input: */
    32         int dim;
    33         int numberofelements;
    34         int numberofnodes;
    35         double* elements=NULL;
     32        int     dim;
     33        int     numberofelements;
     34        int     numberofvertices;
     35        double *elements         = NULL;
    3636        int     elements_width;
    3737
    3838        int numberofelements2d;
    39         int numberofnodes2d;
     39        int numberofvertices2d;
    4040        double* elements2d=NULL;
    4141
    42         int numlayers;
     42        int numberoflayers;
    4343        int numareas=1;
    4444
    4545        /* output: */
    46         int*    int_element_partitioning=NULL;
    47         int*    int_node_partitioning   =NULL;
    48         double* element_partitioning    =NULL;
    49         double* node_partitioning       =NULL;
    50 
     46        int    *int_element_partitioning = NULL;
     47        int    *int_node_partitioning    = NULL;
     48        double *element_partitioning     = NULL;
     49        double *node_partitioning        = NULL;
    5150
    5251        /*Boot module: */
     
    5756
    5857        /*Fetch data: */
    59         FetchMatlabData(&dim,mxGetAssignedField(MODEL,0,"dim"));
     58        FetchMatlabData(&dim,mxGetAssignedField(MODEL,0,"dimension"));
    6059        FetchMatlabData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements"));
    61         FetchMatlabData(&numberofnodes,mxGetAssignedField(MODEL,0,"numberofnodes"));
     60        FetchMatlabData(&numberofvertices,mxGetAssignedField(MODEL,0,"numberofvertices"));
    6261        FetchMatlabData(&elements,NULL,&elements_width,mxGetAssignedField(MODEL,0,"elements"));
    6362
    6463        if (dim==3){
    65        
    6664                FetchMatlabData(&numberofelements2d,mxGetAssignedField(MODEL,0,"numberofelements2d"));
    67                 FetchMatlabData(&numberofnodes2d,mxGetAssignedField(MODEL,0,"numberofnodes2d"));
     65                FetchMatlabData(&numberofvertices2d,mxGetAssignedField(MODEL,0,"numberofvertices2d"));
    6866                FetchMatlabData(&elements2d,NULL,NULL,mxGetAssignedField(MODEL,0,"elements2d"));
    69 
    7067        }
    71         FetchMatlabData(&numlayers,mxGetAssignedField(MODEL,0,"numlayers"));
     68        FetchMatlabData(&numberoflayers,mxGetAssignedField(MODEL,0,"numberoflayers"));
    7269        FetchMatlabData(&numareas,NUMAREAS);
    7370
    7471        /*Run partitioning algorithm based on a "clever" use of the Metis partitioner: */
    75         MeshPartitionx(&int_element_partitioning,&int_node_partitioning,numberofelements,numberofnodes,elements,
    76                 numberofelements2d,numberofnodes2d,elements2d,numlayers,elements_width,dim,numareas);
    77 
     72        MeshPartitionx(&int_element_partitioning,&int_node_partitioning,numberofelements,numberofvertices,elements,
     73                numberofelements2d,numberofvertices2d,elements2d,numberoflayers,elements_width,dim,numareas);
    7874
    7975        /*Post process node_partitioning and element_partitioning to be in double format. Metis needed them in int* format: */
     
    8379        }
    8480       
    85         node_partitioning=(double*)xmalloc(numberofnodes*sizeof(double));
    86         for (i=0;i<numberofnodes;i++){
     81        node_partitioning=(double*)xmalloc(numberofvertices*sizeof(double));
     82        for (i=0;i<numberofvertices;i++){
    8783                node_partitioning[i]=(double)int_node_partitioning[i]+1; //Metis indexing from 0, matlab from 1.
    8884        }
     
    9086        /*Write data:*/
    9187        WriteMatlabData(ELEMENTPARTITIONING,element_partitioning,numberofelements);
    92         WriteMatlabData(NODEPARTITIONING,node_partitioning,numberofnodes);
     88        WriteMatlabData(NODEPARTITIONING,node_partitioning,numberofvertices);
    9389       
    9490        /*Free ressources:*/
    9591        //don't! let matlab do it.
    96 
    9792
    9893        /*end module: */
     
    10297void MeshPartitionUsage(void){
    10398        printf("   usage:\n");
    104         printf("   [element_partitioning,node_partitioning]=MeshPartition(model,numareas)");
     99        printf("   [element_partitioning,node_partitioning]=MeshPartition(md.mesh,numpartitions)");
    105100        printf("   where:\n");
    106         printf("      model is a @model class object instance,numareas is the number of processors on which partitioning will occur.\n");
    107101        printf("      element_partitioning is a vector of partitioning area numbers, for every element.\n");
    108102        printf("      node_partitioning is a vector of partitioning area numbers, for every node.\n");
Note: See TracChangeset for help on using the changeset viewer.