function phi = main_advection(phi,f,u,v,runTime,tFinal) % %*************************************************************************** % Program: Passive Advection Equation % % Written by Chiu Yen Kao in matlab : July 2 2007 % All rights researved !!! % %*************************************************************************** % % In this program, we are going to solve the 2D passive advection problem % % The Equation is as following: % % phi.t + (u*phi).x + (v*phi).y = f (5) % where (u,v) and f is given % on the rectangular domain % D = [0,1] x[0,1] % % The BC for phi is: % % phi(x,0,t)= 0 % %*************************************************************************** global xmin xmax ymin ymax Mx My global gx gy nx ny nxs nys nxe nye dx dy x y global runTime tol = 1.0e-5; dtUp = 0.5*dx; dtLow = 1e-8; run = 0; eps = 0; %[u,v] = getVelocity(phi,eta,gx,gy,nx,ny,dx,dy,eps); T_st = runTime; % % main time advance loop % while runTime < tFinal dtLim = getTimeStep(u,v,phi,tol,eps); dtRun = min(dtLim,dtUp); if dtRun < dtLow error('dtRun too small') end if (runTime + dtRun) >= tFinal dtRun = tFinal - runTime; end [phi,u,v] = advance(phi,f,u,v,T_st,dtRun); runTime = runTime + dtRun; run = run + 1; end