// Smoke test: load a .cymsim file through the reader and exercise the playback sources. // Usage: node tools/read-check.ts file.cymsim import { readCymsim, type H5Module } from "../src/io/cymsimFile.ts"; import { parseConfigYaml } from "../src/config/yaml.ts"; import { displacementSource, accelerationSource } from "../src/playback.ts"; const h5: H5Module = (await import("h5wasm/node")).default as unknown as H5Module; await h5.ready; const run = readCymsim(h5, process.argv[2], (y) => { const r = parseConfigYaml(y); if (!r.config) throw new Error("bad yaml"); return r.config; }); console.log("nodes", run.mesh.nNodes, "elements", run.mesh.nElements, "boundary", run.mesh.boundary.length); console.log("audio", run.audioUnbaffled.length, "at", run.fs, "hits", run.hits.length, "energy rows", run.energy.length); console.log("displacement frames", run.displacement?.frames.length, "rate", run.displacement?.rate); console.log("acceleration samples", run.acceleration?.nSamples); const ds = displacementSource(run.displacement!); const f0 = ds.frame(100); console.log("disp frame 100: scale", f0.scale, "w[50]", f0.w![50], "finite", Number.isFinite(f0.field![50])); const as = accelerationSource(run.acceleration!, run.displacement); const f1 = as.frame(5000); console.log("acc frame 5000: scale", f1.scale.toExponential(3), "field[50]", f1.field![50].toExponential(3), "w present", f1.w !== null); // probe signal for node 50, as main.ts extracts it const a = run.acceleration!, N = a.nodes, sig = new Float32Array(a.nSamples); for (const b of a.blocks) for (let r = 0; r < b.count; r++) sig[b.first + r] = b.data[r * N + 50] * b.scale[r]; let peak = 0; for (const v of sig) peak = Math.max(peak, Math.abs(v)); console.log("probe node 50: peak |a| =", peak.toExponential(3), "m/s^2");