Grid-Spacing-Builder

Grid Spacing Function Designer

An interactive, browser-based tool for designing 1D grid-spacing functions. The spacing function f(x) is C¹-smooth with a vertical asymptote at x = a, quadratic far-field growth, and a local minimum at x = 1. A Plotly view visualises f(x), its derivative, and the resulting Euler–Lagrange grid generated by equidistribution of √f.

The function

f(x) = α · e^(-k(x-a)) / (x-a)^p  +  β·(x-1)²  -  δ·(x-1)  +  γ

δ is computed automatically from the other parameters so that f'(1) = 0.

Param Meaning
a Asymptote location (a < 1)
α Pole strength
p Pole order
k Spike localisation (exponential decay)
β Quadratic tail growth coefficient
γ Vertical offset

Grid generation

Given a target spacing f(x), points are placed by minimising S[x] = ∫ ½ f(x) (x')² dξ. The Beltrami first integral √f(x) · x'(ξ) = C reduces this to the equidistribution problem ∫_{x_L}^{x_i} √f(s) ds = (i/(N-1)) · C, which is solved by cumulative trapezoidal quadrature followed by linear inverse interpolation.

Usage

Open grid_function_designer.html in a browser — no build step. Drag the sliders or edit the numeric inputs to explore the parameter space. The four preset buttons (sharp wall, soft wall, flat bowl, cfd-like) give reasonable starting points. Use the Python or MATLAB export buttons to copy the current function as code.

Files

Dependencies

Loaded from CDN at runtime: Plotly 3.5.1, KaTeX 0.16.11, and the Fraunces / IBM Plex Sans / JetBrains Mono fonts from Google Fonts.