/ proof-of-concept / plate-mechanics-sim
Sign in
proof-of-concept / plate-mechanics-sim
plate-mechanics-sim / packages / core / src / runner / nodeRunner.ts
33 lines · 1.0 KBCodeBlameHistory
2546961Plate mechanics lab: Kirchhoff-Love plates solved by numbl in the browserJeremy Magland 1import type { BackendInfo, RunRequest, RunResult, Runner } from "./types";
81f3b30Elliptical plates, a WebGPU time loop for the explicit method, and WAV exportJeremy Magland 2import { numblVersion } from "./execute";
3import { executeRequest, type GpuProvider } from "./executeGpu";
6 * Runs numbl in the current Node process. Used by tests and scripts; cannot
7 * cancel. Pass `gpu` to run the ported time loop on a WebGPU device (the
8 * optional `webgpu` package, Google Dawn, provides one under Node).
9 */
2546961Plate mechanics lab: Kirchhoff-Love plates solved by numbl in the browserJeremy Magland 10export class NodeRunner implements Runner {
81f3b30Elliptical plates, a WebGPU time loop for the explicit method, and WAV exportJeremy Magland 11 private readonly info: BackendInfo = {
12 engine: "numbl",
13 version: numblVersion(),
14 optimization: "1",
15 host: "node",
16 };
2546961Plate mechanics lab: Kirchhoff-Love plates solved by numbl in the browserJeremy Magland 17 readonly backend = Promise.resolve(this.info);
81f3b30Elliptical plates, a WebGPU time loop for the explicit method, and WAV exportJeremy Magland 18 private readonly gpu?: GpuProvider;
20 constructor(opts: { gpu?: GpuProvider } = {}) {
21 this.gpu = opts.gpu;
22 }
24 run(req: RunRequest, onOutput?: (text: string) => void): Promise<RunResult> {
81f3b30Elliptical plates, a WebGPU time loop for the explicit method, and WAV exportJeremy Magland 25 return executeRequest(req, this.info, onOutput, this.gpu);
27 cancel(): void {
28 /* synchronous host: nothing in flight between awaits */
29 }
30 dispose(): void {
31 /* nothing to release */
32 }
↑↓ move↵openescclose