@ferscloud/fers-calculation 0.2.97 → 0.2.99
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 +24 -0
- package/fers_calculations.d.ts +36 -0
- package/fers_calculations.js +68 -0
- package/fers_calculations_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -194,6 +194,30 @@ const res = JSON.parse(merge_parts_from_json(model, parts)); // what calculate_f
|
|
|
194
194
|
- Each worker holds its own copy of the model and of its solve, so memory grows with the number of workers.
|
|
195
195
|
- With a solve token, use `calculate_part_from_json_with_token(model, token, index, count)` in the workers and `merge_parts_from_json_with_token(model, token, parts)` to merge.
|
|
196
196
|
|
|
197
|
+
## One result set in full, without solving again
|
|
198
|
+
|
|
199
|
+
A large model's full results do not fit a browser string, so it is solved with a `result_filter` (say `local_envelopes`, `node_displacements`, `reactions`). The rest of one load case or combination is then one call away, in the instance that solved:
|
|
200
|
+
|
|
201
|
+
```js
|
|
202
|
+
import { calculate_from_json, results_for } from "@ferscloud/fers-calculation-web";
|
|
203
|
+
|
|
204
|
+
const res = JSON.parse(calculate_from_json(model)); // few blocks, every result set
|
|
205
|
+
|
|
206
|
+
const set = JSON.parse(
|
|
207
|
+
results_for(JSON.stringify({
|
|
208
|
+
loadcombination: "ULS 1", // or loadcase: the set's key in the results
|
|
209
|
+
result_filter: ["local_end_forces", "section_forces", "internal_force_series"], // absent: every block
|
|
210
|
+
include_member_deflected_shape: true, // absent: the model's own setting
|
|
211
|
+
}))
|
|
212
|
+
);
|
|
213
|
+
if (set.ok) res.result.results.loadcombinations["ULS 1"] = set.result;
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
- `set.result` is what a whole solve writes under that name when asked for those blocks: every number the same bits. Nothing is solved; the member results are built again from the solution the solve left in the instance.
|
|
217
|
+
- Every solve keeps that solution: the model once, and per result set its displacement vector and a little state beside it (about 8 bytes per degree of freedom). The next solve or merge in the instance replaces it; `release_solution()` drops it.
|
|
218
|
+
- After a solve in parts each worker keeps the combinations its part solved, and part 0 the load cases. `kept_result_sets()` lists them; ask the worker that has the set.
|
|
219
|
+
- Errors come in the envelope: `NothingKept` (no solve has run in this instance, the last one failed, or the solution was released), `ResultSetNotKept` (not a result set of this solve, or another part's), `InvalidRequest`, and `RecoveryFailed` (the set did not come back as it was solved, and is withheld: solve it again).
|
|
220
|
+
|
|
197
221
|
## Security note
|
|
198
222
|
|
|
199
223
|
Keep your `FERS_API_KEY` server-side only. The solve token it fetches is safe to pass to the browser — it is short-lived and cryptographically signed. Only FERS Cloud can issue valid tokens; the browser WASM can only verify them.
|
package/fers_calculations.d.ts
CHANGED
|
@@ -29,6 +29,14 @@ export function calculate_part_from_json(json_data: string, part_index: number,
|
|
|
29
29
|
*/
|
|
30
30
|
export function calculate_part_from_json_with_token(json_data: string, solve_token: string, part_index: number, part_count: number): string;
|
|
31
31
|
|
|
32
|
+
/**
|
|
33
|
+
* The result sets [`results_for`] can return, as
|
|
34
|
+
* `{"loadcases": [names], "loadcombinations": [names]}` in the JSON envelope.
|
|
35
|
+
* After a solve in parts each instance lists its own: the combinations its
|
|
36
|
+
* part solved, and in part 0 the load cases.
|
|
37
|
+
*/
|
|
38
|
+
export function kept_result_sets(): string;
|
|
39
|
+
|
|
32
40
|
/**
|
|
33
41
|
* Parse (without solving) a model from a file path and return it as the JSON
|
|
34
42
|
* envelope: `{"ok":true,"result": <FERS JSON> }` or an error envelope.
|
|
@@ -46,6 +54,12 @@ export function merge_parts_from_json(json_data: string, parts: string[]): strin
|
|
|
46
54
|
*/
|
|
47
55
|
export function merge_parts_from_json_with_token(json_data: string, solve_token: string, parts: string[]): string;
|
|
48
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Drop the solution the last solve left, for a caller that will not ask
|
|
59
|
+
* [`results_for`] and wants the memory back before the next solve.
|
|
60
|
+
*/
|
|
61
|
+
export function release_solution(): void;
|
|
62
|
+
|
|
49
63
|
/**
|
|
50
64
|
* Re-render unity-check reports from already-solved results (no re-solve). Fills
|
|
51
65
|
* each `rendered_report` from its check's `report_template` and rebuilds
|
|
@@ -53,6 +67,28 @@ export function merge_parts_from_json_with_token(json_data: string, solve_token:
|
|
|
53
67
|
*/
|
|
54
68
|
export function render_reports_from_json(json_data: string): string;
|
|
55
69
|
|
|
70
|
+
/**
|
|
71
|
+
* One result set of this instance's last solve: the value that solve writes
|
|
72
|
+
* under the set's name in `results.loadcases` or `results.loadcombinations`,
|
|
73
|
+
* with the blocks the request asks for and every number the same bits.
|
|
74
|
+
* Nothing is solved.
|
|
75
|
+
*
|
|
76
|
+
* `request_json` names the set and what to return:
|
|
77
|
+
* `{"loadcombination": "ULS 1", "result_filter": ["section_forces",
|
|
78
|
+
* "internal_force_series"], "include_member_deflected_shape": true}`.
|
|
79
|
+
* Give `loadcase` or `loadcombination`, the set's key in the results.
|
|
80
|
+
* `result_filter` is `analysis.options.result_filter` for this one set
|
|
81
|
+
* (absent: every block); `include_member_deflected_shape` defaults to the
|
|
82
|
+
* model's own.
|
|
83
|
+
*
|
|
84
|
+
* Returns the JSON envelope. Its error codes: `NothingKept` (no solve has
|
|
85
|
+
* run, the last one failed, or it was released), `ResultSetNotKept` (not a
|
|
86
|
+
* result set of this solve; after a solve in parts, a set another part
|
|
87
|
+
* solved), `InvalidRequest`, and `RecoveryFailed` (the set does not come
|
|
88
|
+
* back as it was solved, and is withheld; solve it again).
|
|
89
|
+
*/
|
|
90
|
+
export function results_for(request_json: string): string;
|
|
91
|
+
|
|
56
92
|
/**
|
|
57
93
|
* The engine version, queryable without solving anything. The npm package
|
|
58
94
|
* version is set from the same `Cargo.toml` at build time, but a caller
|
package/fers_calculations.js
CHANGED
|
@@ -120,6 +120,27 @@ function calculate_part_from_json_with_token(json_data, solve_token, part_index,
|
|
|
120
120
|
}
|
|
121
121
|
exports.calculate_part_from_json_with_token = calculate_part_from_json_with_token;
|
|
122
122
|
|
|
123
|
+
/**
|
|
124
|
+
* The result sets [`results_for`] can return, as
|
|
125
|
+
* `{"loadcases": [names], "loadcombinations": [names]}` in the JSON envelope.
|
|
126
|
+
* After a solve in parts each instance lists its own: the combinations its
|
|
127
|
+
* part solved, and in part 0 the load cases.
|
|
128
|
+
* @returns {string}
|
|
129
|
+
*/
|
|
130
|
+
function kept_result_sets() {
|
|
131
|
+
let deferred1_0;
|
|
132
|
+
let deferred1_1;
|
|
133
|
+
try {
|
|
134
|
+
const ret = wasm.kept_result_sets();
|
|
135
|
+
deferred1_0 = ret[0];
|
|
136
|
+
deferred1_1 = ret[1];
|
|
137
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
138
|
+
} finally {
|
|
139
|
+
wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
exports.kept_result_sets = kept_result_sets;
|
|
143
|
+
|
|
123
144
|
/**
|
|
124
145
|
* Parse (without solving) a model from a file path and return it as the JSON
|
|
125
146
|
* envelope: `{"ok":true,"result": <FERS JSON> }` or an error envelope.
|
|
@@ -209,6 +230,15 @@ function merge_parts_from_json_with_token(json_data, solve_token, parts) {
|
|
|
209
230
|
}
|
|
210
231
|
exports.merge_parts_from_json_with_token = merge_parts_from_json_with_token;
|
|
211
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Drop the solution the last solve left, for a caller that will not ask
|
|
235
|
+
* [`results_for`] and wants the memory back before the next solve.
|
|
236
|
+
*/
|
|
237
|
+
function release_solution() {
|
|
238
|
+
wasm.release_solution();
|
|
239
|
+
}
|
|
240
|
+
exports.release_solution = release_solution;
|
|
241
|
+
|
|
212
242
|
/**
|
|
213
243
|
* Re-render unity-check reports from already-solved results (no re-solve). Fills
|
|
214
244
|
* each `rendered_report` from its check's `report_template` and rebuilds
|
|
@@ -232,6 +262,44 @@ function render_reports_from_json(json_data) {
|
|
|
232
262
|
}
|
|
233
263
|
exports.render_reports_from_json = render_reports_from_json;
|
|
234
264
|
|
|
265
|
+
/**
|
|
266
|
+
* One result set of this instance's last solve: the value that solve writes
|
|
267
|
+
* under the set's name in `results.loadcases` or `results.loadcombinations`,
|
|
268
|
+
* with the blocks the request asks for and every number the same bits.
|
|
269
|
+
* Nothing is solved.
|
|
270
|
+
*
|
|
271
|
+
* `request_json` names the set and what to return:
|
|
272
|
+
* `{"loadcombination": "ULS 1", "result_filter": ["section_forces",
|
|
273
|
+
* "internal_force_series"], "include_member_deflected_shape": true}`.
|
|
274
|
+
* Give `loadcase` or `loadcombination`, the set's key in the results.
|
|
275
|
+
* `result_filter` is `analysis.options.result_filter` for this one set
|
|
276
|
+
* (absent: every block); `include_member_deflected_shape` defaults to the
|
|
277
|
+
* model's own.
|
|
278
|
+
*
|
|
279
|
+
* Returns the JSON envelope. Its error codes: `NothingKept` (no solve has
|
|
280
|
+
* run, the last one failed, or it was released), `ResultSetNotKept` (not a
|
|
281
|
+
* result set of this solve; after a solve in parts, a set another part
|
|
282
|
+
* solved), `InvalidRequest`, and `RecoveryFailed` (the set does not come
|
|
283
|
+
* back as it was solved, and is withheld; solve it again).
|
|
284
|
+
* @param {string} request_json
|
|
285
|
+
* @returns {string}
|
|
286
|
+
*/
|
|
287
|
+
function results_for(request_json) {
|
|
288
|
+
let deferred2_0;
|
|
289
|
+
let deferred2_1;
|
|
290
|
+
try {
|
|
291
|
+
const ptr0 = passStringToWasm0(request_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
292
|
+
const len0 = WASM_VECTOR_LEN;
|
|
293
|
+
const ret = wasm.results_for(ptr0, len0);
|
|
294
|
+
deferred2_0 = ret[0];
|
|
295
|
+
deferred2_1 = ret[1];
|
|
296
|
+
return getStringFromWasm0(ret[0], ret[1]);
|
|
297
|
+
} finally {
|
|
298
|
+
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
exports.results_for = results_for;
|
|
302
|
+
|
|
235
303
|
/**
|
|
236
304
|
* The engine version, queryable without solving anything. The npm package
|
|
237
305
|
* version is set from the same `Cargo.toml` at build time, but a caller
|
|
Binary file
|