A moving boundary problem
((∂c)/(∂t))=(((∂^2)c)/(∂(x^2)))-1      for   0 < x < s(t),    t>0
((∂c)/(∂x))(s(t),t)=c(s(t),t)=0,   for t>0
First analytic solution Ac is found such that 
s(t) = 2-cos(t),  (* Example 1 *)
Ac(x,t)  = (∑_(n=2)^∞)(((x-s(t)))^n)(Subscript[F, n])/n!   
(Subscript[F, n]) = (Subscript[A, n])(sin(t)) + cos(t) (Subscript[B, n])(sin(t)) coefficients of polynomials (Subscript[A, n]), (Subscript[B, n]) and stored in vectors (Subscript[a, n]), (Subscript[b, n])
Then the numerical method is used to obtain c and s by requiring that
c(0,t) =  Ac(0,t), c(x,0) = 0.02 for 0 < x < .5

nmax=100;
a=Table[0,nmax];
b=Table[0,nmax];


a[[2]]={1};
a[[3]]={0,-1};
a[[4]]={0,0,1};
a[[5]]={0,0,0,-1};
b[[5]]={-1};
For[n=6,n≤nmax,n++,
n1=n-1;n2=n-2;n4=n-4;n5=n-5;an=Table[0,n1];bn=Table[0,n4];
For[i=1,i<n1,i++,an[[i+1]]-=a[[n1]][[i]]];
For[i=1,i<n5,i++,an[[i+1]]-=b[[n2]][[i]]];
For[i=2,i<n5,i++,an[[i-1]]  +=(i-1) b[[n2]][[i]];
an[[i+1]]  -=(i-1) b[[n2]][[i]]];
For[i=1,i≤n5,i++,bn[[i+1]]-=b[[n1]][[i]]];
For[i=2,i<n2,i++,bn[[i-1]]+=(i-1)a[[n2]][[i]]];
a[[n]]=an;b[[n]]=bn
];

Print["a_9: ",a[[9]]];
Print["b_9: ",b[[9]]];

Ac[x_,t_]:=Module[{s,c,x0,z,z1,z2,y,eps=10.^(-12),go=5,n=2,i,u=0},
s=Sin[t];c=Cos[t];
x0=2-c;
y=x-x0;
z=y;

While[go>0,z*=(y/n);
i=n-1;z1=N[a[[n]][[i]]]; 
While[i>1,i--;z1=z1 s+N[a[[n]][[i]]]];
z2=0.;i=n-3;
While[i>1,i--;z2=z2 s+N[b[[n]][[i]]]];
z1=z(z1+c z2);
u+=z1;
n++;
If[Abs[z1]<eps,go--,go=5; (* if |z1|< eps in five consecutive times quit *)
If[n>nmax,Print["No convergence"];go=-1]]];
u];

Print["Analytic value of c(x,t) at x=.5, t=-.1: ",Ac[.5,-.1]];
g1=Plot[Ac[x,0],{x,0,1},AxesLabel->{"x","initial Ac(x,0), initial c(x,0)"}];
g2=Plot[.02,{x,0,.5},PlotStyle->Red];
Show[g1,g2]

Using the numerical method to solve 
((∂c)/(∂t))=(((∂^2)c)/(∂(x^2)))-1      for   0 < x < s(t),    0 < t < tf
((∂c)/(∂x))(s(t),t)=c(s(t),t)=0,   for 0 < t < tf
c(0,t)  = Ac(0,t)    for   0 < t < tf                    (Ac given above)
c(x,0) = 0.02   for  0 < x < 0.5

tf=.6;                (* final time *)
Plot[Ac[0,t],{t,0,tf},AxesLabel->{"t","forced c(0,t) = Ac(0,t)"}]


wa=0.3;
wb=1.31;
Print["Window [ ",wa," , ",wb," ]dx"];

nx=40;   
x0=.5;
Print["dx = ",x0/nx];
dx=x0/nx;  

α=.4;dt=α dx^2;
nt=Ceiling[tf/dt];dt=tf/nt;α=dt/dx^2;
Print["α = ",α];

c=Table[0.02,{i,0,nx}];    (*  x_i = (i-1)dx,   c[[i]] = c( x_i, 0 ),   1 ≤ i ≤ nx+1  *)
r=nx;              (* start with c[[r+1]]=0, corresponding to x_r+1 = r dx *)
c[[r+1]]=0;

t=0.;
xl={{t,x0}};       (* xl is a list of boundary points *)

vt=0;
While[vt<nt,
vt++;

cn=(1-2α)c;
t+=dt;
cn[[1]]=Ac[0,t];    (* for prescribed boundary value at x=0 *)

For[i=2,i≤r,i++, 
cn[[i]]+= α (c[[i+1]]+c[[i-1]])-dt];
c=cn;

xr=(r-1)dx;

y1=(2c[[r]])^.5;
x0p=(y1-x0+xr)/(dt+y1^2/6); (* drop y1^2/6 to get Crank-Gupta placement *)
x0+=x0p dt;
xl=Append[xl,{t,x0}];

If[x0<xr+wa dx, r--,                                              
y=x0-xr-dx;
c[[r+1]]=y^2(.5+y x0p/6 + (y x0p)^2/24);
If[x0>xr+wb dx, r++;c=Append[c,0];
y=y-dx;
c[[r+1]]=y^2(.5+y x0p/6 + (y x0p)^2/24)]]

];           (* reached final t *)


g3=ListPlot[xl,PlotRange->All,AxesLabel->{"t","s(t)"},PlotStyle->Red];
g4=Plot[2-Cos[t],{t,0,tf}];
Show[g3,g4]

ListPlot[Table[{i dt, xl[[i+1]][[2]]-2+Cos[i dt]},{i,0,nt}],PlotRange->All,
AxesLabel->{"t","s(t)- 2  + cos t"}]


ListPlot[Table[{(i-1)dx,c[[i]]-Ac[(i-1)dx,tf]},{i,1,r}],AxesLabel->{"x","c(x,tf) - Ac(x,tf)"}]