I am solving an advection-diffusion problem where the solution variable is mostly flat apart from a small region near the centre of the domain where there are shape gradients. I would like to generate mesh faces for 1D finite volume cells (see below) where the cells are clustered towards the centre of the domain.
I have not attempted moving or adaptive meshing because, for this application, it will be overkill. I simply want a static but non-uniform mesh. This would seems simple on the surface but I've found it tricky and would like some advice.
I am using the following approach. A uniform distribution of cell faces is defined by, $$x_{j+1/2} = \sum\limits_{j=0}^N hn$$ where $h$ is the constant mesh spacing.
To generate clustered non-uniform cell faces I plan on simply dividing the uniform mesh sequence by a mesh density function $\rho$. For example, $$x_{j+1/2} = \sum\limits_{j=0}^N \frac{hn}{\rho}$$
Choosing a Gaussian mesh density function, with constant added so it doesn't become singular when used as a denominator, allows the mesh density to increase near the peak of the curve,
$$\rho = ae^{\frac{(x-b)^2}{2c^2}}+1$$
With this approach I can then generate the following mesh. Notice how the mesh points start off constant spacing (because $\rho=1$, then initially begin to expand, and then contracts around the centre points. I have plotted the distance between points (blue line) to highlight the issue.
I would prefer if the mesh spacing didn't increase above the minimum $h$ value. Is there a way to preserve this property? It seems that I may need a peak function a zero second derivative. Can you suggest a better mesh density function for this problem?