Changeset 14011


Ignore:
Timestamp:
11/27/12 11:18:40 (12 years ago)
Author:
Mathieu Morlighem
Message:

BUG: reverted back

Location:
issm/trunk-jpl/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/modules/ElementConnectivityx/ElementConnectivityx.cpp

    r14009 r14011  
    1515#include "../../EnumDefinitions/EnumDefinitions.h"
    1616
    17 int hascommondedge(int* element1,int* element2);
     17int hascommondedge(double* element1,double* element2);
    1818
    19 void ElementConnectivityx(int** pelementconnectivity,int* elements, int nels,int* nodeconnectivity, int nods, int width){
     19void    ElementConnectivityx( double** pelementconnectivity, double* elements, int nel, double* nodeconnectivity, int nods, int width){
    2020
    2121        int i,j,k,n;
     
    2323        /*intermediary: */
    2424        int    maxels;
    25         int  connectedelement;
     25        double element;
     26        double connectedelement;
    2627        int    connectedelementindex;
    2728        int    node;
     
    2930        int    num_elements;
    3031
     32        /*output: */
     33        double* elementconnectivity=NULL;
     34
    3135        /*maxels: */
    3236        maxels=width-1;
    33 
    3437        /*Allocate connectivity: */
    35         int* elementconnectivity=xNewZeroInit<int>(nels*3);
     38        elementconnectivity=xNewZeroInit<double>(nel*3);
    3639
    3740        /*Go through all elements, and for each element, go through its nodes, to get the neighbouring elements.
    3841         * Once we get the neighbouring elements, figure out if they share a segment with the current element. If so,
    3942         * plug them in the connectivity, unless they are already there.: */
    40         for(n=0;n<nels;n++){
    4143
    42                 //element=n+1; //matlab indexing
     44        for(n=0;n<nel;n++){
     45
     46                element=(double)(n+1); //matlab indexing
    4347
    4448                for(i=0;i<3;i++){
    4549
    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.
    4751                        index=node-1;
    4852
    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.
    5054
    5155                        for(j=0;j<num_elements;j++){
    5256
    5357                                /*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.
    5660
    57                                 if(hascommondedge(&elements[n*3+0],&elements[connectedelementindex*3+0])){
     61                                if(hascommondedge(elements+n*3+0,elements+connectedelementindex*3+0)){
    5862                                        /*Ok, this connected element has a commond edge  with element, plug it into elementconnectivity, unless
    5963                                         *it is already there: */
    6064
    6165                                        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;
    6468                                                        break;
    6569                                                }
    6670                                                else{
    67                                                         if(connectedelement==elementconnectivity[3*n+k]) break;
     71                                                        if(connectedelement==*(elementconnectivity+3*n+k))break;
    6872                                                }
    6973                                        }
     
    7781}
    7882
    79 int hascommondedge(int* el1,int* el2){
     83int hascommondedge(double* element1,double* element2){
    8084
    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++;
    8592                }
    8693        }
    87         if(count==2)
    88          return 1;
    89         else
    90          return 0;
     94        if (count==2)return 1;
     95        else return 0;
    9196}
  • issm/trunk-jpl/src/c/modules/ElementConnectivityx/ElementConnectivityx.h

    r14009 r14011  
    77
    88/* local prototypes: */
    9 void    ElementConnectivityx(int** pelementconnectivity,int* elements,int nels,int* nodeconnectivity, int nods, int width);
     9void    ElementConnectivityx( double** pelementconnectivity, double* elements, int nel, double* nodeconnectivity, int nods, int width);
    1010
    1111#endif  /* _ELEMENTCONNECTIVITYX_H */
  • issm/trunk-jpl/src/wrappers/ElementConnectivity/ElementConnectivity.cpp

    r14009 r14011  
    1313
    1414        /*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;
    1919
    2020        /*outputs: */
    21         int* elementconnectivity=NULL;
     21        double* elementconnectivity=NULL;
    2222
    2323        /*Boot module: */
     
    2828       
    2929        /*Input datasets: */
    30         FetchData(&elements,&nels,NULL,ELEMENTS);
     30        FetchData(&elements,&nel,NULL,ELEMENTS);
    3131        FetchData(&nodeconnectivity,&nods,&width,NODECONNECTIVITY);
    3232
    3333        /*!Generate internal degree of freedom numbers: */
    34         ElementConnectivityx(&elementconnectivity,elements,nels,nodeconnectivity,nods,width);
     34        ElementConnectivityx(&elementconnectivity, elements,nel, nodeconnectivity, nods, width);
    3535
    3636        /*write output datasets: */
    37         WriteData(ELEMENTCONNECTIVITY,elementconnectivity,nels,3);
     37        WriteData(ELEMENTCONNECTIVITY,elementconnectivity,nel,3);
    3838
    3939        /*end module: */
Note: See TracChangeset for help on using the changeset viewer.