source:
issm/oecreview/Archive/13393-13976/ISSM-13469-13470.diff
Last change on this file was 13980, checked in by , 12 years ago | |
---|---|
File size: 17.5 KB |
-
../trunk-jpl/src/m/geometry/FlagElements.py
40 40 if not os.path.exists(region): 41 41 if len(region)>3 and not strcmp(region[-4:],'.exp'): 42 42 raise IOError("Error: File 'region' not found!" % region) 43 raise RuntimeError("FlagElements -- basinzoom not yet converted.")43 raise RuntimeError("FlagElements.py calling basinzoom.py is not complete.") 44 44 xlim,ylim=basinzoom('basin',region) 45 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])).astype(float) 46 46 flag=numpy.prod(flag_nodes[md.mesh.elements],axis=1) 47 47 else: 48 48 #ok, flag elements 49 [flag, fnone]=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1)49 [flag,dum]=ContourToMesh(md.mesh.elements[:,0:3],md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),region,'element',1) 50 50 51 51 if invert: 52 52 flag=numpy.logical_not(flag) -
../trunk-jpl/src/m/mesh/bamg.py
120 120 raise RuntimeError("one rift has all its points outside of the domain outline") 121 121 122 122 elif numpy.any(numpy.logical_not(flags)): 123 raise RuntimeError("bamg. mfor rifts is not complete.")123 raise RuntimeError("bamg.py for rifts is not complete.") 124 124 #We LOTS of work to do 125 125 print("Rift tip outside of or on the domain has been detected and is being processed...") 126 126 """ … … 346 346 347 347 def processgeometry(geom,tol,outline): # {{{ 348 348 349 raise RuntimeError("bamg. m/processgeometry is not complete.")349 raise RuntimeError("bamg.py/processgeometry is not complete.") 350 350 #Deal with edges 351 351 print("Checking Edge crossing...") 352 352 i=0 -
../trunk-jpl/src/m/classes/model/model.py
166 166 def checkmessage(self,string): # {{{ 167 167 print ("model not consistent: %s" % string) 168 168 self.private.isconsistent=False 169 return self 169 170 # }}} 170 171 171 172 def extrude(md,*args): # {{{ -
../trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.m
52 52 end 53 53 54 54 md.hydrology.spcwatercolumn=zeros(md.mesh.numberofvertices,2); 55 pos=find(md.mesh.vertexonboundary); 55 pos=find(md.mesh.vertexonboundary); 56 56 md.hydrology.spcwatercolumn(pos,1)=1; 57 57 58 58 %segment on Neumann (Ice Front) … … 100 100 pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface 101 101 if (length(md.basalforcings.geothermalflux)~=md.mesh.numberofvertices), 102 102 md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices,1); 103 md.basalforcings.geothermalflux(find(md.mask.vertexongroundedice))=50 *10^-3; %50mW/m2103 md.basalforcings.geothermalflux(find(md.mask.vertexongroundedice))=50.*10.^-3; %50mW/m2 104 104 end 105 105 else 106 106 disp(' no thermal boundary conditions created: no observed temperature found'); -
../trunk-jpl/src/m/boundaryconditions/SetIceShelfBC.py
25 25 if not os.path.exists(icefrontfile): 26 26 raise IOError("SetIceShelfBC error message: ice front file '%s' not found." % icefrontfile) 27 27 [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2) 28 nodeonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront ).astype(float)28 nodeonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1)).astype(float) 29 29 else: 30 nodeonicefront=numpy.zeros((md.mesh.numberofvertices ,1))30 nodeonicefront=numpy.zeros((md.mesh.numberofvertices)) 31 31 32 32 # pos=find(md.mesh.vertexonboundary & ~nodeonicefront); 33 pos= [i for i,(vob,noif) in enumerate(zip(md.mesh.vertexonboundary,nodeonicefront)) if vob and not noif]34 md.diagnostic.spcvx=float(' NaN')*numpy.ones((md.mesh.numberofvertices,1))35 md.diagnostic.spcvy=float(' NaN')*numpy.ones((md.mesh.numberofvertices,1))36 md.diagnostic.spcvz=float(' NaN')*numpy.ones((md.mesh.numberofvertices,1))33 pos=numpy.nonzero(numpy.logical_and(md.mesh.vertexonboundary,numpy.logical_not(nodeonicefront)))[0] 34 md.diagnostic.spcvx=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 35 md.diagnostic.spcvy=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 36 md.diagnostic.spcvz=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 37 37 md.diagnostic.spcvx[pos]=0 38 38 md.diagnostic.spcvy[pos]=0 39 39 md.diagnostic.spcvz[pos]=0 40 md.diagnostic.referential=float(' NaN')*numpy.ones((md.mesh.numberofvertices,6))40 md.diagnostic.referential=float('nan')*numpy.ones((md.mesh.numberofvertices,6)) 41 41 42 42 #Dirichlet Values 43 43 if isinstance(md.inversion.vx_obs,numpy.ndarray) and numpy.size(md.inversion.vx_obs,axis=0)==md.mesh.numberofvertices and isinstance(md.inversion.vy_obs,numpy.ndarray) and numpy.size(md.inversion.vy_obs,axis=0)==md.mesh.numberofvertices: 44 print ' boundary conditions for diagnostic model: spc set as observed velocities'44 print " boundary conditions for diagnostic model: spc set as observed velocities" 45 45 md.diagnostic.spcvx[pos]=md.inversion.vx_obs[pos] 46 46 md.diagnostic.spcvy[pos]=md.inversion.vy_obs[pos] 47 47 else: 48 print ' boundary conditions for diagnostic model: spc set as zero'48 print " boundary conditions for diagnostic model: spc set as zero" 49 49 50 50 #segment on Ice Front 51 51 #segment on Neumann (Ice Front) 52 52 # pos=find(nodeonicefront(md.mesh.segments(:,1)) | nodeonicefront(md.mesh.segments(:,2))); 53 pos= [i for i,(noif1,noif2) in enumerate(zip(nodeonicefront[md.mesh.segments[:,0].astype('int')-1],nodeonicefront[md.mesh.segments[:,1].astype('int')-1])) if noif1 or noif2]53 pos=numpy.nonzero(numpy.logical_or(nodeonicefront[md.mesh.segments[:,0].astype(int)-1],nodeonicefront[md.mesh.segments[:,1].astype(int)-1]))[0] 54 54 if md.mesh.dimension==2: 55 55 pressureload=md.mesh.segments[pos,:] 56 56 elif md.mesh.dimension==3: … … 59 59 pressureload=numpy.zeros((0,5)) 60 60 for i in xrange(1,md.mesh.numberoflayers): 61 61 # pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ]; 62 pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0: 3]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d))))62 pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0:4]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d)))) 63 63 64 64 #Add water or air enum depending on the element 65 65 # pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))]; 66 pressureload=numpy.hstack((pressureload,1 *md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape((-1,1))))66 pressureload=numpy.hstack((pressureload,1.*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape(-1,1))) 67 67 68 68 #plug onto model 69 69 md.diagnostic.icefront=pressureload … … 71 71 #Create zeros basalforcings and surfaceforcings 72 72 if numpy.all(numpy.isnan(md.surfaceforcings.precipitation)) and (md.surfaceforcings.ispdd==1): 73 73 md.surfaceforcings.precipitation=numpy.zeros((md.mesh.numberofvertices,1)) 74 print ' no surfaceforcings.precipitation specified: values set as zero'74 print " no surfaceforcings.precipitation specified: values set as zero" 75 75 if numpy.all(numpy.isnan(md.surfaceforcings.mass_balance)) and (md.surfaceforcings.ispdd==0): 76 76 md.surfaceforcings.mass_balance=numpy.zeros((md.mesh.numberofvertices,1)) 77 print ' no surfaceforcings.mass_balance specified: values set as zero'77 print " no surfaceforcings.mass_balance specified: values set as zero" 78 78 if numpy.all(numpy.isnan(md.basalforcings.melting_rate)): 79 79 md.basalforcings.melting_rate=numpy.zeros((md.mesh.numberofvertices,1)) 80 print ' no basalforcings.melting_rate specified: values set as zero'80 print " no basalforcings.melting_rate specified: values set as zero" 81 81 if numpy.all(numpy.isnan(md.balancethickness.thickening_rate)): 82 82 md.balancethickness.thickening_rate=numpy.zeros((md.mesh.numberofvertices,1)) 83 print ' no balancethickness.thickening_rate specified: values set as zero'83 print " no balancethickness.thickening_rate specified: values set as zero" 84 84 85 md.prognostic.spcthickness=float(' NaN')*numpy.ones((md.mesh.numberofvertices,1))86 md.balancethickness.spcthickness=float(' NaN')*numpy.ones((md.mesh.numberofvertices,1))85 md.prognostic.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 86 md.balancethickness.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 87 87 88 if numpy.size(md.initialization.temperature)==md.mesh.numberofvertices:89 md.thermal.spctemperature=float(' NaN')*numpy.ones((md.mesh.numberofvertices,1))88 if isinstance(md.initialization.temperature,numpy.ndarray) and numpy.size(md.initialization.temperature,axis=0)==md.mesh.numberofvertices: 89 md.thermal.spctemperature=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 90 90 # pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface 91 pos= [i for i,vos in enumerate(md.mesh.vertexonsurface) if vos]92 md.thermal.spctemperature[pos]=md.initialization.temperature[pos] # 93 if not numpy.size(md.basalforcings.geothermalflux)==md.mesh.numberofvertices:91 pos=numpy.nonzero(md.mesh.vertexonsurface)[0] 92 md.thermal.spctemperature[pos]=md.initialization.temperature[pos] #impose observed temperature on surface 93 if not isinstance(md.basalforcings.geothermalflux,numpy.ndarray) or not numpy.size(md.basalforcings.geothermalflux,axis=0)==md.mesh.numberofvertices: 94 94 md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices,1)) 95 95 else: 96 print ' no thermal boundary conditions created: no observed temperature found'96 print " no thermal boundary conditions created: no observed temperature found" 97 97 98 98 return md 99 99 -
../trunk-jpl/src/m/boundaryconditions/SetMarineIceSheetBC.py
1 import os 2 import numpy 3 from ContourToMesh import * 4 5 def SetMarineIceSheetBC(md,icefrontfile=''): 6 """ 7 SETICEMARINESHEETBC - Create the boundary conditions for diagnostic and thermal models for a Marine Ice Sheet with Ice Front 8 9 Neumann BC are used on the ice front (an ARGUS contour around the ice front 10 can be given in input, or it will be deduced as onfloatingice & onboundary) 11 Dirichlet BC are used elsewhere for diagnostic 12 13 Usage: 14 md=SetMarineIceSheetBC(md,icefrontfile) 15 md=SetMarineIceSheetBC(md) 16 17 Example: 18 md=SetMarineIceSheetBC(md,'Front.exp') 19 md=SetMarineIceSheetBC(md) 20 21 See also: SETICESHELFBC, SETMARINEICESHEETBC 22 """ 23 24 #node on Dirichlet (boundary and ~icefront) 25 if icefrontfile: 26 #User provided Front.exp, use it 27 if not os.path.exists(icefrontfile): 28 raise IOError("SetMarineIceSheetBC error message: ice front file '%s' not found." % icefrontfile) 29 [nodeinsideicefront,dum]=ContourToMesh(md.mesh.elements,md.mesh.x.reshape(-1,1),md.mesh.y.reshape(-1,1),icefrontfile,'node',2) 30 vertexonicefront=numpy.logical_and(md.mesh.vertexonboundary,nodeinsideicefront.reshape(-1)).astype(float) 31 else: 32 #Guess where the ice front is 33 vertexonfloatingice=numpy.zeros((md.mesh.numberofvertices)) 34 vertexonfloatingice[md.mesh.elements[numpy.nonzero(md.mask.elementonfloatingice),:].astype(int)-1]=1 35 vertexonicefront=numpy.logical_and(md.mesh.vertexonboundary,vertexonfloatingice).astype(float) 36 37 # pos=find(md.mesh.vertexonboundary & ~vertexonicefront); 38 pos=numpy.nonzero(numpy.logical_and(md.mesh.vertexonboundary,numpy.logical_not(vertexonicefront)))[0] 39 if not numpy.size(pos): 40 print("SetMarineIceSheetBC warning: ice front all around the glacier, no dirichlet found. Dirichlet must be added manually.") 41 42 md.diagnostic.spcvx=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 43 md.diagnostic.spcvy=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 44 md.diagnostic.spcvz=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 45 md.diagnostic.spcvx[pos]=0 46 md.diagnostic.spcvy[pos]=0 47 md.diagnostic.spcvz[pos]=0 48 md.diagnostic.referential=float('nan')*numpy.ones((md.mesh.numberofvertices,6)) 49 50 #Dirichlet Values 51 if isinstance(md.inversion.vx_obs,numpy.ndarray) and numpy.size(md.inversion.vx_obs,axis=0)==md.mesh.numberofvertices and isinstance(md.inversion.vy_obs,numpy.ndarray) and numpy.size(md.inversion.vy_obs,axis=0)==md.mesh.numberofvertices: 52 print(" boundary conditions for diagnostic model: spc set as observed velocities") 53 md.diagnostic.spcvx[pos]=md.inversion.vx_obs[pos] 54 md.diagnostic.spcvy[pos]=md.inversion.vy_obs[pos] 55 else: 56 print(" boundary conditions for diagnostic model: spc set as zero") 57 58 md.hydrology.spcwatercolumn=numpy.zeros((md.mesh.numberofvertices,2)) 59 pos=numpy.nonzero(md.mesh.vertexonboundary)[0] 60 md.hydrology.spcwatercolumn[pos,0]=1 61 62 #segment on Neumann (Ice Front) 63 # pos=find(vertexonicefront(md.mesh.segments(:,1)) | vertexonicefront(md.mesh.segments(:,2))); 64 pos=numpy.nonzero(numpy.logical_or(vertexonicefront[md.mesh.segments[:,0].astype(int)-1],vertexonicefront[md.mesh.segments[:,1].astype(int)-1]))[0] 65 if md.mesh.dimension==2: 66 pressureload=md.mesh.segments[pos,:] 67 elif md.mesh.dimension==3: 68 # pressureload_layer1=[md.mesh.segments(pos,1:2) md.mesh.segments(pos,2)+md.mesh.numberofvertices2d md.mesh.segments(pos,1)+md.mesh.numberofvertices2d md.mesh.segments(pos,3)]; 69 pressureload_layer1=numpy.hstack((md.mesh.segments[pos,0:2],md.mesh.segments[pos,1]+md.mesh.numberofvertices2d,md.mesh.segments[pos,0]+md.mesh.numberofvertices2d,md.mesh.segments[pos,2])) 70 pressureload=numpy.zeros((0,5)) 71 for i in xrange(1,md.mesh.numberoflayers): 72 # pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ]; 73 pressureload=numpy.vstack((pressureload,numpy.hstack((pressureload_layer1[:,0:4]+(i-1)*md.mesh.numberofvertices2d,pressureload_layer1[:,4]+(i-1)*md.mesh.numberofelements2d)))) 74 75 #Add water or air enum depending on the element 76 # pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))+ 0*md.mask.elementongroundedice(pressureload(:,end))]; 77 pressureload=numpy.hstack((pressureload,1.*md.mask.elementonfloatingice[pressureload[:,-1].astype('int')-1].reshape(-1,1)+0.*md.mask.elementongroundedice[pressureload[:,-1].astype('int')-1].reshape(-1,1))) 78 79 #plug onto model 80 md.diagnostic.icefront=pressureload 81 82 #Create zeros basalforcings and surfaceforcings 83 if numpy.all(numpy.isnan(md.surfaceforcings.precipitation)) and (md.surfaceforcings.ispdd==1): 84 md.surfaceforcings.precipitation=numpy.zeros((md.mesh.numberofvertices,1)) 85 print(" no surfaceforcings.precipitation specified: values set as zero") 86 if numpy.all(numpy.isnan(md.surfaceforcings.mass_balance)) and (md.surfaceforcings.ispdd==0): 87 md.surfaceforcings.mass_balance=numpy.zeros((md.mesh.numberofvertices,1)) 88 print(" no surfaceforcings.mass_balance specified: values set as zero") 89 if numpy.all(numpy.isnan(md.basalforcings.melting_rate)): 90 md.basalforcings.melting_rate=numpy.zeros((md.mesh.numberofvertices,1)) 91 print(" no basalforcings.melting_rate specified: values set as zero") 92 if numpy.all(numpy.isnan(md.balancethickness.thickening_rate)): 93 md.balancethickness.thickening_rate=numpy.zeros((md.mesh.numberofvertices,1)) 94 print(" no balancethickness.thickening_rate specified: values set as zero") 95 96 md.prognostic.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 97 md.balancethickness.spcthickness=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 98 99 if isinstance(md.initialization.temperature,numpy.ndarray) and numpy.size(md.initialization.temperature,axis=0)==md.mesh.numberofvertices: 100 md.thermal.spctemperature=float('nan')*numpy.ones((md.mesh.numberofvertices,1)) 101 # pos=find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); %impose observed temperature on surface 102 pos=numpy.nonzero(md.mesh.vertexonsurface)[0] 103 md.thermal.spctemperature[pos]=md.initialization.temperature[pos] #impose observed temperature on surface 104 if not isinstance(md.basalforcings.geothermalflux,numpy.ndarray) or not numpy.size(md.basalforcings.geothermalflux,axis=0)==md.mesh.numberofvertices: 105 md.basalforcings.geothermalflux=numpy.zeros((md.mesh.numberofvertices,1)) 106 md.basalforcings.geothermalflux[numpy.nonzero(md.mask.vertexongroundedice)]=50.*10.**-3; #50mW/m2 107 else: 108 print(" no thermal boundary conditions created: no observed temperature found"); 109 110 return md 111
Note:
See TracBrowser
for help on using the repository browser.