/ proof-of-concept / plate-mechanics-sim
Sign in
proof-of-concept / plate-mechanics-sim
plate-mechanics-sim / packages / core / src / methods / registry.ts
29 lines · 1.2 KBBlameHistoryRaw
1import type { MethodDefinition } from "./types";
2import { MODAL_METHOD } from "./modal";
3import { FD_METHOD } from "./fd";
4import { IMPLICIT_METHOD } from "./implicit";
5import type { ProblemSpec } from "../spec/types";
7export const METHODS: MethodDefinition[] = [MODAL_METHOD, FD_METHOD, IMPLICIT_METHOD];
9export function getMethod(id: string): MethodDefinition {
10 const m = METHODS.find((x) => x.id === id);
11 if (!m) throw new Error(`unknown method ${id}`);
12 return m;
15/** Reasons a method cannot run on a spec (empty when it can). */
16export function methodBlockers(method: MethodDefinition, spec: ProblemSpec): string[] {
17 const out: string[] = [];
18 if (!method.supports.shape.includes(spec.plate.shape))
19 out.push(
20 `${method.name} has no solution for the ${spec.plate.shape}; the finite-difference methods embed it in their grid.`,
21 );
22 if (!method.supports.bc.includes(spec.bc))
23 out.push(
24 `${method.name} does not support the edge condition "${spec.bc}" (supports: ${method.supports.bc.join(", ")}).`,
25 );
26 if (!method.supports.excitation.includes(spec.excitation.type))
27 out.push(`${method.name} does not support the ${spec.excitation.type} excitation.`);
28 return out;
↑↓ move↵openescclose