Changeset 13030


Ignore:
Timestamp:
08/14/12 12:09:35 (13 years ago)
Author:
jschierm
Message:

NEW: Last bunch more python checkconsistency and marshall methods for sub-classes (plus other minor changes and fixes to keep up with Matlab changes).

Location:
issm/trunk-jpl/src/m
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py

    r12944 r13030  
    6969
    7070        #Create zeros basalforcings and surfaceforcings
    71         if numpy.isnan(md.surfaceforcings.precipitation).all():
     71        if all(numpy.isnan(md.surfaceforcings.precipitation)):
    7272                md.surfaceforcings.precipitation=numpy.zeros(md.mesh.numberofvertices)
    7373                print '      no surfaceforcings.precipitation specified: values set as zero'
    74         if numpy.isnan(md.surfaceforcings.mass_balance).all():
     74        if all(numpy.isnan(md.surfaceforcings.mass_balance)):
    7575                md.surfaceforcings.mass_balance=numpy.zeros(md.mesh.numberofvertices)
    7676                print '      no surfaceforcings.mass_balance specified: values set as zero'
    77         if numpy.isnan(md.basalforcings.melting_rate).all():
     77        if all(numpy.isnan(md.basalforcings.melting_rate)):
    7878                md.basalforcings.melting_rate=numpy.zeros(md.mesh.numberofvertices)
    7979                print '      no basalforcings.melting_rate specified: values set as zero'
    80         if numpy.isnan(md.balancethickness.thickening_rate).all():
     80        if all(numpy.isnan(md.balancethickness.thickening_rate)):
    8181                md.balancethickness.thickening_rate=numpy.zeros(md.mesh.numberofvertices)
    8282                print '      no balancethickness.thickening_rate specified: values set as zero'
  • issm/trunk-jpl/src/m/classes/diagnostic.py

    r13023 r13030  
    139139
    140140                #singular solution
    141                 #if ~any((~isnan(md.diagnostic.spcvx)+~isnan(md.diagnostic.spcvy))==2),
    142                 if not any((numpy.logical_not(numpy.isnan(md.diagnostic.spcvx))+numpy.logical_not(numpy.isnan(md.diagnostic.spcvy)))==2):
     141                if not any(numpy.logical_and(numpy.logical_not(numpy.isnan(md.diagnostic.spcvx)),numpy.logical_not(numpy.isnan(md.diagnostic.spcvy)))):
    143142                        md.checkmessage("model is not well posed (singular). You need at least one node with fixed velocity!")
    144143                #CHECK THAT EACH LINES CONTAINS ONLY NAN VALUES OR NO NAN VALUES
  • issm/trunk-jpl/src/m/classes/inversion.py

    r13029 r13030  
    111111                return self
    112112        #}}}
     113
    113114        def checkconsistency(self,md,solution,analyses):    # {{{
    114115
     
    142143                return md
    143144        # }}}
     145
    144146        def marshall(self,fid):    # {{{
    145147
     
    184186                WriteData(fid,'data',num_cost_functions,'enum',InversionNumCostFunctionsEnum(),'format','Integer')
    185187        # }}}
     188
  • issm/trunk-jpl/src/m/classes/miscellaneous.m

    r12663 r13030  
    1 %MISCELANEOUS class definition
     1%MISCELLANEOUS class definition
    22%
    33%   Usage:
  • issm/trunk-jpl/src/m/classes/miscellaneous.py

    r12958 r13030  
    11#module imports
    22from fielddisplay import fielddisplay
     3from EnumDefinitions import *
     4from checkfield import *
     5from WriteData import *
    36
    47class miscellaneous(object):
     8        """
     9        MISCELLANEOUS class definition
     10
     11           Usage:
     12              miscellaneous=miscellaneous();
     13        """
     14
    515        #properties
    616        def __init__(self):
     
    1424
    1525                #}}}
    16         def __repr__(obj):
     26        def __repr__(self):
    1727                # {{{ Display
    1828                string='   miscellaneous parameters:'
    1929
    20                 string="%s\n\n%s"%(string,fielddisplay(obj,'notes','notes in a cell of strings'))
    21                 string="%s\n%s"%(string,fielddisplay(obj,'name','model name'))
    22                 string="%s\n%s"%(string,fielddisplay(obj,'dummy','empty field to store some data'))
     30                string="%s\n\n%s"%(string,fielddisplay(self,'notes','notes in a cell of strings'))
     31                string="%s\n%s"%(string,fielddisplay(self,'name','model name'))
     32                string="%s\n%s"%(string,fielddisplay(self,'dummy','empty field to store some data'))
    2333                return string
    2434                #}}}
    2535               
    26         def setdefaultparameters(obj):
     36        def setdefaultparameters(self):
    2737                # {{{setdefaultparameters
    28                 return obj
     38                return self
    2939        #}}}
    3040
     41        def checkconsistency(self,md,solution,analyses):    # {{{
     42                md = checkfield(md,'miscellaneous.name','empty',1)
     43                return md
     44        # }}}
     45
     46        def marshall(self,fid):    #  {{{
     47                WriteData(fid,'object',self,'fieldname','name','format','String')
     48        # }}}
     49
  • issm/trunk-jpl/src/m/classes/model/model.py

    r12938 r13030  
    116116                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("inversion","[%s,%s]" % ("1x1",obj.inversion.__class__.__name__),"parameters for inverse methods"))
    117117                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("qmu","[%s,%s]" % ("1x1",obj.qmu.__class__.__name__),"dakota properties"))
    118                 string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("results","[%s,%s]" % ("1x1",obj.results.__class__.__name__),"model results'"))
     118                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("results","[%s,%s]" % ("1x1",obj.results.__class__.__name__),"model results"))
    119119                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("radaroverlay","[%s,%s]" % ("1x1",obj.radaroverlay.__class__.__name__),"radar image for plot overlay"))
    120120                string="%s\n%s" % (string,"%19s: %-22s -- %s" % ("miscellaneous","[%s,%s]" % ("1x1",obj.miscellaneous.__class__.__name__),"miscellaneous fields"))
  • issm/trunk-jpl/src/m/classes/private.py

    r12958 r13030  
    11#module imports
    22from fielddisplay import fielddisplay
     3from EnumDefinitions import *
     4from checkfield import *
    35
    46class private(object):
     7        """
     8        PRIVATE class definition
     9
     10           Usage:
     11              private=private();
     12        """
     13
    514        #properties
    615        def __init__(self):
     
    1524
    1625                #}}}
    17         def __repr__(obj):
     26        def __repr__(self):
    1827                # {{{ Display
    1928                string='   private parameters: do not change'
    2029
    21                 string="%s\n%s"%(string,fielddisplay(obj,'isconsistent','is model self consistent'))
    22                 string="%s\n%s"%(string,fielddisplay(obj,'runtimename','name of the run launched'))
    23                 string="%s\n%s"%(string,fielddisplay(obj,'bamg','structure with mesh properties constructed if bamg is used to mesh the domain'))
    24                 string="%s\n%s"%(string,fielddisplay(obj,'solution','type of solution launched'))
     30                string="%s\n%s"%(string,fielddisplay(self,'isconsistent','is model self consistent'))
     31                string="%s\n%s"%(string,fielddisplay(self,'runtimename','name of the run launched'))
     32                string="%s\n%s"%(string,fielddisplay(self,'bamg','structure with mesh properties constructed if bamg is used to mesh the domain'))
     33                string="%s\n%s"%(string,fielddisplay(self,'solution','type of solution launched'))
    2534                return string
    2635                #}}}
    2736               
    28         def setdefaultparameters(obj):
     37        def setdefaultparameters(self):
    2938                # {{{setdefaultparameters
    30                 return obj
     39                return self
    3140        #}}}
    3241
     42        def checkconsistency(self,md,solution,analyses):    # {{{
     43                return md
     44        # }}}
     45
  • issm/trunk-jpl/src/m/classes/qmu.m

    r12663 r13030  
    4747                                        md = checkmessage(md,['user supplied partition for qmu analysis should have size md.mesh.numberofvertices x 1 ']);
    4848                                end
    49                                 if find(md.qmu.partition)>=md.mesh.numberofvertices,
    50                                         md = checkmessage(md,['user supplied partition should be indexed from 0 (c-convention)']);
    51                                 end
    5249                                if min(md.qmu.partition)~=0,
    5350                                        md = checkmessage(md,['partition vector not indexed from 0 on']);
    54                                 end
    55                                 if max(md.qmu.partition)>=md.mesh.numberofvertices,
    56                                         md = checkmessage(md,['partition vector cannot have maximum index larger than number of nodes']);
    57                                 end
    58                                 if ~isempty(find(md.qmu.partition<0)),
    59                                         md = checkmessage(md,['partition vector cannot have values less than 0']);
    60                                 end
    61                                 if ~isempty(find(md.qmu.partition>=md.qmu.numberofpartitions)),
    62                                         md = checkmessage(md,['partition vector cannot have values more than md.qmu.numberofpartitions-1']);
    6351                                end
    6452                                if max(md.qmu.partition)>=md.qmu.numberofpartitions,
     
    140128                                end
    141129                        end
    142                         fielddisplay(obj,'partition','user provided mesh partitionition, defaults to metis if not specified')
    143                         fielddisplay(obj,'numberofpartitions','number of partitions for semi-descrete qmu')
     130                        fielddisplay(obj,'partition','user provided mesh partitioning, defaults to metis if not specified')
     131                        fielddisplay(obj,'numberofpartitions','number of partitions for semi-discrete qmu')
    144132                        fielddisplay(obj,'variabledescriptors','');
    145133                        fielddisplay(obj,'responsedescriptors','');
  • issm/trunk-jpl/src/m/classes/qmu.py

    r12958 r13030  
    11#module imports
     2import numpy
    23from fielddisplay import fielddisplay
     4from EnumDefinitions import *
     5from checkfield import *
     6from WriteData import *
     7from MatlabFuncs import *
    38
    49class qmu(object):
     10        """
     11        QMU class definition
     12
     13           Usage:
     14              qmu=qmu();
     15        """
     16
    517        #properties
    618        def __init__(self):
     
    2739
    2840                #}}}
    29         def __repr__(obj):
    30                 # {{{ Display
    31                 string="   qmu parameters: not implemented yet!"
    32                 return string
    33                 #}}}
    34                
    35         def setdefaultparameters(obj):
     41
     42        def setdefaultparameters(self):
    3643                # {{{setdefaultparameters
    37                 return obj
     44                return self
    3845        #}}}
    3946
     47        def checkconsistency(self,md,solution,analyses):    # {{{
     48
     49                #Early return
     50                if not md.qmu.isdakota:
     51                        return
     52
     53                if not md.qmu.params.evaluation_concurrency==1:
     54                        md.checkmessage("concurrency should be set to 1 when running dakota in library mode")
     55                if md.qmu.partition:
     56                        if not numpy.size(md.qmu.partition)==md.mesh.numberofvertices:
     57                                md.checkmessage("user supplied partition for qmu analysis should have size md.mesh.numberofvertices x 1")
     58                        if not min(md.qmu.partition)==0:
     59                                md.checkmessage("partition vector not indexed from 0 on")
     60                        if max(md.qmu.partition)>=md.qmu.numberofpartitions:
     61                                md.checkmessage("for qmu analysis, partitioning vector cannot go over npart, number of partition areas")
     62
     63                if not strcmpi(md.cluster.name,'none'):
     64                        if not md.settings.waitonlock:
     65                                md.checkmessage("waitonlock should be activated when running qmu in parallel mode!")
     66
     67                return md
     68        # }}}
     69
     70        def __repr__(self):    # {{{
     71                s ='   qmu parameters:\n'
     72
     73                s+="%s\n" % fielddisplay(self,'isdakota','is qmu analysis activated?')
     74                for i,variable in enumerate(self.variables):
     75                        s+="         variables%s:  (arrays of each variable class)\n" % \
     76                                string_dim(self.variables,i)
     77                        fnames=vars(variable)
     78                        maxlen=0
     79                        for fname in fnames:
     80                                maxlen=max(maxlen,len(fname))
     81
     82                        for fname in fnames:
     83                                s+="'            %-*s:    [%ix%i]    '%s'\n" % \
     84                                        (maxlen+1,fname,size(getattr(variable,fname)),type(getattr(variable,fname)))
     85
     86                for i,response in enumerate(self.responses):
     87                        s+="         responses%s:  (arrays of each response class)\n" % \
     88                                string_dim(self.responses,i)
     89                        fnames=vars(response)
     90                        maxlen=0
     91                        for fname in fnames:
     92                                maxlen=max(maxlen,len(fname))
     93
     94                        for fname in fnames:
     95                                s+="            %-*s:    [%ix%i]    '%s'\n" % \
     96                                        (maxlen+1,fname,size(getattr(response,fname)),type(getattr(response,fname)))
     97
     98                s+="%s\n" % fielddisplay(self,'numberofresponses','number of responses')
     99
     100                for i,method in enumerate(self.method):
     101                        if isinstance(method,'dakota_method'):
     102                                s+="            method%s :    '%s'\n" % \
     103                                        (string_dim(method,i),method.method)
     104
     105                for i,param in enumerate(self.params):
     106                        s+="         params%s:  (array of method-independent parameters)\n" % \
     107                                string_dim(self.params,i)
     108                        fnames=vars(param)
     109                        maxlen=0
     110                        for fname in fnames:
     111                                maxlen=max(maxlen,len(fname))
     112
     113                        for fname in fnames:
     114                                s+="            %-*s: %s\n" % \
     115                                        (maxlen+1,fname,any2str(getattr(param,fname)))
     116
     117                for i,result in enumerate(self.results):
     118                        s+="         results%s:  (information from dakota files)\n" % \
     119                                string_dim(self.results,i)
     120                        fnames=vars(result)
     121                        maxlen=0
     122                        for fname in fnames:
     123                                maxlen=max(maxlen,len(fname))
     124
     125                        for fname in fnames:
     126                                s+="            %-*s:    [%ix%i]    '%s'\n" % \
     127                                        (maxlen+1,fname,size(getattr(result,fname)),type(getattr(result,fname)))
     128
     129                s+="%s\n" % fielddisplay(self,'partition','user provided mesh partitioning, defaults to metis if not specified')
     130                s+="%s\n" % fielddisplay(self,'numberofpartitions','number of partitions for semi-discrete qmu')
     131                s+="%s\n" % fielddisplay(self,'variabledescriptors','')
     132                s+="%s\n" % fielddisplay(self,'responsedescriptors','')
     133                s+="%s\n" % fielddisplay(self,'method','array of dakota_method class')
     134                s+="%s\n" % fielddisplay(self,'mass_flux_profile_directory','directory for mass flux profiles')
     135                s+="%s\n" % fielddisplay(self,'mass_flux_profiles','list of mass_flux profiles')
     136                s+="%s\n" % fielddisplay(self,'mass_flux_segments','')
     137                s+="%s\n" % fielddisplay(self,'adjacency','')
     138                s+="%s\n" % fielddisplay(self,'vertex_weight','weight applied to each mesh vertex')
     139
     140                return s
     141        # }}}
     142               
     143        def marshall(self,fid):    # {{{
     144                WriteData(fid,'object',self,'fieldname','isdakota','format','Boolean')
     145                if not self.isdakota:
     146                        return
     147                WriteData(fid,'object',self,'fieldname','partition','format','DoubleMat','mattype',2)
     148                WriteData(fid,'object',self,'fieldname','numberofpartitions','format','Integer')
     149                WriteData(fid,'object',self,'fieldname','numberofresponses','format','Integer')
     150                WriteData(fid,'object',self,'fieldname','variabledescriptors','format','StringArray')
     151                WriteData(fid,'object',self,'fieldname','responsedescriptors','format','StringArray')
     152                WriteData(fid,'object',self,'fieldname','mass_flux_segments','format','MatArray')
     153        # }}}
     154
  • issm/trunk-jpl/src/m/classes/radaroverlay.py

    r12958 r13030  
    33
    44class radaroverlay(object):
     5        """
     6        RADAROVERLAY class definition
     7
     8           Usage:
     9              radaroverlay=radaroverlay();
     10        """
     11
    512        #properties
    613        def __init__(self):
     
    1421
    1522                #}}}
    16         def __repr__(obj):
     23        def __repr__(self):
    1724                # {{{ Display
    1825                string='   radaroverlay parameters:'
    19                 string="%s\n\n%s"%(string,fielddisplay(obj,'pwr','radar power image (matrix)'))
    20                 string="%s\n%s"%(string,fielddisplay(obj,'x','corresponding x coordinates'))
    21                 string="%s\n%s"%(string,fielddisplay(obj,'y','corresponding y coordinates'))
     26                string="%s\n\n%s"%(string,fielddisplay(self,'pwr','radar power image (matrix)'))
     27                string="%s\n%s"%(string,fielddisplay(self,'x','corresponding x coordinates'))
     28                string="%s\n%s"%(string,fielddisplay(self,'y','corresponding y coordinates'))
    2229                return string
    2330                #}}}
    2431               
    25         def setdefaultparameters(obj):
     32        def setdefaultparameters(self):
    2633                # {{{setdefaultparameters
    27                 return obj
     34                return self
    2835        #}}}
    2936
  • issm/trunk-jpl/src/m/consistency/checkfield.py

    r13023 r13030  
    112112        if options.exist('>='):
    113113                lowerbound=options.getfieldvalue('>=')
    114                 if numpy.any(field<lowerbound):
     114                if any(field<lowerbound):
    115115                        md = md.checkmessage(options.getfieldvalue('message',\
    116116                                "field '%s' should have values above %d" % (fieldname,lowerbound)))
    117117        if options.exist('>'):
    118118                lowerbound=options.getfieldvalue('>')
    119                 if numpy.any(field<=lowerbound):
     119                if any(field<=lowerbound):
    120120                        md = md.checkmessage(options.getfieldvalue('message',\
    121121                                "field '%s' should have values above %d" % (fieldname,lowerbound)))
     
    124124        if options.exist('<='):
    125125                upperbound=options.getfieldvalue('<=')
    126                 if numpy.any(field>upperbound):
     126                if any(field>upperbound):
    127127                        md = md.checkmessage(options.getfieldvalue('message',\
    128128                                "field '%s' should have values below %d" % (fieldname,upperbound)))
    129129        if options.exist('<'):
    130130                upperbound=options.getfieldvalue('<')
    131                 if numpy.any(field>=upperbound):
     131                if any(field>=upperbound):
    132132                        md = md.checkmessage(options.getfieldvalue('message',\
    133133                                "field '%s' should have values below %d" % (fieldname,upperbound)))
     
    145145                                        "field '%s' should have only one column as there are md.mesh.numberofvertices lines" % fieldname))
    146146                elif numpy.size(field,0)==md.mesh.numberofvertices+1:
    147                         if not numpy.all(field[-1,:]==numpy.sort(field[-1,:])):
     147                        if not all(field[-1,:]==numpy.sort(field[-1,:])):
    148148                                md = md.checkmessage(options.getfieldvalue('message',\
    149149                                        "field '%s' columns should be sorted chronologically" % fieldname))
    150                         if nump.any(field[-1,0:-1]==field[-1,1:]):
     150                        if any(field[-1,0:-1]==field[-1,1:]):
    151151                                md = md.checkmessage(options.getfieldvalue('message',\
    152152                                        "field '%s' columns must not contain duplicate timesteps" % fieldname))
  • issm/trunk-jpl/src/m/consistency/ismodelselfconsistent.py

    r13010 r13030  
    1 from AnalysisConfiguration import *
    21from EnumDefinitions import *
    32
  • issm/trunk-jpl/src/m/parameterization/parameterize.py

    r12944 r13030  
    11import os
    22import datetime
    3 from addnote import *
    43
    54def parameterize(md,parametername):
     
    2928                md.miscellaneous.name=os.path.basename(parametername).split('.')[0]
    3029
    31         md=addnote(md,"Model created by using parameter file: '%s' on: %s." % (parametername,datetime.datetime.strftime(datetime.datetime.now(),'%c') ))
     30        md.miscellaneous.notes="Model created by using parameter file: '%s' on: %s." % (parametername,datetime.datetime.strftime(datetime.datetime.now(),'%c'))
    3231
    3332        return md
  • issm/trunk-jpl/src/m/parameterization/setflowequation.py

    r13028 r13030  
    6363
    6464        #check that each element has at least one flag
    65         if not numpy.any(hutterflag+macayealflag+pattynflag+stokesflag):
     65        if not any(hutterflag+macayealflag+pattynflag+stokesflag):
    6666                raise TypeError("setflowequation error message: elements type not assigned, must be specified")
    6767
    6868        #check that each element has only one flag
    69         if numpy.any(hutterflag+macayealflag+pattynflag+stokesflag>1):
     69        if any(hutterflag+macayealflag+pattynflag+stokesflag>1):
    7070                print "setflowequation warning message: some elements have several types, higher order type is used for them"
    7171                hutterflag[numpy.nonzero(numpy.logical_and(hutterflag,macayealflag))]=0
     
    7575        #Check that no pattyn or stokes for 2d mesh
    7676        if md.mesh.dimension==2:
    77                 if numpy.any(numpy.logical_or(stokesflag,pattynflag)):
     77                if any(numpy.logical_or(stokesflag,pattynflag)):
    7878                        raise TypeError("setflowequation error message: stokes and pattyn elements not allowed in 2d mesh, extrude it first")
    7979
    8080        #Stokes can only be used alone for now:
    81         if numpy.any(stokesflag) and numpy.any(hutterflag):
     81        if any(stokesflag) and any(hutterflag):
    8282                raise TypeError("setflowequation error message: stokes cannot be used with any other model for now, put stokes everywhere")
    8383
     
    130130
    131131                #initialize and fill in penalties structure
    132                 if numpy.all(numpy.logical_not(numpy.isnan(bordernodes2d))):
     132                if all(numpy.logical_not(numpy.isnan(bordernodes2d))):
    133133                        penalties=numpy.zeros((0,2))
    134134                        for     i in xrange(1,numlayers):
     
    137137
    138138        elif strcmpi(coupling_method,'tiling'):
    139                 if   numpy.any(macayealflag) and numpy.any(pattynflag):    #coupling macayeal pattyn
     139                if   any(macayealflag) and any(pattynflag):    #coupling macayeal pattyn
    140140                        #Find node at the border
    141141                        nodeonmacayealpattyn[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonpattyn))]=1
     
    152152                        pos=numpy.nonzero(macayealpattynflag)
    153153                        elist=numpy.zeros(len(pos))
    154                         elist = elist + numpy.any(numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
    155                         elist = elist - numpy.any(numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1]  ,axis=1),axis=1)
     154                        elist = elist + any(numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
     155                        elist = elist - any(numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1]  ,axis=1),axis=1)
    156156                        pos1=[i for i,item in enumerate(elist) if item==1]
    157157                        macayealflag[pos[pos1]]=1
     
    169169                        nodeonmacayealpattyn[md.mesh.elements[numpy.nonzero(macayealpattynflag),:].astype(int)-1]=1
    170170
    171                 elif numpy.any(pattynflag) and numpy.any(stokesflag):    #coupling pattyn stokes
     171                elif any(pattynflag) and any(stokesflag):    #coupling pattyn stokes
    172172                        #Find node at the border
    173173                        nodeonpattynstokes[numpy.nonzero(numpy.logical_and(nodeonpattyn,nodeonstokes))]=1
     
    184184                        pos=numpy.nonzero(pattynstokesflag)
    185185                        elist=numpy.zeros(len(pos))
    186                         elist = elist + numpy.any(numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
    187                         elist = elist - numpy.any(numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
     186                        elist = elist + any(numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
     187                        elist = elist - any(numpy.sum(nodeonpattyn[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
    188188                        pos1=[i for i,item in enumerate(elist) if item==1]
    189189                        stokesflag[pos[pos1]]=1
     
    201201                        nodeonpattynstokes[md.mesh.elements[numpy.nonzero(pattynstokesflag),:].astype(int)-1]=1
    202202
    203                 elif numpy.any(stokesflag) and numpy.any(macayealflag):
     203                elif any(stokesflag) and any(macayealflag):
    204204                        #Find node at the border
    205205                        nodeonmacayealstokes[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonstokes))]=1
     
    216216                        pos=numpy.nonzero(macayealstokesflag)
    217217                        elist=numpy.zeros(len(pos))
    218                         elist = elist + numpy.any(numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
    219                         elist = elist - numpy.any(numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1]  ,axis=1),axis=1)
     218                        elist = elist + any(numpy.sum(nodeonmacayeal[md.mesh.elements[pos,:].astype(int)-1],axis=1),axis=1)
     219                        elist = elist - any(numpy.sum(nodeonstokes[md.mesh.elements[pos,:].astype(int)-1]  ,axis=1),axis=1)
    220220                        pos1=[i for i,item in enumerate(elist) if item==1]
    221221                        macayealflag[pos[pos1]]=1
     
    233233                        nodeonmacayealstokes[md.mesh.elements[numpy.nonzero(macayealstokesflag),:].astype(int)-1]=1
    234234
    235                 elif numpy.any(stokesflag) and numpy.any(hutterflag):
     235                elif any(stokesflag) and any(hutterflag):
    236236                        raise TypeError("type of coupling not supported yet")
    237237
     
    266266        pos=numpy.nonzero(nodeonstokes)
    267267        md.flowequation.vertex_equation[pos]=4
    268         if numpy.any(stokesflag):
     268        if any(stokesflag):
    269269                pos=numpy.nonzero(numpy.logical_not(nodeonstokes))
    270                 if not (numpy.any(pattynflag) or numpy.any(macayealflag)):
     270                if not (any(pattynflag) or any(macayealflag)):
    271271                        md.flowequation.vertex_equation[pos]=0
    272272        pos=numpy.nonzero(nodeonpattynstokes)
     
    276276
    277277        #figure out solution types
    278         md.flowequation.ishutter=float(numpy.any(md.flowequation.element_equation==1))
    279         md.flowequation.ismacayealpattyn=float(numpy.any(numpy.logical_or(md.flowequation.element_equation==2,md.flowequation.element_equation==3)))
    280         md.flowequation.isstokes=float(numpy.any(md.flowequation.element_equation==4))
     278        md.flowequation.ishutter=float(any(md.flowequation.element_equation==1))
     279        md.flowequation.ismacayealpattyn=float(any(numpy.logical_or(md.flowequation.element_equation==2,md.flowequation.element_equation==3)))
     280        md.flowequation.isstokes=float(any(md.flowequation.element_equation==4))
    281281
    282282        return md
    283283
    284284        #Check that tiling can work:
    285         if numpy.any(md.flowequation.bordermacayeal) and numpy.any(md.flowequation.borderpattyn) and numpy.any(md.flowequation.borderpattyn + md.flowequation.bordermacayeal !=1):
     285        if any(md.flowequation.bordermacayeal) and any(md.flowequation.borderpattyn) and any(md.flowequation.borderpattyn + md.flowequation.bordermacayeal !=1):
    286286                raise TypeError("error coupling domain too irregular")
    287         if numpy.any(md.flowequation.bordermacayeal) and numpy.any(md.flowequation.borderstokes) and numpy.any(md.flowequation.borderstokes + md.flowequation.bordermacayeal !=1):
     287        if any(md.flowequation.bordermacayeal) and any(md.flowequation.borderstokes) and any(md.flowequation.borderstokes + md.flowequation.bordermacayeal !=1):
    288288                raise TypeError("error coupling domain too irregular")
    289         if numpy.any(md.flowequation.borderstokes) and numpy.any(md.flowequation.borderpattyn) and numpy.any(md.flowequation.borderpattyn + md.flowequation.borderstokes !=1):
     289        if any(md.flowequation.borderstokes) and any(md.flowequation.borderpattyn) and any(md.flowequation.borderpattyn + md.flowequation.borderstokes !=1):
    290290                raise TypeError("error coupling domain too irregular")
    291291
Note: See TracChangeset for help on using the changeset viewer.