classdef doublegyre2d
    
    properties
        A;
        EPS;
        OMEGA;
    end
    
    methods
        % constructor
        function obj = doublegyre2d(a, eps, omega)
            if nargin > 0
                obj.A = a;
            else
                obj.A = 0.1;
            end
                
            if nargin > 1
                obj.EPS = eps;
            else
                obj.EPS = 0.25;
            end
            
            if nargin > 2
                obj.OMEGA = omega;
            else
                obj.OMEGA = pi/5;
            end
        end
        
        % Samples the vector field of the Double Gyre flow
        function [u, v] = sample(obj, x, y, t)
            u = -obj.A * pi*sin(pi*(obj.EPS*sin(obj.OMEGA*t)*x*x + (1 - 2 * obj.EPS*sin(obj.OMEGA*t))*x))*cos(pi*y);
			v = obj.A * pi*(2 * obj.EPS*sin(obj.OMEGA*t)*x - 2 * obj.EPS*sin(obj.OMEGA*t) + 1)* cos(pi*(obj.EPS*sin(obj.OMEGA*t)*x*x + (1 - 2 * obj.EPS*sin(obj.OMEGA*t))*x))*sin(pi*y);
        end
        
        % Samples the x-partial of the vector field of the Double Gyre flow
        function [u, v] = sample_dx(obj, x, y, t)
            u = -obj.A * pi*pi * (2 * obj.EPS*sin(obj.OMEGA*t)*x - 2 * obj.EPS*sin(obj.OMEGA*t) + 1)*cos(pi*(obj.EPS*sin(obj.OMEGA*t)*x*x + (1 - 2 * obj.EPS*sin(obj.OMEGA*t))*x))*cos(pi*y);
			v = 2 * obj.A*obj.EPS*pi* sin(obj.OMEGA*t)*cos(pi*(obj.EPS*sin(obj.OMEGA*t)*x*x + (1 - 2 * obj.EPS*sin(obj.OMEGA*t))*x))*sin(pi*y) - obj.A * pi*pi * (2 * obj.EPS*sin(obj.OMEGA*t)*x - 2 * obj.EPS*sin(obj.OMEGA*t) + 1) * (2 * obj.EPS*sin(obj.OMEGA*t)*x - 2 * obj.EPS*sin(obj.OMEGA*t) + 1) * sin(pi*(obj.EPS*sin(obj.OMEGA*t)*x*x + (1 - 2 * obj.EPS*sin(obj.OMEGA*t))*x))*sin(pi*y);
        end
        
        % Samples the y-partial of the vector field of the Double Gyre flow
        function [u, v] = sample_dy(obj, x, y, t)
            u = obj.A * pi*pi * sin(pi*(obj.EPS*sin(obj.OMEGA*t)*x*x + (1 - 2 * obj.EPS*sin(obj.OMEGA*t))*x))*sin(pi*y);
			v = obj.A * pi*pi * (2 * obj.EPS*sin(obj.OMEGA*t)*x - 2 * obj.EPS*sin(obj.OMEGA*t) + 1)* cos(pi*(obj.EPS*sin(obj.OMEGA*t)*x*x + (1 - 2 * obj.EPS*sin(obj.OMEGA*t))*x))*cos(pi*y);
        end
        
        % Samples the t-partial of the vector field of the Double Gyre flow
        function [u, v] = sample_dt(obj, x, y, t)
            u = -obj.A * pi*pi * (obj.EPS*obj.OMEGA*cos(obj.OMEGA*t)*x*x - 2 * obj.EPS*obj.OMEGA*cos(obj.OMEGA*t)*x)*cos(pi*(obj.EPS*sin(obj.OMEGA*t)*x*x + (1 - 2 * obj.EPS*sin(obj.OMEGA*t))*x))*cos(pi*y);
			v = obj.A * pi * (2 * obj.EPS*obj.OMEGA*cos(obj.OMEGA*t)*x - 2 * obj.EPS*obj.OMEGA*cos(obj.OMEGA*t))*cos(pi*(obj.EPS*sin(obj.OMEGA*t)*x*x + (1 - 2 * obj.EPS*sin(obj.OMEGA*t))*x))*sin(pi*y) - obj.A * pi*pi * (2 * obj.EPS*sin(obj.OMEGA*t)*x - 2 * obj.EPS*sin(obj.OMEGA*t) + 1)*(obj.EPS*obj.OMEGA*cos(obj.OMEGA*t)*x*x - 2 * obj.EPS*obj.OMEGA*cos(obj.OMEGA*t)*x) * sin(pi*(obj.EPS*sin(obj.OMEGA*t)*x*x + (1 - 2 * obj.EPS*sin(obj.OMEGA*t))*x))*sin(pi*y);
        end
    end
    
end

