Changeset 12191
- Timestamp:
- 05/03/12 12:43:52 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/utils/BC/SetIceShelfBC.py
r12127 r12191 1 def SetIceShelfBC(md,icefrontfile='') 1 from numpy import * 2 def SetIceShelfBC(md,icefrontfile=''): 2 3 #SETICESHELFBC - Create the boundary conditions for diagnostic and thermal models for a Ice Shelf with Ice Front 3 4 # … … 22 23 print 'SetIceShelfBC error message: ice front file '+icefrontfile+ ' not found' 23 24 return [] 24 nodeinsideicefront=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2) ;25 nodeonicefront=double(md.mesh.vertexonboundary & nodeinsideicefront);25 nodeinsideicefront=ContourToMesh(md.mesh.elements,md.mesh.x,md.mesh.y,icefrontfile,'node',2) 26 nodeonicefront=double(md.mesh.vertexonboundary.astype(bool) and nodeinsideicefront.astype(bool)) 26 27 27 pos= find(md.mesh.vertexonboundary & ~nodeonicefront);28 md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices ,1);29 md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices ,1);30 md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices ,1);31 md.diagnostic.spcvx (pos)=0;32 md.diagnostic.spcvy (pos)=0;33 md.diagnostic.spcvz (pos)=0;34 md.diagnostic.referential= NaN*ones(md.mesh.numberofvertices,6);28 pos=argwhere(logical_and(md.mesh.vertexonboundary.astype(bool),~nodeonicefront.astype(bool))) 29 md.diagnostic.spcvx=NaN*ones(md.mesh.numberofvertices); 30 md.diagnostic.spcvy=NaN*ones(md.mesh.numberofvertices); 31 md.diagnostic.spcvz=NaN*ones(md.mesh.numberofvertices); 32 md.diagnostic.spcvx[pos]=0; 33 md.diagnostic.spcvy[pos]=0; 34 md.diagnostic.spcvz[pos]=0; 35 md.diagnostic.referential=float('NaN')*ones((md.mesh.numberofvertices,6),float); 35 36 36 37 #Dirichlet Values 37 if (length(md.inversion.vx_obs)==md.mesh.numberofvertices & length(md.inversion.vy_obs)==md.mesh.numberofvertices)38 disp(' boundary conditions for diagnostic model: spc set as observed velocities');39 md.diagnostic.spcvx(pos)=md.inversion.vx_obs(pos);40 md.diagnostic.spcvy(pos)=md.inversion.vy_obs(pos);41 else42 disp(' boundary conditions for diagnostic model: spc set as zero');43 end38 if ~isnan(md.inversion.vx_obs) and ~isnan(md.inversion.vy_obs): 39 if (len(md.inversion.vx_obs)==md.mesh.numberofvertices) and (len(md.inversion.vy_obs)==md.mesh.numberofvertices): 40 print ' boundary conditions for diagnostic model: spc set as observed velocities' 41 md.diagnostic.spcvx[pos]=md.inversion.vx_obs[pos] 42 md.diagnostic.spcvy[pos]=md.inversion.vy_obs[pos] 43 else: 44 print ' boundary conditions for diagnostic model: spc set as zero' 44 45 45 46 #segment on Ice Front 46 47 #segment on Neumann (Ice Front) 47 pos=find(nodeonicefront(md.mesh.segments(:,1)) | nodeonicefront(md.mesh.segments(:,2))); 48 if (md.mesh.dimension==2) 49 pressureload=md.mesh.segments(pos,:); 50 elseif md.mesh.dimension==3 51 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)]; 48 segs1=md.mesh.segments[:,0].astype(int)-1 49 segs2=md.mesh.segments[:,1].astype(int)-1 50 51 pos=argwhere(logical_and(nodeonicefront[segs1].astype(bool),nodeonicefront[segs2].astype(bool))) 52 if (md.mesh.dimension==2): 53 pressureload=md.mesh.segments[pos,:]; 54 elif md.mesh.dimension==3: 55 pressureload_layer=[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]]; 52 56 pressureload=[]; 53 for i=1:md.mesh.numberoflayers-1, 54 pressureload=[pressureload ;pressureload_layer1(:,1:4)+(i-1)*md.mesh.numberofvertices2d pressureload_layer1(:,5)+(i-1)*md.mesh.numberofelements2d ]; 55 end 56 end 57 for i in range(1,md.mesh.numberoflayers-1): 58 pressureload=[pressureload ,pressureload_layer1[:,1:4]+(i-1)*md.mesh.numberofvertices2d, pressureload_layer1[:,5]+(i-1)*md.mesh.numberofelements2d ]; 57 59 58 60 #Add water or air enum depending on the element 59 pressureload=[pressureload 1*md.mask.elementonfloatingice(pressureload(:,end))];61 pressureload=[pressureload, 1*md.mask.elementonfloatingice(pressureload[:,end])]; 60 62 61 63 #plug onto model … … 63 65 64 66 #Create zeros basalforcings and surfaceforcings 65 if isnan(md.surfaceforcings.precipitation), 66 md.surfaceforcings.precipitation=zeros(md.mesh.numberofvertices,1); 67 disp(' no surfaceforcings.precipitation specified: values set as zero'); 68 end 69 if isnan(md.surfaceforcings.mass_balance), 70 md.surfaceforcings.mass_balance=zeros(md.mesh.numberofvertices,1); 71 disp(' no surfaceforcings.mass_balance specified: values set as zero'); 72 end 73 if isnan(md.basalforcings.melting_rate), 74 md.basalforcings.melting_rate=zeros(md.mesh.numberofvertices,1); 75 disp(' no basalforcings.melting_rate specified: values set as zero'); 76 end 77 if isnan(md.balancethickness.thickening_rate), 78 md.balancethickness.thickening_rate=zeros(md.mesh.numberofvertices,1); 79 disp(' no balancethickness.thickening_rate specified: values set as zero'); 80 end 67 if isnan(md.surfaceforcings.precipitation): 68 md.surfaceforcings.precipitation=zeros(md.mesh.numberofvertices); 69 print ' no surfaceforcings.precipitation specified: values set as zero' 70 if isnan(md.surfaceforcings.mass_balance): 71 md.surfaceforcings.mass_balance=zeros(md.mesh.numberofvertices); 72 print ' no surfaceforcings.mass_balance specified: values set as zero' 73 if isnan(md.basalforcings.melting_rate): 74 md.basalforcings.melting_rate=zeros(md.mesh.numberofvertices) 75 print ' no basalforcings.melting_rate specified: values set as zero' 76 if isnan(md.balancethickness.thickening_rate): 77 md.balancethickness.thickening_rate=zeros(md.mesh.numberofvertices); 78 print ' no balancethickness.thickening_rate specified: values set as zero' 81 79 82 md.prognostic.spcthickness=NaN*ones(md.mesh.numberofvertices ,1);83 md.balancethickness.spcthickness=NaN*ones(md.mesh.numberofvertices ,1);80 md.prognostic.spcthickness=NaN*ones(md.mesh.numberofvertices); 81 md.balancethickness.spcthickness=NaN*ones(md.mesh.numberofvertices); 84 82 85 if (len gth(md.initialization.temperature)==md.mesh.numberofvertices),86 md.thermal.spctemperature=NaN*ones(md.mesh.numberofvertices ,1);87 pos= find(md.mesh.vertexonsurface); md.thermal.spctemperature(pos)=md.initialization.temperature(pos); #impose observed temperature on surface88 if (len gth(md.basalforcings.geothermalflux)~=md.mesh.numberofvertices),89 md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices ,1);90 end91 else92 disp(' no thermal boundary conditions created: no observed temperature found'); 93 end83 if (len(md.initialization.temperature)==md.mesh.numberofvertices): 84 md.thermal.spctemperature=NaN*ones(md.mesh.numberofvertices); 85 pos=argwhere(md.mesh.vertexonsurface); md.thermal.spctemperature[pos]=md.initialization.temperature[pos]; #impose observed temperature on surface 86 if (len(md.basalforcings.geothermalflux) !=md.mesh.numberofvertices): 87 md.basalforcings.geothermalflux=zeros(md.mesh.numberofvertices); 88 else: 89 print ' no thermal boundary conditions created: no observed temperature found' 90 91 return md
Note:
See TracChangeset
for help on using the changeset viewer.