@ferscloud/fers-calculation-web 0.1.76

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 ADDED
@@ -0,0 +1,59 @@
1
+ # FERS_calculations
2
+
3
+ `FERS_calculations` is a high-performance library for Rust-backed calculations in mechanical engineering. It can process JSON input files to deliver fast and accurate results. While it can be run as a standalone tool, integration with `FERS_core` simplifies input creation and workflow management.
4
+
5
+ ## Features
6
+
7
+ - **Standalone Functionality:** Run directly by providing a valid JSON input file.
8
+ - **Rust-Powered Performance:** Designed for speed and reliability in computational tasks.
9
+ - **Python Integration:** Seamless integration with `FERS_core` for easy preprocessing and result handling.
10
+ - **Engineer-Friendly Design:** Minimal coding effort required for complex structural engineering calculations.
11
+
12
+ ---
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pip install fers_calculations
18
+ ```
19
+
20
+ This installs the pre-built Rust bindings -- no Rust toolchain required.
21
+
22
+ ## Usage
23
+
24
+ ### Standalone (Python)
25
+
26
+ You can call `fers_calculations` directly from Python without `FERS_core`:
27
+
28
+ ```python
29
+ import fers_calculations
30
+
31
+ # Load your JSON input
32
+ with open("001_cantilever_with_end_load.json") as f:
33
+ json_data = f.read()
34
+
35
+ # Run the analysis
36
+ results_json = fers_calculations.calculate_from_json(json_data)
37
+
38
+ # Save the results
39
+ with open("results.json", "w") as f:
40
+ f.write(results_json)
41
+ ```
42
+
43
+ ### With FERS_core (recommended)
44
+
45
+ For a more ergonomic workflow, use `FERS_core` which handles model creation, calling the Rust engine, and post-processing / visualisation:
46
+
47
+ ```bash
48
+ pip install fers-core
49
+ ```
50
+
51
+ ```python
52
+ from fers_core import FERS
53
+
54
+ model = FERS.from_json("001_cantilever_with_end_load.json")
55
+ model.calculate()
56
+ model.plot_results_3d()
57
+ ```
58
+
59
+ See the [FERS_core README](https://pypi.org/project/FERS/) for full documentation.
@@ -0,0 +1,4 @@
1
+ /* tslint:disable */
2
+ /* eslint-disable */
3
+ export function calculate_from_json(json_data: string): string;
4
+ export function load_fers_from_file(path: string): string;
@@ -0,0 +1,5 @@
1
+ import * as wasm from "./fers_calculations_bg.wasm";
2
+ export * from "./fers_calculations_bg.js";
3
+ import { __wbg_set_wasm } from "./fers_calculations_bg.js";
4
+ __wbg_set_wasm(wasm);
5
+ wasm.__wbindgen_start();
@@ -0,0 +1,138 @@
1
+ let wasm;
2
+ export function __wbg_set_wasm(val) {
3
+ wasm = val;
4
+ }
5
+
6
+
7
+ let WASM_VECTOR_LEN = 0;
8
+
9
+ let cachedUint8ArrayMemory0 = null;
10
+
11
+ function getUint8ArrayMemory0() {
12
+ if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
13
+ cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
14
+ }
15
+ return cachedUint8ArrayMemory0;
16
+ }
17
+
18
+ const cachedTextEncoder = new TextEncoder();
19
+
20
+ if (!('encodeInto' in cachedTextEncoder)) {
21
+ cachedTextEncoder.encodeInto = function (arg, view) {
22
+ const buf = cachedTextEncoder.encode(arg);
23
+ view.set(buf);
24
+ return {
25
+ read: arg.length,
26
+ written: buf.length
27
+ };
28
+ }
29
+ }
30
+
31
+ function passStringToWasm0(arg, malloc, realloc) {
32
+
33
+ if (realloc === undefined) {
34
+ const buf = cachedTextEncoder.encode(arg);
35
+ const ptr = malloc(buf.length, 1) >>> 0;
36
+ getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
37
+ WASM_VECTOR_LEN = buf.length;
38
+ return ptr;
39
+ }
40
+
41
+ let len = arg.length;
42
+ let ptr = malloc(len, 1) >>> 0;
43
+
44
+ const mem = getUint8ArrayMemory0();
45
+
46
+ let offset = 0;
47
+
48
+ for (; offset < len; offset++) {
49
+ const code = arg.charCodeAt(offset);
50
+ if (code > 0x7F) break;
51
+ mem[ptr + offset] = code;
52
+ }
53
+
54
+ if (offset !== len) {
55
+ if (offset !== 0) {
56
+ arg = arg.slice(offset);
57
+ }
58
+ ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
59
+ const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
60
+ const ret = cachedTextEncoder.encodeInto(arg, view);
61
+
62
+ offset += ret.written;
63
+ ptr = realloc(ptr, len, offset, 1) >>> 0;
64
+ }
65
+
66
+ WASM_VECTOR_LEN = offset;
67
+ return ptr;
68
+ }
69
+
70
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
71
+
72
+ cachedTextDecoder.decode();
73
+
74
+ const MAX_SAFARI_DECODE_BYTES = 2146435072;
75
+ let numBytesDecoded = 0;
76
+ function decodeText(ptr, len) {
77
+ numBytesDecoded += len;
78
+ if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
79
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
80
+ cachedTextDecoder.decode();
81
+ numBytesDecoded = len;
82
+ }
83
+ return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
84
+ }
85
+
86
+ function getStringFromWasm0(ptr, len) {
87
+ ptr = ptr >>> 0;
88
+ return decodeText(ptr, len);
89
+ }
90
+ /**
91
+ * @param {string} json_data
92
+ * @returns {string}
93
+ */
94
+ export function calculate_from_json(json_data) {
95
+ let deferred2_0;
96
+ let deferred2_1;
97
+ try {
98
+ const ptr0 = passStringToWasm0(json_data, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
99
+ const len0 = WASM_VECTOR_LEN;
100
+ const ret = wasm.calculate_from_json(ptr0, len0);
101
+ deferred2_0 = ret[0];
102
+ deferred2_1 = ret[1];
103
+ return getStringFromWasm0(ret[0], ret[1]);
104
+ } finally {
105
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
106
+ }
107
+ }
108
+
109
+ /**
110
+ * @param {string} path
111
+ * @returns {string}
112
+ */
113
+ export function load_fers_from_file(path) {
114
+ let deferred2_0;
115
+ let deferred2_1;
116
+ try {
117
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
118
+ const len0 = WASM_VECTOR_LEN;
119
+ const ret = wasm.load_fers_from_file(ptr0, len0);
120
+ deferred2_0 = ret[0];
121
+ deferred2_1 = ret[1];
122
+ return getStringFromWasm0(ret[0], ret[1]);
123
+ } finally {
124
+ wasm.__wbindgen_free(deferred2_0, deferred2_1, 1);
125
+ }
126
+ }
127
+
128
+ export function __wbindgen_init_externref_table() {
129
+ const table = wasm.__wbindgen_export_0;
130
+ const offset = table.grow(4);
131
+ table.set(0, undefined);
132
+ table.set(offset + 0, undefined);
133
+ table.set(offset + 1, null);
134
+ table.set(offset + 2, true);
135
+ table.set(offset + 3, false);
136
+ ;
137
+ };
138
+
Binary file
package/package.json ADDED
@@ -0,0 +1,25 @@
1
+ {
2
+ "name": "@ferscloud/fers-calculation-web",
3
+ "type": "module",
4
+ "version": "0.1.76",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/Jeroen124/FERS_core"
8
+ },
9
+ "files": [
10
+ "fers_calculations_bg.wasm",
11
+ "fers_calculations.js",
12
+ "fers_calculations_bg.js",
13
+ "fers_calculations.d.ts"
14
+ ],
15
+ "main": "fers_calculations.js",
16
+ "homepage": "https://ferscloud.com",
17
+ "types": "fers_calculations.d.ts",
18
+ "sideEffects": [
19
+ "./fers_calculations.js",
20
+ "./snippets/*"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ }
25
+ }