Changeset 10231
- Timestamp:
- 10/18/11 13:22:36 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/mex/MeshPartition/MeshPartition.cpp
r8910 r10231 7 7 %Info needed from model are the following: 8 8 %mesh info: 9 numberofelements,numberof nodes,elements,elements_width9 numberofelements,numberofvertices,elements,elements_width 10 10 %Non-extruded 2d mesh info 11 11 nel2d,nods2d,elements2d, … … 13 13 nel2d_ext,nods2d_ext,elements2d_ext, 14 14 %Diverse 15 num layers,dim)15 numberoflayers,dim) 16 16 17 17 output: … … 30 30 31 31 /* 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; 36 36 int elements_width; 37 37 38 38 int numberofelements2d; 39 int numberof nodes2d;39 int numberofvertices2d; 40 40 double* elements2d=NULL; 41 41 42 int num layers;42 int numberoflayers; 43 43 int numareas=1; 44 44 45 45 /* 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; 51 50 52 51 /*Boot module: */ … … 57 56 58 57 /*Fetch data: */ 59 FetchMatlabData(&dim,mxGetAssignedField(MODEL,0,"dim "));58 FetchMatlabData(&dim,mxGetAssignedField(MODEL,0,"dimension")); 60 59 FetchMatlabData(&numberofelements,mxGetAssignedField(MODEL,0,"numberofelements")); 61 FetchMatlabData(&numberof nodes,mxGetAssignedField(MODEL,0,"numberofnodes"));60 FetchMatlabData(&numberofvertices,mxGetAssignedField(MODEL,0,"numberofvertices")); 62 61 FetchMatlabData(&elements,NULL,&elements_width,mxGetAssignedField(MODEL,0,"elements")); 63 62 64 63 if (dim==3){ 65 66 64 FetchMatlabData(&numberofelements2d,mxGetAssignedField(MODEL,0,"numberofelements2d")); 67 FetchMatlabData(&numberof nodes2d,mxGetAssignedField(MODEL,0,"numberofnodes2d"));65 FetchMatlabData(&numberofvertices2d,mxGetAssignedField(MODEL,0,"numberofvertices2d")); 68 66 FetchMatlabData(&elements2d,NULL,NULL,mxGetAssignedField(MODEL,0,"elements2d")); 69 70 67 } 71 FetchMatlabData(&num layers,mxGetAssignedField(MODEL,0,"numlayers"));68 FetchMatlabData(&numberoflayers,mxGetAssignedField(MODEL,0,"numberoflayers")); 72 69 FetchMatlabData(&numareas,NUMAREAS); 73 70 74 71 /*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); 78 74 79 75 /*Post process node_partitioning and element_partitioning to be in double format. Metis needed them in int* format: */ … … 83 79 } 84 80 85 node_partitioning=(double*)xmalloc(numberof nodes*sizeof(double));86 for (i=0;i<numberof nodes;i++){81 node_partitioning=(double*)xmalloc(numberofvertices*sizeof(double)); 82 for (i=0;i<numberofvertices;i++){ 87 83 node_partitioning[i]=(double)int_node_partitioning[i]+1; //Metis indexing from 0, matlab from 1. 88 84 } … … 90 86 /*Write data:*/ 91 87 WriteMatlabData(ELEMENTPARTITIONING,element_partitioning,numberofelements); 92 WriteMatlabData(NODEPARTITIONING,node_partitioning,numberof nodes);88 WriteMatlabData(NODEPARTITIONING,node_partitioning,numberofvertices); 93 89 94 90 /*Free ressources:*/ 95 91 //don't! let matlab do it. 96 97 92 98 93 /*end module: */ … … 102 97 void MeshPartitionUsage(void){ 103 98 printf(" usage:\n"); 104 printf(" [element_partitioning,node_partitioning]=MeshPartition(m odel,numareas)");99 printf(" [element_partitioning,node_partitioning]=MeshPartition(md.mesh,numpartitions)"); 105 100 printf(" where:\n"); 106 printf(" model is a @model class object instance,numareas is the number of processors on which partitioning will occur.\n");107 101 printf(" element_partitioning is a vector of partitioning area numbers, for every element.\n"); 108 102 printf(" node_partitioning is a vector of partitioning area numbers, for every node.\n");
Note:
See TracChangeset
for help on using the changeset viewer.