Changeset 14211


Ignore:
Timestamp:
01/07/13 10:11:26 (12 years ago)
Author:
jschierm
Message:

NEW: Implement new python logical functions to get rid of ugly nesting.

Location:
issm/trunk-jpl/src/m
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/classes/model/model.py

    r14151 r14211  
    4545from ElementConnectivity import *
    4646from contourenvelope import *
     47from PythonFuncs import *
    4748#}}}
    4849
     
    407408                                md2.diagnostic.icefront[:,2]=Pnode[md1.diagnostic.icefront[:,2].astype(int)-1]
    408409                                md2.diagnostic.icefront[:,3]=Pnode[md1.diagnostic.icefront[:,3].astype(int)-1]
    409                         md2.diagnostic.icefront=md2.diagnostic.icefront[numpy.nonzero(numpy.logical_and(numpy.logical_and(md2.diagnostic.icefront[:,0],md2.diagnostic.icefront[:,1]),md2.diagnostic.icefront[:,-1]))[0],:]
     410                        md2.diagnostic.icefront=md2.diagnostic.icefront[numpy.nonzero(logical_and_n(md2.diagnostic.icefront[:,0],md2.diagnostic.icefront[:,1],md2.diagnostic.icefront[:,-1]))[0],:]
    410411
    411412                #Results fields
  • issm/trunk-jpl/src/m/geometry/FlagElements.py

    r14098 r14211  
    44from ContourToMesh import *
    55from MatlabFuncs import *
     6from PythonFuncs import *
    67
    78def FlagElements(md,region):
     
    4344                                raise RuntimeError("FlagElements.py calling basinzoom.py is not complete.")
    4445                                xlim,ylim=basinzoom('basin',region)
    45                                 flag_nodes=numpy.logical_and(numpy.logical_and(md.mesh.x<xlim[1],md.mesh.x>xlim[0]),numpy.logical_and(md.mesh.y<ylim[1],md.mesh.y>ylim[0]))
     46                                flag_nodes=logical_and_n(md.mesh.x<xlim[1],md.mesh.x>xlim[0],md.mesh.y<ylim[1],md.mesh.y>ylim[0])
    4647                                flag=numpy.prod(flag_nodes[md.mesh.elements],axis=1).astype(bool)
    4748                        else:
  • issm/trunk-jpl/src/m/mesh/ElementsFromEdge.py

    r13524 r14211  
    11import numpy
     2from PythonFuncs import *
    23
    34def ElementsFromEdge(elements,A,B):
     
    1213
    1314        edgeelements=numpy.nonzero(\
    14                 numpy.logical_or( \
    15                 numpy.logical_or( \
    16                 numpy.logical_or(numpy.logical_and(elements[:,0]==A,elements[:,1]==B), \
    17                                                  numpy.logical_and(elements[:,0]==A,elements[:,2]==B)) \
    18                 , \
    19                 numpy.logical_or(numpy.logical_and(elements[:,1]==A,elements[:,2]==B), \
    20                                                  numpy.logical_and(elements[:,1]==A,elements[:,0]==B)) \
    21                 ), \
    22                 numpy.logical_or(numpy.logical_and(elements[:,2]==A,elements[:,0]==B), \
    23                                                  numpy.logical_and(elements[:,2]==A,elements[:,1]==B)) \
     15                logical_or_n(numpy.logical_and(elements[:,0]==A,elements[:,1]==B), \
     16                                         numpy.logical_and(elements[:,0]==A,elements[:,2]==B), \
     17                                         numpy.logical_and(elements[:,1]==A,elements[:,2]==B), \
     18                                         numpy.logical_and(elements[:,1]==A,elements[:,0]==B), \
     19                                         numpy.logical_and(elements[:,2]==A,elements[:,0]==B), \
     20                                         numpy.logical_and(elements[:,2]==A,elements[:,1]==B), \
    2421                ))[0]+1
    2522
  • issm/trunk-jpl/src/m/parameterization/setflowequation.py

    r14020 r14211  
    33from pairoptions import *
    44from MatlabFuncs import *
     5from PythonFuncs import *
    56from FlagElements import *
    67
     
    5051        #Flag the elements that have not been flagged as filltype
    5152        if   strcmpi(filltype,'hutter'):
    52                 hutterflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(macayealflag,pattynflag)))]=True
     53                hutterflag[numpy.nonzero(numpy.logical_not(logical_or_n(macayealflag,pattynflag)))]=True
    5354        elif strcmpi(filltype,'macayeal'):
    54                 macayealflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(hutterflag,numpy.logical_or(pattynflag,stokesflag))))]=True
     55                macayealflag[numpy.nonzero(numpy.logical_not(logical_or_n(hutterflag,pattynflag,stokesflag)))]=True
    5556        elif strcmpi(filltype,'pattyn'):
    56                 pattynflag[numpy.nonzero(numpy.logical_not(numpy.logical_or(hutterflag,numpy.logical_or(macayealflag,stokesflag))))]=True
     57                pattynflag[numpy.nonzero(numpy.logical_not(logical_or_n(hutterflag,macayealflag,stokesflag)))]=True
    5758
    5859        #check that each element has at least one flag
     
    6970        #Check that no pattyn or stokes for 2d mesh
    7071        if md.mesh.dimension==2:
    71                 if numpy.any(numpy.logical_or(l1l2flag,stokesflag,pattynflag)):
     72                if numpy.any(logical_or_n(l1l2flag,stokesflag,pattynflag)):
    7273                        raise TypeError("stokes and pattyn elements not allowed in 2d mesh, extrude it first")
    7374
Note: See TracChangeset for help on using the changeset viewer.