# NDSolveValue::fememrc | Defining initial conditions on a part of a 1D mesh

I am trying to solve a simple PDE in the cylindrical coordinates:

$$\frac{\partial c}{\partial t} = D \bigg(\frac{1}{r}\frac{\partial c}{\partial r}+\frac{\partial c^2}{\partial r^2}\bigg)$$

The initial and boundary conditions are as follows:

$$c[t=0,r] = {0,\hspace{2mm} r<=r_0 ;\hspace{2mm} C_b, \hspace{2mm} r> r_0}$$ $$c[t,r=\infty] = C_b$$ $$\frac{\partial c}{\partial r}[t,r=0] = 0$$

I wrote the following code in Mathematica:

Needs["NDSolveFEM"];

ClearAll[DiffCoeff, Cb, c1, r, t, pde, radialDerivative, \
AvgConcentration, r0, tmax, inf]

DiffCoeff = 1; Cb = 1; r0 = 1; tmax = 10; inf = 100;

(*Define the PDE with NeumannValue for the flux condition*)
pde = Derivative[0, 1][c1][t, r] -
NeumannValue[0, r == 0];

(*Boundary Condition using DirichletCondition*)
boundaryConditions =
DirichletCondition[c1[t, r] == Cb,
r == inf];
(*Initial condition:c1(0,r)=0 for r<=r0 and Cb r>r0*)
initialCondition = c1[0, r] == If[r <= r0, 0, Cb];
(*Solve the PDE*)
sol = NDSolveValue[{pde, boundaryConditions, initialCondition},
c1, {t, 0, tmax}, {r, 0, inf}]


This solves with a warning:

NDSolveValue::femcscd: The PDE is convection dominated and the result may not be stable. Adding artificial diffusion may help.


Now, I was trying to solve the warning by smoothening the mesh with the following modification to the code:

(*Create a custom mesh*)
"MaximalDistance" -> 0.1|>}, {Line[{{2*r0}, {inf}}]}}]
MeshRegion[mesh]

sol = NDSolveValue[{pde, boundaryConditions, initialCondition},
c1, {t, 0, tmax}, {r} \[Element] mesh]


And this gives an error which I would like to solve:

NDSolveValue::femnotime: The differential equation cannot be solved as a time dependent equation as specified, most likely because the initial conditions given at (t==0.) are not sufficient to define an initial value problem. As a consequence the differential equation will be solved as a time independent equation.

NDSolveValue::fememrc: The ranges {{0.,300.},ElementMesh[{{0.},{0.1},{0.2},{0.3},{0.4},{0.5},{0.6},{0.7},{0.8},{0.9},<<431>>},{LineElement[{{1,2,222},{2,3,223},{3,4,224},{4,5,225},{5,6,226},{6,7,227},{7,8,228},{8,9,229},{9,10,230},{10,11,231},<<210>>},{0,0,0,0,0,0,0,0,0,0,<<210>>}]},{PointElement[{{1},{221}}]},{PointElement[{{1},{221}}]}]} cannot be combined to a region. Please specify a combined region.


Now I am open to refining the original mesh in the NDSolve Function itself, maybe using the MaxCellMeasure function. But I want the mesh to be non-uniform. Will MaxCellMeasure allow me to do that?

(*Define the PDE with NeumannValue for the flux condition*)
`