@rulecad/fea 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -1
- package/package.json +1 -1
- package/threads.d.mts +9 -9
- package/threads.mjs +6 -1
package/README.md
CHANGED
|
@@ -42,7 +42,10 @@ r.thin; // { share, cells }: how much of the part is in members under
|
|
|
42
42
|
symmetric Gauss-Seidel through those blocks.
|
|
43
43
|
- **Threads:** `import { threadsBackend } from '@rulecad/fea/threads'` (Node only) shares each product over the
|
|
44
44
|
machine's cores (`FEA_THREADS` to say how many), the rest as `jsBackend`. On a 134,000-unknown grid a product takes
|
|
45
|
-
6.8 ms on seven threads against 19 ms on one, and an optimisation step about a third of the time.
|
|
45
|
+
6.8 ms on seven threads against 19 ms on one, and an optimisation step about a third of the time. It needs Node 22
|
|
46
|
+
or later: on Node 20 a product now and then came out wrong when the workers let go of an old operator's shared
|
|
47
|
+
memory (a few solves in sixty, more with more threads, none on Node 22 or 24), so there it is plain JavaScript
|
|
48
|
+
under another name (its `name` says so).
|
|
46
49
|
|
|
47
50
|
Tested against beam theory: a cantilever's tip moves within 1% of `F L³ / 3 E I` in 2D, and within 2% in 3D.
|
|
48
51
|
Multigrid is tested against the direct solver with stiffnesses a millionfold apart.
|
package/package.json
CHANGED
package/threads.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
multiply(scale:
|
|
6
|
-
diagonal(scale:
|
|
1
|
+
export const threadsBackend: {
|
|
2
|
+
name: string;
|
|
3
|
+
precision: number;
|
|
4
|
+
operator: (g: import("./fea.mjs").Grid, ke: Float64Array | null, cellMatrices?: Float64Array) => {
|
|
5
|
+
multiply: (scale: Float64Array | null, x: Float64Array, y: Float64Array) => void;
|
|
6
|
+
diagonal: (scale: Float64Array | null, d: Float64Array) => void;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
8
|
+
dot: (a: Float64Array, b: Float64Array) => number;
|
|
9
|
+
axpy: (a: number, x: Float64Array, y: Float64Array) => void;
|
|
10
|
+
};
|
package/threads.mjs
CHANGED
|
@@ -48,7 +48,12 @@ function workers() {
|
|
|
48
48
|
return pool;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
|
|
51
|
+
// On Node 20 and older the products came out wrong now and then (a few solves in sixty, more with more threads):
|
|
52
|
+
// letting go of an operator's shared memory there corrupts work still running on it, and Node 20 is past its end of
|
|
53
|
+
// life. There, this backend is plain JavaScript under another name: right, only slower. (Node 22 and later: threads)
|
|
54
|
+
const NODE = Number(process.versions.node.split('.')[0]), SHARED_OK = NODE >= 22;
|
|
55
|
+
|
|
56
|
+
export const threadsBackend = !SHARED_OK ? { ...jsBackend, name: `js (threads need Node 22; this is Node ${NODE})` } : {
|
|
52
57
|
name: `threads (${THREADS})`,
|
|
53
58
|
precision: 64,
|
|
54
59
|
operator(g, ke, cellMatrices) {
|