osis-python 0.9.0__py3-none-any.whl → 0.9.2__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osis-python
3
- Version: 0.9.0
3
+ Version: 0.9.2
4
4
  Summary: A Python client library for Osis APDL
5
5
  Author-email: "CCCC Highway Consultant Co. Ltd." <support@osisbim.com>
6
6
  License-Expression: MIT
@@ -252,8 +252,7 @@ shape = engine.tendon.shape.create_arc3d(
252
252
 
253
253
  # 活载:等级 -> 车道 -> 工况
254
254
  engine.live.grade.create_highway("公路I级", code="JTGD60_2015", live_load_type="HIGHWAY_I")
255
- engine.live.lane.create_ve("车道", length=19.1, wheel=1.8, orientation=1,
256
- ref=0, ref_elems="主梁单元", offset_y=0.0, offset_z=0.0)
255
+ engine.live.lane.create_ve("车道", 19.1, 1.8, 1, 0, "主梁单元", 0.0, 0.0)
257
256
  lc = engine.live.case.create("车道荷载包络", code="JTGD60_2015", sub_cmb_type=1)
258
257
  lc.create_sub("车道荷载工况1", "公路I级", scalar=0.75, calc_mu=True,
259
258
  bridge_type="CUSTOM", mu_params=[6.586960], lane_names=["车道"])
@@ -498,7 +497,7 @@ engine.control.set_calc_shear(True)
498
497
  engine.control.set_calc_relaxation(True)
499
498
  engine.control.set_mod_loc_coor(False)
500
499
  engine.control.set_inc_tendon(True)
501
- engine.control.set_nonlinear(geom=False, link=False)
500
+ engine.control.set_nonlinear(geom=False)
502
501
 
503
502
  # 截面
504
503
  engine.section.create_circle(no=1, name="圆形截面1", d=0.219, tw=0.012)
@@ -1,12 +1,12 @@
1
- osis_python-0.9.0.dist-info/licenses/LICENSE,sha256=T4mkSYliXdU9mYe-NfHkqg6GPhzoYaIQO_a630UzpS4,1088
2
- pyosis/__init__.py,sha256=TQ-uHVUsFHOu8rQFk1GM3zfl0VjvNxhWOk2qyG-ooOg,440
1
+ osis_python-0.9.2.dist-info/licenses/LICENSE,sha256=T4mkSYliXdU9mYe-NfHkqg6GPhzoYaIQO_a630UzpS4,1088
2
+ pyosis/__init__.py,sha256=mDros6jCvp_hvkXnAttNYKvYtn4tOTAsJCyMCSnuE5w,440
3
3
  pyosis/boundary/__init__.py,sha256=W5LfF-jugWa-YI8pnfELZaz0pXLa-D8TiGnBn12HGGQ,102
4
4
  pyosis/boundary/interface.py,sha256=Y1PkDocwlMlKE2Po5hV6B57ocG_8FY5w0Cjp8bpWDig,14643
5
5
  pyosis/boundary/manager.py,sha256=6UKUztKBTnn5db8Cx2O9GKX85oqvavJRvrurWF34LdA,50070
6
6
  pyosis/control/__init__.py,sha256=98UAXB9Wkf93pGUKIjoGBBrSCblVeAwc_MXeaAB-UIA,119
7
7
  pyosis/control/control.py,sha256=GMhlXyY9fBXBJXv3d8hBEZFA3BadfDYUIehvo2_cQow,3215
8
8
  pyosis/control/io.py,sha256=ekYGPJsBBeBPPkOoIN0RIKHlJshLz9gCg-mR3m5fkMk,784
9
- pyosis/control/manager.py,sha256=vvVtZ_6O6iNny0GDEWEGDw69A824urBA0MhqaKQvYU4,12643
9
+ pyosis/control/manager.py,sha256=Bk0bnARkIM5jsexmfWQlXKhKT2A6w2S5kedhcxqi7oM,12507
10
10
  pyosis/control/nonlinear.py,sha256=xQV_v5MtciL5GyD6lz25E56T13Pgcu_OimMrNv8t96Q,2670
11
11
  pyosis/core/__init__.py,sha256=S45sMsDqHJHqHhPLLHuevzWaF_Z4IPdlgI_KwoCtFc4,1119
12
12
  pyosis/core/all_func.py,sha256=VhvAeMJMCQJ1redjqdkm7meTw1PJNDoRdmXXh2LzkVo,521
@@ -43,7 +43,7 @@ pyosis/live/__init__.py,sha256=jl0pMkfAGRnukwuCbc6fOJoWo-ufMnFm4lyBV-xQQxc,112
43
43
  pyosis/live/analysis.py,sha256=uEtHjaKu48uWvNFnrenwkFjfs1vSjNkXP7_ese2qWHc,5568
44
44
  pyosis/live/grade.py,sha256=5mRJ3Ziv9YNQAbMIUnS5bFB_mg6KvDy0NhXYzq1PeGs,6949
45
45
  pyosis/live/lane.py,sha256=OPz5vS768M0Ebm5PDZp6kndtlTlRvJl4ohFElMJmTKI,5633
46
- pyosis/live/manager.py,sha256=ZRhNpqcXk61K5xsmDejBcVGSYyYEepnN2xffOdwF0rc,58254
46
+ pyosis/live/manager.py,sha256=ei4EAe4jFGvE7_BcOzEOXPDPiNr-54U79XZ8n_SUr_8,58963
47
47
  pyosis/load/__init__.py,sha256=BNiG7h7v0VDYpKqGtGxiTgjqv6mPARDJBfqcdh_m2r0,164
48
48
  pyosis/load/environmental.py,sha256=ZxBmSKqgCWwHwENFw9kq-arTcN3ijsMEey6lDX8g7t4,35187
49
49
  pyosis/load/loadcase.py,sha256=5DOty5OBtxHPguw_gYUqL3FFbXRkCjA2IVpCdAzJSJU,2457
@@ -69,7 +69,7 @@ pyosis/property/component_thickness.py,sha256=fH9jpt2V6w2lSL2jDb1cuk5wylfhvnznxZ
69
69
  pyosis/property/coordinate.py,sha256=xFfuzXCzBWqYsDxHifpYCYgC_to9kC4LKD2yTX2CtvM,2668
70
70
  pyosis/property/creep_shrink.py,sha256=5k85N_jSfGrqOwryzIy8Yg0oR4qmgyg8VlT-7uf0nzs,2291
71
71
  pyosis/property/damping.py,sha256=pasnvd1zua1skO-3lcLydFYT3phIZKqC-28DZn5jsGA,3225
72
- pyosis/property/manager.py,sha256=R3JmNFJIO9k9ZLEmv56lhqhim-hYE3eseKwYIfDBIeg,35259
72
+ pyosis/property/manager.py,sha256=Ri7d7BHGYBUOYcEqYKldZWHllx7y6FjgYAKSnmaAQto,35036
73
73
  pyosis/property/pu_curve.py,sha256=9pByhO_IIIjtC7Gw_OKuvEFMVgo6ux7TrXQLaQwSE-E,1608
74
74
  pyosis/property/strength_prog.py,sha256=NWcvgU-t7ZUzdjlCBLSJ78hSMRNVVQJDkeELdU4Jz8E,9301
75
75
  pyosis/quick_building/__init__.py,sha256=QiWapgiZk6pkAdiznKI0bVIc16UcFOIALQuLhupLkqw,48
@@ -77,11 +77,11 @@ pyosis/quick_building/interface.py,sha256=xdQrORabxmnlhi537pspFokQBaXSmnZMIxA_kx
77
77
  pyosis/result/__init__.py,sha256=XdaWwaPDni5r7yBBTvR0CG8DqbsHB3I8IJBAVLvUsKQ,645
78
78
  pyosis/result/check.py,sha256=_-9mRbbwP5zHXUAdAjUae7IJKVqNyvjodqObww_tsY4,5825
79
79
  pyosis/result/manager.py,sha256=WUfNkZIcIxoXvqV8jRRMnG3Co1iPm9h9YZq6yCRGj74,13519
80
- pyosis/result/routes.py,sha256=0vMTTvxDV5BjdHTmqWuj5ZRAimqqUuOj8uM8S6OPPU4,20828
80
+ pyosis/result/routes.py,sha256=aVqFAFy-DdPXqjalFmPyHz4MVFCSH_bDpwz4zDfPiFI,20847
81
81
  pyosis/section/__init__.py,sha256=ArWzCN6GUQbyIsWQabPvR9gj36NUeycjzuWw9PVHmx4,207
82
82
  pyosis/section/common.py,sha256=yI61YQH8btfkoBGnXF7wp3kFhZVW06XABIJZnvkDk3E,26616
83
- pyosis/section/composite.py,sha256=CWNcPagXbL4D8uUouRk8ux7Xv41bE2dXM8JfWX77pBI,9353
84
- pyosis/section/manager.py,sha256=SXlTTYYQBOUzMNlD5eGkhkh0xQTZE0GtFgvlmvw7X58,126104
83
+ pyosis/section/composite.py,sha256=1jVdsxHXRAizeBUTfsjCOx3--WCnfTGF-fZiJy5P_Ys,9458
84
+ pyosis/section/manager.py,sha256=Q3Vl3OMhqqei1ckohSvaUMmISGvnbiMODxNUkCE0-S8,127090
85
85
  pyosis/section/numeric.py,sha256=lDO1KvSTmzBE56wkfDw5xxDhWi-kM0szXPx6CIymIyQ,1479
86
86
  pyosis/section/param.py,sha256=CRtfBoynaGbiTb0uF2SoUBJtbrR05ok5VkxBRyRy8Us,7445
87
87
  pyosis/section/rebar.py,sha256=9ibcOoMd7HYfzSaO6dMpZFwp1ugmwayOmDqIoWUijNc,8337
@@ -95,21 +95,20 @@ pyosis/stability/__init__.py,sha256=dosYKwUeNtzsRD8i_oEkIKDLMdQfCMQiGZdyVgAQIF4,
95
95
  pyosis/stability/buckling.py,sha256=IY8eTKusZUBj86zq5XeTYw03yH4SFpCPbGYGg9fbASg,3361
96
96
  pyosis/stability/manager.py,sha256=djm8MdrBVWW_IJHKy_ARkEJtVzLLqE8uI2aRITDQHMo,9713
97
97
  pyosis/stage/__init__.py,sha256=5CB4xCFfosuyo9sw581D1mlczKfQb-NsVUurILhIgEc,250
98
- pyosis/stage/define.py,sha256=4I0Nw9-a2Rwc7DIMl7uuYX_YfLjTS1m_Jdt3jgBUVVs,4232
99
- pyosis/stage/manager.py,sha256=h1JjjJbGyA6sSMfZ2cPfOwefJZGDEHGiWLJHZWsXEDA,16986
98
+ pyosis/stage/define.py,sha256=tuqT4JBcZBwMyWei4ASZnBSzhTSKIRTaYSKmEvS03Ps,4364
99
+ pyosis/stage/manager.py,sha256=CuU9JqpmWEI-qKcvQ9zZ__HONoXC4eYH1Mk2vzgWgHs,17227
100
100
  pyosis/stage/overall.py,sha256=sNmDhixlC4glttBFsUabspCqeOgkGflqo693ozMVsUU,2177
101
101
  pyosis/thickness/__init__.py,sha256=YGYmUPc9TvAlw4eFuEjxaG7HjvwLQJelU_Mx2M6RhW0,82
102
102
  pyosis/thickness/interface.py,sha256=VHLfpnt5Yf19IOs0NgwtGew8Ia2BpbF7u2qSbrOM8O8,1846
103
103
  pyosis/thickness/manager.py,sha256=a_B2SYeysZ0FPqs0T5kXOJbmlG4i0aH9pzppiR55rWA,6242
104
104
  pyosis/transfer/__init__.py,sha256=OZVxVnjhDGe4fHC6pjtOaKPzAKuoDp3-XkNFzDWepsE,623
105
- pyosis/transfer/generator.py,sha256=NHQxhqxiQYj6u2XLCC22ILqaUSrRMcktV9F6GExke-8,6299
106
- pyosis/transfer/introspect.py,sha256=auOKh6KJrT3dZckNnTA59zuGm9kzSsVNiSkpvDo1G9Q,5125
105
+ pyosis/transfer/generator.py,sha256=oNp3FGPQa4zkKprGpyT5y705n32yonC57x50DdcTALs,3990
107
106
  pyosis/transfer/matrix.py,sha256=sHw9X34-PUeY1EdoNklgK0LUHwbBPnhkhk0R9ME0XG0,3378
108
- pyosis/transfer/out_to_python.py,sha256=69UnwkmkQiAZvpB0RLZqXlj9I0hItWgvTZRY5dWN2lY,17880
109
- pyosis/transfer/parser.py,sha256=R_aBlYJTe53hD1sX5PBv86bhj88NQwANFRN4pGYudQ8,6774
110
- pyosis/transfer/routes.py,sha256=064L-aHRtu1WzGL1NEugqm0aWHAdk3HU-1NWtQEppvw,16223
107
+ pyosis/transfer/out_to_python.py,sha256=q1toQNGVpJGlul58qjFtJOwoL3RHj0hjLksIPaJpT_w,16219
108
+ pyosis/transfer/parser.py,sha256=enww-1e28ZGcIgXDulmayxa9Pa7A0cWQaaz7iUDmNWA,5260
109
+ pyosis/transfer/routes.py,sha256=KBrd1rkAHOaifQy7tGeEQK3as490p3STyHCoWML_0eM,11947
111
110
  pyosis/transfer/split.py,sha256=hpBe9D9WbjbKsovx4hM3X5RjTrruWNkuFmZt2ed0fME,1284
112
- osis_python-0.9.0.dist-info/METADATA,sha256=Gs2L7OuzCiIv2qeNKpzc1Fu0_BUJSbNWfa6stJByXuo,21351
113
- osis_python-0.9.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
114
- osis_python-0.9.0.dist-info/top_level.txt,sha256=6VDNySkQKwipRXcN8ayKVci4vAXi4oPyWLqFhNVcIfM,7
115
- osis_python-0.9.0.dist-info/RECORD,,
111
+ osis_python-0.9.2.dist-info/METADATA,sha256=4Y6Bnn56rXQK-HSEHGR9n3MX2P4ZRTG8coKO0Jnf_kw,21255
112
+ osis_python-0.9.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
113
+ osis_python-0.9.2.dist-info/top_level.txt,sha256=6VDNySkQKwipRXcN8ayKVci4vAXi4oPyWLqFhNVcIfM,7
114
+ osis_python-0.9.2.dist-info/RECORD,,
pyosis/__init__.py CHANGED
@@ -7,7 +7,7 @@ A library for extending OSIS functionality.
7
7
  A library that allows users to use CAE with great flexibility.
8
8
  """
9
9
 
10
- __version__ = "0.9.0"
10
+ __version__ = "0.9.2"
11
11
 
12
12
  from .core.engine import OSISEngine
13
13
  from .core.batch import batch, flush, batch_state, BatchError
pyosis/control/manager.py CHANGED
@@ -288,14 +288,13 @@ class ControlManager:
288
288
 
289
289
  # ── 非线性分析 ──────────────────────────────
290
290
 
291
- def set_nonlinear(self, geom: Literal[0,1] = 0, link: Literal[0,1] | None = None) -> None:
291
+ def set_nonlinear(self, geom: Literal[0,1] = 0) -> None:
292
292
  '''设置非线性分析控制开关
293
293
 
294
- 非线性连接单元由软件在转换时强制考虑,link 参数已废弃、不再下发。
294
+ 非线性连接单元由软件在转换时强制考虑。
295
295
 
296
296
  Args:
297
297
  geom (int): 是否打开几何非线性(大位移大转角),1=开,0=关
298
- link (int): 已废弃,仅为兼容旧调用保留
299
298
 
300
299
  Returns:
301
300
  None
pyosis/live/manager.py CHANGED
@@ -1089,8 +1089,8 @@ class LaneManager(BasicManager):
1089
1089
  RuntimeError: 创建失败
1090
1090
 
1091
1091
  Examples:
1092
- >>> live_manager.lane.create("车道1", "VE", length=30.0, wheel=1.8, ref_elems="主梁", offset_y=2.5)
1093
- >>> live_manager.lane.create("重车道", "TCB", crossbeam_elems="横梁", length=30.0, wheel=1.8, ref_elems="主梁")
1092
+ >>> live_manager.lane.create("车道1", "VE", 30.0, 1.8, 1, 0, "主梁", 2.5, 0.0)
1093
+ >>> live_manager.lane.create("重车道", "TCB", "横梁", 30.0, 1.8, 0, 0, "主梁", 0.0, 0.0)
1094
1094
  """
1095
1095
  _creator = {
1096
1096
  "VE": self.create_ve,
@@ -1110,14 +1110,13 @@ class LaneManager(BasicManager):
1110
1110
  wheel: float = 0,
1111
1111
  orientation: Literal[-1, 0, 1] = 0,
1112
1112
  ref: Literal[0, 1] = 0,
1113
- ref_elems: str | None = None,
1114
- offset_y: float = 0.0,
1115
- offset_z: float = 0.0,
1116
- spline_name: str | None = None,
1113
+ *params: Any,
1117
1114
  ) -> Lane:
1118
1115
  """创建车道(车道单元法 VE)
1119
1116
 
1120
1117
  适用于主梁为梁单元的桥梁结构,车辆沿纵向路径移动。
1118
+ 位置参数与命令流严格对应:
1119
+ InflAlgo, Name, type, length, wheel, vehOri, ref, par1, par2, par3
1121
1120
 
1122
1121
  Args:
1123
1122
  name: 车道名称
@@ -1130,10 +1129,12 @@ class LaneManager(BasicManager):
1130
1129
  ref: 车道参照方式
1131
1130
  - 0: 参照单元组(默认)
1132
1131
  - 1: 参照样条曲线
1133
- ref_elems: 参照纵梁单元组名称(ref=0/1 均必填)
1134
- offset_y: Y方向偏移量(m),默认 0.0;ref=1 时不使用
1135
- offset_z: Z方向偏移量(m),默认 0.0;ref=1 时不使用
1136
- spline_name: 样条曲线名称(ref=1 时必填)
1132
+ *params: 与命令流 par1..par3 一一对应的尾部字段
1133
+ - ref=0: (ref_elems, offset_y, offset_z)
1134
+ ref_elems 为参照纵梁单元组名称,offset_y/offset_z 为局部
1135
+ 坐标系下的 Y/Z 偏移量(m)
1136
+ - ref=1: (ref_elems, spline_name)
1137
+ ref_elems 为参照纵梁单元组名称,spline_name 为样条曲线名称
1137
1138
 
1138
1139
  Returns:
1139
1140
  创建的 Lane 对象
@@ -1142,11 +1143,19 @@ class LaneManager(BasicManager):
1142
1143
  RuntimeError: 参数校验失败或创建失败时抛出
1143
1144
  """
1144
1145
  if ref == 0:
1146
+ if len(params) != 3:
1147
+ raise RuntimeError(
1148
+ "ref=0 时尾部参数应为 (ref_elems, offset_y, offset_z)"
1149
+ )
1150
+ ref_elems, offset_y, offset_z = params
1145
1151
  if not ref_elems:
1146
1152
  raise RuntimeError(f"参照单元组名称 ref_elems 不能为空")
1147
1153
  param = [ref_elems, offset_y, offset_z]
1148
1154
  else:
1149
1155
  # 命令流 eRef=1:ESel, SplineName
1156
+ if len(params) != 2:
1157
+ raise RuntimeError("ref=1 时尾部参数应为 (ref_elems, spline_name)")
1158
+ ref_elems, spline_name = params
1150
1159
  if not ref_elems:
1151
1160
  raise RuntimeError(f"参照纵梁单元组名称 ref_elems 不能为空")
1152
1161
  if not spline_name:
@@ -1166,14 +1175,13 @@ class LaneManager(BasicManager):
1166
1175
  wheel: float = 0,
1167
1176
  orientation: Literal[-1, 0, 1] = 0,
1168
1177
  ref: Literal[0, 1] = 0,
1169
- ref_elems: str | None = None,
1170
- offset_y: float = 0.0,
1171
- offset_z: float = 0.0,
1172
- spline_name: str | None = None,
1178
+ *params: Any,
1173
1179
  ) -> Lane:
1174
1180
  """创建车道(横向联系梁法 TCB)
1175
1181
 
1176
1182
  适用于由主梁+横梁组成的空间传力结构,荷载先分配给横梁再传递至主梁。
1183
+ 位置参数与命令流严格对应:
1184
+ InflAlgo, Name, type, ESel, length, wheel, vehOri, ref, par1, par2, par3, par4
1177
1185
 
1178
1186
  Args:
1179
1187
  name: 车道名称
@@ -1187,10 +1195,9 @@ class LaneManager(BasicManager):
1187
1195
  ref: 车道参照方式
1188
1196
  - 0: 参照单元组(默认)
1189
1197
  - 1: 参照样条曲线
1190
- ref_elems: 参照纵梁单元组名称(ref=0/1 均必填)
1191
- offset_y: Y方向偏移量(m),默认 0.0;ref=1 时不使用
1192
- offset_z: Z方向偏移量(m),默认 0.0;ref=1 时不使用
1193
- spline_name: 样条曲线名称(ref=1 时必填)
1198
+ *params: 与命令流 par1..par4 一一对应的尾部字段
1199
+ - ref=0: (ref_elems, offset_y, offset_z)
1200
+ - ref=1: (ref_elems, spline_name)
1194
1201
 
1195
1202
  Returns:
1196
1203
  创建的 Lane 对象
@@ -1199,11 +1206,19 @@ class LaneManager(BasicManager):
1199
1206
  RuntimeError: 参数校验失败或创建失败时抛出
1200
1207
  """
1201
1208
  if ref == 0:
1209
+ if len(params) != 3:
1210
+ raise RuntimeError(
1211
+ "ref=0 时尾部参数应为 (ref_elems, offset_y, offset_z)"
1212
+ )
1213
+ ref_elems, offset_y, offset_z = params
1202
1214
  if not ref_elems:
1203
1215
  raise RuntimeError(f"参照单元组名称 ref_elems 不能为空")
1204
1216
  param = [ref_elems, offset_y, offset_z]
1205
1217
  else:
1206
1218
  # 命令流 eRef=1:RefESel, SplineName
1219
+ if len(params) != 2:
1220
+ raise RuntimeError("ref=1 时尾部参数应为 (ref_elems, spline_name)")
1221
+ ref_elems, spline_name = params
1207
1222
  if not ref_elems:
1208
1223
  raise RuntimeError(f"参照纵梁单元组名称 ref_elems 不能为空")
1209
1224
  if not spline_name:
@@ -1480,7 +1495,7 @@ class LiveManager:
1480
1495
  >>> grade = live_manager.grade.create_highway("简支空心板移动荷载",code="JTGD60_2015",live_load_type="HIGHWAY_I")
1481
1496
  >>>
1482
1497
  >>> # 创建车道(VE 车道单元法)
1483
- >>> lane = live_manager.lane.create_ve(name="车道1",length=30.0,wheel=1.80,orientation=1,ref=0,ref_elems="主梁单元",offset_y=2.5,offset_z=0.0)
1498
+ >>> lane = live_manager.lane.create_ve("车道1", 30.0, 1.80, 1, 0, "主梁单元", 2.5, 0.0)
1484
1499
  >>>
1485
1500
  >>> # 创建活载工况并添加子工况
1486
1501
  >>> live_case = live_manager.case.create("活载工况1", "JTGD60_2015", 1)
@@ -1514,7 +1529,7 @@ class LiveManager:
1514
1529
 
1515
1530
  用法::
1516
1531
 
1517
- >>> live_manager.lane.create_ve("车道1", 30.0, ref_elems="主梁")
1532
+ >>> live_manager.lane.create_ve("车道1", 30.0, 0, 0, 0, "主梁", 0.0, 0.0)
1518
1533
  >>> live_manager.lane.all()
1519
1534
  >>> live_manager.lane.get("车道1")
1520
1535
  """
@@ -399,7 +399,6 @@ class CreepShrinkManager(BasicManager):
399
399
  type_coeff: float = 5.0,
400
400
  birth_by_shrinking: int = 3,
401
401
  fly_ash_ratio: float = 0.0,
402
- shrink_birth: int | None = None,
403
402
  ) -> CreepShrink:
404
403
  '''创建或修改收缩徐变特性
405
404
 
@@ -418,7 +417,6 @@ class CreepShrinkManager(BasicManager):
418
417
  type_coeff (float): 水泥种类系数
419
418
  birth_by_shrinking (int): 收缩开始时的混凝土龄期(天数)
420
419
  fly_ash_ratio (float): 粉煤灰添加量(百分比),0~50
421
- shrink_birth (int|None): birth_by_shrinking 的旧写法,传了就覆盖上面的值
422
420
 
423
421
  Returns:
424
422
  创建的 CreepShrink 对象
@@ -426,8 +424,6 @@ class CreepShrinkManager(BasicManager):
426
424
  Raises:
427
425
  RuntimeError: 创建失败时抛出
428
426
  '''
429
- if shrink_birth is not None:
430
- birth_by_shrinking = shrink_birth
431
427
  ok, err = osis_creep_shrink(
432
428
  nNO=no,
433
429
  strName=name,
pyosis/result/routes.py CHANGED
@@ -28,8 +28,8 @@
28
28
  Python 重装,不用重编 DLL。认不出来的表头会告警,必需的列缺失会直接报错,不会
29
29
  静默给出一张少列的表。
30
30
 
31
- 数值已在服务端按该列单位换算成工程单位(与软件导出 txt、界面显示一致)。unit 是
32
- ``yilEnumType::UnitType`` 的枚举值,仅作诊断,本模块不用。
31
+ 数值由 OSIS 引擎统一按标准单位返回:力 N、力矩 N·m、应力 Pa,与模型的显示单位
32
+ 设置无关。unit 是 ``yilEnumType::UnitType`` 的枚举值,仅作诊断,本模块不用。
33
33
 
34
34
  source 是诊断信息而非稳定契约:同一次调用可能因结果文件是否落盘而在 file/memory
35
35
  之间翻转,也可能缺失,不要用业务逻辑依赖它。
@@ -252,6 +252,7 @@ def osis_section_part_polygon(
252
252
  PartDensity: float,
253
253
  PartGeoType: Literal["Polygon"],
254
254
  ContourMatrix: str,
255
+ ContourWidth: str,
255
256
  ):
256
257
  """定义或修改自定义组合截面的面域Part信息。
257
258
  Args:
@@ -263,6 +264,7 @@ def osis_section_part_polygon(
263
264
  PartDensity:分部重度
264
265
  PartGeoType:分部几何类型,=Polygon为面域
265
266
  ContourMatrix:轮廓点矩阵,大小为n*3,n为点的个数,第一列为点所在的轮廓线编号,第二列为点的x坐标,第三列为点的y坐标
267
+ ContourWidth:轮廓线宽度矩阵,大小为n*1,n为轮廓线数量
266
268
  Returns:
267
269
  tuple (bool, str): 返回一个元组,包含:
268
270
  - bool: 操作是否成功
pyosis/section/manager.py CHANGED
@@ -331,18 +331,20 @@ class Section:
331
331
 
332
332
  def set_mesh(
333
333
  self,
334
+ part_id: int = 1,
334
335
  mesh_method: Literal[0, 1] = 0,
335
336
  mesh_size: float = 0.0,
336
- part_id: int = 1,
337
337
  ) -> None:
338
338
  '''设置截面网格(适用于混凝土截面、模板组合截面与自定义组合截面)。
339
339
 
340
+ 形参顺序与命令流 SectionMesh, Index, PartID, MeshMethod, MeshSize 一致。
341
+
340
342
  Args:
343
+ part_id (int): 分部编号,混凝土截面输入 1,模板组合截面输入 2
341
344
  mesh_method (int): 网格划分方式
342
345
  * 0 = 自动划分
343
346
  * 1 = 手动划分
344
347
  mesh_size (float): 网格划分尺寸,在 mesh_method=1 时起作用
345
- part_id (int): 分部编号,混凝土截面输入 1,模板组合截面输入 2
346
348
 
347
349
  Raises:
348
350
  RuntimeError: 设置失败时抛出
@@ -437,24 +439,41 @@ class Section:
437
439
 
438
440
  def add_part(
439
441
  self,
440
- type: Literal["POLYGON", "LINE"],
441
- *args: float,
442
+ part_index: int,
443
+ part_mat_type: Literal["Concrete", "Steel"],
444
+ part_e: float,
445
+ part_mu: float,
446
+ part_density: float,
447
+ part_geo_type: Literal["Polygon", "Line"],
448
+ *matrices: str,
442
449
  ) -> None:
443
- """添加或修改组合截面 Part(按类型分发)
450
+ """添加或修改组合截面 Part(按几何类型分发)
451
+
452
+ 形参顺序与命令流
453
+ SectionPart, SecIndex, PartIndex, PartMatType, PartE, PartMu,
454
+ PartDensity, PartGeoType, Matrices... 一致。
444
455
 
445
456
  Args:
446
- type: Part 类型(大小写不敏感)
447
- * POLYGON = 多边形
448
- * LINE = 折线
449
- args: 剩余参数透传给对应子方法
457
+ part_index: Part 编号
458
+ part_mat_type: 分部材料类型
459
+ * Concrete = 混凝土,可布置钢筋
460
+ * Steel = 钢,不可布置钢筋
461
+ part_e: 分部弹性模量
462
+ part_mu: 分部泊松比
463
+ part_density: 分部重度
464
+ part_geo_type: 分部几何类型(大小写不敏感)
465
+ * Polygon = 面域(后面 2 个矩阵:ContourMatrix, ContourWidth)
466
+ * Line = 线域(后面 3 个矩阵:PointMatrix, LineMatrix, WidthMatrix)
467
+ matrices: 几何矩阵,数量由 part_geo_type 决定
450
468
  """
451
- key = str(type).upper()
469
+ key = str(part_geo_type).upper()
470
+ head = (part_index, part_mat_type, part_e, part_mu, part_density)
452
471
  if key == "POLYGON":
453
- self.add_composite_part_polygon(*args)
472
+ self.add_composite_part_polygon(*head, *matrices)
454
473
  elif key == "LINE":
455
- self.add_composite_part_line(*args)
474
+ self.add_composite_part_line(*head, *matrices)
456
475
  else:
457
- raise ValueError(f"未知 Part 类型: {type!r},支持 POLYGON/LINE")
476
+ raise ValueError(f"未知 Part 类型: {part_geo_type!r},支持 POLYGON/LINE")
458
477
 
459
478
  # ── 组合截面材料 ──────────────────────────
460
479
 
pyosis/stage/define.py CHANGED
@@ -35,7 +35,7 @@ def osis_stage_element(nIndex: int, eOP: Literal[1, 0], eType: Literal[1, 0], st
35
35
  pass
36
36
 
37
37
  @REGISTRY.register("StgBd")
38
- def osis_stage_boundary(nIndex: int, eOP: Literal[1, 0], eType: Literal[1, 0], strGroupName: str):
38
+ def osis_stage_boundary(nIndex: int, eOP: Literal[1, 0], eType: Literal[1, 0], strGroupName: str, nPos: int = None):
39
39
  """通过边界组激活/钝化边界
40
40
 
41
41
  Args:
@@ -43,11 +43,14 @@ def osis_stage_boundary(nIndex: int, eOP: Literal[1, 0], eType: Literal[1, 0], s
43
43
  eOP (int): 操作
44
44
  * 1 = 添加
45
45
  * 0 = 移除
46
- eType (int):
46
+ eType (int):
47
47
  * 1 = 激活
48
48
  * 0 = 钝化
49
49
  strGroupName (str): 待操作的边界组名称
50
-
50
+ nPos (int): 变形位置,可缺省(None)
51
+ * 1 = 变形前(默认)
52
+ * 0 = 变形后
53
+
51
54
  Returns:
52
55
  tuple (bool, str): 返回一个元组,包含:
53
56
  - bool: 操作是否成功
pyosis/stage/manager.py CHANGED
@@ -264,10 +264,13 @@ class Stage:
264
264
  self,
265
265
  op: Literal[1, 0],
266
266
  type: Literal[1, 0],
267
- group_name: str
267
+ group_name: str,
268
+ pos: int | None = None,
268
269
  ) -> None:
269
270
  """通过边界组激活/钝化边界
270
271
 
272
+ 形参顺序与命令流 StgBd, Index, OP, type, grp, pos 一致。
273
+
271
274
  Args:
272
275
  op (int): 操作
273
276
  * 1 = 添加
@@ -276,11 +279,14 @@ class Stage:
276
279
  * 1 = 激活
277
280
  * 0 = 钝化
278
281
  group_name (str): 待操作的边界组名称
279
-
282
+ pos (int|None): 变形位置,缺省时不下发
283
+ * 1 = 变形前(默认)
284
+ * 0 = 变形后
285
+
280
286
  Raises:
281
287
  RuntimeError: 操作失败时抛出异常
282
288
  """
283
- ok, err = osis_stage_boundary(self.no, op, type, group_name)
289
+ ok, err = osis_stage_boundary(self.no, op, type, group_name, pos)
284
290
  if not ok:
285
291
  raise RuntimeError(f"阶段 {self.no} 定义边界组 {group_name} 失败: {err}")
286
292
 
@@ -1,30 +1,22 @@
1
1
  """命令流 → pyosis 代码生成器.
2
2
 
3
- 所有普通命令经 routes.ROUTES 透传:
4
- - direct: engine.method(args...)
5
- - chain: engine.get(key).method(reordered args...)
3
+ 只有三类映射(详见 routes.py 的模块说明):
4
+ - direct: engine.method(f0, f1, ...)
5
+ - chain: engine.get(fk).method(其余字段原序)
6
+ - list: 前 n_head 个字段按位置传,其余聚合成一个 list
6
7
 
7
- 长参数列表(≥ KWARGS_MIN 个形参、签名可内省、无 *args)的调用生成为
8
- 关键字实参——命令流字段重排不再静默错位到别的形参上。
9
- 矩阵 *dim / 赋值仍由 MatrixAccumulator 合并为 engine.matrix(...)。
8
+ 生成的调用一律使用位置实参: 第 N 个实参对应命令流第 N 个字段。
9
+ 矩阵 *dim / 赋值由 MatrixAccumulator 合并为 engine.matrix(...)。
10
10
  未注册命令 → engine.run("原始命令流")。
11
-
12
- generate_lines(commands, ctx=None) 的 ctx 为跨命令下文:
13
- ctx["creep_grades"]: 编号 → CONC 材料等级集合(由 out_to_python 预扫描)
14
- ctx["warnings"]: fixer 追加的告警,作为注释行插在对应调用前
15
11
  """
16
12
 
17
13
  from __future__ import annotations
18
14
 
19
15
  from typing import List
20
16
 
21
- from .introspect import positional_param_names, resolve_chain_method, resolve_callable
22
17
  from .matrix import MatrixAccumulator
23
18
  from .parser import ParsedCommand
24
- from .routes import CMD_ALIASES, REST_FIXERS, ROUTES
25
-
26
- # 形参个数达到该值的调用才生成关键字实参;短调用保持位置实参(生成的代码更紧凑)
27
- KWARGS_MIN = 5
19
+ from .routes import CMD_ALIASES, ROUTES
28
20
 
29
21
  _ROUTE_ALIASES = {
30
22
  "clear": "Clear",
@@ -39,6 +31,7 @@ _ROUTE_ALIASES = {
39
31
  }
40
32
  _SKIP_COMMANDS = frozenset({"CalcSecProp"})
41
33
 
34
+
42
35
  def _format_value(raw: str) -> str:
43
36
  s = raw.strip()
44
37
  if s == "":
@@ -64,78 +57,48 @@ def _route_key(name: str) -> str:
64
57
 
65
58
 
66
59
  def _fallback_run(cmd: ParsedCommand) -> str:
67
- """未注册命令的兜底:用 engine.run("...") 包裹原始命令流,确保所有命令都可执行。"""
60
+ """未注册命令(或字段不足)的兜底:用 engine.run("...") 包裹原始命令流。"""
68
61
  raw = cmd.source.replace("\\", "\\\\").replace('"', '\\"')
69
62
  return f'engine.run("{raw}")'
70
63
 
71
64
 
72
- def _join_args(fields: list[str], func) -> str:
73
- """按目标方法签名渲染实参:长签名用关键字实参,其余位置实参。"""
74
- formatted = [_format_value(v) for v in fields]
75
- if not formatted:
76
- return ""
77
- if len(formatted) >= KWARGS_MIN and func is not None:
78
- names = positional_param_names(func)
79
- # 实参个数须不超过形参个数(逐位对应),否则映射不可靠,退回位置实参
80
- if names and len(formatted) <= len(names):
81
- return ", ".join(f"{n}={v}" for n, v in zip(names, formatted))
82
- return ", ".join(formatted)
65
+ def _join_args(fields: list[str]) -> str:
66
+ return ", ".join(_format_value(v) for v in fields)
83
67
 
84
68
 
85
- def _render_route(cmd: ParsedCommand, ctx: dict | None) -> str:
86
- """按 ROUTES 生成单行 Python 调用,无 per-command 特殊分支。"""
87
- key = _route_key(cmd.name)
88
- route = ROUTES.get(key)
69
+ def _render_route(cmd: ParsedCommand) -> str:
70
+ """按 ROUTES 生成单行 Python 调用,无任何 per-command 特殊分支。"""
71
+ route = ROUTES.get(_route_key(cmd.name))
89
72
  if route is None:
90
73
  return _fallback_run(cmd)
91
74
 
92
- engine = ctx.get("engine") if ctx else None
93
-
94
75
  fields = cmd.fields[1:]
95
76
 
96
77
  if isinstance(route, str):
97
- fixer = REST_FIXERS.get(key)
98
- if fixer is not None:
99
- fields = fixer(fields, ctx)
100
- args = _join_args(fields, resolve_callable(engine, route) if engine else None)
101
- return f"{route}({args})"
102
-
103
- if isinstance(route, tuple) and route[0] == "list":
104
- # 前 n_head 个字段按位置传,其余合并成一个 list 字面量
105
- # (如 Spline3D 的坐标序列,接口收的是 list 而不是展平的多个实参)
106
- _, target, n_head = route[:3]
107
- head, tail = list(fields[:n_head]), list(fields[n_head:])
108
- head_args = _join_args(head, resolve_callable(engine, target) if engine else None)
109
- tail_lit = "[" + ", ".join(_format_value(v) for v in tail) + "]"
78
+ return f"{route}({_join_args(fields)})"
79
+
80
+ if route[0] == "chain":
81
+ _, get_path, method_name, key_index = route
82
+ if key_index >= len(fields):
83
+ return _fallback_run(cmd)
84
+ key_field = _format_value(fields[key_index])
85
+ rest = fields[:key_index] + fields[key_index + 1:]
86
+ return f"{get_path}({key_field}).{method_name}({_join_args(rest)})"
87
+
88
+ if route[0] == "list":
89
+ _, target, n_head = route
90
+ head, tail = fields[:n_head], fields[n_head:]
91
+ tail_lit = "[" + _join_args(tail) + "]"
92
+ head_args = _join_args(head)
110
93
  return f"{target}({head_args}, {tail_lit})" if head_args else f"{target}({tail_lit})"
111
94
 
112
- if isinstance(route, tuple) and route[0] == "chain":
113
- _, get_path, method_name, skip = route[:4]
114
- rest_prefix = route[4] if len(route) > 4 else 0
115
- if len(fields) <= skip:
116
- return f"{get_path}().{method_name}()"
117
- key_field = fields[skip]
118
- rest_fields = list(fields[:rest_prefix]) + list(fields[skip + 1:])
119
- fixer = REST_FIXERS.get(key)
120
- if fixer is not None:
121
- rest_fields = fixer(rest_fields, ctx)
122
- method = resolve_chain_method(engine, get_path, method_name) if engine else None
123
- args = _join_args(rest_fields, method)
124
- formatted_key = _format_value(key_field)
125
- return f"{get_path}({formatted_key}).{method_name}({args})"
126
-
127
95
  return _fallback_run(cmd)
128
96
 
129
97
 
130
- def generate_lines(commands: List[ParsedCommand], ctx: dict | None = None) -> List[str]:
131
- """生成 Python 调用行;矩阵命令合并为 engine.matrix(...)。
132
-
133
- ctx 同时传 engine 实例时可启用关键字实参;fixer 告警以注释行形式
134
- 插在对应调用前。
135
- """
98
+ def generate_lines(commands: List[ParsedCommand]) -> List[str]:
99
+ """生成 Python 调用行;矩阵命令合并为 engine.matrix(...)。"""
136
100
  lines: List[str] = []
137
101
  accumulator = MatrixAccumulator()
138
- warnings = ctx.setdefault("warnings", []) if ctx is not None else None
139
102
 
140
103
  for cmd in commands:
141
104
  if cmd.name in _SKIP_COMMANDS:
@@ -155,11 +118,7 @@ def generate_lines(commands: List[ParsedCommand], ctx: dict | None = None) -> Li
155
118
  if flushed:
156
119
  lines.append(flushed)
157
120
 
158
- rendered = _render_route(cmd, ctx)
159
- if warnings:
160
- lines.extend(f"# 注意: {w}" for w in warnings)
161
- warnings.clear()
162
- lines.append(rendered)
121
+ lines.append(_render_route(cmd))
163
122
 
164
123
  flushed = accumulator.flush()
165
124
  if flushed:
@@ -168,5 +127,5 @@ def generate_lines(commands: List[ParsedCommand], ctx: dict | None = None) -> Li
168
127
  return lines
169
128
 
170
129
 
171
- def generate(commands: List[ParsedCommand], ctx: dict | None = None) -> str:
172
- return "\n".join(generate_lines(commands, ctx)) + "\n"
130
+ def generate(commands: List[ParsedCommand]) -> str:
131
+ return "\n".join(generate_lines(commands)) + "\n"
@@ -304,41 +304,8 @@ def _insert_method_doc_comments(lines: list[str]) -> list[str]:
304
304
  return out
305
305
 
306
306
 
307
- # ── 跨命令下文:CONC 材料 → 收缩徐变引用 ────────────────────────────
307
+ # ── 写入 prep 模块 ──────────────────────────────────────────────
308
308
 
309
- def _strip_quotes(raw: str) -> str:
310
- return raw.strip().strip("\"'")
311
-
312
-
313
- def _scan_creep_grades(commands: Iterable[ParsedCommand]) -> dict[str, set[str]]:
314
- """预扫描 Material 命令,建立 {收缩徐变编号: {混凝土等级, ...}}。
315
-
316
- 命令流: Material,No,Name,CONC,Code,Grade,CrepShrk[,Dmp]
317
- .out 中 PROPERTY(CrpShrk) 段在 MATERIAL 段之前,前向引用必须先扫全量。
318
- """
319
- grades: dict[str, set[str]] = {}
320
- for cmd in commands:
321
- if _route_key(cmd.name) != "Material":
322
- continue
323
- f = cmd.fields
324
- for i in range(1, len(f)):
325
- if _strip_quotes(f[i]).upper() != "CONC":
326
- continue
327
- grade = _strip_quotes(f[i + 2]) if i + 2 < len(f) else ""
328
- creep = _strip_quotes(f[i + 3]) if i + 3 < len(f) else ""
329
- if grade and creep:
330
- grades.setdefault(creep, set()).add(grade)
331
- break
332
- return grades
333
-
334
-
335
- def _route_key(name: str) -> str:
336
- """与 generator._route_key 一致的命令名归一(此处避免循环导入,本地实现)。"""
337
- from pyosis.transfer.routes import CMD_ALIASES
338
- return CMD_ALIASES.get(name, name)
339
-
340
-
341
- # 写入 prep 模块
342
309
  def _write_prep_module(prep_dir: Path, module: str, lines: list[str]) -> Path:
343
310
  """写入 prep 模块;lines 为空时写 pass stub。
344
311
 
@@ -439,25 +406,17 @@ def write_prep_outputs(out_path: Path, prep_dir: Path) -> tuple[int, list[Path]]
439
406
  text = _read_out_text(out_path)
440
407
  preamble, by_module = _split_by_module(text)
441
408
 
442
- # 跨命令下文:先扫全量命令拿到 CONC 材料等级 → 收缩徐变编号 的引用关系,
443
- # _fix_creep_shrk 升级旧 CrpShrk 时据此推断 fcuk(而不是写死 50MPa)。
444
- # engine 只用于方法签名内省(生成关键字实参),不产生连接。
445
- all_cmds: list[ParsedCommand] = list(preamble)
446
- for cmds in by_module.values():
447
- all_cmds.extend(cmds)
448
- ctx: dict = {"engine": _get_engine(), "creep_grades": _scan_creep_grades(all_cmds)}
449
-
450
409
  code_line_count = 0
451
410
  prep_paths: list[Path] = []
452
411
 
453
412
  for module in MODULE_ORDER:
454
413
  cmds = by_module.get(module, [])
455
- lines = generate_lines(cmds, ctx) if cmds else []
414
+ lines = generate_lines(cmds) if cmds else []
456
415
  code_line_count += len(lines)
457
416
  prep_paths.append(_write_prep_module(prep_dir, module, lines))
458
417
 
459
418
  # 前言(典型 clear/clc)放到 main.py 顶部;无前言时为空列表
460
- preamble_lines = generate_lines(preamble, ctx) if preamble else []
419
+ preamble_lines = generate_lines(preamble) if preamble else []
461
420
 
462
421
  (prep_dir / "_0_engine.py").write_text(
463
422
  '"""模块级单例 OSISEngine,供同包内其他 prep 模块 import 使用。\n\n'
pyosis/transfer/parser.py CHANGED
@@ -10,7 +10,6 @@
10
10
  - 分号分隔的多条命令
11
11
  - 空行
12
12
  - *dim / 矩阵赋值(kind=matrix_dim / matrix_assign)
13
- - OSIS 粘连命令拆分(如 BothSectionOffset → Both + SectionOffset)
14
13
  """
15
14
 
16
15
  from __future__ import annotations
@@ -21,9 +20,6 @@ from typing import Iterator, List
21
20
 
22
21
  from .split import split_cmd, split_commands
23
22
 
24
- # OSIS 导出时将下一条命令名粘在上一个字段末尾的情况(如 BothSectionOffset)
25
- _GLUED_TAIL_COMMANDS = ("SectionOffset",)
26
-
27
23
  # 矩阵赋值命令正则表达式
28
24
  MATRIX_ASSIGN_RE = re.compile(r"^(\w+)\[([\d,\s]+)\]\s*=\s*(.+)$")
29
25
  # 注释行正则表达式
@@ -66,46 +62,6 @@ def _join_continuation_lines(lines: List[str]) -> List[str]:
66
62
  return result
67
63
 
68
64
 
69
- def _split_glued_command_fields(fields: List[str]) -> List[List[str]]:
70
- """将粘连字段拆成多条命令的 fields 列表。
71
-
72
- 例: SteelPlate,...,BothSectionOffset,50,... →
73
- [SteelPlate,...,Both] + [SectionOffset,50,...]
74
- """
75
- if not fields:
76
- return [fields]
77
-
78
- groups: List[List[str]] = []
79
- current = list(fields)
80
-
81
- while current:
82
- split_at: int | None = None
83
- tail_cmd: str | None = None
84
- prefix: str | None = None
85
-
86
- for i, field in enumerate(current):
87
- for tail in _GLUED_TAIL_COMMANDS:
88
- if len(field) > len(tail) and field.endswith(tail):
89
- split_at = i
90
- tail_cmd = tail
91
- prefix = field[: -len(tail)]
92
- break
93
- if split_at is not None:
94
- break
95
-
96
- if split_at is None:
97
- groups.append(current)
98
- break
99
-
100
- head = current[:split_at]
101
- if prefix:
102
- head.append(prefix)
103
- groups.append(head)
104
- current = [tail_cmd] + current[split_at + 1 :] # type: ignore[list-item]
105
-
106
- return groups
107
-
108
-
109
65
  # 去除一行内的 // 注释(保留 // 之前的有效命令部分)
110
66
  def strip_inline_comment(line: str) -> str:
111
67
  if "//" not in line:
@@ -178,12 +134,8 @@ def _parse_one_command(source: str) -> List[ParsedCommand]:
178
134
  ]
179
135
 
180
136
  result: List[ParsedCommand] = []
181
- # 处理粘连命令
182
- for group in _split_glued_command_fields(fields):
183
- if not group:
184
- continue
185
- sub_source = ",".join(group)
186
- result.append(_make_parsed_command(group, sub_source))
137
+ if fields:
138
+ result.append(_make_parsed_command(fields, source))
187
139
  return result
188
140
 
189
141
 
pyosis/transfer/routes.py CHANGED
@@ -1,22 +1,24 @@
1
1
  """命令流 → pyosis 路由表
2
2
 
3
- 字典格式:
4
- key = OSIS 命令名
5
- value = (kind, ...)
6
- kind:
7
- "direct": str (engine 方法路径)
8
- "chain": (engine_get_path, obj_method_name, skip_fields)
9
- Cmd,fields[skip_fields=0]=key, fields[skip_fields+1:]=args
10
- 生成: engine.get(key).method(args...)
3
+ 转换规则(全局唯一,不再为单个命令写例外):
4
+ Cmd, f0, f1, f2, ... 的字段顺序必须与目标函数的位置参数顺序一致。
11
5
 
12
- fixer 签名: fixer(rest, ctx=None) -> list[str]
13
- ctx 为生成器下文(dict),无跨命令信息时忽略;key 约定:
14
- ctx["creep_grades"]: {收缩徐变编号(str): {"C40", ...}} 引用它的 CONC 材料等级
15
- ctx["warnings"]: list[str],fixer 追加、生成器作为注释行输出
6
+ key = OSIS 命令名
7
+ value = 目标,三种形态:
8
+ "direct": str (engine 方法路径)
9
+ 生成: engine.method(f0, f1, ...)
10
+ ("chain", get_path, method_name, key_index)
11
+ 第 key_index 个字段用于取对象,其余字段保持原序:
12
+ 生成: get(f[key_index]).method(f0, ..., f[key_index-1],
13
+ f[key_index+1], ...)
14
+ ("list", target, n_head)
15
+ 前 n_head 个字段按位置传,其余字段聚合成一个 list:
16
+ 生成: target(f0, ..., f[n_head-1], [f[n_head], f[n_head+1], ...])
17
+
18
+ 字段重排/补位/旧格式升级一律通过修改对应的 Python 函数解决,不要在这里
19
+ 增加 fixer。
16
20
  """
17
21
 
18
- import re
19
-
20
22
  # 5.01 版 .out 使用缩写命令名,生成代码前统一归一化为全名
21
23
  CMD_ALIASES = {
22
24
  "N": "Node",
@@ -44,118 +46,6 @@ CMD_ALIASES = {
44
46
  "StgRmv": "StageRmv",
45
47
  }
46
48
 
47
- # 命令流字段顺序 ≠ 方法形参顺序的命令,按字段名重排后再生成调用
48
- def _fix_section_mesh(rest: list[str], ctx=None) -> list[str]:
49
- """SectionMesh 字段序 → set_mesh(mesh_method, mesh_size, part_id)
50
-
51
- 新格式: PartID, MeshMethod, MeshSize → MeshMethod, MeshSize, PartID
52
- 旧格式: MeshMethod, MeshSize → 原样(part_id 缺省 1)
53
- """
54
- if len(rest) == 3:
55
- part_id, mesh_method, mesh_size = rest
56
- return [mesh_method, mesh_size, part_id]
57
- return rest
58
-
59
-
60
- def _fix_section_part(rest: list[str], ctx=None) -> list[str]:
61
- """SectionPart 字段序 → add_part(type, part_index, mat_type, e, mu, density, *matrices)
62
-
63
- 命令流: PartIndex, PartMatType, PartE, PartMu, PartDensity, PartGeoType, Matrices...
64
- """
65
- if len(rest) >= 6:
66
- return [rest[5], *rest[:5], *rest[6:]]
67
- return rest
68
-
69
-
70
- _GRADE_RE = re.compile(r"^C(\d+)$", re.IGNORECASE)
71
-
72
-
73
- def _resolve_fcuk(index: str, ctx: dict | None) -> str:
74
- """从引用该收缩徐变特性的 CONC 材料等级推断 fcuk(如 C50 → 5e7,单位随工程)。
75
-
76
- 软件侧 UpdatePreviousCommand 与本转换器旧逻辑都硬编码 50MPa——C40/C55 的
77
- 旧模型会静默算错收缩徐变,这里改为按材料等级取值;多等级共用/无引用时
78
- 保持 50MPa 并追加告警注释。
79
- """
80
- default = "50000000"
81
- if not ctx:
82
- return default
83
- grades = (ctx.get("creep_grades") or {}).get(index.strip().strip('"\'')) or set()
84
- if not grades:
85
- (ctx.setdefault("warnings", [])).append(
86
- f"CrpShrk {index}: 未找到引用它的 CONC 材料,fcuk 保持默认 50MPa"
87
- "(旧命令流未记录强度,请核对该特性参数)"
88
- )
89
- return default
90
- if len(grades) > 1:
91
- (ctx.setdefault("warnings", [])).append(
92
- f"CrpShrk {index}: 被 {'/'.join(sorted(grades))} 多种强度等级共用,"
93
- f"无法唯一推断 fcuk,保持默认 50MPa;请核对该特性参数"
94
- )
95
- return default
96
- m = _GRADE_RE.match(next(iter(grades)).strip())
97
- if not m:
98
- (ctx.setdefault("warnings", [])).append(
99
- f"CrpShrk {index}: 材料等级 {next(iter(grades))!r} 无法换算 fcuk,保持默认 50MPa"
100
- )
101
- return default
102
- return f"{int(m.group(1))}e6"
103
-
104
-
105
- def _fix_creep_shrk(rest: list[str], ctx=None) -> list[str]:
106
- """CrpShrk 旧命令流 → 新 9 字段序(同软件侧 UpdatePreviousCommand 的升级逻辑)
107
-
108
- 新: Index, Name, Code, Fcuk, AVG.Humidity, ComponentApproximateSize,
109
- Type.Coeff, BirthByShrinking, FlyAshRatio
110
- 早期5.01: Index, Name, Humidity, Birth, Type.Coeff, BirthByShrinking,
111
- FlyAshRatio, ComponentApproximateSize (8 字段)
112
- 4.9.6: Index, Name, Humidity, Birth, Type.Coeff, BirthByShrinking (6 字段)
113
-
114
- 旧格式的 Birth(加载龄期)在新命令流里已取消,直接丢弃;
115
- Code 固定 JTG3362_2018;Fcuk 优先按引用材料的混凝土强度等级取值
116
- (C40→4e7),取不到时回退软件升级用的默认值 50MPa 并追加告警。
117
- """
118
- n = len(rest)
119
- if n == 9:
120
- return rest
121
- if n == 6:
122
- index, name, humidity, _birth, type_coeff, shrink_age = rest
123
- fly_ash, size = "0", "1"
124
- elif n == 8:
125
- index, name, humidity, _birth, type_coeff, shrink_age, fly_ash, size = rest
126
- else:
127
- return rest
128
- fcuk = _resolve_fcuk(index, ctx)
129
- return [index, name, "JTG3362_2018", fcuk, humidity, size,
130
- type_coeff, shrink_age, fly_ash]
131
-
132
-
133
- def _fix_infl_algo(rest: list[str], ctx=None) -> list[str]:
134
- """InflAlgo eRef=1 的命令流字段序 → create_ve/create_tcb 形参序
135
-
136
- 命令流 ref=1: ... ref, ESel, SplineName
137
- 方法形参: ... ref, ref_elems, offset_y, offset_z, spline_name
138
- ref=1 时 offset_y/offset_z 不参与命令组装,补两个空列占位,
139
- 把 SplineName 挪到 spline_name 形参上。
140
- """
141
- if len(rest) < 7:
142
- return rest
143
- type_key = rest[1].upper()
144
- ref_idx = 5 if type_key == "VE" else 6
145
- if ref_idx >= len(rest) or rest[ref_idx].strip() != "1":
146
- return rest
147
- if len(rest) != ref_idx + 3:
148
- return rest
149
- return rest[:-1] + ["", "", rest[-1]]
150
-
151
-
152
- REST_FIXERS = {
153
- "SectionMesh": _fix_section_mesh,
154
- "SectionPart": _fix_section_part,
155
- "CrpShrk": _fix_creep_shrk,
156
- "InflAlgo": _fix_infl_algo,
157
- }
158
-
159
49
  ROUTES = {
160
50
  # ─── CONTROL ───
161
51
  "Acel": "engine.control.set_gravity_acceleration",
@@ -259,10 +149,10 @@ ROUTES = {
259
149
  "LoadCaseDel": "engine.load.delete",
260
150
  "LCMod": "engine.load.rename",
261
151
  # Load 子命令: Load,type,lcName,... → engine.load.get(lcName).create(type, ...)
262
- "Load": ("chain", "engine.load.get", "create", 1, 1), # skip=1(lcName), rest_prefix=1(type)
152
+ "Load": ("chain", "engine.load.get", "create", 1),
263
153
  # LoadDel/LoadMod: TYPE, LC, ... → engine.load.get(LC).delete/modify(TYPE, ...)
264
- "LoadDel": ("chain", "engine.load.get", "delete", 1, 1),
265
- "LoadMod": ("chain", "engine.load.get", "modify", 1, 1),
154
+ "LoadDel": ("chain", "engine.load.get", "delete", 1),
155
+ "LoadMod": ("chain", "engine.load.get", "modify", 1),
266
156
  "PlanarLoad": "engine.load.planar_load",
267
157
  "PlanarLoadCopy": "engine.load.planar_load_copy_flat",
268
158
  "PlanarLoadDel": "engine.load.planar_load_del",
@@ -382,4 +272,4 @@ ROUTES = {
382
272
  "Clc": "engine.clc",
383
273
  "APDL": "engine.import_apdl",
384
274
  "Matrix": "engine.matrix",
385
- }
275
+ }
@@ -1,149 +0,0 @@
1
- """engine 方法签名内省(transfer 专用)。
2
-
3
- 供两处使用:
4
- - generator: 把长参数列表的调用生成为关键字实参,参数重排不再破坏生成的脚本
5
- - out_to_python: 取方法 docstring 首行作为生成代码的注释
6
-
7
- engine 属性是 property 描述符,链式调用中间还有 .get(...) 返回的实体对象,
8
- 所以这里按" property 返回注解 → 管理器类 → get 注解 → 实体类"逐层解析,
9
- 全程不实例化任何管理器。
10
- """
11
-
12
- from __future__ import annotations
13
-
14
- import inspect
15
- import sys
16
- from typing import Any
17
-
18
-
19
- def _eval_annotation(target: Any, owner: Any = None) -> list[type]:
20
- """把返回注解规整成类列表(展开 Optional/Union/list 等泛型)。
21
-
22
- target 为字符串注解时(from __future__ annotations 下必然如此),
23
- 在 owner 函数所属模块的命名空间里求值。
24
- """
25
- ann = target
26
- if isinstance(ann, str):
27
- mod = sys.modules.get(getattr(owner, "__module__", "")) if owner is not None else None
28
- ns = dict(vars(mod)) if mod is not None else {}
29
- try:
30
- ann = eval(ann, ns) # noqa: S307 - 注解来自本仓库代码
31
- except Exception:
32
- return []
33
- out: list[type] = []
34
- if isinstance(ann, type):
35
- out.append(ann)
36
- else:
37
- for arg in getattr(ann, "__args__", ()) or ():
38
- if isinstance(arg, type):
39
- out.append(arg)
40
- else:
41
- for inner in getattr(arg, "__args__", ()) or ():
42
- if isinstance(inner, type):
43
- out.append(inner)
44
- return out
45
-
46
-
47
- def _walk_class(cls: type, name: str) -> Any:
48
- """在类(含基类)上找属性;property 描述符取其 fget 继续向下解析。"""
49
- attr = vars(cls).get(name)
50
- if attr is None:
51
- return None
52
- if isinstance(attr, property):
53
- return attr.fget
54
- return attr
55
-
56
-
57
- def _return_class_of(func: Any) -> type | None:
58
- """取函数返回注解中的第一个类(property.fget → 管理器类等)。"""
59
- try:
60
- sig = inspect.signature(func)
61
- except (ValueError, TypeError):
62
- return None
63
- if sig.return_annotation is inspect.Parameter.empty:
64
- return None
65
- for cls in _eval_annotation(sig.return_annotation, func):
66
- return cls
67
- return None
68
-
69
-
70
- def resolve_callable(engine: object, dotted: str) -> Any:
71
- """解析 'engine.section.get' / 'engine.prop.creep_shrink.create' 等点路径。
72
-
73
- 实例属性直接 getattr(property 已实例化解析);类级回退按
74
- "property → fget → 返回注解类" 逐层下钻,全程不实例化。失败返回 None。
75
- """
76
- parts = dotted.split(".")
77
- if len(parts) < 2 or parts[0] != "engine":
78
- return None
79
-
80
- # 1) 实例直取
81
- try:
82
- obj: Any = engine
83
- for p in parts[1:]:
84
- obj = getattr(obj, p)
85
- if callable(obj):
86
- return obj
87
- except AttributeError:
88
- pass
89
-
90
- # 2) 类级解析(OSISEngine 上的 property 需经 fget → 返回注解类下钻)
91
- from pyosis.core.engine import OSISEngine
92
-
93
- obj: Any = OSISEngine
94
- for p in parts[1:]:
95
- if isinstance(obj, type):
96
- obj = _walk_class(obj, p)
97
- else:
98
- # 上一段解析出的是 getter 函数:落到其返回注解类上继续找
99
- cls = _return_class_of(obj) if callable(obj) else None
100
- obj = _walk_class(cls, p) if cls is not None else None
101
- if obj is None:
102
- return None
103
- if isinstance(obj, (staticmethod, classmethod)):
104
- obj = obj.__func__
105
- return obj if callable(obj) else None
106
-
107
-
108
- def resolve_chain_method(engine: object, get_path: str, method_name: str) -> Any:
109
- """解析链式路由的终点方法: engine.<mgr>.get(k).<method>。
110
-
111
- get 的返回注解给出实体类(Section/LoadCase/...),再在其上找 method。
112
- """
113
- get_func = resolve_callable(engine, get_path)
114
- if get_func is None:
115
- return None
116
- try:
117
- sig = inspect.signature(get_func)
118
- except (ValueError, TypeError):
119
- return None
120
- if sig.return_annotation is inspect.Parameter.empty:
121
- return None
122
- for cls in _eval_annotation(sig.return_annotation, get_func):
123
- target = vars(cls).get(method_name)
124
- if target is not None and callable(target):
125
- return target
126
- return None
127
-
128
-
129
- def positional_param_names(func: Any) -> tuple[str, ...] | None:
130
- """取函数的显式位置参数名;带 *args/**kwargs 或解析失败时返回 None。
131
-
132
- 类上取到的方法带 self,跳过;返回 None 表示调用方应保持位置实参生成。
133
- """
134
- try:
135
- sig = inspect.signature(func)
136
- except (ValueError, TypeError):
137
- return None
138
- names: list[str] = []
139
- for p in sig.parameters.values():
140
- if p.kind in (p.VAR_POSITIONAL, p.VAR_KEYWORD):
141
- return None
142
- if p.kind is p.POSITIONAL_ONLY:
143
- return None
144
- if p.kind is p.KEYWORD_ONLY:
145
- continue
146
- names.append(p.name)
147
- if names and names[0] in ("self", "cls"):
148
- names = names[1:]
149
- return tuple(names)