Changeset 14017


Ignore:
Timestamp:
11/27/12 14:32:53 (12 years ago)
Author:
jschierm
Message:

CHG: Changed flag arrays in md.flowequation to bool for python.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/parameterization/setflowequation.py

    r14015 r14017  
    5050        #Flag the elements that have not been flagged as filltype
    5151        if   strcmpi(filltype,'hutter'):
    52                 hutterflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(macayealflag,pattynflag)))]=1
     52                hutterflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(macayealflag,pattynflag)))]=True
    5353        elif strcmpi(filltype,'macayeal'):
    54                 macayealflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(hutterflag,numpy.logical_or(pattynflag,stokesflag))))]=1
     54                macayealflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(hutterflag,numpy.logical_or(pattynflag,stokesflag))))]=True
    5555        elif strcmpi(filltype,'pattyn'):
    56                 pattynflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(hutterflag,numpy.logical_or(macayealflag,stokesflag))))]=1
     56                pattynflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(hutterflag,numpy.logical_or(macayealflag,stokesflag))))]=True
    5757
    5858        #check that each element has at least one flag
     
    6363        if any(hutterflag+macayealflag+l1l2flag+pattynflag+stokesflag>1):
    6464                print "setflowequation warning message: some elements have several types, higher order type is used for them"
    65                 hutterflag[numpy.nonzero(numpy.logical_and(hutterflag,macayealflag))]=0
    66                 hutterflag[numpy.nonzero(numpy.logical_and(hutterflag,pattynflag))]=0
    67                 macayealflag[numpy.nonzero(numpy.logical_and(macayealflag,pattynflag))]=0
     65                hutterflag[numpy.nonzero(numpy.logical_and(hutterflag,macayealflag))]=False
     66                hutterflag[numpy.nonzero(numpy.logical_and(hutterflag,pattynflag))]=False
     67                macayealflag[numpy.nonzero(numpy.logical_and(macayealflag,pattynflag))]=False
    6868
    6969        #Check that no pattyn or stokes for 2d mesh
     
    7777
    7878        #Initialize node fields
    79         nodeonhutter=numpy.zeros(md.mesh.numberofvertices)
    80         nodeonhutter[md.mesh.elements[numpy.nonzero(hutterflag),:]-1]=1
    81         nodeonmacayeal=numpy.zeros(md.mesh.numberofvertices)
    82         nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=1
    83         nodeonl1l2=numpy.zeros(md.mesh.numberofvertices)
    84         nodeonl1l2[md.mesh.elements[numpy.nonzero(l1l2flag),:]-1]=1
    85         nodeonpattyn=numpy.zeros(md.mesh.numberofvertices)
    86         nodeonpattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=1
    87         nodeonstokes=numpy.zeros(md.mesh.numberofvertices)
    88         noneflag=numpy.zeros(md.mesh.numberofelements)
     79        nodeonhutter=numpy.zeros(md.mesh.numberofvertices,bool)
     80        nodeonhutter[md.mesh.elements[numpy.nonzero(hutterflag),:]-1]=True
     81        nodeonmacayeal=numpy.zeros(md.mesh.numberofvertices,bool)
     82        nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=True
     83        nodeonl1l2=numpy.zeros(md.mesh.numberofvertices,bool)
     84        nodeonl1l2[md.mesh.elements[numpy.nonzero(l1l2flag),:]-1]=True
     85        nodeonpattyn=numpy.zeros(md.mesh.numberofvertices,bool)
     86        nodeonpattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=True
     87        nodeonstokes=numpy.zeros(md.mesh.numberofvertices,bool)
     88        noneflag=numpy.zeros(md.mesh.numberofelements,bool)
    8989
    9090        #First modify stokesflag to get rid of elements contrained everywhere (spc + border with pattyn or macayeal)
     
    9797#               fullspcelems=double(sum(fullspcnodes(md.mesh.elements),2)==6);         %find all the nodes on the boundary of the domain without icefront
    9898                fullspcelems=(numpy.sum(fullspcnodes[md.mesh.elements-1],axis=1)==6).astype(int)    #find all the nodes on the boundary of the domain without icefront
    99                 stokesflag[numpy.nonzero(fullspcelems.reshape(-1))]=0
    100                 nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=1
     99                stokesflag[numpy.nonzero(fullspcelems.reshape(-1))]=False
     100                nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=True
    101101
    102102        #Then complete with NoneApproximation or the other model used if there is no stokes
    103103        if any(stokesflag):
    104104                if   any(pattynflag):    #fill with pattyn
    105                         pattynflag[numpy.logical_not(stokesflag)]=1
    106                         nodeonpattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=1
     105                        pattynflag[numpy.logical_not(stokesflag)]=True
     106                        nodeonpattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=True
    107107                elif any(macayealflag):    #fill with macayeal
    108                         macayealflag[numpy.logical_not(stokesflag)]=1
    109                         nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=1
     108                        macayealflag[numpy.logical_not(stokesflag)]=True
     109                        nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=True
    110110                else:    #fill with none
    111                         noneflag[numpy.nonzero(numpy.logical_not(stokesflag))]=1
     111                        noneflag[numpy.nonzero(numpy.logical_not(stokesflag))]=True
    112112
    113113        #Now take care of the coupling between MacAyeal and Pattyn
    114114        md.diagnostic.vertex_pairing=numpy.array([])
    115         nodeonmacayealpattyn=numpy.zeros(md.mesh.numberofvertices)
    116         nodeonpattynstokes=numpy.zeros(md.mesh.numberofvertices)
    117         nodeonmacayealstokes=numpy.zeros(md.mesh.numberofvertices)
    118         macayealpattynflag=numpy.zeros(md.mesh.numberofelements)
    119         macayealstokesflag=numpy.zeros(md.mesh.numberofelements)
    120         pattynstokesflag=numpy.zeros(md.mesh.numberofelements)
     115        nodeonmacayealpattyn=numpy.zeros(md.mesh.numberofvertices,bool)
     116        nodeonpattynstokes=numpy.zeros(md.mesh.numberofvertices,bool)
     117        nodeonmacayealstokes=numpy.zeros(md.mesh.numberofvertices,bool)
     118        macayealpattynflag=numpy.zeros(md.mesh.numberofelements,bool)
     119        macayealstokesflag=numpy.zeros(md.mesh.numberofelements,bool)
     120        pattynstokesflag=numpy.zeros(md.mesh.numberofelements,bool)
    121121        if   strcmpi(coupling_method,'penalties'):
    122122                #Create the border nodes between Pattyn and MacAyeal and extrude them
     
    135135                if   any(macayealflag) and any(pattynflag):    #coupling macayeal pattyn
    136136                        #Find node at the border
    137                         nodeonmacayealpattyn[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonpattyn))]=1
     137                        nodeonmacayealpattyn[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonpattyn))]=True
    138138                        #Macayeal elements in contact with this layer become MacAyealPattyn elements
    139139                        matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeonmacayealpattyn)[0])
    140140                        commonelements=numpy.sum(matrixelements,axis=1)!=0
    141                         commonelements[numpy.nonzero(pattynflag)]=0    #only one layer: the elements previously in macayeal
    142                         macayealflag[numpy.nonzero(commonelements)]=0    #these elements are now macayealpattynelements
    143                         macayealpattynflag[numpy.nonzero(commonelements)]=1
    144                         nodeonmacayeal[:]=0
    145                         nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=1
     141                        commonelements[numpy.nonzero(pattynflag)]=False    #only one layer: the elements previously in macayeal
     142                        macayealflag[numpy.nonzero(commonelements)]=False    #these elements are now macayealpattynelements
     143                        macayealpattynflag[numpy.nonzero(commonelements)]=True
     144                        nodeonmacayeal[:]=False
     145                        nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=True
    146146
    147147                        #rule out elements that don't touch the 2 boundaries
     
    151151                        elist = elist - numpy.sum(nodeonpattyn[md.mesh.elements[pos,:]-1]  ,axis=1).astype(bool)
    152152                        pos1=numpy.nonzero(elist==1)[0]
    153                         macayealflag[pos[pos1]]=1
    154                         macayealpattynflag[pos[pos1]]=0
     153                        macayealflag[pos[pos1]]=True
     154                        macayealpattynflag[pos[pos1]]=False
    155155                        pos2=numpy.nonzero(elist==-1)[0]
    156                         pattynflag[pos[pos2]]=1
    157                         macayealpattynflag[pos[pos2]]=0
     156                        pattynflag[pos[pos2]]=True
     157                        macayealpattynflag[pos[pos2]]=False
    158158
    159159                        #Recompute nodes associated to these elements
    160                         nodeonmacayeal[:]=0
    161                         nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=1
    162                         nodeonpattyn[:]=0
    163                         nodeonpattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=1
    164                         nodeonmacayealpattyn[:]=0
    165                         nodeonmacayealpattyn[md.mesh.elements[numpy.nonzero(macayealpattynflag),:]-1]=1
     160                        nodeonmacayeal[:]=False
     161                        nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=True
     162                        nodeonpattyn[:]=False
     163                        nodeonpattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=True
     164                        nodeonmacayealpattyn[:]=False
     165                        nodeonmacayealpattyn[md.mesh.elements[numpy.nonzero(macayealpattynflag),:]-1]=True
    166166
    167167                elif any(pattynflag) and any(stokesflag):    #coupling pattyn stokes
    168168                        #Find node at the border
    169                         nodeonpattynstokes[numpy.nonzero(numpy.logical_and(nodeonpattyn,nodeonstokes))]=1
     169                        nodeonpattynstokes[numpy.nonzero(numpy.logical_and(nodeonpattyn,nodeonstokes))]=True
    170170                        #Stokes elements in contact with this layer become PattynStokes elements
    171171                        matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeonpattynstokes)[0])
    172172                        commonelements=numpy.sum(matrixelements,axis=1)!=0
    173                         commonelements[numpy.nonzero(pattynflag)]=0    #only one layer: the elements previously in macayeal
    174                         stokesflag[numpy.nonzero(commonelements)]=0    #these elements are now macayealpattynelements
    175                         pattynstokesflag[numpy.nonzero(commonelements)]=1
    176                         nodeonstokes=numpy.zeros(md.mesh.numberofvertices)
    177                         nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=1
     173                        commonelements[numpy.nonzero(pattynflag)]=False    #only one layer: the elements previously in macayeal
     174                        stokesflag[numpy.nonzero(commonelements)]=False    #these elements are now macayealpattynelements
     175                        pattynstokesflag[numpy.nonzero(commonelements)]=True
     176                        nodeonstokes=numpy.zeros(md.mesh.numberofvertices,bool)
     177                        nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=True
    178178
    179179                        #rule out elements that don't touch the 2 boundaries
     
    183183                        elist = elist - numpy.sum(nodeonpattyn[md.mesh.elements[pos,:]-1],axis=1).astype(bool)
    184184                        pos1=numpy.nonzero(elist==1)[0]
    185                         stokesflag[pos[pos1]]=1
    186                         pattynstokesflag[pos[pos1]]=0
     185                        stokesflag[pos[pos1]]=True
     186                        pattynstokesflag[pos[pos1]]=False
    187187                        pos2=numpy.nonzero(elist==-1)[0]
    188                         pattynflag[pos[pos2]]=1
    189                         pattynstokesflag[pos[pos2]]=0
     188                        pattynflag[pos[pos2]]=True
     189                        pattynstokesflag[pos[pos2]]=False
    190190
    191191                        #Recompute nodes associated to these elements
    192                         nodeonstokes[:]=0
    193                         nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=1
    194                         nodeonpattyn[:]=0
    195                         nodeonpattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=1
    196                         nodeonpattynstokes[:]=0
    197                         nodeonpattynstokes[md.mesh.elements[numpy.nonzero(pattynstokesflag),:]-1]=1
     192                        nodeonstokes[:]=False
     193                        nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=True
     194                        nodeonpattyn[:]=False
     195                        nodeonpattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=True
     196                        nodeonpattynstokes[:]=False
     197                        nodeonpattynstokes[md.mesh.elements[numpy.nonzero(pattynstokesflag),:]-1]=True
    198198
    199199                elif any(stokesflag) and any(macayealflag):
    200200                        #Find node at the border
    201                         nodeonmacayealstokes[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonstokes))]=1
     201                        nodeonmacayealstokes[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonstokes))]=True
    202202                        #Stokes elements in contact with this layer become MacAyealStokes elements
    203203                        matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeonmacayealstokes)[0])
    204204                        commonelements=numpy.sum(matrixelements,axis=1)!=0
    205                         commonelements[numpy.nonzero(macayealflag)]=0    #only one layer: the elements previously in macayeal
    206                         stokesflag[numpy.nonzero(commonelements)]=0    #these elements are now macayealmacayealelements
    207                         macayealstokesflag[numpy.nonzero(commonelements)]=1
    208                         nodeonstokes=numpy.zeros(md.mesh.numberofvertices)
    209                         nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=1
     205                        commonelements[numpy.nonzero(macayealflag)]=False    #only one layer: the elements previously in macayeal
     206                        stokesflag[numpy.nonzero(commonelements)]=False    #these elements are now macayealmacayealelements
     207                        macayealstokesflag[numpy.nonzero(commonelements)]=True
     208                        nodeonstokes=numpy.zeros(md.mesh.numberofvertices,bool)
     209                        nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=True
    210210
    211211                        #rule out elements that don't touch the 2 boundaries
     
    215215                        elist = elist - numpy.sum(nodeonstokes[md.mesh.elements[pos,:]-1]  ,axis=1).astype(bool)
    216216                        pos1=numpy.nonzero(elist==1)[0]
    217                         macayealflag[pos[pos1]]=1
    218                         macayealstokesflag[pos[pos1]]=0
     217                        macayealflag[pos[pos1]]=True
     218                        macayealstokesflag[pos[pos1]]=False
    219219                        pos2=numpy.nonzero(elist==-1)[0]
    220                         stokesflag[pos[pos2]]=1
    221                         macayealstokesflag[pos[pos2]]=0
     220                        stokesflag[pos[pos2]]=True
     221                        macayealstokesflag[pos[pos2]]=False
    222222
    223223                        #Recompute nodes associated to these elements
    224                         nodeonmacayeal[:]=0
    225                         nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=1
    226                         nodeonstokes[:]=0
    227                         nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=1
    228                         nodeonmacayealstokes[:]=0
    229                         nodeonmacayealstokes[md.mesh.elements[numpy.nonzero(macayealstokesflag),:]-1]=1
     224                        nodeonmacayeal[:]=False
     225                        nodeonmacayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=True
     226                        nodeonstokes[:]=False
     227                        nodeonstokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=True
     228                        nodeonmacayealstokes[:]=False
     229                        nodeonmacayealstokes[md.mesh.elements[numpy.nonzero(macayealstokesflag),:]-1]=True
    230230
    231231                elif any(stokesflag) and any(hutterflag):
Note: See TracChangeset for help on using the changeset viewer.