Changeset 12878 for issm/branches/trunk-jpl-damage/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
- Timestamp:
- 08/02/12 17:13:12 (13 years ago)
- Location:
- issm/branches/trunk-jpl-damage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/branches/trunk-jpl-damage
- Property svn:mergeinfo changed
-
issm/branches/trunk-jpl-damage/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp
r12168 r12878 10 10 11 11 #include <string.h> 12 #include "../../ objects/objects.h"12 #include "../../classes/objects/objects.h" 13 13 #include "../../shared/shared.h" 14 14 #include "../../EnumDefinitions/EnumDefinitions.h" … … 42 42 int el1,el2; 43 43 int dim; 44 double* elements=NULL;45 double* elements2d=NULL;46 double* riftinfo=NULL;47 double* vertex_pairing=NULL;44 IssmDouble* elements=NULL; 45 IssmDouble* elements2d=NULL; 46 IssmDouble* riftinfo=NULL; 47 IssmDouble* vertex_pairing=NULL; 48 48 49 49 /*Fetch parameters: */ … … 76 76 77 77 /*Free elements and elements2d: */ 78 x free((void**)&elements);79 x free((void**)&elements2d);78 xDelete<IssmDouble>(elements); 79 xDelete<IssmDouble>(elements2d); 80 80 81 81 /*Deal with rifts, they have to be included into one partition only, not several: */ … … 83 83 iomodel->FetchData(&riftinfo,&numrifts,NULL,RiftsRiftstructEnum); 84 84 for(i=0;i<numrifts;i++){ 85 el1= (int)*(riftinfo+RIFTINFOSIZE*i+2)-1; //matlab indexing to c indexing86 el2= (int)*(riftinfo+RIFTINFOSIZE*i+3)-1; //matlab indexing to c indexing85 el1=reCast<int>(*(riftinfo+RIFTINFOSIZE*i+2))-1; //matlab indexing to c indexing 86 el2=reCast<int>(*(riftinfo+RIFTINFOSIZE*i+3))-1; //matlab indexing to c indexing 87 87 epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices; 88 88 } 89 x free((void**)&riftinfo);89 xDelete<IssmDouble>(riftinfo); 90 90 } 91 91 92 92 /*Used later on: */ 93 my_vertices= (int*)xcalloc(numberofvertices,sizeof(int));94 my_elements= (bool*)xcalloc(numberofelements,sizeof(bool));93 my_vertices=xNewZeroInit<int>(numberofvertices); 94 my_elements=xNewZeroInit<bool>(numberofelements); 95 95 96 96 /*Start figuring out, out of the partition, which elements belong to this cpu: */ … … 107 107 into the vertices coordinates. If we start plugging 1 into my_vertices for each index[n][i] (i=0:2), then my_vertices 108 108 will hold which vertices belong to this partition*/ 109 my_vertices[ (int)*(elements+elements_width*i+0)-1]=1;110 my_vertices[ (int)*(elements+elements_width*i+1)-1]=1;111 my_vertices[ (int)*(elements+elements_width*i+2)-1]=1;109 my_vertices[reCast<int>(*(elements+elements_width*i+0))-1]=1; 110 my_vertices[reCast<int>(*(elements+elements_width*i+1))-1]=1; 111 my_vertices[reCast<int>(*(elements+elements_width*i+2))-1]=1; 112 112 113 113 if(elements_width==6){ 114 my_vertices[ (int)*(elements+elements_width*i+3)-1]=1;115 my_vertices[ (int)*(elements+elements_width*i+4)-1]=1;116 my_vertices[ (int)*(elements+elements_width*i+5)-1]=1;114 my_vertices[reCast<int>(*(elements+elements_width*i+3))-1]=1; 115 my_vertices[reCast<int>(*(elements+elements_width*i+4))-1]=1; 116 my_vertices[reCast<int>(*(elements+elements_width*i+5))-1]=1; 117 117 } 118 118 } 119 119 }//for (i=0;i<numberofelements;i++) 120 120 /*Free data : */ 121 x free((void**)&elements);121 xDelete<IssmDouble>(elements); 122 122 123 123 /*We might have vertex_pairing in which case, some vertices have to be cloned: … … 126 126 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,DiagnosticVertexPairingEnum); 127 127 for(i=0;i<numvertex_pairing;i++){ 128 if(my_vertices[ (int)vertex_pairing[2*i+0]-1] && !my_vertices[(int)vertex_pairing[2*i+1]-1]){129 my_vertices[ (int)vertex_pairing[2*i+1]-1]=2; //to know that these elements are not on the partition128 if(my_vertices[reCast<int>(vertex_pairing[2*i+0])-1] && !my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]){ 129 my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]=2; //to know that these elements are not on the partition 130 130 } 131 131 } 132 x free((void**)&vertex_pairing);132 xDelete<IssmDouble>(vertex_pairing); 133 133 iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,PrognosticVertexPairingEnum); 134 134 for(i=0;i<numvertex_pairing;i++){ 135 if(my_vertices[ (int)vertex_pairing[2*i+0]-1] && !my_vertices[(int)vertex_pairing[2*i+1]-1]){136 my_vertices[ (int)vertex_pairing[2*i+1]-1]=2; //to know that these elements are not on the partition135 if(my_vertices[reCast<int>(vertex_pairing[2*i+0])-1] && !my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]){ 136 my_vertices[reCast<int>(vertex_pairing[2*i+1])-1]=2; //to know that these elements are not on the partition 137 137 } 138 138 } 139 x free((void**)&vertex_pairing);139 xDelete<IssmDouble>(vertex_pairing); 140 140 141 141 /*Free ressources:*/ 142 x free((void**)&npart);143 x free((void**)&epart);142 xDelete<int>(npart); 143 xDelete<int>(epart); 144 144 145 145 /*Assign output pointers:*/
Note:
See TracChangeset
for help on using the changeset viewer.