openseesjs 0.2.1 → 0.2.2
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.
Potentially problematic release.
This version of openseesjs might be problematic. Click here for more details.
- package/CHANGELOG.md +5 -0
- package/dist/native/OpenSeesNativeBindingLoader.d.ts.map +1 -1
- package/dist/native/OpenSeesNativeBindingLoader.js +9 -3
- package/dist/native/OpenSeesNativeBindingLoader.js.map +1 -1
- package/dist/native-index.cjs +712 -0
- package/dist/native-index.cjs.map +7 -0
- package/package.json +9 -4
|
@@ -0,0 +1,712 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/native-index.ts
|
|
21
|
+
var native_index_exports = {};
|
|
22
|
+
__export(native_index_exports, {
|
|
23
|
+
OPEN_SEES_PY_COMMANDS: () => OPEN_SEES_PY_COMMANDS,
|
|
24
|
+
OPEN_SEES_PY_VERSION: () => OPEN_SEES_PY_VERSION,
|
|
25
|
+
OpenSeesCommandError: () => OpenSeesCommandError,
|
|
26
|
+
OpenSeesNativeCommands: () => OpenSeesNativeCommands,
|
|
27
|
+
OpenSeesNativeQueries: () => OpenSeesNativeQueries,
|
|
28
|
+
OpenSeesNativeSession: () => OpenSeesNativeSession,
|
|
29
|
+
createOpenSeesOps: () => createOpenSeesOps,
|
|
30
|
+
defaultNativeBindingPath: () => defaultNativeBindingPath,
|
|
31
|
+
inspectNativeBackend: () => inspectNativeBackend,
|
|
32
|
+
loadNativeBinding: () => loadNativeBinding,
|
|
33
|
+
ops: () => ops
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(native_index_exports);
|
|
36
|
+
|
|
37
|
+
// src/openseespy/generated/OpenSeesPyApi.generated.ts
|
|
38
|
+
var OPEN_SEES_PY_VERSION = "3.8.0.0";
|
|
39
|
+
var OPEN_SEES_PY_COMMANDS = [
|
|
40
|
+
"Bcast",
|
|
41
|
+
"IGA",
|
|
42
|
+
"InitialStateAnalysis",
|
|
43
|
+
"NDTest",
|
|
44
|
+
"ShallowFoundationGen",
|
|
45
|
+
"accelCPU",
|
|
46
|
+
"addToParameter",
|
|
47
|
+
"algorithm",
|
|
48
|
+
"analysis",
|
|
49
|
+
"analyze",
|
|
50
|
+
"barrier",
|
|
51
|
+
"basicDeformation",
|
|
52
|
+
"basicForce",
|
|
53
|
+
"basicStiffness",
|
|
54
|
+
"beamIntegration",
|
|
55
|
+
"block2D",
|
|
56
|
+
"block3D",
|
|
57
|
+
"build",
|
|
58
|
+
"cbdiDisplacement",
|
|
59
|
+
"classType",
|
|
60
|
+
"computeGradients",
|
|
61
|
+
"constraints",
|
|
62
|
+
"convertBinaryToText",
|
|
63
|
+
"convertTextToBinary",
|
|
64
|
+
"correlate",
|
|
65
|
+
"damping",
|
|
66
|
+
"database",
|
|
67
|
+
"defaultUnits",
|
|
68
|
+
"domainChange",
|
|
69
|
+
"domainCommitTag",
|
|
70
|
+
"eigen",
|
|
71
|
+
"eleDynamicalForce",
|
|
72
|
+
"eleForce",
|
|
73
|
+
"eleLoad",
|
|
74
|
+
"eleNodes",
|
|
75
|
+
"eleResponse",
|
|
76
|
+
"eleType",
|
|
77
|
+
"element",
|
|
78
|
+
"equalDOF",
|
|
79
|
+
"equalDOF_Mixed",
|
|
80
|
+
"equationConstraint",
|
|
81
|
+
"fiber",
|
|
82
|
+
"filter",
|
|
83
|
+
"findCurvatures",
|
|
84
|
+
"findDesignPoint",
|
|
85
|
+
"fix",
|
|
86
|
+
"fixX",
|
|
87
|
+
"fixY",
|
|
88
|
+
"fixZ",
|
|
89
|
+
"frictionModel",
|
|
90
|
+
"functionEvaluator",
|
|
91
|
+
"geomTransf",
|
|
92
|
+
"getCDF",
|
|
93
|
+
"getConstrainedDOFs",
|
|
94
|
+
"getConstrainedNodes",
|
|
95
|
+
"getCrdTransfTags",
|
|
96
|
+
"getDampTangent",
|
|
97
|
+
"getEleClassTags",
|
|
98
|
+
"getEleLoadClassTags",
|
|
99
|
+
"getEleLoadData",
|
|
100
|
+
"getEleLoadTags",
|
|
101
|
+
"getEleTags",
|
|
102
|
+
"getFixedDOFs",
|
|
103
|
+
"getFixedNodes",
|
|
104
|
+
"getInverseCDF",
|
|
105
|
+
"getLSFTags",
|
|
106
|
+
"getLoadFactor",
|
|
107
|
+
"getMean",
|
|
108
|
+
"getNDF",
|
|
109
|
+
"getNDM",
|
|
110
|
+
"getNP",
|
|
111
|
+
"getNodeLoadData",
|
|
112
|
+
"getNodeLoadTags",
|
|
113
|
+
"getNodeTags",
|
|
114
|
+
"getNodeTemperature",
|
|
115
|
+
"getNumElements",
|
|
116
|
+
"getNumThreads",
|
|
117
|
+
"getPDF",
|
|
118
|
+
"getPID",
|
|
119
|
+
"getParamTags",
|
|
120
|
+
"getParamValue",
|
|
121
|
+
"getPatterns",
|
|
122
|
+
"getRVParamTag",
|
|
123
|
+
"getRVTags",
|
|
124
|
+
"getRVValue",
|
|
125
|
+
"getRetainedDOFs",
|
|
126
|
+
"getRetainedNodes",
|
|
127
|
+
"getStdv",
|
|
128
|
+
"getStrain",
|
|
129
|
+
"getStress",
|
|
130
|
+
"getTangent",
|
|
131
|
+
"getTime",
|
|
132
|
+
"gradPerformanceFunction",
|
|
133
|
+
"gradientEvaluator",
|
|
134
|
+
"groundMotion",
|
|
135
|
+
"hystereticBackbone",
|
|
136
|
+
"imposedMotion",
|
|
137
|
+
"imposedSupportMotion",
|
|
138
|
+
"initialize",
|
|
139
|
+
"integrator",
|
|
140
|
+
"layer",
|
|
141
|
+
"limitCurve",
|
|
142
|
+
"load",
|
|
143
|
+
"loadConst",
|
|
144
|
+
"logFile",
|
|
145
|
+
"mass",
|
|
146
|
+
"meritFunctionCheck",
|
|
147
|
+
"mesh",
|
|
148
|
+
"metaData",
|
|
149
|
+
"modalDamping",
|
|
150
|
+
"modalDampingQ",
|
|
151
|
+
"modalProperties",
|
|
152
|
+
"model",
|
|
153
|
+
"modulatingFunction",
|
|
154
|
+
"nDMaterial",
|
|
155
|
+
"node",
|
|
156
|
+
"nodeAccel",
|
|
157
|
+
"nodeBounds",
|
|
158
|
+
"nodeCoord",
|
|
159
|
+
"nodeDOFs",
|
|
160
|
+
"nodeDisp",
|
|
161
|
+
"nodeEigenvector",
|
|
162
|
+
"nodeMass",
|
|
163
|
+
"nodePressure",
|
|
164
|
+
"nodeReaction",
|
|
165
|
+
"nodeResponse",
|
|
166
|
+
"nodeUnbalance",
|
|
167
|
+
"nodeVel",
|
|
168
|
+
"numFact",
|
|
169
|
+
"numIter",
|
|
170
|
+
"numberer",
|
|
171
|
+
"parameter",
|
|
172
|
+
"partition",
|
|
173
|
+
"patch",
|
|
174
|
+
"pattern",
|
|
175
|
+
"performanceFunction",
|
|
176
|
+
"pressureConstraint",
|
|
177
|
+
"printA",
|
|
178
|
+
"printB",
|
|
179
|
+
"printGID",
|
|
180
|
+
"printModel",
|
|
181
|
+
"printX",
|
|
182
|
+
"probabilityTransformation",
|
|
183
|
+
"pyversion",
|
|
184
|
+
"randomNumberGenerator",
|
|
185
|
+
"randomVariable",
|
|
186
|
+
"rayleigh",
|
|
187
|
+
"reactions",
|
|
188
|
+
"record",
|
|
189
|
+
"recorder",
|
|
190
|
+
"recv",
|
|
191
|
+
"region",
|
|
192
|
+
"reliabilityConvergenceCheck",
|
|
193
|
+
"remesh",
|
|
194
|
+
"remove",
|
|
195
|
+
"reset",
|
|
196
|
+
"responseSpectrumAnalysis",
|
|
197
|
+
"restore",
|
|
198
|
+
"rigidDiaphragm",
|
|
199
|
+
"rigidLink",
|
|
200
|
+
"rootFinding",
|
|
201
|
+
"runFORMAnalysis",
|
|
202
|
+
"runFOSMAnalysis",
|
|
203
|
+
"runImportanceSamplingAnalysis",
|
|
204
|
+
"runSORMAnalysis",
|
|
205
|
+
"save",
|
|
206
|
+
"sdfResponse",
|
|
207
|
+
"searchDirection",
|
|
208
|
+
"searchPeerNGA",
|
|
209
|
+
"section",
|
|
210
|
+
"sectionDeformation",
|
|
211
|
+
"sectionDisplacement",
|
|
212
|
+
"sectionFlexibility",
|
|
213
|
+
"sectionForce",
|
|
214
|
+
"sectionLocation",
|
|
215
|
+
"sectionResponseType",
|
|
216
|
+
"sectionStiffness",
|
|
217
|
+
"sectionTag",
|
|
218
|
+
"sectionWeight",
|
|
219
|
+
"send",
|
|
220
|
+
"sensLambda",
|
|
221
|
+
"sensNodeAccel",
|
|
222
|
+
"sensNodeDisp",
|
|
223
|
+
"sensNodePressure",
|
|
224
|
+
"sensNodeVel",
|
|
225
|
+
"sensSectionForce",
|
|
226
|
+
"sensitivityAlgorithm",
|
|
227
|
+
"setCreep",
|
|
228
|
+
"setElementRayleighDampingFactors",
|
|
229
|
+
"setElementRayleighFactors",
|
|
230
|
+
"setMaxOpenFiles",
|
|
231
|
+
"setNodeAccel",
|
|
232
|
+
"setNodeCoord",
|
|
233
|
+
"setNodeDisp",
|
|
234
|
+
"setNodePressure",
|
|
235
|
+
"setNodeTemperature",
|
|
236
|
+
"setNodeVel",
|
|
237
|
+
"setNumThreads",
|
|
238
|
+
"setParameter",
|
|
239
|
+
"setPrecision",
|
|
240
|
+
"setStartNodeTag",
|
|
241
|
+
"setStrain",
|
|
242
|
+
"setTime",
|
|
243
|
+
"solveCPU",
|
|
244
|
+
"sp",
|
|
245
|
+
"spectrum",
|
|
246
|
+
"start",
|
|
247
|
+
"startPoint",
|
|
248
|
+
"stepSizeRule",
|
|
249
|
+
"stiffnessDegradation",
|
|
250
|
+
"stop",
|
|
251
|
+
"strengthControl",
|
|
252
|
+
"strengthDegradation",
|
|
253
|
+
"stripXML",
|
|
254
|
+
"system",
|
|
255
|
+
"systemSize",
|
|
256
|
+
"test",
|
|
257
|
+
"testIter",
|
|
258
|
+
"testNorm",
|
|
259
|
+
"testNorms",
|
|
260
|
+
"testUniaxialMaterial",
|
|
261
|
+
"timeSeries",
|
|
262
|
+
"totalCPU",
|
|
263
|
+
"transformUtoX",
|
|
264
|
+
"uniaxialMaterial",
|
|
265
|
+
"unloadingRule",
|
|
266
|
+
"updateElementDomain",
|
|
267
|
+
"updateMaterialStage",
|
|
268
|
+
"updateParameter",
|
|
269
|
+
"version",
|
|
270
|
+
"wipe",
|
|
271
|
+
"wipeAnalysis",
|
|
272
|
+
"wipeReliability"
|
|
273
|
+
];
|
|
274
|
+
|
|
275
|
+
// src/native/flattenArguments.ts
|
|
276
|
+
function flattenNativeArguments(values) {
|
|
277
|
+
const result = [];
|
|
278
|
+
for (const value of values) {
|
|
279
|
+
if (value === void 0) continue;
|
|
280
|
+
if (isArgumentArray(value)) {
|
|
281
|
+
result.push(...flattenNativeArguments(value));
|
|
282
|
+
} else if (isExpression(value)) {
|
|
283
|
+
throw new Error("Tcl expressions cannot be passed to the native backend. Invoke the query directly instead.");
|
|
284
|
+
} else if (isFlagOptions(value)) {
|
|
285
|
+
for (const [flag, flagValue] of Object.entries(value)) {
|
|
286
|
+
if (flagValue === void 0 || flagValue === false) continue;
|
|
287
|
+
result.push(flag.startsWith("-") ? flag : `-${flag}`);
|
|
288
|
+
if (flagValue !== true) result.push(...flattenNativeArguments([flagValue]));
|
|
289
|
+
}
|
|
290
|
+
} else {
|
|
291
|
+
result.push(value);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return result;
|
|
295
|
+
}
|
|
296
|
+
function isExpression(value) {
|
|
297
|
+
return typeof value === "object" && value !== null && "tcl" in value;
|
|
298
|
+
}
|
|
299
|
+
function isArgumentArray(value) {
|
|
300
|
+
return Array.isArray(value);
|
|
301
|
+
}
|
|
302
|
+
function isFlagOptions(value) {
|
|
303
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// src/native/OpenSeesCommandError.ts
|
|
307
|
+
var OpenSeesCommandError = class extends Error {
|
|
308
|
+
constructor(command, arguments_, message, options) {
|
|
309
|
+
super(message, { cause: options?.cause });
|
|
310
|
+
this.command = command;
|
|
311
|
+
this.arguments_ = arguments_;
|
|
312
|
+
this.rowIndex = options?.rowIndex;
|
|
313
|
+
}
|
|
314
|
+
name = "OpenSeesCommandError";
|
|
315
|
+
rowIndex;
|
|
316
|
+
};
|
|
317
|
+
function invokeNative(invoke, command, args, rowIndex) {
|
|
318
|
+
try {
|
|
319
|
+
return invoke();
|
|
320
|
+
} catch (cause) {
|
|
321
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
322
|
+
const row = rowIndex === void 0 ? "" : ` at batch row ${rowIndex}`;
|
|
323
|
+
throw new OpenSeesCommandError(
|
|
324
|
+
command,
|
|
325
|
+
args,
|
|
326
|
+
`OpenSees command "${command}" failed${row}: ${detail}`,
|
|
327
|
+
{ cause, ...rowIndex === void 0 ? {} : { rowIndex } }
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// src/native/OpenSeesNativeBindingLoader.ts
|
|
333
|
+
var import_node_fs = require("node:fs");
|
|
334
|
+
var import_node_module = require("node:module");
|
|
335
|
+
var import_node_path = require("node:path");
|
|
336
|
+
var import_node_url = require("node:url");
|
|
337
|
+
var modulePath = typeof __filename === "string" ? __filename : (0, import_node_url.fileURLToPath)(__filename);
|
|
338
|
+
var moduleDirectory = typeof __dirname === "string" ? __dirname : (0, import_node_path.dirname)(modulePath);
|
|
339
|
+
var require2 = (0, import_node_module.createRequire)(modulePath);
|
|
340
|
+
function platformPackageName() {
|
|
341
|
+
return `@openseesjs/native-${process.platform}-${process.arch}`;
|
|
342
|
+
}
|
|
343
|
+
function resolveBinding() {
|
|
344
|
+
const override = process.env.OPEN_SEES_NODE_BINDING;
|
|
345
|
+
if (override) return { path: (0, import_node_path.resolve)(override), distribution: "environment" };
|
|
346
|
+
try {
|
|
347
|
+
return {
|
|
348
|
+
path: require2.resolve(`${platformPackageName()}/opensees.node`),
|
|
349
|
+
distribution: "platform-package"
|
|
350
|
+
};
|
|
351
|
+
} catch {
|
|
352
|
+
const packageRoots = [
|
|
353
|
+
(0, import_node_path.resolve)(moduleDirectory, "..", ".."),
|
|
354
|
+
(0, import_node_path.resolve)(moduleDirectory, "..")
|
|
355
|
+
];
|
|
356
|
+
const bundledCandidates = packageRoots.map((packageRoot) => (0, import_node_path.resolve)(packageRoot, "native", "prebuilds", `${process.platform}-${process.arch}`, "opensees.node"));
|
|
357
|
+
return {
|
|
358
|
+
path: bundledCandidates.find(import_node_fs.existsSync) ?? bundledCandidates[0],
|
|
359
|
+
distribution: "bundled"
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
function defaultNativeBindingPath() {
|
|
364
|
+
return resolveBinding().path;
|
|
365
|
+
}
|
|
366
|
+
function inspectNativeBackend(bindingPath = defaultNativeBindingPath()) {
|
|
367
|
+
const resolved = (0, import_node_path.resolve)(bindingPath);
|
|
368
|
+
const automatic = resolveBinding();
|
|
369
|
+
const distribution = resolved === automatic.path ? automatic.distribution : "explicit";
|
|
370
|
+
const base = { bindingPath: resolved, platform: process.platform, arch: process.arch, distribution };
|
|
371
|
+
if (!(0, import_node_fs.existsSync)(resolved)) {
|
|
372
|
+
return {
|
|
373
|
+
available: false,
|
|
374
|
+
...base,
|
|
375
|
+
reason: `No native OpenSees runtime is available for ${process.platform}-${process.arch}. Install ${platformPackageName()} or set OPEN_SEES_NODE_BINDING.`
|
|
376
|
+
};
|
|
377
|
+
}
|
|
378
|
+
try {
|
|
379
|
+
const loaded = require2(resolved);
|
|
380
|
+
if (typeof loaded.createSession !== "function") {
|
|
381
|
+
return { available: false, ...base, reason: "The native addon does not export createSession()." };
|
|
382
|
+
}
|
|
383
|
+
return { available: true, ...base, ...readBuildInfo(resolved) };
|
|
384
|
+
} catch (error) {
|
|
385
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
386
|
+
return {
|
|
387
|
+
available: false,
|
|
388
|
+
...base,
|
|
389
|
+
reason: `The native addon or one of its runtime libraries could not be loaded: ${message}`
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function readBuildInfo(bindingPath) {
|
|
394
|
+
const candidates = [
|
|
395
|
+
(0, import_node_path.resolve)((0, import_node_path.dirname)(bindingPath), "BUILD_INFO.json"),
|
|
396
|
+
(0, import_node_path.resolve)((0, import_node_path.dirname)(bindingPath), "..", "..", "BUILD_INFO.json")
|
|
397
|
+
];
|
|
398
|
+
for (const candidate of candidates) {
|
|
399
|
+
if (!(0, import_node_fs.existsSync)(candidate)) continue;
|
|
400
|
+
try {
|
|
401
|
+
const info = JSON.parse((0, import_node_fs.readFileSync)(candidate, "utf8"));
|
|
402
|
+
return {
|
|
403
|
+
...info.openSeesVersion === void 0 ? {} : { openSeesVersion: info.openSeesVersion },
|
|
404
|
+
...info.openSeesSourceRevision === void 0 ? {} : { sourceRevision: info.openSeesSourceRevision },
|
|
405
|
+
...info.nodeApi === void 0 ? {} : { nodeApi: info.nodeApi }
|
|
406
|
+
};
|
|
407
|
+
} catch {
|
|
408
|
+
return {};
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return {};
|
|
412
|
+
}
|
|
413
|
+
function loadNativeBinding(bindingPath = defaultNativeBindingPath()) {
|
|
414
|
+
const availability = inspectNativeBackend(bindingPath);
|
|
415
|
+
if (!availability.available) {
|
|
416
|
+
throw new Error(`${availability.reason} Expected: ${availability.bindingPath}`);
|
|
417
|
+
}
|
|
418
|
+
const loaded = require2(availability.bindingPath);
|
|
419
|
+
if (typeof loaded.createSession !== "function") {
|
|
420
|
+
throw new Error(`Invalid OpenSees native addon at ${availability.bindingPath}: createSession() is missing.`);
|
|
421
|
+
}
|
|
422
|
+
return loaded;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// src/native/OpenSeesNativeQueries.ts
|
|
426
|
+
var OpenSeesNativeQueries = class {
|
|
427
|
+
constructor(session) {
|
|
428
|
+
this.session = session;
|
|
429
|
+
}
|
|
430
|
+
analyze(numIncr = 1, dt, dtMin, dtMax, jd) {
|
|
431
|
+
return this.number("analyze", numIncr, dt, dtMin, dtMax, jd);
|
|
432
|
+
}
|
|
433
|
+
getTime() {
|
|
434
|
+
return this.number("getTime");
|
|
435
|
+
}
|
|
436
|
+
getLoadFactor(patternTag) {
|
|
437
|
+
return this.number("getLoadFactor", patternTag);
|
|
438
|
+
}
|
|
439
|
+
getNodeTags(meshTag) {
|
|
440
|
+
return this.numbers("getNodeTags", meshTag === void 0 ? void 0 : { mesh: meshTag });
|
|
441
|
+
}
|
|
442
|
+
getEleTags(meshTag) {
|
|
443
|
+
return this.numbers("getEleTags", meshTag === void 0 ? void 0 : { mesh: meshTag });
|
|
444
|
+
}
|
|
445
|
+
nodeCoord(nodeTag, dimension) {
|
|
446
|
+
return dimension === void 0 ? this.numbers("nodeCoord", nodeTag) : this.number("nodeCoord", nodeTag, dimension);
|
|
447
|
+
}
|
|
448
|
+
nodeDisp(nodeTag, dof) {
|
|
449
|
+
return dof === void 0 ? this.numbers("nodeDisp", nodeTag) : this.number("nodeDisp", nodeTag, dof);
|
|
450
|
+
}
|
|
451
|
+
nodeVel(nodeTag, dof) {
|
|
452
|
+
return dof === void 0 ? this.numbers("nodeVel", nodeTag) : this.number("nodeVel", nodeTag, dof);
|
|
453
|
+
}
|
|
454
|
+
nodeAccel(nodeTag, dof) {
|
|
455
|
+
return dof === void 0 ? this.numbers("nodeAccel", nodeTag) : this.number("nodeAccel", nodeTag, dof);
|
|
456
|
+
}
|
|
457
|
+
nodeReaction(nodeTag, dof) {
|
|
458
|
+
return dof === void 0 ? this.numbers("nodeReaction", nodeTag) : this.number("nodeReaction", nodeTag, dof);
|
|
459
|
+
}
|
|
460
|
+
nodeDisplacements(nodeTags) {
|
|
461
|
+
return this.vectorRecord("nodeDisp", nodeTags);
|
|
462
|
+
}
|
|
463
|
+
nodeReactions(nodeTags) {
|
|
464
|
+
return this.vectorRecord("nodeReaction", nodeTags);
|
|
465
|
+
}
|
|
466
|
+
eleResponse(eleTag, response) {
|
|
467
|
+
return this.numbers("eleResponse", eleTag, response);
|
|
468
|
+
}
|
|
469
|
+
eleForce(eleTag, dof) {
|
|
470
|
+
return dof === void 0 ? this.numbers("eleForce", eleTag) : this.number("eleForce", eleTag, dof);
|
|
471
|
+
}
|
|
472
|
+
elementForces(elementTags) {
|
|
473
|
+
return this.vectorRecord("eleForce", elementTags);
|
|
474
|
+
}
|
|
475
|
+
printA(...args) {
|
|
476
|
+
return args.some((argument) => argument === "-ret") ? this.numbers("printA", ...args) : this.number("printA", ...args);
|
|
477
|
+
}
|
|
478
|
+
printB(...args) {
|
|
479
|
+
return args.some((argument) => argument === "-ret") ? this.numbers("printB", ...args) : this.number("printB", ...args);
|
|
480
|
+
}
|
|
481
|
+
elementLocalForces2D(eleTag) {
|
|
482
|
+
const raw = this.eleResponse(eleTag, ["localForce"]);
|
|
483
|
+
if (raw.length < 6) throw resultTypeError("eleResponse localForce", "at least six values", raw);
|
|
484
|
+
return {
|
|
485
|
+
i: { axial: raw[0], shear: raw[1], moment: raw[2] },
|
|
486
|
+
j: { axial: raw[3], shear: raw[4], moment: raw[5] },
|
|
487
|
+
raw
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
eigen(solverOrModes, numModes) {
|
|
491
|
+
return typeof solverOrModes === "number" ? this.numbers("eigen", solverOrModes) : this.numbers("eigen", solverOrModes, numModes);
|
|
492
|
+
}
|
|
493
|
+
modalResults(numModes, solver = "-genBandArpack") {
|
|
494
|
+
return this.eigen(solver, numModes).map((eigenvalue, index) => {
|
|
495
|
+
const omega = Math.sqrt(eigenvalue);
|
|
496
|
+
const frequency = omega / (2 * Math.PI);
|
|
497
|
+
return {
|
|
498
|
+
mode: index + 1,
|
|
499
|
+
eigenvalue,
|
|
500
|
+
omega,
|
|
501
|
+
frequency,
|
|
502
|
+
period: frequency === 0 ? Number.POSITIVE_INFINITY : 1 / frequency
|
|
503
|
+
};
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
nodeEigenvector(nodeTag, mode, dof) {
|
|
507
|
+
return dof === void 0 ? this.numbers("nodeEigenvector", nodeTag, mode) : this.number("nodeEigenvector", nodeTag, mode, dof);
|
|
508
|
+
}
|
|
509
|
+
modalProperties(...flags) {
|
|
510
|
+
const value = this.call("modalProperties", [...flags, "-return"]);
|
|
511
|
+
if (!Array.isArray(value) || value.length % 2 !== 0) {
|
|
512
|
+
throw resultTypeError("modalProperties", "Tcl dictionary", value);
|
|
513
|
+
}
|
|
514
|
+
const properties = {};
|
|
515
|
+
for (let index = 0; index < value.length; index += 2) {
|
|
516
|
+
const key = value[index];
|
|
517
|
+
const entry = value[index + 1];
|
|
518
|
+
if (typeof key !== "string" || !isNumericValue(entry)) {
|
|
519
|
+
throw resultTypeError("modalProperties", "numeric Tcl dictionary", value);
|
|
520
|
+
}
|
|
521
|
+
properties[key] = entry;
|
|
522
|
+
}
|
|
523
|
+
return properties;
|
|
524
|
+
}
|
|
525
|
+
version() {
|
|
526
|
+
const value = this.call("version");
|
|
527
|
+
if (typeof value !== "string") throw resultTypeError("version", "string", value);
|
|
528
|
+
return value;
|
|
529
|
+
}
|
|
530
|
+
/** Escape hatch tipado para resultados todavía no especializados. */
|
|
531
|
+
call(command, args = []) {
|
|
532
|
+
const flattened = flattenNativeArguments(args);
|
|
533
|
+
return invokeNative(() => this.session.invoke(command, flattened), command, flattened);
|
|
534
|
+
}
|
|
535
|
+
number(command, ...args) {
|
|
536
|
+
const value = this.call(command, args);
|
|
537
|
+
if (typeof value !== "number") throw resultTypeError(command, "number", value);
|
|
538
|
+
return value;
|
|
539
|
+
}
|
|
540
|
+
numbers(command, ...args) {
|
|
541
|
+
const value = this.call(command, args);
|
|
542
|
+
if (!Array.isArray(value) || !value.every((item) => typeof item === "number")) {
|
|
543
|
+
throw resultTypeError(command, "number[]", value);
|
|
544
|
+
}
|
|
545
|
+
return value;
|
|
546
|
+
}
|
|
547
|
+
vectorRecord(command, tags) {
|
|
548
|
+
const rows = tags.map((tag) => [tag]);
|
|
549
|
+
const values = this.session.invokeMany === void 0 ? rows.map((row, index) => invokeNative(() => this.session.invoke(command, row), command, row, index)) : invokeNative(() => this.session.invokeMany(command, rows), command, []);
|
|
550
|
+
const record = {};
|
|
551
|
+
for (let index = 0; index < tags.length; index++) {
|
|
552
|
+
const value = values[index];
|
|
553
|
+
if (!Array.isArray(value) || !value.every((item) => typeof item === "number")) {
|
|
554
|
+
throw resultTypeError(command, "number[]", value);
|
|
555
|
+
}
|
|
556
|
+
record[tags[index]] = value;
|
|
557
|
+
}
|
|
558
|
+
return record;
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
function isNumericValue(value) {
|
|
562
|
+
return typeof value === "number" || Array.isArray(value) && value.every((item) => typeof item === "number");
|
|
563
|
+
}
|
|
564
|
+
function resultTypeError(command, expected, actual) {
|
|
565
|
+
return new TypeError(`${command} returned ${JSON.stringify(actual)}; expected ${expected}.`);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
// src/native/OpenSeesNativeSession.ts
|
|
569
|
+
var commandNames = new Set(OPEN_SEES_PY_COMMANDS);
|
|
570
|
+
var OpenSeesNativeCommands = class {
|
|
571
|
+
constructor(session) {
|
|
572
|
+
this.session = session;
|
|
573
|
+
return new Proxy(this, {
|
|
574
|
+
get: (target, property, receiver) => {
|
|
575
|
+
if (typeof property === "string" && commandNames.has(property) && !(property in target)) {
|
|
576
|
+
const cached = target.methods.get(property);
|
|
577
|
+
if (cached !== void 0) return cached;
|
|
578
|
+
const method = (...args) => {
|
|
579
|
+
target.command(property, args);
|
|
580
|
+
return receiver;
|
|
581
|
+
};
|
|
582
|
+
target.methods.set(property, method);
|
|
583
|
+
return method;
|
|
584
|
+
}
|
|
585
|
+
return Reflect.get(target, property, receiver);
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
methods = /* @__PURE__ */ new Map();
|
|
590
|
+
command(name, args = []) {
|
|
591
|
+
const flattened = flattenNativeArguments(args);
|
|
592
|
+
invokeNative(() => this.session.invoke(name, flattened), name, flattened);
|
|
593
|
+
return this;
|
|
594
|
+
}
|
|
595
|
+
many(name, argumentRows) {
|
|
596
|
+
const rows = argumentRows.map((row) => flattenNativeArguments(row));
|
|
597
|
+
if (this.session.invokeMany) {
|
|
598
|
+
invokeNative(() => this.session.invokeMany(name, rows), name, [], void 0);
|
|
599
|
+
} else {
|
|
600
|
+
rows.forEach((row, index) => invokeNative(() => this.session.invoke(name, row), name, row, index));
|
|
601
|
+
}
|
|
602
|
+
return this;
|
|
603
|
+
}
|
|
604
|
+
nodes(rows) {
|
|
605
|
+
return this.many("node", rows);
|
|
606
|
+
}
|
|
607
|
+
elements(rows) {
|
|
608
|
+
return this.many("element", rows);
|
|
609
|
+
}
|
|
610
|
+
loads(rows) {
|
|
611
|
+
return this.many("load", rows);
|
|
612
|
+
}
|
|
613
|
+
};
|
|
614
|
+
var OpenSeesNativeSession = class {
|
|
615
|
+
bindingSession;
|
|
616
|
+
closed = false;
|
|
617
|
+
ops;
|
|
618
|
+
query;
|
|
619
|
+
constructor(options = {}) {
|
|
620
|
+
const binding = options.binding ?? loadNativeBinding(options.bindingPath);
|
|
621
|
+
this.bindingSession = binding.createSession();
|
|
622
|
+
this.ops = new OpenSeesNativeCommands(this.bindingSession);
|
|
623
|
+
this.query = new OpenSeesNativeQueries(this.bindingSession);
|
|
624
|
+
}
|
|
625
|
+
invoke(command, args = []) {
|
|
626
|
+
this.assertOpen();
|
|
627
|
+
const flattened = flattenNativeArguments(args);
|
|
628
|
+
return invokeNative(
|
|
629
|
+
() => this.bindingSession.invoke(command, flattened),
|
|
630
|
+
command,
|
|
631
|
+
flattened
|
|
632
|
+
);
|
|
633
|
+
}
|
|
634
|
+
invokeMany(command, argumentRows) {
|
|
635
|
+
this.assertOpen();
|
|
636
|
+
const rows = argumentRows.map((row) => flattenNativeArguments(row));
|
|
637
|
+
if (this.bindingSession.invokeMany) {
|
|
638
|
+
return invokeNative(
|
|
639
|
+
() => this.bindingSession.invokeMany(command, rows),
|
|
640
|
+
command,
|
|
641
|
+
[]
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
return rows.map((row, index) => invokeNative(
|
|
645
|
+
() => this.bindingSession.invoke(command, row),
|
|
646
|
+
command,
|
|
647
|
+
row,
|
|
648
|
+
index
|
|
649
|
+
));
|
|
650
|
+
}
|
|
651
|
+
close() {
|
|
652
|
+
if (this.closed) return;
|
|
653
|
+
this.bindingSession.close();
|
|
654
|
+
this.closed = true;
|
|
655
|
+
}
|
|
656
|
+
[Symbol.dispose]() {
|
|
657
|
+
this.close();
|
|
658
|
+
}
|
|
659
|
+
assertOpen() {
|
|
660
|
+
if (this.closed) throw new Error("The OpenSees native session is closed.");
|
|
661
|
+
}
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
// src/native/OpenSeesOps.ts
|
|
665
|
+
function createOpenSeesOps(options = {}) {
|
|
666
|
+
let session;
|
|
667
|
+
const getSession = () => session ??= new OpenSeesNativeSession(options);
|
|
668
|
+
const methods = /* @__PURE__ */ new Map();
|
|
669
|
+
let facade;
|
|
670
|
+
facade = new Proxy({}, {
|
|
671
|
+
get(_target, property) {
|
|
672
|
+
if (property === "dispose") {
|
|
673
|
+
return () => {
|
|
674
|
+
session?.close();
|
|
675
|
+
session = void 0;
|
|
676
|
+
};
|
|
677
|
+
}
|
|
678
|
+
if (typeof property !== "string") return void 0;
|
|
679
|
+
const cached = methods.get(property);
|
|
680
|
+
if (cached !== void 0) return cached;
|
|
681
|
+
const method = (...args) => {
|
|
682
|
+
const current = getSession();
|
|
683
|
+
const isQuery = property in OpenSeesNativeQueries.prototype;
|
|
684
|
+
const owner = isQuery ? current.query : current.ops;
|
|
685
|
+
const value = Reflect.get(owner, property);
|
|
686
|
+
if (typeof value !== "function") return value;
|
|
687
|
+
const result = Reflect.apply(value, owner, args);
|
|
688
|
+
return result === current.ops ? facade : result;
|
|
689
|
+
};
|
|
690
|
+
methods.set(property, method);
|
|
691
|
+
return method;
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
return facade;
|
|
695
|
+
}
|
|
696
|
+
var ops = createOpenSeesOps();
|
|
697
|
+
process.once("exit", () => ops.dispose());
|
|
698
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
699
|
+
0 && (module.exports = {
|
|
700
|
+
OPEN_SEES_PY_COMMANDS,
|
|
701
|
+
OPEN_SEES_PY_VERSION,
|
|
702
|
+
OpenSeesCommandError,
|
|
703
|
+
OpenSeesNativeCommands,
|
|
704
|
+
OpenSeesNativeQueries,
|
|
705
|
+
OpenSeesNativeSession,
|
|
706
|
+
createOpenSeesOps,
|
|
707
|
+
defaultNativeBindingPath,
|
|
708
|
+
inspectNativeBackend,
|
|
709
|
+
loadNativeBinding,
|
|
710
|
+
ops
|
|
711
|
+
});
|
|
712
|
+
//# sourceMappingURL=native-index.cjs.map
|