function [uv] = demo_ufunc(t,z,flo) %DEMO_UFUNC ODE file defining the velocities for demo1,demo2 % % orig. by: cbm (24/01/2002) % hacked on later by: djm, cbm % current version: jrg, cbm (09/02/2002) % Scroll down to find out how to add your own problem... global FLOW_TITLE DOMAIN; switch flo case {1} % line vortex example, (Acheson, page12) k = 1; r2 = real(z).^2 + imag(z).^2; uv = (-k*imag(z)./r2) + i * (k*real(z)./r2); % global paramters for this problem: DOMAIN.left = -1; DOMAIN.right = 1; DOMAIN.bottom = -1; DOMAIN.top = 1; FLOW_TITLE = ['\bf line vortex (irrotational)']; case {2} % solid body rotation (HW#1, Question 2, Acheson, page 24) GAMMA = 3; uv = -GAMMA*imag(z) + i * GAMMA*real(z); % global parameters for this problem: DOMAIN.left = -1; DOMAIN.right = 1; DOMAIN.bottom = -1; DOMAIN.top = 1; FLOW_TITLE = ['\bf solid body rotation (rotational)']; case {3} % shear flow (Acheson, page12) BETA = 3; uv = BETA*imag(z); % global parameters for this problem DOMAIN.left = -1; DOMAIN.right = 1; DOMAIN.bottom = -1; DOMAIN.top = 1; FLOW_TITLE = ['\bf parallel shear flow (rotational)']; case {4} % HW#0, problem 2 (flow around cylinder) B = 1; k = 2; x = real(z); y = imag(z); r2 = x.^2+y.^2; u = (r2 >= 1).*( k*((1 - 1./r2) + (2*y.*y)./(r2.^2) + (B*y./r2)) ); v = (r2 >= 1).*( k*(-(2*x.*y)./(r2.^2) - (B*x)./r2) ); uv = u + i*v; % global parameters for this problem: DOMAIN.left = -2; DOMAIN.right = 2; DOMAIN.bottom = -2; DOMAIN.top = 2; FLOW_TITLE = ['\bf flow around a rotating cylinder (irrotational!)']; case {5} % add your own problem here... % see examples above error('you need to implement your own problem in demo_flow.m'); % global parameters for this problem: DOMAIN.left = -1; DOMAIN.right = 1; DOMAIN.bottom = -1; DOMAIN.top = 1; FLOW_TITLE = ['\bf my own problem']; otherwise error(['Flow case ' num2str(flo) ' not implemented']); end