Changeset 23504
- Timestamp:
- 12/05/18 14:35:58 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
r20980 r23504 17 17 void ElementsAndVerticesPartitioning(bool** pmy_elements, int** pmy_vertices, IoModel* iomodel){ 18 18 19 int i,j;20 21 const int RIFTINFOSIZE = 12;22 19 int numberofelements2d; 23 20 int numberofvertices2d; 24 21 int numlayers; 25 int numrifts;26 22 int numvertex_pairing; 27 28 /*output: */29 bool *my_elements = NULL;30 int *my_vertices = NULL;31 23 32 24 /*intermediary: */ … … 36 28 int el1,el2; 37 29 int *elements2d = NULL; 38 int *vertex_pairing = NULL;39 IssmDouble *riftinfo = NULL;40 30 41 31 /*Get my_rank:*/ … … 43 33 int num_procs = IssmComm::GetSize(); 44 34 45 /*Fetch parameters: */46 iomodel->FindConstant(&numrifts,"md.rifts.numrifts");47 48 35 /*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; 50 37 51 38 /*Number of vertices per elements, needed to correctly retrieve data: */ … … 75 62 } 76 63 64 /*Partition and free resouces*/ 77 65 MeshPartitionx(&epart,&npart,iomodel->numberofelements,iomodel->numberofvertices,iomodel->elements,numberofelements2d,numberofvertices2d,elements2d,numlayers,elements_width,iomodel->meshelementtype,num_procs); 78 79 /*Free elements2d: */80 66 xDelete<int>(elements2d); 67 xDelete<int>(npart); 81 68 82 69 /*Deal with rifts, they have to be included into one partition only, not several: */ 70 int numrifts; 71 iomodel->FindConstant(&numrifts,"md.rifts.numrifts"); 83 72 if(numrifts){ 73 IssmDouble *riftinfo = NULL; 84 74 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; 86 77 el1=reCast<int>(*(riftinfo+RIFTINFOSIZE*i+2))-1; //matlab indexing to c indexing 87 78 el2=reCast<int>(*(riftinfo+RIFTINFOSIZE*i+3))-1; //matlab indexing to c indexing … … 91 82 } 92 83 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); 96 87 97 88 /*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++){ 99 90 100 91 /*!All elements have been partitioned above, only deal with elements for this cpu: */ … … 105 96 into the vertices coordinates. If we start plugging 1 into my_vertices for each index[n][i] (i=0:2), then my_vertices 106 97 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++){ 108 99 my_vertices[iomodel->elements[elements_width*i+j]-1]=1; 109 100 } … … 114 105 * penpair has 2 nodes that are poointing toward 2 vertices. 115 106 * The 2 vertices must be in the same cpu as the penpair*/ 107 int *vertex_pairing = NULL; 116 108 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++){ 118 110 if(my_vertices[vertex_pairing[2*i+0]-1] && !my_vertices[vertex_pairing[2*i+1]-1]){ 119 111 my_vertices[vertex_pairing[2*i+1]-1]=2; //to know that these elements are not on the partition … … 122 114 xDelete<int>(vertex_pairing); 123 115 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++){ 125 117 if(my_vertices[vertex_pairing[2*i+0]-1] && !my_vertices[vertex_pairing[2*i+1]-1]){ 126 118 my_vertices[vertex_pairing[2*i+1]-1]=2; //to know that these elements are not on the partition … … 129 121 xDelete<int>(vertex_pairing); 130 122 131 /*Free ressources:*/ 132 xDelete<int>(npart); 123 /*cleanup and assign output pointer*/ 133 124 xDelete<int>(epart); 134 135 /*Assign output pointers:*/136 125 *pmy_elements=my_elements; 137 126 *pmy_vertices=my_vertices;
Note:
See TracChangeset
for help on using the changeset viewer.