Changeset 23584
- Timestamp:
- 12/30/18 19:42:32 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/ModelProcessorx/CreateNodes.cpp
r23576 r23584 9 9 #include "./ModelProcessorx.h" 10 10 11 #define MAXCONNECTIVITY 5 12 13 bool IsNodeInRank(int* nodes_ranks,int* nodes_proc_count,int nid,int rank){/*{{{*/ 14 15 /*See if node is already in partition*/ 16 for(int k=0;k<nodes_proc_count[nid];k++){ 17 if(nodes_ranks[MAXCONNECTIVITY*nid+k] == rank) return true; 18 } 19 20 return false; 21 }/*}}}*/ 22 int NodeMasterRank(int* nodes_ranks,int nid){/*{{{*/ 23 return nodes_ranks[MAXCONNECTIVITY*nid+0]; 24 }/*}}}*/ 25 void AddNodeToRank(int* nodes_ranks,int* nodes_proc_count,int nid,int rank){/*{{{*/ 26 27 /*See if node is already in partition, return if this is the case*/ 28 if(IsNodeInRank(nodes_ranks,nodes_proc_count,nid,rank)) return; 29 30 /*This rank has not been marked for this node just yet so go ahead and add it*/ 31 nodes_ranks[MAXCONNECTIVITY*nid+nodes_proc_count[nid]] = rank; 32 nodes_proc_count[nid]++; 33 }/*}}}*/ 34 11 35 void CreateNodes(Nodes* nodes, IoModel* iomodel,int analysis,int finite_element,int approximation,int* approximations){ 12 36 13 37 /*Intermediaries*/ 14 38 int numnodes; 15 const int MAXCONNECTIVITY = 5;16 39 int element_numnodes; 17 40 int element_node_ids[40] = {0}; … … 22 45 int* epart = iomodel->epart; 23 46 24 25 47 /*Determine how many nodes we have in total*/ 26 /* Define nodes sids for each element*/48 /*{{{*/ 27 49 if(iomodel->meshelementtype==TriaEnum){ 28 50 switch(finite_element){ … … 125 147 _error_("mesh elements "<< EnumToStringx(iomodel->meshelementtype) <<" not supported yet"); 126 148 } 149 /*}}}*/ 127 150 128 151 /*create matrix that keeps track of all ranks that have node i, and initialize as -1 (Common to all CPUs)*/ … … 132 155 /*For all nodes, count how many cpus have node i (initialize with 0)*/ 133 156 int* nodes_proc_count = xNewZeroInit<int>(numnodes); 134 135 /*Create vector of size total numnodes, initialized with -1, that will keep track of local ids*/136 int* nodes_lids = xNew<int>(numnodes);137 for(int i=0;i<numnodes;i++) nodes_lids[i] = -1;138 157 139 158 /*Create vector of approximation per node (used for FS: vel or pressure)*/ … … 147 166 148 167 /*Go through all elements and mark all vertices for all partitions*/ 149 int lid = 0;168 /*{{{*/ 150 169 for(int i=0;i<iomodel->numberofelements;i++){ 151 170 … … 478 497 } 479 498 499 /*Add rank epart[i] for all nodes belonging to this element*/ 480 500 for(int j=0;j<element_numnodes;j++){ 481 501 int nid = element_node_ids[j]; _assert_(nid<numnodes); 482 483 /*See if it has already been marked*/ 484 bool found = false; 485 for(int k=0;k<nodes_proc_count[nid];k++){ 486 if(nodes_ranks[MAXCONNECTIVITY*nid+k] == epart[i]){ 487 found = true; 488 break; 489 } 490 } 491 492 /*On go below if this vertex has not been seen yet in this partition*/ 493 if(!found){ 494 /*This rank has not been marked for this vertex just yet so go ahead and mark it*/ 495 nodes_ranks[MAXCONNECTIVITY*nid+nodes_proc_count[nid]] = epart[i]; 496 nodes_proc_count[nid]++; 497 498 /*Keep track of local ids!*/ 499 if(epart[i]==my_rank){ 500 nodes_lids[nid] = lid; 501 lid++; 502 } 503 504 /*Make sure we don't go too far in the table*/ 505 if(nodes_proc_count[nid]>MAXCONNECTIVITY) _error_("need to increase MAXCONNECTIVITY (this is hard coded, contact ISSM developer)"); 506 } 507 } 508 } 509 if(finite_element==P1DGEnum){/* Special case for DG...{{{*/ 502 AddNodeToRank(nodes_ranks,nodes_proc_count,nid,epart[i]); 503 } 504 } 505 /*}}}*/ 506 if(finite_element==P1DGEnum){/*Special case for DG...{{{*/ 510 507 int node_list[4]; 511 508 if(!iomodel->domaintype==Domain2DhorizontalEnum) _error_("not implemented yet"); … … 533 530 for(int j=0;j<4;j++){ 534 531 int nid = node_list[j]; 535 bool found = false; 536 for(int k=0;k<nodes_proc_count[nid];k++){ 537 if(nodes_ranks[MAXCONNECTIVITY*nid+k] == epart[e1]){ 538 found = true; 539 break; 540 } 541 } 542 if(!found){ 543 nodes_ranks[MAXCONNECTIVITY*nid+nodes_proc_count[nid]] = epart[e1]; 544 nodes_proc_count[nid]++; 545 if(epart[e1]==my_rank){ 546 nodes_lids[nid] = lid; 547 lid++; 548 } 549 if(nodes_proc_count[nid]>MAXCONNECTIVITY) _error_("need to increase MAXCONNECTIVITY (this is hard coded, contact ISSM developer)"); 550 } 551 } 552 for(int j=0;j<4;j++){ 553 int nid = node_list[j]; 554 bool found = false; 555 for(int k=0;k<nodes_proc_count[nid];k++){ 556 if(nodes_ranks[MAXCONNECTIVITY*nid+k] == epart[e2]){ 557 found = true; 558 break; 559 } 560 } 561 if(!found){ 562 nodes_ranks[MAXCONNECTIVITY*nid+nodes_proc_count[nid]] = epart[e2]; 563 nodes_proc_count[nid]++; 564 if(epart[e2]==my_rank){ 565 nodes_lids[nid] = lid; 566 lid++; 567 } 568 if(nodes_proc_count[nid]>MAXCONNECTIVITY) _error_("need to increase MAXCONNECTIVITY (this is hard coded, contact ISSM developer)"); 569 } 532 AddNodeToRank(nodes_ranks,nodes_proc_count,nid,epart[e1]); 533 AddNodeToRank(nodes_ranks,nodes_proc_count,nid,epart[e2]); 570 534 } 571 535 } … … 573 537 } 574 538 }/*}}}*/ 575 //if(my_rank==0) printarray(nodes_ranks,numnodes,MAXCONNECTIVITY); 539 /*Vertex pairing for stressbalance{{{*/ 540 if(analysis==StressbalanceAnalysisEnum || analysis==StressbalanceVerticalAnalysisEnum){ 541 int *vertex_pairing = NULL; 542 int numvertex_pairing; 543 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,"md.stressbalance.vertex_pairing"); 544 _assert_(numvertex_pairing==0 || finite_element==P1Enum); 545 for(int i=0;i<numvertex_pairing;i++){ 546 int nid1 = vertex_pairing[2*i+0]-1; 547 int nid2 = vertex_pairing[2*i+1]-1; 548 for(int j=0;j<nodes_proc_count[nid1];j++) AddNodeToRank(nodes_ranks,nodes_proc_count,nid2,nodes_ranks[MAXCONNECTIVITY*nid1+j]); 549 for(int j=0;j<nodes_proc_count[nid2];j++) AddNodeToRank(nodes_ranks,nodes_proc_count,nid1,nodes_ranks[MAXCONNECTIVITY*nid2+j]); 550 } 551 xDelete<int>(vertex_pairing); 552 } 553 /*}}}*/ 554 555 /*Create vector of size total numnodes, initialized with -1, that will keep track of local ids*/ 556 int lid = 0; 557 int* nodes_lids = xNew<int>(numnodes); 558 for(int i=0;i<numnodes;i++){ 559 if(IsNodeInRank(nodes_ranks,nodes_proc_count,i,my_rank)){ 560 nodes_lids[i] = lid++; 561 } 562 else{ 563 nodes_lids[i] = -1; 564 } 565 } 576 566 577 567 /*Now, Count how many clones we have with other partitions*/ … … 687 677 nodes->common_recv_ids=common_recv_ids; 688 678 } 679
Note:
See TracChangeset
for help on using the changeset viewer.