1 function err = mass_cons_flux_test
2 disp('mass_cons_flux_test - testing mass consistent flux approximation with terrain')
6 % 'constant' : constant wind to x direction,
7 % 'log' : vertical log profile,
9 terrain_following = true; % still under developmentssss
10 u0 = 1; % initial wind magnitude
11 h0 = .5; % roughness high: only for log profile cases ('log' or 'terrain')
15 X = regular_mesh(mesh_len,h,1.2);
16 X = add_terrain_to_mesh(X,'hill','squash',0.05);
20 [nx,ny,nz] = size(X{1});
23 % declare initial wind
24 U0 = grad3z(ones(size(x)-1),mesh_len);
27 U0{1} = u0*ones(size(U0{1}));
28 U0{2} = 0*ones(size(U0{2}));
29 U0{3} = 0*ones(size(U0{3}));
32 h_at_u = (hz(:,1:end-1,1:end-1)+hz(:,2:end,1:end-1)+hz(:,1:end-1,2:end)+hz(:,2:end,2:end))/4;
33 mlogh = log(max(h_at_u(:)));
34 U0{1} = u0*log(max(h_at_u/h0,1))/mlogh;
35 U0{2} = 0*ones(size(U0{2}));
36 U0{3} = 0*ones(size(U0{3}));
38 error('mass_cons_flux_test: unknown init_wind')
40 plot_wind_above_terrain(U0,X,mesh_disp)
42 U0 = terrain_correction(U0,X);
43 plot_wind_above_terrain(U0,X,mesh_disp)
47 [U,Lambda_d] = mass_cons_flux(U0,X,'direct','check');
48 plot_wind_above_terrain(U,X,mesh_disp)
51 [V,Lambda_pcg,err] = mass_cons_flux(U0,X,'pcg','check');
52 plot_wind_above_terrain(V,X,mesh_disp)
55 direct_vs_pcg = big(cell2vec(U)-cell2vec(V))
56 lambda_diff = big(Lambda_d-Lambda_pcg)