Q:

A simple function for generating a nonuniform mesh in 1D with fixed minimum spacing

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?

A:

I suggest the following simple algorithm:

Depending on whether you want symmetry of the mesh, either start at a point $x_0$ at the left end of your interval, or in the center. In the latter case, just mirror the mesh you obtain.
Having performed the algorithm to $x_k$, compute $x_{k+1}$ as $x_k+h_k$, where
\begin{gather}
 h_k = \min \left\{ h_{\max}, \frac{\bar h}{\rho(x_k)}\right\},
\end{gather}
where $h_{\max}$ is your maximal allowed interval size, $\bar h$ is a control parameter determining the average spacing of the mesh, and $\rho$ is your density function. If you want this more fancy, you could use a denominator of $\rho(x_k+h_k/2)$, but that involves solving a nonlinear problem for $h_k$.

