get_hx

emg3d.meshes.get_hx(alpha, domain, nx, x0, resp_domain=True)[source]

Return cell widths for given input.

Find the number of cells left and right of x0, nl and nr respectively, for the provided alpha. For this, we solve

\[\frac{x_\text{max}-x_0}{x_0-x_\text{min}} = \frac{a^{nr}-1}{a^{nl}-1}\]

where \(a = 1+\alpha\).

Parameters:
alpha : float

Stretching factor a is given by a=1+alpha.

domain : list

[start, end] of model domain.

nx : int

Number of cells.

x0 : float

Center of the grid. x0 is restricted to domain.

resp_domain : bool

If False (default), then the domain-end might shift slightly to assure that the same stretching factor is applied throughout. If set to True, however, the domain is respected absolutely. This will introduce one stretch-factor which is different from the other stretch factors, to accommodate the restriction. This one-off factor is between the left- and right-side of x0, or, if x1 is provided, just after x1.

Returns:
hx : ndarray

Cell widths of mesh.