Ignore:
Timestamp:
08/02/12 17:13:12 (13 years ago)
Author:
cborstad
Message:

merged trunk-jpl into trunk-jpl-damage through revision 12877

Location:
issm/branches/trunk-jpl-damage
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/branches/trunk-jpl-damage

  • issm/branches/trunk-jpl-damage/src/c/modules/ModelProcessorx/ElementsAndVerticesPartitioning.cpp

    r12168 r12878  
    1010
    1111#include <string.h>
    12 #include "../../objects/objects.h"
     12#include "../../classes/objects/objects.h"
    1313#include "../../shared/shared.h"
    1414#include "../../EnumDefinitions/EnumDefinitions.h"
     
    4242        int  el1,el2;
    4343        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;
    4848
    4949        /*Fetch parameters: */
     
    7676
    7777        /*Free elements and elements2d: */
    78         xfree((void**)&elements);
    79         xfree((void**)&elements2d);
     78        xDelete<IssmDouble>(elements);
     79        xDelete<IssmDouble>(elements2d);
    8080
    8181        /*Deal with rifts, they have to be included into one partition only, not several: */
     
    8383                iomodel->FetchData(&riftinfo,&numrifts,NULL,RiftsRiftstructEnum);
    8484                for(i=0;i<numrifts;i++){
    85                         el1=(int)*(riftinfo+RIFTINFOSIZE*i+2)-1; //matlab indexing to c indexing
    86                         el2=(int)*(riftinfo+RIFTINFOSIZE*i+3)-1; //matlab indexing to c indexing
     85                        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
    8787                        epart[el2]=epart[el1]; //ensures that this pair of elements will be in the same partition, as well as the corresponding vertices;
    8888                }
    89                 xfree((void**)&riftinfo);
     89                xDelete<IssmDouble>(riftinfo);
    9090        }
    9191
    9292        /*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);
    9595
    9696        /*Start figuring out, out of the partition, which elements belong to this cpu: */
     
    107107                         into the vertices coordinates. If we start plugging 1 into my_vertices for each index[n][i] (i=0:2), then my_vertices
    108108                         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;
    112112                       
    113113                        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;
    117117                        }
    118118                }
    119119        }//for (i=0;i<numberofelements;i++)
    120120        /*Free data : */
    121         xfree((void**)&elements);
     121        xDelete<IssmDouble>(elements);
    122122
    123123        /*We might have vertex_pairing in which case, some vertices have to be cloned:
     
    126126        iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,DiagnosticVertexPairingEnum);
    127127        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 partition
     128                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
    130130                }
    131131        }
    132         xfree((void**)&vertex_pairing);
     132        xDelete<IssmDouble>(vertex_pairing);
    133133        iomodel->FetchData(&vertex_pairing,&numvertex_pairing,NULL,PrognosticVertexPairingEnum);
    134134        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 partition
     135                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
    137137                }
    138138        }
    139         xfree((void**)&vertex_pairing);
     139        xDelete<IssmDouble>(vertex_pairing);
    140140
    141141        /*Free ressources:*/
    142         xfree((void**)&npart);
    143         xfree((void**)&epart);
     142        xDelete<int>(npart);
     143        xDelete<int>(epart);
    144144
    145145        /*Assign output pointers:*/
Note: See TracChangeset for help on using the changeset viewer.