Expand description
Solver-aware mesh checks and suggestions (design §4, §5.6, §7).
Mesh generation is csx’s business (csx::mesh::MeshBuilder,
csx::mesh::detect_edges, csx::grid::smooth_lines). This module
looks at a finished mesh with the eyes of the FDTD solver and reports
what is likely to go wrong:
- Resolution. Every cell must be smaller than
λ_min/N, whereλ_min = c0 / (f_max·n)withn = sqrt(ε_r·μ_r)the largest refractive index of the materials present in that cell slab, andf_maxfromFdtd::get_max_frequency. The rule of thumbN ≥ 10…20follows from the numerical dispersion analysis of the Yee scheme (Taflove & Hagness, Computational Electrodynamics, 3rd ed., ch. 4: the phase velocity error is below about 1 % for 10 cells per wavelength and falls off quadratically). - Grading. Neighbouring cells should not differ in size by more than a factor of about 1.5: on a non-uniform mesh the scheme is only first-order accurate at a size jump, and large jumps reflect waves (Taflove & Hagness, non-uniform grids in ch. 3; Monk & Süli 1994 on the supraconvergence of the Yee scheme on non-uniform meshes).
- Time step. The Courant limit (design §5.4) is set by the smallest
cell on every axis; a few tiny cells can make the whole simulation
many times slower. The report gives
dt, the limiting cells and the ratio to the time step a typical (median) cell would allow. On a cylindrical grid (Grid::cylindrical) the limit comes from the discrete operator and is usually set by the short arcsρ·Δαnext to the axis (design §5.15). - Cylindrical grids. Messages name the axes
x,y,zforρ,α,z; α positions are in radians. The resolution check uses the largest arcρ_max·Δαof each α cell. - PML (design §5.6): the layer occupies the outermost
nmesh cells of a face; the mesh needs enough cells for it, structure primitives should stay out of it, and the cells in it should be roughly uniform (the conductivity profile assumes slowly varying cells; Berenger 1994, Roden & Gedney 2000). - Sheets. Zero-thickness metal or conducting sheets (and axis-aligned lines) must lie on a mesh plane (line) or csx’s discretisation drops them.
- Cost. Cell count, estimated memory, memory traffic per step and the number of steps implied by the settings.
check works on the model and its csx grid; check_compiled
reuses an already compiled model (the actual
discretised materials and csx’s discretisation warnings).
All coordinates in messages and Locations are csx drawing units
(the unit of the mesh lines); lengths in MeshStats are metres.
use csx::primitives::BoxShape;
use csx::{ContinuousStructure, Primitive, Property};
use ems::prelude::*;
let mut model = ContinuousStructure::new();
model.grid.delta_unit = 1e-3; // mm
for a in 0..3 {
model.grid.set_lines(a, (0..=40).map(|i| i as f64))?;
}
let fdtd = Fdtd::new()
.waveform(Waveform::gaussian(5e9, 5e9)) // f_max = 10 GHz, λ = 30 mm
.boundaries(Boundaries::all(Boundary::pml(8)));
let report = ems::mesh::check(&model, &fdtd)?;
assert!(report.is_ok());
// csx's mesher wants the maximum cell size in drawing units.
let max_res = ems::mesh::suggest_max_cell(&model, &fdtd, 20.0)?;
assert!((max_res - 1.499).abs() < 1e-3); // 29.98 mm / 20Structs§
- Check
Options - Thresholds of the mesh checks.
- Mesh
Issue - One finding of a mesh check.
- Mesh
Report - Result of a mesh check: issues plus
MeshStats. - Mesh
Stats - Mesh statistics and cost estimates gathered by a check.
Enums§
- Location
- Where a
MeshIssueis located. Coordinates are drawing units. - Severity
- Severity of a
MeshIssue.
Constants§
- CSX_
DISCRETISATION_ PREFIX - Prefix of the
MeshIssue::messages with whichcheck_compiledre-reports csx discretisation warnings (the original warnings are inCompiled::warnings; filter on this prefix to avoid duplicates).
Functions§
- check
- Checks the mesh of
modelfor the solver settingsfdtdwith the defaultCheckOptions; see the module docs. - check_
compiled - Checks an already compiled model: the
refractive index per cell slab comes from the discretised
EdgeMaterials(what the solver actually sees, including sub-cell averaging), sheet and line snapping problems are taken from csx’s discretisation warnings inCompiled::warnings, and the grid, time step and PML faces fromcompiled.modelis still needed for the PML intrusion check. - check_
with checkwith explicit options.- suggest_
max_ cell - Largest cell size (in drawing units, as expected by
csx::mesh::MeshOptions::max_res) that resolves the shortest wavelength inmodelwithncells:c0 / (f_max·n_max·n) / delta_unit, wheren_maxis the largest refractive indexsqrt(ε_r·μ_r)of the background and all material properties.