source: issm/trunk/src/m/solutions/ice/transient2d.m@ 34

Last change on this file since 34 was 34, checked in by Mathieu Morlighem, 16 years ago

moved icediagnostic -> diagnostic (removed ice from the functions name)

File size: 3.7 KB
Line 
1function md=transient2d(md);
2%ICETRANSIENT2D - transient solution of 2d models
3%
4% Usage:
5% md=transient2d(md)
6
7global gridset
8
9%Create fem structure (input of diagnostic2d)
10fem=struct();
11
12%Figure out which type of elements are present
13[fem.ishutter,fem.ismacayealpattyn,fem.isstokes]=DiagnosticSolutionType(md.elements_type);
14
15%First, build elements,grids,loads, etc ... for horizontal model
16if fem.ishutter,
17 fem.m_ss=CreateFemModel(md,'surface_slope_compute');
18 fem.m_dhu=CreateFemModel(md,'diagnostic_hutter');
19end
20if fem.ismacayealpattyn,
21 fem.m_dh=CreateFemModel(md,'diagnostic_horiz');
22end
23m_p=CreateFemModel(md,'prognostic');
24
25%initialize (velocity,pressure)
26solution.u_g=zeros(m_p.gridset.gsize,1);
27if ~isnan(md.vx), solution.u_g(1:6:m_p.gridset.gsize)=md.vx/md.yts; end
28if ~isnan(md.vy), solution.u_g(2:6:m_p.gridset.gsize)=md.vy/md.yts; end
29
30%initialize geometry and time
31solution.thickness=zeros(m_p.gridset.gsize,1);solution.thickness(1:6:m_p.gridset.gsize)=md.thickness;
32solution.surface=zeros(m_p.gridset.gsize,1);solution.surface(1:6:m_p.gridset.gsize)=md.surface;
33solution.bed=zeros(m_p.gridset.gsize,1);solution.bed(1:6:m_p.gridset.gsize)=md.bed;
34solution.time=0;
35
36%melting and accumulation are taken constant for all iterations
37melting=zeros(m_p.gridset.gsize,1);
38accumulation=zeros(m_p.gridset.gsize,1);
39melting(1:6:end)=md.melting/md.yts; %from m/yr to m/s
40accumulation(1:6:end)=md.accumulation/md.yts; %from m/yr to m/s
41
42%build constant inputs
43fem.inputs=struct();
44fem.inputs.accumulation=accumulation;
45fem.inputs.melting=melting;
46fem.inputs.dt=md.dt;
47
48%first time step is given by model.
49dt=md.dt;
50finaltime=md.ndt;
51time=dt;
52n=1; %counter
53
54while time<finaltime+dt, %make sure we run up to finaltime.
55
56 disp(sprintf('\n%s%g%s%g%s%g\n','time [yr]: ',time/md.yts,' iteration number: ',n,'/',floor(finaltime/dt)));
57
58 solution(n+1).time=time;
59
60 %update inputs
61 fem.inputs.velocity=solution(n).u_g;
62 fem.inputs.thickness=solution(n).thickness;
63 fem.inputs.bed=solution(n).bed;
64 fem.inputs.surface=solution(n).surface;
65
66 %Deal with velocities.
67
68 %Get horizontal solution.
69 solution(n+1).u_g=diagnostic2d(md,fem);
70
71 %compute new thickness
72 disp(sprintf('%s',' computing new thickness...'));
73 fem.inputs.velocity_average=solution(n+1).u_g;
74 new_thickness=prognostic_core(m_p,'prognostic',fem.inputs);
75
76 %update surface and bed using the new thickness
77 disp(sprintf('%s',' updating geometry...'));
78 indx=1:6:m_p.gridset.gsize; indx=indx(m_p.tpart);
79 [new_bed,new_surface,new_thickness]=UpdateGeometry(md,new_thickness(indx),solution(n).bed(indx),solution(n).surface(indx));
80
81 %Record bed surface and thickness in the solution
82 solution(n+1).thickness=zeros(m_p.gridset.gsize,1);solution(n+1).thickness(1:6:m_p.gridset.gsize)=new_thickness;
83 solution(n+1).bed=zeros(m_p.gridset.gsize,1);solution(n+1).bed(1:6:m_p.gridset.gsize)=new_bed;
84 solution(n+1).surface=zeros(m_p.gridset.gsize,1);solution(n+1).surface(1:6:m_p.gridset.gsize)=new_surface;
85
86 %figure out if time stepping is good
87 disp(sprintf('%s',' checking time stepping...'));
88 [back,dt,time]=TimeStepping(md,solution,dt,time);
89 if back,
90 continue;
91 end
92
93 %update time and counter
94 time=time+dt;
95 n=n+1;
96
97end
98
99%load results onto model
100indx=1:6:m_p.gridset.gsize; indx=indx(m_p.tpart);
101indy=2:6:m_p.gridset.gsize; indy=indy(m_p.tpart);
102for i=1:length(solution),
103 solution2(i).vx=solution(i).u_g(indx)*md.yts;
104 solution2(i).vy=solution(i).u_g(indy)*md.yts;
105 solution2(i).vel=sqrt(solution2(i).vx.^2+solution2(i).vy.^2);
106 solution2(i).thickness=solution(i).thickness(indx);
107 solution2(i).surface=solution(i).surface(indx);
108 solution2(i).bed=solution(i).bed(indx);
109 solution2(i).time=solution(i).time/md.yts;
110end
111md.transient_results=solution2;
Note: See TracBrowser for help on using the repository browser.