Changeset 14009
- Timestamp:
- 11/27/12 11:12:10 (12 years ago)
- Location:
- issm/trunk-jpl/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp
r13622 r14009 15 15 #include "../../EnumDefinitions/EnumDefinitions.h" 16 16 17 int hascommondedge( double* element1,double* element2);17 int hascommondedge(int* element1,int* element2); 18 18 19 void ElementConnectivityx( double** pelementconnectivity, double* elements, int nel, double* nodeconnectivity, int nods, int width){19 void ElementConnectivityx(int** pelementconnectivity,int* elements, int nels,int* nodeconnectivity, int nods, int width){ 20 20 21 21 int i,j,k,n; … … 23 23 /*intermediary: */ 24 24 int maxels; 25 double element; 26 double connectedelement; 25 int connectedelement; 27 26 int connectedelementindex; 28 27 int node; … … 30 29 int num_elements; 31 30 32 /*output: */33 double* elementconnectivity=NULL;34 35 31 /*maxels: */ 36 32 maxels=width-1; 33 37 34 /*Allocate connectivity: */ 38 elementconnectivity=xNewZeroInit<double>(nel*3);35 int* elementconnectivity=xNewZeroInit<int>(nels*3); 39 36 40 37 /*Go through all elements, and for each element, go through its nodes, to get the neighbouring elements. 41 38 * Once we get the neighbouring elements, figure out if they share a segment with the current element. If so, 42 39 * plug them in the connectivity, unless they are already there.: */ 40 for(n=0;n<nels;n++){ 43 41 44 for(n=0;n<nel;n++){ 45 46 element=(double)(n+1); //matlab indexing 42 //element=n+1; //matlab indexing 47 43 48 44 for(i=0;i<3;i++){ 49 45 50 node= (int)*(elements+n*3+i); //already matlab indexed, elements comes directly from the workspace.46 node=elements[n*3+i]; //already matlab indexed, elements comes directly from the workspace. 51 47 index=node-1; 52 48 53 num_elements= (int)*(nodeconnectivity+width*index+maxels); //retrieve number of elements already plugged into the connectivity of this node.49 num_elements=nodeconnectivity[width*index+maxels]; //retrieve number of elements already plugged into the connectivity of this node. 54 50 55 51 for(j=0;j<num_elements;j++){ 56 52 57 53 /*for each element connected to node, figure out if it has a commond edge with element: */ 58 connectedelement= *(nodeconnectivity+width*index+j);59 connectedelementindex= (int)(connectedelement-1); //go from matlab indexing to c indexing.54 connectedelement=nodeconnectivity[width*index+j]; 55 connectedelementindex=connectedelement-1; //go from matlab indexing to c indexing. 60 56 61 if(hascommondedge( elements+n*3+0,elements+connectedelementindex*3+0)){57 if(hascommondedge(&elements[n*3+0],&elements[connectedelementindex*3+0])){ 62 58 /*Ok, this connected element has a commond edge with element, plug it into elementconnectivity, unless 63 59 *it is already there: */ 64 60 65 61 for(k=0;k<3;k++){ 66 if (*(elementconnectivity+3*n+k)==0){67 *(elementconnectivity+3*n+k)=connectedelement;62 if(elementconnectivity[3*n+k]==0){ 63 elementconnectivity[3*n+k]=connectedelement; 68 64 break; 69 65 } 70 66 else{ 71 if(connectedelement== *(elementconnectivity+3*n+k))break;67 if(connectedelement==elementconnectivity[3*n+k]) break; 72 68 } 73 69 } … … 81 77 } 82 78 83 int hascommondedge( double* element1,double* element2){79 int hascommondedge(int* el1,int* el2){ 84 80 85 int i,j; 86 int count; 87 88 count=0; 89 for(i=0;i<3;i++){ 90 for(j=0;j<3;j++){ 91 if (*(element1+i)==*(element2+j))count++; 81 int count=0; 82 for(int i=0;i<3;i++){ 83 for(int j=0;j<3;j++){ 84 if(el1[i]==el2[j]) count++; 92 85 } 93 86 } 94 if (count==2)return 1; 95 else return 0; 87 if(count==2) 88 return 1; 89 else 90 return 0; 96 91 } -
issm/trunk-jpl/src/c/modules/ElementConnectivityx/ElementConnectivityx.h
r13623 r14009 7 7 8 8 /* local prototypes: */ 9 void ElementConnectivityx( double** pelementconnectivity, double* elements, int nel, double* nodeconnectivity, int nods, int width);9 void ElementConnectivityx(int** pelementconnectivity,int* elements,int nels,int* nodeconnectivity, int nods, int width); 10 10 11 11 #endif /* _ELEMENTCONNECTIVITYX_H */ -
issm/trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.cpp
r13236 r14009 13 13 14 14 /*inputs: */ 15 double* elements=NULL;16 double* nodeconnectivity=NULL;17 int nel,nods;18 int 15 int* elements=NULL; 16 int* nodeconnectivity=NULL; 17 int nels,nods; 18 int width; 19 19 20 20 /*outputs: */ 21 double* elementconnectivity=NULL;21 int* elementconnectivity=NULL; 22 22 23 23 /*Boot module: */ … … 28 28 29 29 /*Input datasets: */ 30 FetchData(&elements,&nel ,NULL,ELEMENTS);30 FetchData(&elements,&nels,NULL,ELEMENTS); 31 31 FetchData(&nodeconnectivity,&nods,&width,NODECONNECTIVITY); 32 32 33 33 /*!Generate internal degree of freedom numbers: */ 34 ElementConnectivityx(&elementconnectivity, elements,nel, nodeconnectivity, nods,width);34 ElementConnectivityx(&elementconnectivity,elements,nels,nodeconnectivity,nods,width); 35 35 36 36 /*write output datasets: */ 37 WriteData(ELEMENTCONNECTIVITY,elementconnectivity,nel ,3);37 WriteData(ELEMENTCONNECTIVITY,elementconnectivity,nels,3); 38 38 39 39 /*end module: */
Note:
See TracChangeset
for help on using the changeset viewer.