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