source:
issm/oecreview/Archive/23390-24306/ISSM-23503-23504.diff
Last change on this file was 24307, checked in by , 5 years ago | |
---|---|
File size: 5.1 KB |
-
../trunk-jpl/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
16 16 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 23 28 /*output: */29 bool *my_elements = NULL;30 int *my_vertices = NULL;31 32 24 /*intermediary: */ 33 25 int *epart = NULL; //element partitioning. 34 26 int *npart = NULL; //node partitioning. … … 35 27 int elements_width; //number of columns in elements (2d->3, 3d->6) 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:*/ 42 32 int my_rank = IssmComm::GetRank(); 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: */ 52 39 /*Determine parallel partitioning of elements: we use Metis for now. First load the data, then partition*/ … … 74 61 _error_("mesh elements "<< EnumToStringx(iomodel->meshelementtype) <<" not supported yet"); 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 88 79 epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices; … … 90 81 iomodel->DeleteData(riftinfo,"md.rifts.riftstruct"); 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: */ 101 92 if(my_rank==epart[i]){ … … 104 95 *the element index to do this. For each element n, we know index[n][0:2] holds the indices (matlab indexing) 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 } 110 101 } … … 113 104 /*We might have vertex_pairing in which case, some vertices have to be cloned: 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 120 112 } … … 121 113 } 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 127 119 } … … 128 120 } 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; 138 127 }
Note:
See TracBrowser
for help on using the repository browser.