Calculator
Example Data Table
| Case | d | N₀ | h₀ | p | err | tol | f | r | Suggested L |
|---|---|---|---|---|---|---|---|---|---|
| Wave hotspot | 2 | 100,000 | 0.010 | 2 | 1.0e-3 | 1.0e-4 | 0.20 | 2 | 2 |
| Boundary layer | 3 | 2,000,000 | 0.005 | 2 | 5.0e-4 | 5.0e-5 | 0.10 | 2 | 2 |
| Diffusion front | 1 | 20,000 | 0.002 | 1 | 2.0e-3 | 1.0e-3 | 0.30 | 2 | 1 |
Formula Used
This calculator uses a standard mesh-convergence model where an error indicator scales with cell size: error(h) = error(h₀) · (h / h₀)^p.
Solving for a target spacing h that meets tolerance tol gives: h = h₀ · (tol / err)^(1/p) · safety.
If refinement is applied in levels with ratio r, then h = h₀ / r^L and the recommended levels are: L = ceil( log(h₀/h) / log(r) ).
For localized refinement over fraction f in d dimensions, the estimated total cells are: N = N₀(1−f) + N₀ f · r^(d·L).
How to Use
- Pick the dimension that matches your simulation geometry.
- Enter your base spacing h₀ and an error estimate from your indicator.
- Set a tolerance that reflects acceptable error in the refined region.
- Choose method order p and refinement ratio r used by your AMR framework.
- Estimate the refined region fraction f to plan memory and runtime.
- Click Calculate, then download CSV or PDF for records.
Professional Article
1) Adaptive refinement in modern solvers
Adaptive mesh refinement focuses resolution where physics changes quickly, while keeping coarse cells elsewhere. A practical target is reducing local error from 1×10⁻³ to 1×10⁻⁴ without multiplying the whole-domain grid. This calculator estimates required refinement levels, expected cell counts, and memory before running a costly simulation.
2) Error scaling with cell size
Many discretizations follow error ∝ hᵖ, where p is the method order used by the estimator. For example, with p=2, halving h reduces error by about 4×. Enter your current indicator value and let the model compute the spacing that meets your tolerance using a safety factor.
3) Turning tolerance into refinement levels
AMR frameworks commonly refine by an integer ratio r per level, often r=2. The calculator converts the spacing target into levels using logarithms, then caps the result at your maximum level. If the achieved error remains above tolerance at the cap, increase max levels or relax the tolerance to match resources.
4) Refined fraction and cell growth
Refinement rarely covers the entire domain. If only f=0.20 of cells refine in 2D, the refined region grows by r^(2L). With r=2 and L=3, that region is 64× denser, while the remaining 80% stays unchanged. This produces realistic totals compared with uniform refinement.
5) Memory estimation from state variables
Memory is approximated as N × variables × bytes. A compressible flow state might use 6 variables, and float64 storage uses 8 bytes each. If the refined total reaches 5×10⁶ cells, raw state storage is about 240 MB, before halos, fluxes, and multigrid work arrays.
6) Runtime scaling for planning
Compute time usually scales with cell count, but the exponent can exceed one for stiff physics or implicit solves. The calculator reports a relative cost (N/N₀)ᵅ, where α is your time-cost exponent. Use α=1 for explicit steps and consider α=1.2–1.8 when linear solves dominate.
7) Selecting conservative safety margins
Indicators can under-predict true error near shocks, interfaces, or singular fields. The safety factor tightens the spacing target, typically 0.8–0.95, to reduce the chance of under-refinement. If results overshoot the tolerance by a wide margin, the guidance will suggest coarsening by one level to reclaim memory.
8) A repeatable AMR workflow
Start with a base mesh, record an error indicator, and define a tolerance tied to the quantity of interest. Estimate levels and resources here, run a short pilot, then update err, f, and p from diagnostics. Export CSV or PDF to document decisions across teams and to keep simulation budgets auditable.
FAQs
1) What should I use for the “error estimate” field?
Use your refinement indicator value, such as a residual norm, gradient sensor magnitude, or Richardson error estimate, evaluated on the current base mesh and representative timestep or iteration.
2) How do I choose method order p?
Choose the order that best matches how your indicator scales with spacing. Many second-order finite-volume schemes use p≈2, while first-order upwinding can behave closer to p≈1.
3) Why does dimension change the cell multiplier?
Because refining by ratio r shrinks spacing in every direction. The refined-region cell growth scales as r^(d·L), so 3D refinement increases cells much faster than 2D.
4) What is a reasonable refined fraction f?
Start with 0.05–0.20 for localized features. If shocks or interfaces fill more of the domain, f can rise. Update it after a pilot run by measuring refined patches.
5) Why is my achieved error below tolerance?
Discrete refinement levels are integer steps, so the next level may overshoot the target. If achieved error is far smaller than tolerance, consider one fewer level or adjust the safety factor upward.
6) Does the memory estimate include ghost cells and auxiliary arrays?
No. It estimates raw state storage only. Real runs need additional memory for halos, fluxes, reconstruction buffers, multigrid vectors, and I/O. Multiply by 2–5× for a conservative planning range.
7) Can I use this for time-adaptive refinement too?
Yes for planning. Use the same tolerance and scaling idea, but interpret inputs as representative values over time. For evolving features, compute a range of f and indicator values and compare worst-case resources.