-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathTadpoleInitialize.m
More file actions
69 lines (51 loc) · 1.49 KB
/
TadpoleInitialize.m
File metadata and controls
69 lines (51 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function [p g] = TadpoleInitialize(initial,p)
% TadpoleInitialize.m
%
% Performs initialization steps for Tadpole
%%%%%%%%%%%%%%%%%%
% TIME VARIABLES %
%%%%%%%%%%%%%%%%%%
p.t = 0; % time in yr
p.dt = p.dtmax;
if p.doAdaptiveTimeStep && ~isfield(p,'Courant')
p.Courant = 0.5; % default maximum Courant number
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% INITIAL AND BOUNDARY CONDITIONS %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[p.K p.J] = size(initial);
g.U = initial;
% g.Uprev = g.U; % elevations at previous time step
[p g] = BoundaryMat(p,g);
if p.doStreamPower && ~p.doChannelDiffusion
g.Channels = ones(p.K,p.J);
[p g] = MarkChannels(p,g);
else
g.Channels = zeros(p.K,p.J);
end
%%%%%%%%%%%%%%%%%
% SET UP OUTPUT %
%%%%%%%%%%%%%%%%%
if p.doSaveOutput
% assign a default name for the output if it was not specified
if ~isfield(p,'runname')
p.runname = 'default_run_name';
end
p.saveint = ceil(p.saveint);
g.output(:,:,1) = initial; % the initial surface
g.t = 0; % vector that will hold the times corresponding to the saved grids
end
%%%%%%%%%%%%%%%%%%%%%
% MEMORY ALLOCATION %
%%%%%%%%%%%%%%%%%%%%%
% construct matrix operators used in the Alternating-Direction Implicit (ADI) scheme for linear diffusion
if p.doDiffusion
g = SetUpADI(p,g);
end
%%%%%%%%%%%%%%%%%%%%%
% SET UP PLOT %
%%%%%%%%%%%%%%%%%%%%%
if p.doDrawPlot
p.plotint = round(p.plotint);
[p g] = SetUpPlot(p,g);
end