5 % dimensions in elements
11 fprintf('linear array of %ix%ix%i cells\n',n(1),n(2),n(3))
13 string_diag_A=sprintf('%g %g %g',da);
15 lambda = zeros(prod(n+1),1); % placeholder solution
18 X = regular_mesh(n,h,1.5^(1/sc));
19 X = add_terrain_to_mesh(X,'hill','squash',0.3);
22 % initial wind at the centers of the elements
23 U0={ones(n),zeros(n),zeros(n)};
30 plot_mesh_3d(X), hold on,
31 title('The wind mesh, wind vector in centers, lambda in corners')
35 plot_mesh_3d(X,[1,n(1),1,n(2),1,1]), hold on,
43 plot_mesh_3d(X,[1,n(1),1,n(2),1,1]), hold on,
47 title('Initial wind lowest layer')
50 % assemble sparse system matrix
51 [K,F,~] = sparse_assembly(A,X,U0,lambda);
53 % dirichlet boundary conditions
54 [K,F]=apply_boundary_conditions(K,F,X);
57 lambda = sparse_solve(K,F,X,'s');
60 [~,~,W] = sparse_assembly(A,X,U0,lambda);
65 plot_mesh_3d(X,[1,n(1),1,n(2),1,1]), hold on,
69 title(['Final wind a=',string_diag_A])
72 plot_mesh_3d(X,[1,n(1),1,n(2),1,1]), hold on,
76 title(['Final wind lowest layer a=',string_diag_A])
79 plot_mesh_3d(X,[1,n(1),1,n(2),1,1]), hold on,
80 plot_wind_3d(CX,W,1:2)
83 title(['Final wind lowest layers a=',string_diag_A])
85 % condition_number=scond(K)