function pclaw_ex_bucklev
%PCLAW_EX_BUCKLEV
%   Example for PARTICLECLAW, a numerical scheme for scalar
%   conservation and balance laws
%       u_t+(f(u))_x = g(x,u)
%   in one space dimension.
%   
%   Example: Buckley-Leverett equations
%       f(u) = u.^2./(u.^2+a*(1-u).^2)
%   with a = 0.5, and Riemann initial data.
%
%   Copyright (c) 2008 Benjamin Seibold and Yossi Farjoun
%   http://math.mit.edu/~seibold/research/particleclaw
%   http://arxiv.org/abs/0809.0726

%===============================================================================
parameters = struct(...
'name','Buckley-Leverett',...    % name of example
'f',@f,'f1',@f1,'f2',@f2,...     % flux function and derivatives (below)
'u_ip',.386963143105396,...      % value of an inflection point
'ic',@ic,...                     % initial condition (below)
'xbox',[0.5 3.5],...             % computational domain
'ubox',[-.1 1.1],...             % axis for function values (for plotting only)
'd',[0 1e-1 1.2*1e-1],...        % [d_min d_init d_max]
'tfinal',1.2,...                 % final time
'steps',250,...                  % number of output steps
'flag_sharpen',0,...             % if yes, shocks get sharpened upon output
'flag_plot',1,...                % if yes, animation gets plotted in figure
'flag_save',0      );            % if yes, solution gets stored in data files
%===============================================================================
particleclaw(parameters)
%===============================================================================
function y = f(u),  a = .5; y = u.^2./(u.^2+a*(1-u).^2);
function y = f1(u), a = .5; y = 2*a*(1-u).*u./(u.^2+a*(1-u).^2).^2;
function y = f2(u), a = .5;
    y = 2*a*((2*u-3).*u.^2+a*(1-u).^2.*(1+2*u))./(u.^2+a*(1-u).^2).^3;
function y = ic(x), y = (x<1)+(x>1.3)*.3;

%===============================================================================
% Copyright (c) 2008 Benjamin Seibold and Yossi Farjoun
% 
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the "Software"), to deal
% in the Software without restriction for non-commercial purposes, including
% without limitation the rights to use, copy, modify, merge, publish, and/or
% distribute copies of the Software, and to permit persons to whom the
% Software is furnished to do so, subject to the following conditions:
% 
% The above copyright notice and this permission notice shall be included in
% all copies or substantial portions of the Software, and credit has to be
% given to the authors in publications that are in any form based on this
% Software.
% 
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
% THE SOFTWARE.
%===============================================================================

