Changeset 16137 for issm/trunk/src/m/parameterization/setflowequation.py
- Timestamp:
- 09/16/13 09:43:55 (12 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
- Property svn:ignore
-
old new 1 nightlylog 2 configure.sh 1 3 par 2 4 ad
-
- Property svn:mergeinfo changed
/issm/trunk-jpl merged: 15397-15401,15403-15487,15489-15701,15704-15735,15737-16076,16082-16133
- Property svn:ignore
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/parameterization/setflowequation.py
r14310 r16137 11 11 12 12 This routine works like plotmodel: it works with an even number of inputs 13 ' hutter','macayeal','pattyn','l1l2','stokes' and 'fill' are the possible options13 'SIA','SSA','HO','L1L2','FS' and 'fill' are the possible options 14 14 that must be followed by the corresponding exp file or flags list 15 15 It can either be a domain file (argus type, .exp extension), or an array of element flags. 16 16 If user wants every element outside the domain to be 17 setflowequationd, add '~' to the name of the domain file (ex: '~ Pattyn.exp');17 setflowequationd, add '~' to the name of the domain file (ex: '~HO.exp'); 18 18 an empty string '' will be considered as an empty domain 19 19 a string 'all' will be considered as the entire domain … … 24 24 25 25 Example: 26 md=setflowequation(md,'pattyn','Pattyn.exp','macayeal',md.mask.elementonfloatingice,'fill','hutter'); 27 md=setflowequation(md,'pattyn','Pattyn.exp',fill','hutter','coupling','tiling'); 26 md=setflowequation(md,'HO','HO.exp',fill','SIA','coupling','tiling'); 28 27 """ 29 28 … … 42 41 43 42 #recover elements distribution 44 hutterflag = FlagElements(md,options.getfieldvalue('hutter',''))45 macayealflag = FlagElements(md,options.getfieldvalue('macayeal',''))46 pattynflag = FlagElements(md,options.getfieldvalue('pattyn',''))47 l1l2flag = FlagElements(md,options.getfieldvalue('l1l2',''))48 stokesflag = FlagElements(md,options.getfieldvalue('stokes',''))43 SIAflag = FlagElements(md,options.getfieldvalue('SIA','')) 44 SSAflag = FlagElements(md,options.getfieldvalue('SSA','')) 45 HOflag = FlagElements(md,options.getfieldvalue('HO','')) 46 L1L2flag = FlagElements(md,options.getfieldvalue('L1L2','')) 47 FSflag = FlagElements(md,options.getfieldvalue('FS','')) 49 48 filltype = options.getfieldvalue('fill','none') 50 49 51 50 #Flag the elements that have not been flagged as filltype 52 if strcmpi(filltype,' hutter'):53 hutterflag[numpy.nonzero(numpy.logical_not(logical_or_n(macayealflag,pattynflag)))]=True54 elif strcmpi(filltype,' macayeal'):55 macayealflag[numpy.nonzero(numpy.logical_not(logical_or_n(hutterflag,pattynflag,stokesflag)))]=True56 elif strcmpi(filltype,' pattyn'):57 pattynflag[numpy.nonzero(numpy.logical_not(logical_or_n(hutterflag,macayealflag,stokesflag)))]=True51 if strcmpi(filltype,'SIA'): 52 SIAflag[numpy.nonzero(numpy.logical_not(logical_or_n(SSAflag,HOflag)))]=True 53 elif strcmpi(filltype,'SSA'): 54 SSAflag[numpy.nonzero(numpy.logical_not(logical_or_n(SIAflag,HOflag,FSflag)))]=True 55 elif strcmpi(filltype,'HO'): 56 HOflag[numpy.nonzero(numpy.logical_not(logical_or_n(SIAflag,SSAflag,FSflag)))]=True 58 57 59 58 #check that each element has at least one flag 60 if not any( hutterflag+macayealflag+l1l2flag+pattynflag+stokesflag):61 raise TypeError("elements type not assigned, must be specified")59 if not any(SIAflag+SSAflag+L1L2flag+HOflag+FSflag): 60 raise TypeError("elements type not assigned, supported models are 'SIA','SSA','HO' and 'FS'") 62 61 63 62 #check that each element has only one flag 64 if any( hutterflag+macayealflag+l1l2flag+pattynflag+stokesflag>1):63 if any(SIAflag+SSAflag+L1L2flag+HOflag+FSflag>1): 65 64 print "setflowequation warning message: some elements have several types, higher order type is used for them" 66 hutterflag[numpy.nonzero(numpy.logical_and(hutterflag,macayealflag))]=False67 hutterflag[numpy.nonzero(numpy.logical_and(hutterflag,pattynflag))]=False68 macayealflag[numpy.nonzero(numpy.logical_and(macayealflag,pattynflag))]=False69 70 #Check that no pattyn or stokesfor 2d mesh65 SIAflag[numpy.nonzero(numpy.logical_and(SIAflag,SSAflag))]=False 66 SIAflag[numpy.nonzero(numpy.logical_and(SIAflag,HOflag))]=False 67 SSAflag[numpy.nonzero(numpy.logical_and(SSAflag,HOflag))]=False 68 69 #Check that no HO or FS for 2d mesh 71 70 if md.mesh.dimension==2: 72 if numpy.any(logical_or_n( l1l2flag,stokesflag,pattynflag)):73 raise TypeError(" stokes and pattynelements not allowed in 2d mesh, extrude it first")74 75 # Stokescan only be used alone for now:76 if any( stokesflag) and any(hutterflag):77 raise TypeError(" stokes cannot be used with any other model for now, put stokeseverywhere")71 if numpy.any(logical_or_n(L1L2flag,FSflag,HOflag)): 72 raise TypeError("FS and HO elements not allowed in 2d mesh, extrude it first") 73 74 #FS can only be used alone for now: 75 if any(FSflag) and any(SIAflag): 76 raise TypeError("FS cannot be used with any other model for now, put FS everywhere") 78 77 79 78 #Initialize node fields 80 nodeon hutter=numpy.zeros(md.mesh.numberofvertices,bool)81 nodeon hutter[md.mesh.elements[numpy.nonzero(hutterflag),:]-1]=True82 nodeon macayeal=numpy.zeros(md.mesh.numberofvertices,bool)83 nodeon macayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=True84 nodeon l1l2=numpy.zeros(md.mesh.numberofvertices,bool)85 nodeon l1l2[md.mesh.elements[numpy.nonzero(l1l2flag),:]-1]=True86 nodeon pattyn=numpy.zeros(md.mesh.numberofvertices,bool)87 nodeon pattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=True88 nodeon stokes=numpy.zeros(md.mesh.numberofvertices,bool)79 nodeonSIA=numpy.zeros(md.mesh.numberofvertices,bool) 80 nodeonSIA[md.mesh.elements[numpy.nonzero(SIAflag),:]-1]=True 81 nodeonSSA=numpy.zeros(md.mesh.numberofvertices,bool) 82 nodeonSSA[md.mesh.elements[numpy.nonzero(SSAflag),:]-1]=True 83 nodeonL1L2=numpy.zeros(md.mesh.numberofvertices,bool) 84 nodeonL1L2[md.mesh.elements[numpy.nonzero(L1L2flag),:]-1]=True 85 nodeonHO=numpy.zeros(md.mesh.numberofvertices,bool) 86 nodeonHO[md.mesh.elements[numpy.nonzero(HOflag),:]-1]=True 87 nodeonFS=numpy.zeros(md.mesh.numberofvertices,bool) 89 88 noneflag=numpy.zeros(md.mesh.numberofelements,bool) 90 89 91 #First modify stokesflag to get rid of elements contrained everywhere (spc + border with pattyn or macayeal)92 if any( stokesflag):93 # fullspcnodes=double((~isnan(md. diagnostic.spcvx)+~isnan(md.diagnostic.spcvy)+~isnan(md.diagnostic.spcvz))==3 | (nodeonpattyn & nodeonstokes)); %find all the nodes on the boundary of the domain without icefront94 fullspcnodes=numpy.logical_or(numpy.logical_not(numpy.isnan(md. diagnostic.spcvx)).astype(int)+ \95 numpy.logical_not(numpy.isnan(md. diagnostic.spcvy)).astype(int)+ \96 numpy.logical_not(numpy.isnan(md. diagnostic.spcvz)).astype(int)==3, \97 numpy.logical_and(nodeon pattyn,nodeonstokes).reshape(-1,1)).astype(int) #find all the nodes on the boundary of the domain without icefront90 #First modify FSflag to get rid of elements contrained everywhere (spc + border with HO or SSA) 91 if any(FSflag): 92 # fullspcnodes=double((~isnan(md.stressbalance.spcvx)+~isnan(md.stressbalance.spcvy)+~isnan(md.stressbalance.spcvz))==3 | (nodeonHO & nodeonFS)); %find all the nodes on the boundary of the domain without icefront 93 fullspcnodes=numpy.logical_or(numpy.logical_not(numpy.isnan(md.stressbalance.spcvx)).astype(int)+ \ 94 numpy.logical_not(numpy.isnan(md.stressbalance.spcvy)).astype(int)+ \ 95 numpy.logical_not(numpy.isnan(md.stressbalance.spcvz)).astype(int)==3, \ 96 numpy.logical_and(nodeonHO,nodeonFS).reshape(-1,1)).astype(int) #find all the nodes on the boundary of the domain without icefront 98 97 # fullspcelems=double(sum(fullspcnodes(md.mesh.elements),2)==6); %find all the nodes on the boundary of the domain without icefront 99 98 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 100 stokesflag[numpy.nonzero(fullspcelems.reshape(-1))]=False101 nodeon stokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=True102 103 #Then complete with NoneApproximation or the other model used if there is no stokes104 if any( stokesflag):105 if any( pattynflag): #fill with pattyn106 pattynflag[numpy.logical_not(stokesflag)]=True107 nodeon pattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=True108 elif any( macayealflag): #fill with macayeal109 macayealflag[numpy.logical_not(stokesflag)]=True110 nodeon macayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=True99 FSflag[numpy.nonzero(fullspcelems.reshape(-1))]=False 100 nodeonFS[md.mesh.elements[numpy.nonzero(FSflag),:]-1]=True 101 102 #Then complete with NoneApproximation or the other model used if there is no FS 103 if any(FSflag): 104 if any(HOflag): #fill with HO 105 HOflag[numpy.logical_not(FSflag)]=True 106 nodeonHO[md.mesh.elements[numpy.nonzero(HOflag),:]-1]=True 107 elif any(SSAflag): #fill with SSA 108 SSAflag[numpy.logical_not(FSflag)]=True 109 nodeonSSA[md.mesh.elements[numpy.nonzero(SSAflag),:]-1]=True 111 110 else: #fill with none 112 noneflag[numpy.nonzero(numpy.logical_not( stokesflag))]=True113 114 #Now take care of the coupling between MacAyeal and Pattyn115 md. diagnostic.vertex_pairing=numpy.array([])116 nodeon macayealpattyn=numpy.zeros(md.mesh.numberofvertices,bool)117 nodeon pattynstokes=numpy.zeros(md.mesh.numberofvertices,bool)118 nodeon macayealstokes=numpy.zeros(md.mesh.numberofvertices,bool)119 macayealpattynflag=numpy.zeros(md.mesh.numberofelements,bool)120 macayealstokesflag=numpy.zeros(md.mesh.numberofelements,bool)121 pattynstokesflag=numpy.zeros(md.mesh.numberofelements,bool)111 noneflag[numpy.nonzero(numpy.logical_not(FSflag))]=True 112 113 #Now take care of the coupling between SSA and HO 114 md.stressbalance.vertex_pairing=numpy.array([]) 115 nodeonSSAHO=numpy.zeros(md.mesh.numberofvertices,bool) 116 nodeonHOFS=numpy.zeros(md.mesh.numberofvertices,bool) 117 nodeonSSAFS=numpy.zeros(md.mesh.numberofvertices,bool) 118 SSAHOflag=numpy.zeros(md.mesh.numberofelements,bool) 119 SSAFSflag=numpy.zeros(md.mesh.numberofelements,bool) 120 HOFSflag=numpy.zeros(md.mesh.numberofelements,bool) 122 121 if strcmpi(coupling_method,'penalties'): 123 #Create the border nodes between Pattyn and MacAyealand extrude them122 #Create the border nodes between HO and SSA and extrude them 124 123 numnodes2d=md.mesh.numberofvertices2d 125 124 numlayers=md.mesh.numberoflayers 126 bordernodes2d=numpy.nonzero(numpy.logical_and(nodeon pattyn[0:numnodes2d],nodeonmacayeal[0:numnodes2d]))[0]+1 #Nodes connected to two different types of elements125 bordernodes2d=numpy.nonzero(numpy.logical_and(nodeonHO[0:numnodes2d],nodeonSSA[0:numnodes2d]))[0]+1 #Nodes connected to two different types of elements 127 126 128 127 #initialize and fill in penalties structure … … 131 130 for i in xrange(1,numlayers): 132 131 penalties=numpy.vstack((penalties,numpy.hstack((bordernodes2d.reshape(-1,1),bordernodes2d.reshape(-1,1)+md.mesh.numberofvertices2d*(i))))) 133 md. diagnostic.vertex_pairing=penalties132 md.stressbalance.vertex_pairing=penalties 134 133 135 134 elif strcmpi(coupling_method,'tiling'): 136 if any( macayealflag) and any(pattynflag): #coupling macayeal pattyn135 if any(SSAflag) and any(HOflag): #coupling SSA HO 137 136 #Find node at the border 138 nodeon macayealpattyn[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonpattyn))]=True139 # Macayeal elements in contact with this layer become MacAyealPattynelements140 matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeon macayealpattyn)[0])137 nodeonSSAHO[numpy.nonzero(numpy.logical_and(nodeonSSA,nodeonHO))]=True 138 #SSA elements in contact with this layer become SSAHO elements 139 matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeonSSAHO)[0]) 141 140 commonelements=numpy.sum(matrixelements,axis=1)!=0 142 commonelements[numpy.nonzero( pattynflag)]=False #only one layer: the elements previously in macayeal143 macayealflag[numpy.nonzero(commonelements)]=False #these elements are now macayealpattynelements144 macayealpattynflag[numpy.nonzero(commonelements)]=True145 nodeon macayeal[:]=False146 nodeon macayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=True141 commonelements[numpy.nonzero(HOflag)]=False #only one layer: the elements previously in SSA 142 SSAflag[numpy.nonzero(commonelements)]=False #these elements are now SSAHOelements 143 SSAHOflag[numpy.nonzero(commonelements)]=True 144 nodeonSSA[:]=False 145 nodeonSSA[md.mesh.elements[numpy.nonzero(SSAflag),:]-1]=True 147 146 148 147 #rule out elements that don't touch the 2 boundaries 149 pos=numpy.nonzero( macayealpattynflag)[0]148 pos=numpy.nonzero(SSAHOflag)[0] 150 149 elist=numpy.zeros(numpy.size(pos),dtype=int) 151 elist = elist + numpy.sum(nodeon macayeal[md.mesh.elements[pos,:]-1],axis=1).astype(bool)152 elist = elist - numpy.sum(nodeon pattyn[md.mesh.elements[pos,:]-1] ,axis=1).astype(bool)150 elist = elist + numpy.sum(nodeonSSA[md.mesh.elements[pos,:]-1],axis=1).astype(bool) 151 elist = elist - numpy.sum(nodeonHO[md.mesh.elements[pos,:]-1] ,axis=1).astype(bool) 153 152 pos1=numpy.nonzero(elist==1)[0] 154 macayealflag[pos[pos1]]=True155 macayealpattynflag[pos[pos1]]=False153 SSAflag[pos[pos1]]=True 154 SSAHOflag[pos[pos1]]=False 156 155 pos2=numpy.nonzero(elist==-1)[0] 157 pattynflag[pos[pos2]]=True158 macayealpattynflag[pos[pos2]]=False156 HOflag[pos[pos2]]=True 157 SSAHOflag[pos[pos2]]=False 159 158 160 159 #Recompute nodes associated to these elements 161 nodeon macayeal[:]=False162 nodeon macayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=True163 nodeon pattyn[:]=False164 nodeon pattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=True165 nodeon macayealpattyn[:]=False166 nodeon macayealpattyn[md.mesh.elements[numpy.nonzero(macayealpattynflag),:]-1]=True167 168 elif any( pattynflag) and any(stokesflag): #coupling pattyn stokes160 nodeonSSA[:]=False 161 nodeonSSA[md.mesh.elements[numpy.nonzero(SSAflag),:]-1]=True 162 nodeonHO[:]=False 163 nodeonHO[md.mesh.elements[numpy.nonzero(HOflag),:]-1]=True 164 nodeonSSAHO[:]=False 165 nodeonSSAHO[md.mesh.elements[numpy.nonzero(SSAHOflag),:]-1]=True 166 167 elif any(HOflag) and any(FSflag): #coupling HO FS 169 168 #Find node at the border 170 nodeon pattynstokes[numpy.nonzero(numpy.logical_and(nodeonpattyn,nodeonstokes))]=True171 # Stokes elements in contact with this layer become PattynStokeselements172 matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeon pattynstokes)[0])169 nodeonHOFS[numpy.nonzero(numpy.logical_and(nodeonHO,nodeonFS))]=True 170 #FS elements in contact with this layer become HOFS elements 171 matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeonHOFS)[0]) 173 172 commonelements=numpy.sum(matrixelements,axis=1)!=0 174 commonelements[numpy.nonzero( pattynflag)]=False #only one layer: the elements previously in macayeal175 stokesflag[numpy.nonzero(commonelements)]=False #these elements are now macayealpattynelements176 pattynstokesflag[numpy.nonzero(commonelements)]=True177 nodeon stokes=numpy.zeros(md.mesh.numberofvertices,bool)178 nodeon stokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=True173 commonelements[numpy.nonzero(HOflag)]=False #only one layer: the elements previously in SSA 174 FSflag[numpy.nonzero(commonelements)]=False #these elements are now SSAHOelements 175 HOFSflag[numpy.nonzero(commonelements)]=True 176 nodeonFS=numpy.zeros(md.mesh.numberofvertices,bool) 177 nodeonFS[md.mesh.elements[numpy.nonzero(FSflag),:]-1]=True 179 178 180 179 #rule out elements that don't touch the 2 boundaries 181 pos=numpy.nonzero( pattynstokesflag)[0]180 pos=numpy.nonzero(HOFSflag)[0] 182 181 elist=numpy.zeros(numpy.size(pos),dtype=int) 183 elist = elist + numpy.sum(nodeon stokes[md.mesh.elements[pos,:]-1],axis=1).astype(bool)184 elist = elist - numpy.sum(nodeon pattyn[md.mesh.elements[pos,:]-1],axis=1).astype(bool)182 elist = elist + numpy.sum(nodeonFS[md.mesh.elements[pos,:]-1],axis=1).astype(bool) 183 elist = elist - numpy.sum(nodeonHO[md.mesh.elements[pos,:]-1],axis=1).astype(bool) 185 184 pos1=numpy.nonzero(elist==1)[0] 186 stokesflag[pos[pos1]]=True187 pattynstokesflag[pos[pos1]]=False185 FSflag[pos[pos1]]=True 186 HOFSflag[pos[pos1]]=False 188 187 pos2=numpy.nonzero(elist==-1)[0] 189 pattynflag[pos[pos2]]=True190 pattynstokesflag[pos[pos2]]=False188 HOflag[pos[pos2]]=True 189 HOFSflag[pos[pos2]]=False 191 190 192 191 #Recompute nodes associated to these elements 193 nodeon stokes[:]=False194 nodeon stokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=True195 nodeon pattyn[:]=False196 nodeon pattyn[md.mesh.elements[numpy.nonzero(pattynflag),:]-1]=True197 nodeon pattynstokes[:]=False198 nodeon pattynstokes[md.mesh.elements[numpy.nonzero(pattynstokesflag),:]-1]=True199 200 elif any( stokesflag) and any(macayealflag):192 nodeonFS[:]=False 193 nodeonFS[md.mesh.elements[numpy.nonzero(FSflag),:]-1]=True 194 nodeonHO[:]=False 195 nodeonHO[md.mesh.elements[numpy.nonzero(HOflag),:]-1]=True 196 nodeonHOFS[:]=False 197 nodeonHOFS[md.mesh.elements[numpy.nonzero(HOFSflag),:]-1]=True 198 199 elif any(FSflag) and any(SSAflag): 201 200 #Find node at the border 202 nodeon macayealstokes[numpy.nonzero(numpy.logical_and(nodeonmacayeal,nodeonstokes))]=True203 # Stokes elements in contact with this layer become MacAyealStokeselements204 matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeon macayealstokes)[0])201 nodeonSSAFS[numpy.nonzero(numpy.logical_and(nodeonSSA,nodeonFS))]=True 202 #FS elements in contact with this layer become SSAFS elements 203 matrixelements=ismember(md.mesh.elements-1,numpy.nonzero(nodeonSSAFS)[0]) 205 204 commonelements=numpy.sum(matrixelements,axis=1)!=0 206 commonelements[numpy.nonzero( macayealflag)]=False #only one layer: the elements previously in macayeal207 stokesflag[numpy.nonzero(commonelements)]=False #these elements are now macayealmacayealelements208 macayealstokesflag[numpy.nonzero(commonelements)]=True209 nodeon stokes=numpy.zeros(md.mesh.numberofvertices,bool)210 nodeon stokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=True205 commonelements[numpy.nonzero(SSAflag)]=False #only one layer: the elements previously in SSA 206 FSflag[numpy.nonzero(commonelements)]=False #these elements are now SSASSAelements 207 SSAFSflag[numpy.nonzero(commonelements)]=True 208 nodeonFS=numpy.zeros(md.mesh.numberofvertices,bool) 209 nodeonFS[md.mesh.elements[numpy.nonzero(FSflag),:]-1]=True 211 210 212 211 #rule out elements that don't touch the 2 boundaries 213 pos=numpy.nonzero( macayealstokesflag)[0]212 pos=numpy.nonzero(SSAFSflag)[0] 214 213 elist=numpy.zeros(numpy.size(pos),dtype=int) 215 elist = elist + numpy.sum(nodeon macayeal[md.mesh.elements[pos,:]-1],axis=1).astype(bool)216 elist = elist - numpy.sum(nodeon stokes[md.mesh.elements[pos,:]-1] ,axis=1).astype(bool)214 elist = elist + numpy.sum(nodeonSSA[md.mesh.elements[pos,:]-1],axis=1).astype(bool) 215 elist = elist - numpy.sum(nodeonFS[md.mesh.elements[pos,:]-1] ,axis=1).astype(bool) 217 216 pos1=numpy.nonzero(elist==1)[0] 218 macayealflag[pos[pos1]]=True219 macayealstokesflag[pos[pos1]]=False217 SSAflag[pos[pos1]]=True 218 SSAFSflag[pos[pos1]]=False 220 219 pos2=numpy.nonzero(elist==-1)[0] 221 stokesflag[pos[pos2]]=True222 macayealstokesflag[pos[pos2]]=False220 FSflag[pos[pos2]]=True 221 SSAFSflag[pos[pos2]]=False 223 222 224 223 #Recompute nodes associated to these elements 225 nodeon macayeal[:]=False226 nodeon macayeal[md.mesh.elements[numpy.nonzero(macayealflag),:]-1]=True227 nodeon stokes[:]=False228 nodeon stokes[md.mesh.elements[numpy.nonzero(stokesflag),:]-1]=True229 nodeon macayealstokes[:]=False230 nodeon macayealstokes[md.mesh.elements[numpy.nonzero(macayealstokesflag),:]-1]=True231 232 elif any( stokesflag) and any(hutterflag):224 nodeonSSA[:]=False 225 nodeonSSA[md.mesh.elements[numpy.nonzero(SSAflag),:]-1]=True 226 nodeonFS[:]=False 227 nodeonFS[md.mesh.elements[numpy.nonzero(FSflag),:]-1]=True 228 nodeonSSAFS[:]=False 229 nodeonSSAFS[md.mesh.elements[numpy.nonzero(SSAFSflag),:]-1]=True 230 231 elif any(FSflag) and any(SIAflag): 233 232 raise TypeError("type of coupling not supported yet") 234 233 235 #Create MacAyealPattynApproximation where needed234 #Create SSAHOApproximation where needed 236 235 md.flowequation.element_equation=numpy.zeros(md.mesh.numberofelements,int) 237 236 md.flowequation.element_equation[numpy.nonzero(noneflag)]=0 238 md.flowequation.element_equation[numpy.nonzero( hutterflag)]=1239 md.flowequation.element_equation[numpy.nonzero( macayealflag)]=2240 md.flowequation.element_equation[numpy.nonzero( l1l2flag)]=8241 md.flowequation.element_equation[numpy.nonzero( pattynflag)]=3242 md.flowequation.element_equation[numpy.nonzero( stokesflag)]=4243 md.flowequation.element_equation[numpy.nonzero( macayealpattynflag)]=5244 md.flowequation.element_equation[numpy.nonzero( macayealstokesflag)]=6245 md.flowequation.element_equation[numpy.nonzero( pattynstokesflag)]=7237 md.flowequation.element_equation[numpy.nonzero(SIAflag)]=1 238 md.flowequation.element_equation[numpy.nonzero(SSAflag)]=2 239 md.flowequation.element_equation[numpy.nonzero(L1L2flag)]=8 240 md.flowequation.element_equation[numpy.nonzero(HOflag)]=3 241 md.flowequation.element_equation[numpy.nonzero(FSflag)]=4 242 md.flowequation.element_equation[numpy.nonzero(SSAHOflag)]=5 243 md.flowequation.element_equation[numpy.nonzero(SSAFSflag)]=6 244 md.flowequation.element_equation[numpy.nonzero(HOFSflag)]=7 246 245 247 246 #border 248 md.flowequation.border pattyn=nodeonpattyn249 md.flowequation.border macayeal=nodeonmacayeal250 md.flowequation.border stokes=nodeonstokes247 md.flowequation.borderHO=nodeonHO 248 md.flowequation.borderSSA=nodeonSSA 249 md.flowequation.borderFS=nodeonFS 251 250 252 251 #Create vertices_type 253 252 md.flowequation.vertex_equation=numpy.zeros(md.mesh.numberofvertices,int) 254 pos=numpy.nonzero(nodeon macayeal)253 pos=numpy.nonzero(nodeonSSA) 255 254 md.flowequation.vertex_equation[pos]=2 256 pos=numpy.nonzero(nodeon l1l2)255 pos=numpy.nonzero(nodeonL1L2) 257 256 md.flowequation.vertex_equation[pos]=8 258 pos=numpy.nonzero(nodeon pattyn)257 pos=numpy.nonzero(nodeonHO) 259 258 md.flowequation.vertex_equation[pos]=3 260 pos=numpy.nonzero(nodeon hutter)259 pos=numpy.nonzero(nodeonSIA) 261 260 md.flowequation.vertex_equation[pos]=1 262 pos=numpy.nonzero(nodeon macayealpattyn)261 pos=numpy.nonzero(nodeonSSAHO) 263 262 md.flowequation.vertex_equation[pos]=5 264 pos=numpy.nonzero(nodeon stokes)263 pos=numpy.nonzero(nodeonFS) 265 264 md.flowequation.vertex_equation[pos]=4 266 if any( stokesflag):267 pos=numpy.nonzero(numpy.logical_not(nodeon stokes))268 if not (any( pattynflag) or any(macayealflag)):265 if any(FSflag): 266 pos=numpy.nonzero(numpy.logical_not(nodeonFS)) 267 if not (any(HOflag) or any(SSAflag)): 269 268 md.flowequation.vertex_equation[pos]=0 270 pos=numpy.nonzero(nodeon pattynstokes)269 pos=numpy.nonzero(nodeonHOFS) 271 270 md.flowequation.vertex_equation[pos]=7 272 pos=numpy.nonzero(nodeon macayealstokes)271 pos=numpy.nonzero(nodeonSSAFS) 273 272 md.flowequation.vertex_equation[pos]=6 274 273 275 274 #figure out solution types 276 md.flowequation.ishutter=any(md.flowequation.element_equation==1) 277 md.flowequation.ismacayealpattyn=bool(numpy.any(numpy.logical_or(md.flowequation.element_equation==2,md.flowequation.element_equation==3))) 278 md.flowequation.isl1l2=any(md.flowequation.element_equation==8) 279 md.flowequation.isstokes=any(md.flowequation.element_equation==4) 275 md.flowequation.isSIA=any(md.flowequation.element_equation==1) 276 md.flowequation.isSSA=any(md.flowequation.element_equation==2) 277 md.flowequation.isL1L2=any(md.flowequation.element_equation==8) 278 md.flowequation.isHO=any(md.flowequation.element_equation==3) 279 md.flowequation.isFS=any(md.flowequation.element_equation==4) 280 280 281 281 return md 282 282 283 283 #Check that tiling can work: 284 if any(md.flowequation.border macayeal) and any(md.flowequation.borderpattyn) and any(md.flowequation.borderpattyn + md.flowequation.bordermacayeal!=1):284 if any(md.flowequation.borderSSA) and any(md.flowequation.borderHO) and any(md.flowequation.borderHO + md.flowequation.borderSSA !=1): 285 285 raise TypeError("error coupling domain too irregular") 286 if any(md.flowequation.border macayeal) and any(md.flowequation.borderstokes) and any(md.flowequation.borderstokes + md.flowequation.bordermacayeal!=1):286 if any(md.flowequation.borderSSA) and any(md.flowequation.borderFS) and any(md.flowequation.borderFS + md.flowequation.borderSSA !=1): 287 287 raise TypeError("error coupling domain too irregular") 288 if any(md.flowequation.border stokes) and any(md.flowequation.borderpattyn) and any(md.flowequation.borderpattyn + md.flowequation.borderstokes!=1):288 if any(md.flowequation.borderFS) and any(md.flowequation.borderHO) and any(md.flowequation.borderHO + md.flowequation.borderFS !=1): 289 289 raise TypeError("error coupling domain too irregular") 290 290
Note:
See TracChangeset
for help on using the changeset viewer.