%ADFEM is an adaptive finite element MATLAB program for approximate
%solution of two-point boundary value problems of the form: 
%find u=u(x) such that, with D = d/dx,
%
% -D(d(x)Du) + c(x)Du + a(x)u = f(x)  for  xmin < x < xmax,
%
%and such that
%
% -dDu + ku = g  (Neumann/Robin)  or  u = g  (Dirichlet)  at x=xmin, 
%  dDu + ku = g  (Neumann/Robin)  or  u = g  (Dirichlet)  at x=xmax. 
%
%The following is an example of how to enter the data and to run adfem
%directly at the MATLAB prompt.  The example solves the boundary value
%problem:
%
% -((1+x)^(-1) u'(x))'=x  for  0<x<1, 
% (1+x)^(-1) u'(x)=0  at  x=0,  u(x)=1  at  x=1. 
%
%To run this example type the following:  
%
% xmin=0
% xmax=1
% diffusion='1/(1+x)'
% convection='0'
% absorbtion='0'
% force='x'
% errnorm='ma'
% exactflag='y'
% uexact='31/24-(x^3)/6-(x^4)/8'
% bctype=[1 0]  
% k=[0 0]
% g=[0 1]
% tol=0.01
% run=0
% bvpsolve
%
%Note that this example is provided in order to explain the meaning of
%the the input variables.  Normally you would input the data by
%answering the questions from ADFEM.  
%
warning off
disp('This program solves the diffusion-convection-absorbtion equation');
disp('')
disp('    -D(dDu) + cDu + au = f      (D=d/dx)')
disp('')
disp('in the domain  [xmin,xmax],')
disp('with boundary conditions')
disp('')
disp(' -dDu + ku = g  (Neumann/Robin)  or  u = g  (Dirichlet)  at x=xmin, ')
disp('  dDu + ku = g  (Neumann/Robin)  or  u = g  (Dirichlet)  at x=xmax. ')
disp('')
disp('and with energy, L2 or maximum norm error less than a given tolerance.')
%
%data input
%
xmin=input('xmin = ');
xmax=input('xmax = ');
%
diffusion=input('d(x) = ','s');
convection=input('c(x) = ','s');
absorbtion=input('a(x) = ','s');
force=input('f(x) = ','s');
%
k=[0 0];
input('b.c. type at  x = xmin,  n (Neuman/Robin) or d (Dirichlet) ? ','s');
if ans=='d'; bctype(1)=0; else; bctype(1)=1; end
if bctype(1)==1
k(1)=input('k = ');
end
g(1)=input('g = ');
input('b.c. type at  x = xmax,  n or d ? ','s');
if ans=='d'; bctype(2)=0; else; bctype(2)=1; end
if bctype(2)==1
k(2)=input('k = ');
end
g(2)=input('g = ');
%
errnorm=input('error norm ?  en (energy), l2  or  ma (maximum) ? ','s');
if convection=='0';
%disp('hope absorbtion term  a  is not (too) negative')
else
if errnorm=='en';
disp('problem non symmetric - energy norm does not exist')
disp('choose another error norm')
errnorm=input('l2  or  ma ? ','s');
end
end
tol=input('tol = ');
%
disp('is the exact solution known? ')
exactflag=input('y  or  n ?','s');
if exactflag=='y';
disp('give  u(x) ')
uexact=input('u(x) = ','s');
end
%
run=0;
bvpsolve

