import type { MethodDefinition } from "./types"; import { MODAL_METHOD } from "./modal"; import { FD_METHOD } from "./fd"; import { IMPLICIT_METHOD } from "./implicit"; import type { ProblemSpec } from "../spec/types"; export const METHODS: MethodDefinition[] = [MODAL_METHOD, FD_METHOD, IMPLICIT_METHOD]; export function getMethod(id: string): MethodDefinition { const m = METHODS.find((x) => x.id === id); if (!m) throw new Error(`unknown method ${id}`); return m; } /** Reasons a method cannot run on a spec (empty when it can). */ export function methodBlockers(method: MethodDefinition, spec: ProblemSpec): string[] { const out: string[] = []; if (!method.supports.shape.includes(spec.plate.shape)) out.push( `${method.name} has no solution for the ${spec.plate.shape}; the finite-difference methods embed it in their grid.`, ); if (!method.supports.bc.includes(spec.bc)) out.push( `${method.name} does not support the edge condition "${spec.bc}" (supports: ${method.supports.bc.join(", ")}).`, ); if (!method.supports.excitation.includes(spec.excitation.type)) out.push(`${method.name} does not support the ${spec.excitation.type} excitation.`); return out; }