ANYfeSolver 0.5.0a1__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.
Files changed (751) hide show
  1. anyfesolver/__init__.py +1075 -0
  2. anyfesolver/_b2_attachment_elimination_dev.py +261 -0
  3. anyfesolver/_b2_f10_f11_point_attachment.py +163 -0
  4. anyfesolver/_b2_loaded_point_trace_dev.py +173 -0
  5. anyfesolver/_b2_physical_flexibility_linear.py +707 -0
  6. anyfesolver/_b2_physical_linear_batch_dev.py +491 -0
  7. anyfesolver/_b2_physical_linear_definition.py +415 -0
  8. anyfesolver/_b2_physical_load_bubbles.py +282 -0
  9. anyfesolver/_compensated_contractions.py +497 -0
  10. anyfesolver/_compensated_native.py +437 -0
  11. anyfesolver/_corotational_batch.py +219 -0
  12. anyfesolver/_director_trace.py +214 -0
  13. anyfesolver/_dyadic_bilinear.py +76 -0
  14. anyfesolver/_dyadic_factor_chain.py +25 -0
  15. anyfesolver/_ge_beam3_adaptive_arc_program.py +286 -0
  16. anyfesolver/_ge_beam3_analysis_combined.py +102 -0
  17. anyfesolver/_ge_beam3_analysis_fibre_translation.py +130 -0
  18. anyfesolver/_ge_beam3_analysis_modal_snapshot.py +27 -0
  19. anyfesolver/_ge_beam3_analysis_nodal_program.py +140 -0
  20. anyfesolver/_ge_beam3_analysis_translation.py +147 -0
  21. anyfesolver/_ge_beam3_analysis_translation_modal.py +84 -0
  22. anyfesolver/_ge_beam3_arc_geometry.py +89 -0
  23. anyfesolver/_ge_beam3_arc_program.py +304 -0
  24. anyfesolver/_ge_beam3_authoritative_cell_seed.py +25 -0
  25. anyfesolver/_ge_beam3_cell_identity.py +52 -0
  26. anyfesolver/_ge_beam3_centered_batched_finite_inertia.py +132 -0
  27. anyfesolver/_ge_beam3_centered_finite_inertia.py +171 -0
  28. anyfesolver/_ge_beam3_centered_mixed.py +104 -0
  29. anyfesolver/_ge_beam3_centered_reference.py +187 -0
  30. anyfesolver/_ge_beam3_centered_so3_strain.py +76 -0
  31. anyfesolver/_ge_beam3_complementary_section.py +122 -0
  32. anyfesolver/_ge_beam3_compliance_snapshot_guard.py +20 -0
  33. anyfesolver/_ge_beam3_connected_dynamic.py +486 -0
  34. anyfesolver/_ge_beam3_connected_trajectory.py +258 -0
  35. anyfesolver/_ge_beam3_conservative_backtrack.py +26 -0
  36. anyfesolver/_ge_beam3_controlled_fibre_modes.py +105 -0
  37. anyfesolver/_ge_beam3_coupled_beam_subdomain.py +128 -0
  38. anyfesolver/_ge_beam3_coupled_modes.py +256 -0
  39. anyfesolver/_ge_beam3_deterministic_reduction.py +264 -0
  40. anyfesolver/_ge_beam3_displacement_program.py +255 -0
  41. anyfesolver/_ge_beam3_durable_coupled.py +251 -0
  42. anyfesolver/_ge_beam3_dynamic_elastic_state.py +461 -0
  43. anyfesolver/_ge_beam3_effective_deadline.py +58 -0
  44. anyfesolver/_ge_beam3_elastic_seed_continuation.py +223 -0
  45. anyfesolver/_ge_beam3_elastic_seed_modal.py +139 -0
  46. anyfesolver/_ge_beam3_equilibrium_line_program.py +98 -0
  47. anyfesolver/_ge_beam3_equilibrium_schur_solver.py +96 -0
  48. anyfesolver/_ge_beam3_factor_chain_modes.py +103 -0
  49. anyfesolver/_ge_beam3_fibre_cell.py +408 -0
  50. anyfesolver/_ge_beam3_fibre_distributed_couples.py +191 -0
  51. anyfesolver/_ge_beam3_fibre_kinematic_cell.py +75 -0
  52. anyfesolver/_ge_beam3_fibre_line_program.py +157 -0
  53. anyfesolver/_ge_beam3_fibre_line_work.py +87 -0
  54. anyfesolver/_ge_beam3_fibre_reference_modal.py +104 -0
  55. anyfesolver/_ge_beam3_fibre_schur_solver.py +134 -0
  56. anyfesolver/_ge_beam3_fibre_section.py +286 -0
  57. anyfesolver/_ge_beam3_fibre_static_boundary.py +113 -0
  58. anyfesolver/_ge_beam3_g1_analysis.py +307 -0
  59. anyfesolver/_ge_beam3_g1_elastic.py +161 -0
  60. anyfesolver/_ge_beam3_g1_element.py +185 -0
  61. anyfesolver/_ge_beam3_g1_operator.py +137 -0
  62. anyfesolver/_ge_beam3_g2_analysis.py +176 -0
  63. anyfesolver/_ge_beam3_g2_constraints.py +162 -0
  64. anyfesolver/_ge_beam3_g3_analysis.py +385 -0
  65. anyfesolver/_ge_beam3_g3_constraints.py +168 -0
  66. anyfesolver/_ge_beam3_g3b_owner.py +296 -0
  67. anyfesolver/_ge_beam3_g3b_q4_reference.py +186 -0
  68. anyfesolver/_ge_beam3_g3b_reference.py +206 -0
  69. anyfesolver/_ge_beam3_g3b_result_schema.py +107 -0
  70. anyfesolver/_ge_beam3_g3b_s3_reference.py +185 -0
  71. anyfesolver/_ge_beam3_g3b_weighted_reference.py +193 -0
  72. anyfesolver/_ge_beam3_g3c_affine_q4_chart.py +58 -0
  73. anyfesolver/_ge_beam3_g3c_affine_q4_increment_chart.py +257 -0
  74. anyfesolver/_ge_beam3_g3c_affine_q4_recovery.py +434 -0
  75. anyfesolver/_ge_beam3_g3c_affine_q4_registry.py +127 -0
  76. anyfesolver/_ge_beam3_g3c_b2_physical.py +153 -0
  77. anyfesolver/_ge_beam3_g3c_b2_physical_adapter.py +160 -0
  78. anyfesolver/_ge_beam3_g3c_definition.py +117 -0
  79. anyfesolver/_ge_beam3_g3c_local_beam.py +188 -0
  80. anyfesolver/_ge_beam3_g3c_local_shell.py +371 -0
  81. anyfesolver/_ge_beam3_g3c_owner.py +400 -0
  82. anyfesolver/_ge_beam3_g3c_physical_authority.py +203 -0
  83. anyfesolver/_ge_beam3_g3c_physical_owner.py +556 -0
  84. anyfesolver/_ge_beam3_g3c_recovery.py +91 -0
  85. anyfesolver/_ge_beam3_g3c_so3_numerics.py +81 -0
  86. anyfesolver/_ge_beam3_g3c_stable/__init__.py +1 -0
  87. anyfesolver/_ge_beam3_g3c_stable/authority.py +152 -0
  88. anyfesolver/_ge_beam3_g3c_stable/beam.py +196 -0
  89. anyfesolver/_ge_beam3_g3c_stable/boundary.py +38 -0
  90. anyfesolver/_ge_beam3_g3c_stable/chart.py +23 -0
  91. anyfesolver/_ge_beam3_g3c_stable/compensated.py +46 -0
  92. anyfesolver/_ge_beam3_g3c_stable/element.py +190 -0
  93. anyfesolver/_ge_beam3_g3c_stable/fit.py +54 -0
  94. anyfesolver/_ge_beam3_g3c_stable/joint.py +255 -0
  95. anyfesolver/_ge_beam3_g3c_stable/line_work.py +92 -0
  96. anyfesolver/_ge_beam3_g3c_stable/operator.py +147 -0
  97. anyfesolver/_ge_beam3_g3c_stable/owner.py +415 -0
  98. anyfesolver/_ge_beam3_g3c_stable/shell.py +358 -0
  99. anyfesolver/_ge_beam3_g4_completion.py +186 -0
  100. anyfesolver/_ge_beam3_g4a_station_transaction.py +385 -0
  101. anyfesolver/_ge_beam3_g5_completion.py +68 -0
  102. anyfesolver/_ge_beam3_g6_domain.py +354 -0
  103. anyfesolver/_ge_beam3_generalized_cell.py +172 -0
  104. anyfesolver/_ge_beam3_generalized_ellipsoid_section.py +215 -0
  105. anyfesolver/_ge_beam3_generalized_static_boundary.py +233 -0
  106. anyfesolver/_ge_beam3_lifted_kinetic_factor.py +26 -0
  107. anyfesolver/_ge_beam3_line_fibre_modes.py +121 -0
  108. anyfesolver/_ge_beam3_load_program.py +275 -0
  109. anyfesolver/_ge_beam3_loaded_modal.py +225 -0
  110. anyfesolver/_ge_beam3_mixed_ad.py +286 -0
  111. anyfesolver/_ge_beam3_native_analysis.py +484 -0
  112. anyfesolver/_ge_beam3_native_arc.py +269 -0
  113. anyfesolver/_ge_beam3_native_arc_adaptive.py +251 -0
  114. anyfesolver/_ge_beam3_native_arc_restart.py +88 -0
  115. anyfesolver/_ge_beam3_native_arc_source.py +62 -0
  116. anyfesolver/_ge_beam3_native_buckling.py +206 -0
  117. anyfesolver/_ge_beam3_native_combined_couples.py +179 -0
  118. anyfesolver/_ge_beam3_native_combined_restart.py +205 -0
  119. anyfesolver/_ge_beam3_native_definition.py +238 -0
  120. anyfesolver/_ge_beam3_native_distributed_element.py +220 -0
  121. anyfesolver/_ge_beam3_native_distributed_loading.py +92 -0
  122. anyfesolver/_ge_beam3_native_distributed_program.py +165 -0
  123. anyfesolver/_ge_beam3_native_distributed_recovery.py +34 -0
  124. anyfesolver/_ge_beam3_native_distributed_restart.py +221 -0
  125. anyfesolver/_ge_beam3_native_dynamic_analysis.py +149 -0
  126. anyfesolver/_ge_beam3_native_dynamic_restart.py +261 -0
  127. anyfesolver/_ge_beam3_native_fibre_current_modal.py +104 -0
  128. anyfesolver/_ge_beam3_native_fibre_recovery.py +34 -0
  129. anyfesolver/_ge_beam3_native_fibre_restart.py +211 -0
  130. anyfesolver/_ge_beam3_native_fibre_static_element.py +193 -0
  131. anyfesolver/_ge_beam3_native_force_adaptation.py +56 -0
  132. anyfesolver/_ge_beam3_native_generalized_combined_couples.py +188 -0
  133. anyfesolver/_ge_beam3_native_generalized_combined_restart.py +207 -0
  134. anyfesolver/_ge_beam3_native_generalized_element.py +222 -0
  135. anyfesolver/_ge_beam3_native_generalized_factor_modal.py +122 -0
  136. anyfesolver/_ge_beam3_native_generalized_loading.py +92 -0
  137. anyfesolver/_ge_beam3_native_generalized_modal.py +274 -0
  138. anyfesolver/_ge_beam3_native_generalized_paired_modal.py +13 -0
  139. anyfesolver/_ge_beam3_native_generalized_parameter.py +89 -0
  140. anyfesolver/_ge_beam3_native_generalized_program.py +196 -0
  141. anyfesolver/_ge_beam3_native_generalized_recovery.py +34 -0
  142. anyfesolver/_ge_beam3_native_generalized_restart.py +243 -0
  143. anyfesolver/_ge_beam3_native_history_profile.py +53 -0
  144. anyfesolver/_ge_beam3_native_line_loading.py +93 -0
  145. anyfesolver/_ge_beam3_native_line_program.py +150 -0
  146. anyfesolver/_ge_beam3_native_line_recovery.py +34 -0
  147. anyfesolver/_ge_beam3_native_line_restart.py +197 -0
  148. anyfesolver/_ge_beam3_native_line_static_element.py +220 -0
  149. anyfesolver/_ge_beam3_native_load_admission.py +37 -0
  150. anyfesolver/_ge_beam3_native_midpoint.py +1004 -0
  151. anyfesolver/_ge_beam3_native_multi_shell_contact.py +539 -0
  152. anyfesolver/_ge_beam3_native_pair_contact.py +236 -0
  153. anyfesolver/_ge_beam3_native_shell_contact.py +357 -0
  154. anyfesolver/_ge_beam3_native_spatial_couples.py +176 -0
  155. anyfesolver/_ge_beam3_native_spatial_restart.py +204 -0
  156. anyfesolver/_ge_beam3_native_transient.py +467 -0
  157. anyfesolver/_ge_beam3_native_translation.py +225 -0
  158. anyfesolver/_ge_beam3_native_translation_restart.py +54 -0
  159. anyfesolver/_ge_beam3_operator_validation_scope.py +53 -0
  160. anyfesolver/_ge_beam3_p5/__init__.py +11 -0
  161. anyfesolver/_ge_beam3_p5/algebra.py +91 -0
  162. anyfesolver/_ge_beam3_p5/arrays.py +29 -0
  163. anyfesolver/_ge_beam3_p5/chart.py +45 -0
  164. anyfesolver/_ge_beam3_p5/codec.py +82 -0
  165. anyfesolver/_ge_beam3_p5/committed_modal.py +191 -0
  166. anyfesolver/_ge_beam3_p5/compensated.py +118 -0
  167. anyfesolver/_ge_beam3_p5/compensated_coordinates.py +44 -0
  168. anyfesolver/_ge_beam3_p5/core.py +159 -0
  169. anyfesolver/_ge_beam3_p5/element.py +207 -0
  170. anyfesolver/_ge_beam3_p5/factors.py +61 -0
  171. anyfesolver/_ge_beam3_p5/inertia.py +120 -0
  172. anyfesolver/_ge_beam3_p5/mass.py +70 -0
  173. anyfesolver/_ge_beam3_p5/mixed.py +256 -0
  174. anyfesolver/_ge_beam3_p5/reference_modal.py +73 -0
  175. anyfesolver/_ge_beam3_p5/section.py +139 -0
  176. anyfesolver/_ge_beam3_p5/typed_schema.py +111 -0
  177. anyfesolver/_ge_beam3_p5_centered/__init__.py +6 -0
  178. anyfesolver/_ge_beam3_p5_centered/codec.py +84 -0
  179. anyfesolver/_ge_beam3_p5_centered/committed_modal.py +192 -0
  180. anyfesolver/_ge_beam3_p5_centered/core.py +171 -0
  181. anyfesolver/_ge_beam3_p5_centered/element.py +216 -0
  182. anyfesolver/_ge_beam3_p5_centered/mass.py +99 -0
  183. anyfesolver/_ge_beam3_p5_centered/positions.py +34 -0
  184. anyfesolver/_ge_beam3_p5_centered/reference_modal.py +73 -0
  185. anyfesolver/_ge_beam3_p5_coordinates/__init__.py +6 -0
  186. anyfesolver/_ge_beam3_p5_coordinates/codec.py +84 -0
  187. anyfesolver/_ge_beam3_p5_coordinates/committed_modal.py +192 -0
  188. anyfesolver/_ge_beam3_p5_coordinates/core.py +163 -0
  189. anyfesolver/_ge_beam3_p5_coordinates/element.py +213 -0
  190. anyfesolver/_ge_beam3_p5_coordinates/positions.py +102 -0
  191. anyfesolver/_ge_beam3_p5_coordinates/reference_modal.py +73 -0
  192. anyfesolver/_ge_beam3_p5_loads/__init__.py +7 -0
  193. anyfesolver/_ge_beam3_p5_loads/codec.py +85 -0
  194. anyfesolver/_ge_beam3_p5_loads/core.py +192 -0
  195. anyfesolver/_ge_beam3_p5_loads/element.py +243 -0
  196. anyfesolver/_ge_beam3_p5_loads/state.py +120 -0
  197. anyfesolver/_ge_beam3_p5_loads/work.py +45 -0
  198. anyfesolver/_ge_beam3_p5_seeded/__init__.py +9 -0
  199. anyfesolver/_ge_beam3_p5_seeded/codec.py +87 -0
  200. anyfesolver/_ge_beam3_p5_seeded/core.py +197 -0
  201. anyfesolver/_ge_beam3_p5_seeded/element.py +245 -0
  202. anyfesolver/_ge_beam3_p5_seeded/state.py +122 -0
  203. anyfesolver/_ge_beam3_p5_seeded/work.py +47 -0
  204. anyfesolver/_ge_beam3_pose_joint.py +268 -0
  205. anyfesolver/_ge_beam3_precise_geometric_work.py +147 -0
  206. anyfesolver/_ge_beam3_reassembled_signed_modes.py +101 -0
  207. anyfesolver/_ge_beam3_reference_identity.py +92 -0
  208. anyfesolver/_ge_beam3_refined_fibre_schur_solver.py +104 -0
  209. anyfesolver/_ge_beam3_refinement_capacity.py +19 -0
  210. anyfesolver/_ge_beam3_relative_virgin_reference_modes.py +60 -0
  211. anyfesolver/_ge_beam3_retained_arc.py +350 -0
  212. anyfesolver/_ge_beam3_retained_arc_geometry.py +66 -0
  213. anyfesolver/_ge_beam3_retained_arc_modal.py +125 -0
  214. anyfesolver/_ge_beam3_retained_elastic.py +134 -0
  215. anyfesolver/_ge_beam3_retained_fibre.py +209 -0
  216. anyfesolver/_ge_beam3_retained_fibre_control.py +270 -0
  217. anyfesolver/_ge_beam3_retained_fibre_element.py +58 -0
  218. anyfesolver/_ge_beam3_retained_fibre_modal.py +155 -0
  219. anyfesolver/_ge_beam3_retained_fibre_modes.py +189 -0
  220. anyfesolver/_ge_beam3_retained_fibre_program.py +68 -0
  221. anyfesolver/_ge_beam3_retained_fibre_state.py +268 -0
  222. anyfesolver/_ge_beam3_retained_force_program.py +72 -0
  223. anyfesolver/_ge_beam3_retained_generalized.py +186 -0
  224. anyfesolver/_ge_beam3_retained_generalized_modal.py +171 -0
  225. anyfesolver/_ge_beam3_retained_generalized_program.py +63 -0
  226. anyfesolver/_ge_beam3_retained_generalized_state.py +281 -0
  227. anyfesolver/_ge_beam3_retained_nodal_loading.py +111 -0
  228. anyfesolver/_ge_beam3_retained_plastic.py +116 -0
  229. anyfesolver/_ge_beam3_retained_plastic_modes.py +144 -0
  230. anyfesolver/_ge_beam3_retained_plastic_program.py +69 -0
  231. anyfesolver/_ge_beam3_retained_plastic_state.py +165 -0
  232. anyfesolver/_ge_beam3_retained_state.py +194 -0
  233. anyfesolver/_ge_beam3_retained_translation_control.py +345 -0
  234. anyfesolver/_ge_beam3_retained_translation_modal.py +137 -0
  235. anyfesolver/_ge_beam3_schur_line_program.py +98 -0
  236. anyfesolver/_ge_beam3_seeded_fibre_control.py +175 -0
  237. anyfesolver/_ge_beam3_seeded_load_program.py +301 -0
  238. anyfesolver/_ge_beam3_seeded_loaded_modal.py +226 -0
  239. anyfesolver/_ge_beam3_seeded_signed_modes.py +150 -0
  240. anyfesolver/_ge_beam3_shared_kinematic_split.py +53 -0
  241. anyfesolver/_ge_beam3_shell_joint_state.py +396 -0
  242. anyfesolver/_ge_beam3_shell_joint_trial.py +217 -0
  243. anyfesolver/_ge_beam3_signed_loaded_modes.py +140 -0
  244. anyfesolver/_ge_beam3_spatial_fibre_program.py +113 -0
  245. anyfesolver/_ge_beam3_spatial_nodal_moments.py +38 -0
  246. anyfesolver/_ge_beam3_station_resultant_cell.py +235 -0
  247. anyfesolver/_ge_beam3_variational_shell.py +211 -0
  248. anyfesolver/_ge_beam3_virgin_reference_modes.py +60 -0
  249. anyfesolver/_impact_coupling.py +162 -0
  250. anyfesolver/_native_authority_dag.py +77 -0
  251. anyfesolver/_native_dyadic_interval_inertia.py +64 -0
  252. anyfesolver/_native_exact_shift_chain_modes.py +140 -0
  253. anyfesolver/_native_exact_shift_inertia.py +86 -0
  254. anyfesolver/_native_factor_chain_modes.py +192 -0
  255. anyfesolver/_native_guard.cpp +828 -0
  256. anyfesolver/_native_guard_dispatch.py +140 -0
  257. anyfesolver/_native_large_factor_chain.py +55 -0
  258. anyfesolver/_native_material_protocol.py +51 -0
  259. anyfesolver/_native_midpoint_controller.py +90 -0
  260. anyfesolver/_native_modal_capacity.py +26 -0
  261. anyfesolver/_native_paired_factor_chain_modes.py +244 -0
  262. anyfesolver/_native_reassembled_factor_modes.py +185 -0
  263. anyfesolver/_native_reference_factor_spectrum.py +102 -0
  264. anyfesolver/_native_reference_modal.py +180 -0
  265. anyfesolver/_native_relative_factor_chain_modes.py +204 -0
  266. anyfesolver/_native_relative_reference_factor_spectrum.py +110 -0
  267. anyfesolver/_native_retained_step.py +15 -0
  268. anyfesolver/_native_rotation_state.py +797 -0
  269. anyfesolver/_native_signed_factor_modes.py +257 -0
  270. anyfesolver/_native_signed_kinetic_factor_modes.py +279 -0
  271. anyfesolver/_native_stationary_spectrum.py +79 -0
  272. anyfesolver/_nonlinear_events.py +150 -0
  273. anyfesolver/_nonlinear_seed.py +80 -0
  274. anyfesolver/_paired_modal_arithmetic.py +71 -0
  275. anyfesolver/_plate_stability_continuation.py +171 -0
  276. anyfesolver/_q4_assumed_strain_plasticity.py +502 -0
  277. anyfesolver/_qualified_authority_epoch.py +561 -0
  278. anyfesolver/_relative_reference_svd.py +44 -0
  279. anyfesolver/_stiffened_shell_affine_endpoint.py +232 -0
  280. anyfesolver/_stiffened_shell_algorithmic_pullback.py +38 -0
  281. anyfesolver/_stiffened_shell_arc_checkpoint.py +422 -0
  282. anyfesolver/_stiffened_shell_arc_control.py +108 -0
  283. anyfesolver/_stiffened_shell_arc_metric.py +222 -0
  284. anyfesolver/_stiffened_shell_arc_publication.py +153 -0
  285. anyfesolver/_stiffened_shell_arc_trial.py +310 -0
  286. anyfesolver/_stiffened_shell_b2_affine_resolution.py +101 -0
  287. anyfesolver/_stiffened_shell_b2_assembly_diagnostics.py +172 -0
  288. anyfesolver/_stiffened_shell_b2_definition_ownership.py +189 -0
  289. anyfesolver/_stiffened_shell_b2_experimental.py +153 -0
  290. anyfesolver/_stiffened_shell_b2_nodal_footprint.py +273 -0
  291. anyfesolver/_stiffened_shell_b2_physical_rigid_footprint.py +237 -0
  292. anyfesolver/_stiffened_shell_b2_q4_panel_experimental.py +2447 -0
  293. anyfesolver/_stiffened_shell_b2_q4_point_experimental.py +251 -0
  294. anyfesolver/_stiffened_shell_b2_reference_buckling.py +413 -0
  295. anyfesolver/_stiffened_shell_b3_chart.py +70 -0
  296. anyfesolver/_stiffened_shell_b3_local_adapter.py +141 -0
  297. anyfesolver/_stiffened_shell_beam_history.py +107 -0
  298. anyfesolver/_stiffened_shell_bl5_local_experimental.py +173 -0
  299. anyfesolver/_stiffened_shell_bl5_native_elastic.py +28 -0
  300. anyfesolver/_stiffened_shell_branch_event_trial.py +58 -0
  301. anyfesolver/_stiffened_shell_consumer_capabilities.py +124 -0
  302. anyfesolver/_stiffened_shell_coordinate_support.py +110 -0
  303. anyfesolver/_stiffened_shell_displacement_adaptive.py +327 -0
  304. anyfesolver/_stiffened_shell_displacement_checkpoint.py +360 -0
  305. anyfesolver/_stiffened_shell_displacement_control.py +326 -0
  306. anyfesolver/_stiffened_shell_displacement_corrector.py +293 -0
  307. anyfesolver/_stiffened_shell_displacement_increment.py +121 -0
  308. anyfesolver/_stiffened_shell_distributing_footprint.py +354 -0
  309. anyfesolver/_stiffened_shell_distributing_pose.py +267 -0
  310. anyfesolver/_stiffened_shell_f06_increment_arithmetic.py +205 -0
  311. anyfesolver/_stiffened_shell_ge_body_load.py +300 -0
  312. anyfesolver/_stiffened_shell_ge_checkpoint_binary.py +472 -0
  313. anyfesolver/_stiffened_shell_ge_distributed_load.py +210 -0
  314. anyfesolver/_stiffened_shell_ge_distributed_programme.py +175 -0
  315. anyfesolver/_stiffened_shell_ge_distributing_finite.py +242 -0
  316. anyfesolver/_stiffened_shell_ge_distributing_reference.py +296 -0
  317. anyfesolver/_stiffened_shell_ge_experimental.py +2454 -0
  318. anyfesolver/_stiffened_shell_ge_finite_experimental.py +2714 -0
  319. anyfesolver/_stiffened_shell_ge_mixed_modal_mass.py +33 -0
  320. anyfesolver/_stiffened_shell_ge_point_buckling.py +723 -0
  321. anyfesolver/_stiffened_shell_ge_pressure_load.py +366 -0
  322. anyfesolver/_stiffened_shell_ge_reference_modal.py +580 -0
  323. anyfesolver/_stiffened_shell_generalized_recovery.py +150 -0
  324. anyfesolver/_stiffened_shell_increment_control.py +217 -0
  325. anyfesolver/_stiffened_shell_l1_assembly_experimental.py +420 -0
  326. anyfesolver/_stiffened_shell_l1_local_experimental.py +284 -0
  327. anyfesolver/_stiffened_shell_l1_supported_work_experimental.py +146 -0
  328. anyfesolver/_stiffened_shell_native_distributed_load.py +120 -0
  329. anyfesolver/_stiffened_shell_native_gravity.py +236 -0
  330. anyfesolver/_stiffened_shell_nodal_footprint.py +255 -0
  331. anyfesolver/_stiffened_shell_physical_q4_mass.py +98 -0
  332. anyfesolver/_stiffened_shell_physical_s3_mass.py +53 -0
  333. anyfesolver/_stiffened_shell_point_recovery.py +49 -0
  334. anyfesolver/_stiffened_shell_q4_algorithmic_pullback.py +88 -0
  335. anyfesolver/_stiffened_shell_q4_material_event.py +114 -0
  336. anyfesolver/_stiffened_shell_q4_reference.py +65 -0
  337. anyfesolver/_stiffened_shell_rotation_charts.py +58 -0
  338. anyfesolver/_stiffened_shell_s3_algorithmic_pullback.py +59 -0
  339. anyfesolver/_stiffened_shell_s3_conservative_buckling.py +28 -0
  340. anyfesolver/_stiffened_shell_s3_dead_work_candidate.py +107 -0
  341. anyfesolver/_stiffened_shell_s3_material_event.py +30 -0
  342. anyfesolver/_stiffened_shell_same_parent_trial.py +224 -0
  343. anyfesolver/_stiffened_shell_selected_recovery.py +113 -0
  344. anyfesolver/_stiffened_shell_staged_load_experimental.py +392 -0
  345. anyfesolver/_stiffened_shell_stress_free_reference.py +204 -0
  346. anyfesolver/_wire_types.py +17 -0
  347. anyfesolver/activity.py +1537 -0
  348. anyfesolver/algebraic_dynamics.py +2864 -0
  349. anyfesolver/analysis_session.py +897 -0
  350. anyfesolver/anystructure_fem_mode.py +1637 -0
  351. anyfesolver/arc_length.py +2587 -0
  352. anyfesolver/assembly.py +1830 -0
  353. anyfesolver/b3_ge.py +179 -0
  354. anyfesolver/baselines.py +303 -0
  355. anyfesolver/beam_sections.py +292 -0
  356. anyfesolver/beam_shell_verification.py +4685 -0
  357. anyfesolver/beam_validity.py +110 -0
  358. anyfesolver/benchmarks.py +495 -0
  359. anyfesolver/boundary.py +1680 -0
  360. anyfesolver/buckling.py +2136 -0
  361. anyfesolver/buckling_validity.py +91 -0
  362. anyfesolver/capacity_workflow.py +431 -0
  363. anyfesolver/capsule_runtime_guard.py +99 -0
  364. anyfesolver/cases.py +173 -0
  365. anyfesolver/composite_strip_verification.py +297 -0
  366. anyfesolver/concentrated_mass.py +84 -0
  367. anyfesolver/constraint_audit.py +553 -0
  368. anyfesolver/contact.py +4785 -0
  369. anyfesolver/contact_performance.py +301 -0
  370. anyfesolver/control.py +206 -0
  371. anyfesolver/corotational.py +1935 -0
  372. anyfesolver/corotational_performance.py +157 -0
  373. anyfesolver/current_state_tangent.py +2780 -0
  374. anyfesolver/cylinder_benchmarks.py +369 -0
  375. anyfesolver/damage_matrix_performance.py +617 -0
  376. anyfesolver/dynamics.py +2833 -0
  377. anyfesolver/e4_pl_element.py +8265 -0
  378. anyfesolver/e4_pl_enriched.py +194 -0
  379. anyfesolver/e4_pl_enriched_nonlinear.py +159 -0
  380. anyfesolver/e4_pl_s3_element.py +9752 -0
  381. anyfesolver/e4_pl_s3_initial_fields.py +101 -0
  382. anyfesolver/e4_pl_s3_state.py +4723 -0
  383. anyfesolver/e4_pl_s3_v2_element.py +1844 -0
  384. anyfesolver/e4_pl_s3_v2b_element.py +1936 -0
  385. anyfesolver/e4_pl_s3_v2c_element.py +2196 -0
  386. anyfesolver/e4_pl_s3_v2d_element.py +2621 -0
  387. anyfesolver/e4_pl_s3_v2d_state.py +376 -0
  388. anyfesolver/element_capabilities.py +159 -0
  389. anyfesolver/element_qualification.py +432 -0
  390. anyfesolver/elements.py +6327 -0
  391. anyfesolver/experimental_csr_assembly.py +238 -0
  392. anyfesolver/external_references.py +1253 -0
  393. anyfesolver/fe_core.py +832 -0
  394. anyfesolver/floating_pressure_regions.py +119 -0
  395. anyfesolver/floating_response.py +486 -0
  396. anyfesolver/floating_transient.py +1281 -0
  397. anyfesolver/fracture.py +621 -0
  398. anyfesolver/ge_beam3_curved_reference.py +725 -0
  399. anyfesolver/ge_beam3_element.py +885 -0
  400. anyfesolver/ge_beam3_mixed_element.py +1216 -0
  401. anyfesolver/ge_beam3_mixed_state.py +814 -0
  402. anyfesolver/ge_beam3_native.py +129 -0
  403. anyfesolver/ge_beam3_native_connected_dynamics.py +24 -0
  404. anyfesolver/ge_beam3_native_dynamics.py +70 -0
  405. anyfesolver/ge_beam3_state.py +672 -0
  406. anyfesolver/general_contact/__init__.py +151 -0
  407. anyfesolver/general_contact/_enriched_multitarget_empty.py +202 -0
  408. anyfesolver/general_contact/_enriched_multitarget_trial.py +183 -0
  409. anyfesolver/general_contact/_results_archive_common.py +65 -0
  410. anyfesolver/general_contact/algebraic_path.py +206 -0
  411. anyfesolver/general_contact/arc_contact.py +237 -0
  412. anyfesolver/general_contact/arc_results_archive.py +158 -0
  413. anyfesolver/general_contact/augmentation.py +157 -0
  414. anyfesolver/general_contact/automatic_domain.py +621 -0
  415. anyfesolver/general_contact/beam_chain_consistent.py +357 -0
  416. anyfesolver/general_contact/beam_chain_end_geometry.py +237 -0
  417. anyfesolver/general_contact/beam_chain_ends.py +220 -0
  418. anyfesolver/general_contact/beam_chain_pair.py +416 -0
  419. anyfesolver/general_contact/beam_curve_end_geometry.py +254 -0
  420. anyfesolver/general_contact/beam_curve_ends.py +237 -0
  421. anyfesolver/general_contact/beam_curve_pair.py +794 -0
  422. anyfesolver/general_contact/beam_curve_pair_static.py +303 -0
  423. anyfesolver/general_contact/beam_end_radial_geometry.py +221 -0
  424. anyfesolver/general_contact/beam_end_topology.py +15 -0
  425. anyfesolver/general_contact/beam_hemisphere_coupled_tool.py +61 -0
  426. anyfesolver/general_contact/beam_hemisphere_cylinder.py +134 -0
  427. anyfesolver/general_contact/beam_hemisphere_cylinder_motion.py +89 -0
  428. anyfesolver/general_contact/beam_hemisphere_cylinder_work.py +216 -0
  429. anyfesolver/general_contact/beam_hemisphere_plane.py +175 -0
  430. anyfesolver/general_contact/beam_hemisphere_s3_support.py +152 -0
  431. anyfesolver/general_contact/beam_hemisphere_sphere.py +135 -0
  432. anyfesolver/general_contact/beam_hemisphere_sphere_work.py +114 -0
  433. anyfesolver/general_contact/beam_hemisphere_support.py +211 -0
  434. anyfesolver/general_contact/beam_pair.py +523 -0
  435. anyfesolver/general_contact/beam_pair_end_geometry.py +269 -0
  436. anyfesolver/general_contact/beam_pair_ends.py +222 -0
  437. anyfesolver/general_contact/beam_plane.py +425 -0
  438. anyfesolver/general_contact/beam_radial.py +500 -0
  439. anyfesolver/general_contact/beam_radial_ends.py +223 -0
  440. anyfesolver/general_contact/beam_s3_directional_rates.py +196 -0
  441. anyfesolver/general_contact/beam_s3_rotational_transient.py +126 -0
  442. anyfesolver/general_contact/beam_s3_transient.py +139 -0
  443. anyfesolver/general_contact/beam_shell.py +648 -0
  444. anyfesolver/general_contact/beam_shell_patch.py +395 -0
  445. anyfesolver/general_contact/beam_temporal_bounds.py +230 -0
  446. anyfesolver/general_contact/capability.py +101 -0
  447. anyfesolver/general_contact/capped_cylinder.py +618 -0
  448. anyfesolver/general_contact/contact_search.py +95 -0
  449. anyfesolver/general_contact/core.py +1769 -0
  450. anyfesolver/general_contact/curved_s3_q4_work.py +238 -0
  451. anyfesolver/general_contact/curved_shell_skin.py +520 -0
  452. anyfesolver/general_contact/d1_interior_profile.py +427 -0
  453. anyfesolver/general_contact/deformable_beam_s3_caps.py +143 -0
  454. anyfesolver/general_contact/deformable_beam_s3_line.py +211 -0
  455. anyfesolver/general_contact/deformable_beam_s3_static.py +152 -0
  456. anyfesolver/general_contact/descriptor_rates.py +61 -0
  457. anyfesolver/general_contact/enriched_cold_predictor.py +161 -0
  458. anyfesolver/general_contact/enriched_moment_batch.py +337 -0
  459. anyfesolver/general_contact/enriched_multitarget.py +308 -0
  460. anyfesolver/general_contact/enriched_multitarget_gap.py +156 -0
  461. anyfesolver/general_contact/enriched_multitarget_moments.py +194 -0
  462. anyfesolver/general_contact/enriched_multitarget_topology.py +171 -0
  463. anyfesolver/general_contact/enriched_nonlinear.py +440 -0
  464. anyfesolver/general_contact/enriched_overlap.py +299 -0
  465. anyfesolver/general_contact/enriched_path.py +253 -0
  466. anyfesolver/general_contact/enriched_small_cut.py +310 -0
  467. anyfesolver/general_contact/enriched_static.py +481 -0
  468. anyfesolver/general_contact/enriched_union.py +320 -0
  469. anyfesolver/general_contact/equilibrated_pressure_pivot.py +140 -0
  470. anyfesolver/general_contact/event_subdivision.py +273 -0
  471. anyfesolver/general_contact/finite_mixed_state.py +133 -0
  472. anyfesolver/general_contact/finite_rigid_patch.py +196 -0
  473. anyfesolver/general_contact/finite_rigid_support.py +129 -0
  474. anyfesolver/general_contact/finite_rigid_sweep.py +53 -0
  475. anyfesolver/general_contact/finite_rotation_predictor.py +171 -0
  476. anyfesolver/general_contact/finite_rotation_skin.py +212 -0
  477. anyfesolver/general_contact/finite_rotation_state.py +106 -0
  478. anyfesolver/general_contact/finite_rotation_sweep.py +161 -0
  479. anyfesolver/general_contact/finite_v2d_state.py +104 -0
  480. anyfesolver/general_contact/fixed_projection_graph.py +205 -0
  481. anyfesolver/general_contact/fixed_projection_s3_events.py +235 -0
  482. anyfesolver/general_contact/free_rigid.py +134 -0
  483. anyfesolver/general_contact/friction_point.py +378 -0
  484. anyfesolver/general_contact/gap_extrema.py +119 -0
  485. anyfesolver/general_contact/guided_pair_transient_geometry.py +138 -0
  486. anyfesolver/general_contact/initial_contact_seed.py +368 -0
  487. anyfesolver/general_contact/linearized_pivot.py +595 -0
  488. anyfesolver/general_contact/material_work_diagnostics.py +159 -0
  489. anyfesolver/general_contact/moment_batch_ad.py +129 -0
  490. anyfesolver/general_contact/moment_batch_points.py +75 -0
  491. anyfesolver/general_contact/moving.py +1031 -0
  492. anyfesolver/general_contact/multiple_beam_rigid.py +248 -0
  493. anyfesolver/general_contact/multiple_beam_s3_caps.py +199 -0
  494. anyfesolver/general_contact/multiple_beam_s3_transient.py +223 -0
  495. anyfesolver/general_contact/multiple_projected_pairs.py +196 -0
  496. anyfesolver/general_contact/multiple_shell_planes.py +226 -0
  497. anyfesolver/general_contact/native_activation_static.py +143 -0
  498. anyfesolver/general_contact/native_checkpoint_results.py +213 -0
  499. anyfesolver/general_contact/native_curve_union.py +268 -0
  500. anyfesolver/general_contact/native_curved_geometry.py +374 -0
  501. anyfesolver/general_contact/native_curved_pair_partition.py +590 -0
  502. anyfesolver/general_contact/native_curved_plane_work.py +864 -0
  503. anyfesolver/general_contact/native_curved_s3_work.py +472 -0
  504. anyfesolver/general_contact/native_event_polynomial.py +164 -0
  505. anyfesolver/general_contact/native_fibre_context.py +173 -0
  506. anyfesolver/general_contact/native_fibre_results.py +74 -0
  507. anyfesolver/general_contact/native_initial_guess.py +122 -0
  508. anyfesolver/general_contact/native_material_activation.py +108 -0
  509. anyfesolver/general_contact/native_material_plane.py +111 -0
  510. anyfesolver/general_contact/native_material_s3.py +209 -0
  511. anyfesolver/general_contact/native_multi_s3_static.py +722 -0
  512. anyfesolver/general_contact/native_normal_angles.py +233 -0
  513. anyfesolver/general_contact/native_pair_error_budget.py +49 -0
  514. anyfesolver/general_contact/native_replay_arithmetic.py +103 -0
  515. anyfesolver/general_contact/native_replay_diagnostics.py +90 -0
  516. anyfesolver/general_contact/native_retained_body_junction.py +99 -0
  517. anyfesolver/general_contact/native_retained_body_pair.py +220 -0
  518. anyfesolver/general_contact/native_retained_body_projection.py +160 -0
  519. anyfesolver/general_contact/native_retained_body_static.py +62 -0
  520. anyfesolver/general_contact/native_retained_cell_pair.py +185 -0
  521. anyfesolver/general_contact/native_retained_curve_cell.py +102 -0
  522. anyfesolver/general_contact/native_retained_line_plane.py +210 -0
  523. anyfesolver/general_contact/native_retained_line_s3.py +440 -0
  524. anyfesolver/general_contact/native_retained_line_s3_work.py +91 -0
  525. anyfesolver/general_contact/native_retained_pair_static.py +845 -0
  526. anyfesolver/general_contact/native_retained_s3_static.py +554 -0
  527. anyfesolver/general_contact/native_retained_static.py +478 -0
  528. anyfesolver/general_contact/native_retained_station.py +222 -0
  529. anyfesolver/general_contact/native_retained_whole_pair.py +2120 -0
  530. anyfesolver/general_contact/native_s3_swept.py +149 -0
  531. anyfesolver/general_contact/native_shell_static_driver.py +144 -0
  532. anyfesolver/general_contact/native_surface_activation.py +391 -0
  533. anyfesolver/general_contact/native_surface_bounds.py +198 -0
  534. anyfesolver/general_contact/native_surface_contributor.py +121 -0
  535. anyfesolver/general_contact/native_surface_crossing.py +81 -0
  536. anyfesolver/general_contact/native_surface_event_sequence.py +320 -0
  537. anyfesolver/general_contact/native_surface_extrema.py +72 -0
  538. anyfesolver/general_contact/native_surface_friction_integral.py +1724 -0
  539. anyfesolver/general_contact/native_surface_front.py +742 -0
  540. anyfesolver/general_contact/native_surface_front_boundary.py +160 -0
  541. anyfesolver/general_contact/native_surface_front_precision.py +78 -0
  542. anyfesolver/general_contact/native_surface_front_work.py +118 -0
  543. anyfesolver/general_contact/native_surface_history.py +334 -0
  544. anyfesolver/general_contact/native_surface_normal.py +324 -0
  545. anyfesolver/general_contact/native_surface_patch.py +213 -0
  546. anyfesolver/general_contact/native_surface_path.py +348 -0
  547. anyfesolver/general_contact/native_surface_quadrature.py +212 -0
  548. anyfesolver/general_contact/native_surface_s3_friction.py +340 -0
  549. anyfesolver/general_contact/native_surface_support.py +776 -0
  550. anyfesolver/general_contact/native_surface_transaction.py +198 -0
  551. anyfesolver/general_contact/native_transient_multi_shell.py +108 -0
  552. anyfesolver/general_contact/native_transient_pair.py +61 -0
  553. anyfesolver/general_contact/native_transient_shell.py +44 -0
  554. anyfesolver/general_contact/normal_s3_skin_path.py +163 -0
  555. anyfesolver/general_contact/overlap.py +443 -0
  556. anyfesolver/general_contact/pair.py +466 -0
  557. anyfesolver/general_contact/patch_broadphase.py +111 -0
  558. anyfesolver/general_contact/patch_mortar.py +593 -0
  559. anyfesolver/general_contact/patch_sliding.py +644 -0
  560. anyfesolver/general_contact/plane_newmark_events.py +278 -0
  561. anyfesolver/general_contact/pointwise_patch.py +288 -0
  562. anyfesolver/general_contact/polynomial_roots.py +312 -0
  563. anyfesolver/general_contact/pressure_basis.py +241 -0
  564. anyfesolver/general_contact/pressure_diagnostics.py +155 -0
  565. anyfesolver/general_contact/pressure_overlay.py +182 -0
  566. anyfesolver/general_contact/pressure_space.py +51 -0
  567. anyfesolver/general_contact/q4_material_checkpoint.py +276 -0
  568. anyfesolver/general_contact/q4_overlap_local_bound.py +1111 -0
  569. anyfesolver/general_contact/q4_q4_overlap_derivatives.py +234 -0
  570. anyfesolver/general_contact/q4_q4_swept_bound.py +58 -0
  571. anyfesolver/general_contact/q4_s3_overlap_derivatives.py +1159 -0
  572. anyfesolver/general_contact/q4_s3_tiny_wedge.py +180 -0
  573. anyfesolver/general_contact/q4_skin_work.py +87 -0
  574. anyfesolver/general_contact/q4_source_mortar_energy.py +181 -0
  575. anyfesolver/general_contact/q4_source_overlap.py +401 -0
  576. anyfesolver/general_contact/q4_target_overlap.py +181 -0
  577. anyfesolver/general_contact/request_identity.py +192 -0
  578. anyfesolver/general_contact/rigid_translation.py +199 -0
  579. anyfesolver/general_contact/runtime.py +27 -0
  580. anyfesolver/general_contact/s3_friction_chart_interval.py +104 -0
  581. anyfesolver/general_contact/s3_friction_coverage.py +165 -0
  582. anyfesolver/general_contact/s3_friction_dyadic_interval.py +39 -0
  583. anyfesolver/general_contact/s3_friction_history_path.py +111 -0
  584. anyfesolver/general_contact/s3_friction_mesh_coverage.py +145 -0
  585. anyfesolver/general_contact/s3_friction_mesh_gap.py +74 -0
  586. anyfesolver/general_contact/s3_friction_mesh_monolithic.py +150 -0
  587. anyfesolver/general_contact/s3_friction_monolithic.py +121 -0
  588. anyfesolver/general_contact/s3_friction_moving_coverage.py +114 -0
  589. anyfesolver/general_contact/s3_friction_pair.py +237 -0
  590. anyfesolver/general_contact/s3_friction_point.py +129 -0
  591. anyfesolver/general_contact/s3_friction_prepared_path.py +254 -0
  592. anyfesolver/general_contact/s3_friction_replay.py +1094 -0
  593. anyfesolver/general_contact/s3_friction_rim_path.py +69 -0
  594. anyfesolver/general_contact/s3_friction_rim_transaction.py +23 -0
  595. anyfesolver/general_contact/s3_friction_static.py +267 -0
  596. anyfesolver/general_contact/s3_friction_swept_gap.py +112 -0
  597. anyfesolver/general_contact/s3_friction_touch.py +94 -0
  598. anyfesolver/general_contact/s3_friction_weak_pressure.py +66 -0
  599. anyfesolver/general_contact/s3_overlap_derivatives.py +220 -0
  600. anyfesolver/general_contact/s3_overlap_hermite_gap.py +180 -0
  601. anyfesolver/general_contact/s3_pair_static.py +343 -0
  602. anyfesolver/general_contact/s3_patch_augmented.py +2056 -0
  603. anyfesolver/general_contact/s3_patch_mortar_energy.py +545 -0
  604. anyfesolver/general_contact/s3_patch_static.py +1725 -0
  605. anyfesolver/general_contact/s3_pressure_hermite_bounds.py +395 -0
  606. anyfesolver/general_contact/s3_pressure_polygon_bounds.py +73 -0
  607. anyfesolver/general_contact/s3_q4_gap_resolution.py +191 -0
  608. anyfesolver/general_contact/s3_q4_overlap_derivatives.py +252 -0
  609. anyfesolver/general_contact/s3_q4_swept.py +56 -0
  610. anyfesolver/general_contact/s3_skin_work.py +101 -0
  611. anyfesolver/general_contact/s3_sliding_friction.py +640 -0
  612. anyfesolver/general_contact/s3_stable_plane_gap.py +43 -0
  613. anyfesolver/general_contact/seed_path_vertex_interval.py +323 -0
  614. anyfesolver/general_contact/semismooth.py +133 -0
  615. anyfesolver/general_contact/semismooth_block.py +147 -0
  616. anyfesolver/general_contact/semismooth_path.py +871 -0
  617. anyfesolver/general_contact/shell_pair_hermite_sweep.py +336 -0
  618. anyfesolver/general_contact/shell_sphere_temporal_bounds.py +305 -0
  619. anyfesolver/general_contact/skin_geometry.py +106 -0
  620. anyfesolver/general_contact/sliding.py +349 -0
  621. anyfesolver/general_contact/sphere.py +691 -0
  622. anyfesolver/general_contact/sphere_temporal_bounds.py +241 -0
  623. anyfesolver/general_contact/static_path.py +2608 -0
  624. anyfesolver/general_contact/static_results_archive.py +140 -0
  625. anyfesolver/general_contact/structural_state_bridge.py +196 -0
  626. anyfesolver/general_contact/supported_schur.py +594 -0
  627. anyfesolver/general_contact/swept_patch_broadphase.py +160 -0
  628. anyfesolver/general_contact/transient.py +2921 -0
  629. anyfesolver/general_contact/transient_results_archive.py +491 -0
  630. anyfesolver/general_contact/triangle_mortar_energy.py +280 -0
  631. anyfesolver/general_contact/triangle_pair_energy.py +211 -0
  632. anyfesolver/general_contact/triangulated_rigid.py +94 -0
  633. anyfesolver/general_contact/triangulated_rigid_static.py +399 -0
  634. anyfesolver/general_contact/warped_q4_plane.py +185 -0
  635. anyfesolver/general_contact/warped_q4_skin.py +302 -0
  636. anyfesolver/general_contact/warped_q4_static.py +331 -0
  637. anyfesolver/impact_performance.py +273 -0
  638. anyfesolver/impact_reduced_assembly.py +294 -0
  639. anyfesolver/imperfections.py +397 -0
  640. anyfesolver/inertia_relief.py +676 -0
  641. anyfesolver/initial_field_state.py +54 -0
  642. anyfesolver/jit_compiler.py +135 -0
  643. anyfesolver/kernel_warmup.py +228 -0
  644. anyfesolver/linalg.py +1002 -0
  645. anyfesolver/marine_contributions.py +634 -0
  646. anyfesolver/marine_coupled_equilibrium.py +292 -0
  647. anyfesolver/marine_equilibrium.py +405 -0
  648. anyfesolver/marine_hydro_coordinates.py +346 -0
  649. anyfesolver/marine_linear.py +549 -0
  650. anyfesolver/marine_link.py +306 -0
  651. anyfesolver/marine_mechanical.py +923 -0
  652. anyfesolver/marine_mooring.py +533 -0
  653. anyfesolver/marine_morison.py +331 -0
  654. anyfesolver/marine_potential_flow.py +403 -0
  655. anyfesolver/marine_rigid.py +397 -0
  656. anyfesolver/marine_seabed.py +122 -0
  657. anyfesolver/mass_properties.py +352 -0
  658. anyfesolver/material_curves.py +52 -0
  659. anyfesolver/materials.py +43 -0
  660. anyfesolver/matrix_assembly.py +7330 -0
  661. anyfesolver/mesh_gen.py +904 -0
  662. anyfesolver/mesh_load_bc_verification.py +612 -0
  663. anyfesolver/modal.py +2494 -0
  664. anyfesolver/nonlinear.py +341 -0
  665. anyfesolver/nonlinear_analysis_diagnostics.py +466 -0
  666. anyfesolver/nonlinear_element_evaluation.py +126 -0
  667. anyfesolver/nonlinear_performance.py +2094 -0
  668. anyfesolver/nonlinear_performance_batch_b.py +1173 -0
  669. anyfesolver/nonlinear_performance_batch_c.py +850 -0
  670. anyfesolver/nonlinear_performance_bootstrap.py +164 -0
  671. anyfesolver/nonlinear_reduced_assembly.py +806 -0
  672. anyfesolver/nonlinear_restart.py +1708 -0
  673. anyfesolver/nonlinear_state.py +2800 -0
  674. anyfesolver/nonlinear_static.py +9407 -0
  675. anyfesolver/outcomes.py +694 -0
  676. anyfesolver/plasticity.py +2087 -0
  677. anyfesolver/plasticity_qualification.py +758 -0
  678. anyfesolver/prepared_static.py +1129 -0
  679. anyfesolver/prepared_static_envelopes.py +389 -0
  680. anyfesolver/prepared_static_loads.py +1180 -0
  681. anyfesolver/prepared_static_measures.py +18 -0
  682. anyfesolver/prepared_static_numeric.py +247 -0
  683. anyfesolver/prepared_static_q4.py +297 -0
  684. anyfesolver/prepared_static_recovery.py +2068 -0
  685. anyfesolver/prepared_static_response.py +1013 -0
  686. anyfesolver/prepared_static_shared.py +226 -0
  687. anyfesolver/prepared_static_snapshot.py +323 -0
  688. anyfesolver/prepared_static_vectorized.py +866 -0
  689. anyfesolver/pressure_regions.py +287 -0
  690. anyfesolver/production_readiness.py +343 -0
  691. anyfesolver/quality_control.py +1487 -0
  692. anyfesolver/quantities.py +1289 -0
  693. anyfesolver/recovery.py +4217 -0
  694. anyfesolver/recovery_batches.py +1985 -0
  695. anyfesolver/recovery_policy.py +205 -0
  696. anyfesolver/recovery_s4.py +289 -0
  697. anyfesolver/recovery_shell_frames.py +102 -0
  698. anyfesolver/reference_cases.py +366 -0
  699. anyfesolver/result_capsule.py +2175 -0
  700. anyfesolver/results.py +752 -0
  701. anyfesolver/runtime.py +9819 -0
  702. anyfesolver/s3_reference_batch.py +1338 -0
  703. anyfesolver/s3_v2c_fast_assembly.py +544 -0
  704. anyfesolver/s3_v2d_fast_assembly.py +447 -0
  705. anyfesolver/s4_validity.py +354 -0
  706. anyfesolver/sections.py +67 -0
  707. anyfesolver/sesam_fem/__init__.py +55 -0
  708. anyfesolver/sesam_fem/__main__.py +80 -0
  709. anyfesolver/sesam_fem/diagnostics.py +5 -0
  710. anyfesolver/sesam_fem/document.py +39 -0
  711. anyfesolver/sesam_fem/exporter.py +9 -0
  712. anyfesolver/sesam_fem/importer.py +228 -0
  713. anyfesolver/sesam_fem/records.py +21 -0
  714. anyfesolver/sesam_fem/schema.py +35 -0
  715. anyfesolver/sesam_fem/sif_importer.py +9 -0
  716. anyfesolver/sesam_fem/validation.py +5 -0
  717. anyfesolver/sestra_deep_diagnostics.py +173 -0
  718. anyfesolver/sestra_mixed_verification.py +146 -0
  719. anyfesolver/sestra_structure_benchmarks.py +270 -0
  720. anyfesolver/sestra_three_case.py +215 -0
  721. anyfesolver/sestra_verification.py +523 -0
  722. anyfesolver/shell_benchmarks.py +367 -0
  723. anyfesolver/shell_formulations/director_field.py +799 -0
  724. anyfesolver/shell_formulations/geometry_provenance.py +921 -0
  725. anyfesolver/shell_formulations/mitc4_plus_d_quality.py +318 -0
  726. anyfesolver/shell_formulations/mitc4_plus_d_reference.py +837 -0
  727. anyfesolver/shell_formulations/mitc4_plus_d_scalar.py +209 -0
  728. anyfesolver/shell_formulations/protocol.py +222 -0
  729. anyfesolver/shell_formulations/q4_common.py +271 -0
  730. anyfesolver/shell_formulations/s4_restricted_policy.py +78 -0
  731. anyfesolver/shell_sections.py +394 -0
  732. anyfesolver/solid_submodel.py +930 -0
  733. anyfesolver/static_batch.py +662 -0
  734. anyfesolver/static_envelopes.py +250 -0
  735. anyfesolver/stiffened_shell.py +388 -0
  736. anyfesolver/submodel_transfer.py +1306 -0
  737. anyfesolver/test_cases.py +610 -0
  738. anyfesolver/threading_policy.py +431 -0
  739. anyfesolver/validation.py +719 -0
  740. anyfesolver/vectorized_beam.py +139 -0
  741. anyfesolver/vectorized_generalized_shell.py +448 -0
  742. anyfesolver/vectorized_hill48.py +956 -0
  743. anyfesolver/vectorized_nonlinear.py +360 -0
  744. anyfesolver/vectorized_stiffness.py +694 -0
  745. anyfesolver-0.5.0a1.dist-info/METADATA +374 -0
  746. anyfesolver-0.5.0a1.dist-info/RECORD +751 -0
  747. anyfesolver-0.5.0a1.dist-info/WHEEL +5 -0
  748. anyfesolver-0.5.0a1.dist-info/licenses/COPYRIGHT +1 -0
  749. anyfesolver-0.5.0a1.dist-info/licenses/LICENSE +373 -0
  750. anyfesolver-0.5.0a1.dist-info/licenses/THIRD_PARTY_NOTICES.md +32 -0
  751. anyfesolver-0.5.0a1.dist-info/top_level.txt +1 -0
@@ -0,0 +1,1306 @@
1
+ """Sequential displacement-driven shell submodel transfer.
2
+
3
+ Implements the ANYfeSolver part of the submodelling contract
4
+ (``docs/SUBMODEL_TRANSFER_CONTRACT.md``):
5
+
6
+ * :func:`interpolate_nodal_field` -- evaluate a source solution at target points
7
+ with the source element's own interpolation functions and the rigid transport
8
+ rule ``u(x_f) = u(x_p) + theta(x_p) x (x_f - x_p)``; alternative hits on a
9
+ shared boundary are evaluated too and their spread is recorded;
10
+ * :func:`interpolation_allowance` -- the per-component allowance of one value;
11
+ * :func:`build_driven_trace` / :func:`apply_driven_trace` -- the constraint-reduced
12
+ driven boundary: every driven row is reduced to the model's independent
13
+ coordinates, redundant rows are reported and dropped, inconsistent rows and
14
+ numerically ambiguous rank decisions refuse, and constraint slaves are never
15
+ prescribed directly;
16
+ * :func:`update_driven_trace_values` -- change only the driven values, atomically,
17
+ so a session refreshes the constraint offset without refactorizing;
18
+ * :func:`interface_forces` -- interface forces and retained support reactions from
19
+ one multiplier solve over the physical constraint rows, with equilibrium
20
+ enforced against the force allowance;
21
+ * :func:`estimate_static_error_allowance` / :func:`force_allowance` -- the
22
+ first-order allowance on the solver's own equilibrated operator.
23
+
24
+ This is a nodal-field transfer, not a formulation-native physical recovery.
25
+ Source-result admission (a certified linear static solve) belongs to the
26
+ calling workflow; this module validates shapes, finiteness, element types and
27
+ control parameters and fails closed. Shell admission is an explicit allow-list
28
+ of exact classes, for sources and targets.
29
+ """
30
+
31
+ from __future__ import annotations
32
+
33
+ import hashlib
34
+ from dataclasses import dataclass, field
35
+ from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence, Tuple
36
+
37
+ import numpy as np
38
+ from scipy import sparse
39
+ from scipy.sparse.linalg import LinearOperator, onenormest
40
+
41
+ __all__ = [
42
+ "DOF_NAMES",
43
+ "TRACE_POLICIES",
44
+ "JUNCTION_RANK3",
45
+ "JUNCTION_RANK2",
46
+ "SubmodelTransferError",
47
+ "TransferPoint",
48
+ "TransferValue",
49
+ "TraceRow",
50
+ "DrivenTrace",
51
+ "InterfaceForces",
52
+ "StaticErrorAllowance",
53
+ "admitted_transfer_element_types",
54
+ "element_interpolation_weights",
55
+ "interpolate_nodal_field",
56
+ "interpolation_allowance",
57
+ "rotation_rows",
58
+ "build_driven_trace",
59
+ "apply_driven_trace",
60
+ "update_driven_trace_values",
61
+ "interface_forces",
62
+ "interface_resultant",
63
+ "estimate_static_error_allowance",
64
+ "force_allowance",
65
+ ]
66
+
67
+ DOF_NAMES: Tuple[str, ...] = ("ux", "uy", "uz", "rx", "ry", "rz")
68
+ TRACE_POLICIES: Tuple[str, ...] = ("drive_all", "release_normal_rotation")
69
+ _EPS = float(np.finfo(float).eps)
70
+ #: Junction rule (contract section 4).
71
+ JUNCTION_RANK3 = 1.0e-3
72
+ JUNCTION_RANK2 = 1.0e-9
73
+ #: An equilibrated reduced row whose surviving size lies above its roundoff bound
74
+ #: but below this value is a numerically ambiguous rank decision and refuses.
75
+ _RANK_INDEPENDENT = 1.0e-8
76
+ #: Same limit the linear static path certifies (assembly._LINEAR_STATIC_BACKWARD_ERROR_LIMIT).
77
+ _CERTIFIED_BACKWARD_ERROR = 1.0e-10
78
+
79
+
80
+ class SubmodelTransferError(ValueError):
81
+ """A typed, fail-closed refusal of the submodel transfer."""
82
+
83
+ def __init__(self, code: str, message: str, *, details: Optional[Mapping[str, Any]] = None):
84
+ super().__init__(f"{code}: {message}")
85
+ self.code = code
86
+ self.details = dict(details or {})
87
+
88
+
89
+ def _finite(value: Any, code: str, what: str) -> np.ndarray:
90
+ try:
91
+ array = np.asarray(value, dtype=float)
92
+ except (TypeError, ValueError) as error:
93
+ raise SubmodelTransferError(code, f"{what} is not numeric") from error
94
+ if not np.all(np.isfinite(array)):
95
+ raise SubmodelTransferError(code, f"{what} is not finite")
96
+ return array
97
+
98
+
99
+ def _control(value: Any, what: str, *, positive: bool = False) -> float:
100
+ number = float(_finite(value, "CONTROL_INVALID", what).reshape(()))
101
+ if number < 0.0 or (positive and number == 0.0):
102
+ raise SubmodelTransferError("CONTROL_INVALID", f"{what} must be {'positive' if positive else 'non-negative'}")
103
+ return number
104
+
105
+
106
+ def _six(value: Any, code: str, what: str, *, non_negative: bool = False) -> np.ndarray:
107
+ array = _finite(value, code, what).reshape(-1)
108
+ if array.shape != (6,):
109
+ raise SubmodelTransferError(code, f"{what} needs six components")
110
+ if non_negative and np.any(array < 0.0):
111
+ raise SubmodelTransferError(code, f"{what} must be non-negative")
112
+ return array
113
+
114
+
115
+ def admitted_transfer_element_types() -> Tuple[type, ...]:
116
+ """Exact shell classes admitted as transfer sources and targets (v1)."""
117
+
118
+ from .e4_pl_element import QualifiedE4PLShellElement
119
+ from .e4_pl_s3_v2d_element import NativeParityE4PLS3V2DShellElement
120
+
121
+ return (QualifiedE4PLShellElement, NativeParityE4PLS3V2DShellElement)
122
+
123
+
124
+ def _require_admitted(element: Any, element_id: int) -> None:
125
+ admitted = admitted_transfer_element_types()
126
+ if type(element) not in admitted:
127
+ raise SubmodelTransferError(
128
+ "TRANSFER_ELEMENT_NOT_ADMITTED",
129
+ f"element {element_id} is {type(element).__name__}; admitted shells: "
130
+ + ", ".join(cls.__name__ for cls in admitted),
131
+ details={"element_id": int(element_id), "type": type(element).__name__},
132
+ )
133
+
134
+
135
+ def _require_target_shells(model: Any) -> None:
136
+ """Every shell of a target model must be admitted; beams and constraint-only
137
+ elements (couplings) are retained as they are."""
138
+
139
+ from .elements import ShellElement
140
+
141
+ for element_id, element in model.mesh.elements.items():
142
+ if isinstance(element, ShellElement):
143
+ _require_admitted(element, int(element_id))
144
+
145
+
146
+ def _shape(element: Any, natural: Sequence[float]) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
147
+ from .e4_pl_s3_v2d_element import NativeParityE4PLS3V2DShellElement
148
+
149
+ xi, eta = (float(v) for v in _finite(natural, "TRANSFER_NATURAL", "natural coordinates").reshape(2))
150
+ if type(element) is NativeParityE4PLS3V2DShellElement:
151
+ n, dxi, deta = element.compute_native_surface_shape_functions(xi, eta)
152
+ else:
153
+ n, dxi, deta = element.compute_shape_functions(xi, eta)
154
+ return (np.asarray(n, float).reshape(-1), np.asarray(dxi, float).reshape(-1), np.asarray(deta, float).reshape(-1))
155
+
156
+
157
+ def element_interpolation_weights(element: Any, natural: Sequence[float]) -> np.ndarray:
158
+ """Geometric interpolation weights of an admitted element at ``natural``.
159
+
160
+ The E4-PL Q4 uses its bilinear shell functions; the S3 V2D its native surface
161
+ functions (it forbids the legacy ``ShellElement`` dispatch).
162
+ """
163
+
164
+ return _shape(element, natural)[0]
165
+
166
+
167
+ def _node_six(model: Any, displacements: np.ndarray, node_id: int) -> np.ndarray:
168
+ dofs = model.mesh.dof_manager.get_node_dofs(int(node_id))
169
+ if len(dofs) != 6:
170
+ raise SubmodelTransferError("TRANSFER_NODE_DOFS", f"node {node_id} has no six DOFs")
171
+ return np.asarray(displacements[dofs], dtype=float)
172
+
173
+
174
+ def _vector(model: Any, displacements: Any, code: str) -> np.ndarray:
175
+ u = _finite(displacements, code, "displacement vector").reshape(-1)
176
+ total = int(model.mesh.dof_manager.total_dofs)
177
+ if u.shape != (total,):
178
+ raise SubmodelTransferError(code, f"displacement vector has {u.size} entries, model has {total} DOFs")
179
+ return u
180
+
181
+
182
+ # ----------------------------------------------------------------------
183
+ # interpolation
184
+ # ----------------------------------------------------------------------
185
+ @dataclass(frozen=True)
186
+ class TransferPoint:
187
+ """One target node and its correspondence in a source element.
188
+
189
+ ``natural`` uses the source element's convention: ``(xi, eta)`` in
190
+ ``[-1, 1]^2`` for four-node shells, ``(r, s)`` with ``N = (1 - r - s, r, s)``
191
+ for three-node shells. ``mesher_weights`` (optional) must agree with the
192
+ element's own weights. ``inverse_residual`` is the correspondence owner's
193
+ in-plane inverse residual. ``alternatives`` lists the other conforming hits
194
+ as ``(element_id, natural, inverse_residual)``; a two-element form uses the
195
+ selected residual as the caller's common bound. Each alternative's complete
196
+ allowance enters the selected value's allowance.
197
+ """
198
+
199
+ target_node: int
200
+ element_id: int
201
+ natural: Tuple[float, float]
202
+ target_point: Tuple[float, float, float]
203
+ mesher_weights: Optional[Tuple[float, ...]] = None
204
+ inverse_residual: float = 0.0
205
+ alternatives: Tuple[Tuple[Any, ...], ...] = ()
206
+
207
+
208
+ @dataclass(frozen=True)
209
+ class TransferValue:
210
+ target_node: int
211
+ values: np.ndarray # (ux, uy, uz, rx, ry, rz), global frame
212
+ source_point: np.ndarray
213
+ offset: np.ndarray # target point minus source point
214
+ distance: float
215
+ weights: np.ndarray
216
+ source_nodes: Tuple[int, ...]
217
+ element_id: int
218
+ natural: Tuple[float, float]
219
+ inverse_residual: float
220
+ alternative_spread: np.ndarray # per component, max |value - alternative value|
221
+ alternatives: Tuple["TransferValue", ...] = () # other conforming hits, each with its own geometry
222
+
223
+
224
+ def _evaluate(model: Any, u: np.ndarray, element_id: int, natural: Sequence[float], target: np.ndarray, transport: bool):
225
+ element = model.mesh.elements.get(int(element_id))
226
+ if element is None:
227
+ raise SubmodelTransferError("TRANSFER_ELEMENT_MISSING", f"source element {element_id} is not in the model")
228
+ _require_admitted(element, int(element_id))
229
+ weights = element_interpolation_weights(element, natural)
230
+ node_ids = tuple(int(n) for n in element.node_ids)
231
+ if weights.shape != (len(node_ids),) or not np.all(np.isfinite(weights)):
232
+ raise SubmodelTransferError("TRANSFER_WEIGHTS", f"element {element_id} returned invalid weights")
233
+ coordinates = np.array([model.mesh.get_node(n).coords() for n in node_ids], dtype=float)
234
+ source_point = weights @ coordinates
235
+ values = weights @ np.array([_node_six(model, u, n) for n in node_ids])
236
+ offset = target - source_point
237
+ if transport:
238
+ values = values.copy()
239
+ values[:3] = values[:3] + np.cross(values[3:], offset)
240
+ return weights, node_ids, source_point, offset, values
241
+
242
+
243
+ def interpolate_nodal_field(
244
+ model: Any,
245
+ displacements: Any,
246
+ points: Iterable[TransferPoint],
247
+ *,
248
+ transport: bool = True,
249
+ weight_tolerance: float = 1.0e-12,
250
+ ) -> Dict[int, TransferValue]:
251
+ """Interpolate a source nodal six-vector field at target points."""
252
+
253
+ tolerance = _control(weight_tolerance, "weight_tolerance")
254
+ u = _vector(model, displacements, "TRANSFER_SOURCE")
255
+ out: Dict[int, TransferValue] = {}
256
+ for point in points:
257
+ target = _finite(point.target_point, "TRANSFER_TARGET", f"target point of node {point.target_node}").reshape(3)
258
+ residual = _control(point.inverse_residual, "inverse residual")
259
+ weights, node_ids, source_point, offset, values = _evaluate(model, u, point.element_id, point.natural, target, transport)
260
+ if point.mesher_weights is not None:
261
+ given = _finite(point.mesher_weights, "TRANSFER_CONVENTION_MISMATCH", "correspondence weights").reshape(-1)
262
+ if given.shape != weights.shape or float(np.max(np.abs(given - weights))) > tolerance:
263
+ raise SubmodelTransferError(
264
+ "TRANSFER_CONVENTION_MISMATCH",
265
+ f"correspondence weights for node {point.target_node} disagree with element {point.element_id}",
266
+ details={"element_weights": weights.tolist(), "mesher_weights": given.tolist()},
267
+ )
268
+ spread = np.zeros(6)
269
+ alternatives = []
270
+ for record in point.alternatives:
271
+ if len(record) == 3:
272
+ alt_id, alt_natural, alt_raw_residual = record
273
+ alt_residual = _control(alt_raw_residual, "alternative inverse residual")
274
+ elif len(record) == 2:
275
+ # No own residual given: the selected residual is the caller's common bound.
276
+ alt_id, alt_natural = record
277
+ alt_residual = residual
278
+ else:
279
+ raise SubmodelTransferError("TRANSFER_ALTERNATIVE", "alternatives are (element, natural[, residual])")
280
+ alt_weights, alt_nodes, alt_point, alt_offset, alt_values = _evaluate(
281
+ model, u, alt_id, alt_natural, target, transport)
282
+ spread = np.maximum(spread, np.abs(alt_values - values))
283
+ alternatives.append(TransferValue(
284
+ int(point.target_node), alt_values, alt_point, alt_offset, float(np.linalg.norm(alt_offset)),
285
+ alt_weights, alt_nodes, int(alt_id), tuple(float(v) for v in alt_natural), alt_residual, np.zeros(6),
286
+ ))
287
+ if not (np.all(np.isfinite(values)) and np.all(np.isfinite(spread))):
288
+ raise SubmodelTransferError("TRANSFER_NONFINITE", f"interpolated value of node {point.target_node} is not finite")
289
+ out[int(point.target_node)] = TransferValue(
290
+ int(point.target_node), values, source_point, offset, float(np.linalg.norm(offset)), weights, node_ids,
291
+ int(point.element_id), tuple(float(v) for v in point.natural), residual, spread, tuple(alternatives),
292
+ )
293
+ return out
294
+
295
+
296
+ def _gradient_norms(model: Any, u: np.ndarray, value: TransferValue) -> np.ndarray:
297
+ """Per-component physical gradient magnitude, max over the hit and the element corners."""
298
+
299
+ element = model.mesh.elements[value.element_id]
300
+ coordinates = np.array([model.mesh.get_node(n).coords() for n in value.source_nodes], dtype=float)
301
+ nodal = np.array([_node_six(model, u, n) for n in value.source_nodes])
302
+ if len(value.source_nodes) == 4:
303
+ samples = [value.natural, (-1, -1), (1, -1), (1, 1), (-1, 1)]
304
+ else:
305
+ samples = [value.natural, (0, 0), (1, 0), (0, 1)]
306
+ best = np.zeros(6)
307
+ for natural in samples:
308
+ _n, dxi, deta = _shape(element, natural)
309
+ jacobian = np.column_stack([coordinates.T @ dxi, coordinates.T @ deta]) # (3, 2)
310
+ pseudo = np.linalg.pinv(jacobian) # (2, 3)
311
+ derivative = np.vstack([dxi @ nodal, deta @ nodal]) # (2, 6)
312
+ gradients = pseudo.T @ derivative # (3, 6)
313
+ best = np.maximum(best, np.linalg.norm(gradients, axis=0))
314
+ return best
315
+
316
+
317
+ def interpolation_allowance(
318
+ value: TransferValue,
319
+ model: Any,
320
+ displacements: Any,
321
+ source_displacement_allowance: Optional[Any] = None,
322
+ ) -> np.ndarray:
323
+ """Per-component allowance of one interpolated value (contract section 6).
324
+
325
+ Terms: evaluation roundoff ``(n_e + 1) eps max|u_i|``; propagated source
326
+ allowance ``sum |N_i| du_i``; the in-plane correspondence residual times the
327
+ physical gradient (shape-function derivatives through the element Jacobian,
328
+ maximum over the hit and the corners); the spread of the alternative
329
+ conforming hits; and, through the transport rule, the rotation allowance
330
+ times ``|offset|`` plus its roundoff.
331
+ """
332
+
333
+ u = _vector(model, displacements, "TRANSFER_SOURCE")
334
+ du = None
335
+ if source_displacement_allowance is not None:
336
+ du = _finite(source_displacement_allowance, "ALLOWANCE_INVALID", "source allowance").reshape(-1)
337
+ if du.shape != u.shape or np.any(du < 0.0):
338
+ raise SubmodelTransferError("ALLOWANCE_INVALID", "source allowance must match the DOFs and be non-negative")
339
+
340
+ def single(candidate: "TransferValue") -> np.ndarray:
341
+ """Complete allowance of one candidate through its own geometry and offset."""
342
+
343
+ nodal_values = np.array([_node_six(model, u, n) for n in candidate.source_nodes])
344
+ part = (len(candidate.source_nodes) + 1) * _EPS * np.max(np.abs(nodal_values), axis=0)
345
+ if du is not None:
346
+ part = part + np.abs(candidate.weights) @ np.array([_node_six(model, du, n) for n in candidate.source_nodes])
347
+ coordinates = np.array([model.mesh.get_node(n).coords() for n in candidate.source_nodes], dtype=float)
348
+ # Position uncertainty of the correspondence point (inverse residual plus
349
+ # coordinate roundoff) moves F(p) = u(p) + theta(p) x (x_f - p) by
350
+ # grad(u) dp + (grad(theta) dp) x offset - theta x dp.
351
+ position = candidate.inverse_residual + 4.0 * _EPS * float(np.max(np.abs(coordinates)))
352
+ gradient = _gradient_norms(model, u, candidate)
353
+ distance = float(np.linalg.norm(candidate.offset))
354
+ part = part + position * gradient
355
+ part[:3] = part[:3] + position * float(np.linalg.norm(gradient[3:])) * distance
356
+ part[:3] = part[:3] + position * float(np.linalg.norm(candidate.values[3:]))
357
+ if distance > 0.0:
358
+ rotation = float(np.linalg.norm(part[3:]))
359
+ part[:3] = part[:3] + rotation * distance + 4.0 * _EPS * float(np.linalg.norm(candidate.values[3:])) * distance
360
+ return part
361
+
362
+ allowance = single(value)
363
+ # Alternative conforming hits: each bounded by its difference from the selected
364
+ # value plus its own complete allowance.
365
+ extra = np.zeros(6)
366
+ for alternative in value.alternatives:
367
+ extra = np.maximum(extra, np.abs(alternative.values - value.values) + single(alternative))
368
+ allowance = allowance + extra
369
+ if not np.all(np.isfinite(allowance)):
370
+ raise SubmodelTransferError("ALLOWANCE_NONFINITE", "the interpolation allowance is not finite")
371
+ return allowance
372
+
373
+
374
+ # ----------------------------------------------------------------------
375
+ # driven trace
376
+ # ----------------------------------------------------------------------
377
+ @dataclass(frozen=True)
378
+ class TraceRow:
379
+ node: int
380
+ label: str
381
+ b: Tuple[Tuple[int, float], ...] # u-space row: (global DOF, coefficient)
382
+ direction: Optional[Tuple[float, float, float]] = None # rotation direction of P1 rows
383
+
384
+
385
+ @dataclass
386
+ class DrivenTrace:
387
+ """A constraint-reduced driven boundary bound to one target model."""
388
+
389
+ policy: str
390
+ rows: Tuple[TraceRow, ...]
391
+ values: np.ndarray # one driven value per row
392
+ uncertainty: np.ndarray # per-row allowance of the driven value
393
+ transformation: sparse.csr_matrix # T of the model without the trace
394
+ offset: np.ndarray # c of the model without the trace
395
+ independent_dofs: np.ndarray
396
+ reduced_rows: Tuple[Dict[int, float], ...] # a_i = b_i T (q-space), unscaled
397
+ row_scale: np.ndarray # equilibration: max |a_i|
398
+ kept: Tuple[int, ...]
399
+ redundant: Tuple[int, ...]
400
+ combinations: Tuple[Dict[int, float], ...] # per kept row, over scaled original rows
401
+ echelon: Tuple[Dict[int, float], ...] # per kept row, eliminated scaled q-space row
402
+ pivots: Tuple[int, ...]
403
+ redundant_combinations: Dict[int, Dict[int, float]]
404
+ consistency: Dict[int, Tuple[float, float]] # redundant row -> (remaining, tolerance), scaled
405
+ model_token: int
406
+ retained_fingerprint: str
407
+ applied: Dict[str, Any] = field(default_factory=dict)
408
+
409
+
410
+ def _unit_rows(node: int, dofs: Sequence[int], names: Sequence[str]) -> List[TraceRow]:
411
+ return [TraceRow(int(node), name, ((int(dof), 1.0),)) for dof, name in zip(dofs, names)]
412
+
413
+
414
+ def rotation_rows(
415
+ node: int,
416
+ rotation_dofs: Sequence[int],
417
+ normals: Sequence[Sequence[float]],
418
+ *,
419
+ rank3: float = JUNCTION_RANK3,
420
+ rank2: float = JUNCTION_RANK2,
421
+ ) -> List[TraceRow]:
422
+ """Rotation rows of one node under P1 (contract section 4)."""
423
+
424
+ rank3 = _control(rank3, "rank3", positive=True)
425
+ rank2 = _control(rank2, "rank2", positive=True)
426
+ if not rank2 < rank3 <= 1.0:
427
+ raise SubmodelTransferError("CONTROL_INVALID", "junction thresholds need 0 < rank2 < rank3 <= 1")
428
+ tangents = []
429
+ for raw in normals:
430
+ n = _finite(raw, "TRACE_NORMAL_INVALID", f"incident normal of node {node}").reshape(3)
431
+ length = float(np.linalg.norm(n))
432
+ if length <= 0.0:
433
+ raise SubmodelTransferError("TRACE_NORMAL_INVALID", f"node {node} has a zero incident normal")
434
+ n = n / length
435
+ helper = np.array([1.0, 0.0, 0.0]) if abs(n[0]) < 0.9 else np.array([0.0, 1.0, 0.0])
436
+ t1 = np.cross(n, helper)
437
+ t1 /= np.linalg.norm(t1)
438
+ tangents.extend((t1, np.cross(n, t1)))
439
+ if not tangents:
440
+ raise SubmodelTransferError("TRACE_NORMAL_MISSING", f"node {node} has no incident normal for P1")
441
+ _u, sigma, vt = np.linalg.svd(np.array(tangents), full_matrices=True)
442
+ if sigma.size < 3:
443
+ sigma = np.concatenate([sigma, np.zeros(3 - sigma.size)])
444
+ ratio = float(sigma[2] / sigma[0])
445
+ if ratio >= rank3:
446
+ return _unit_rows(node, rotation_dofs, DOF_NAMES[3:])
447
+ if ratio <= rank2:
448
+ rows = []
449
+ for k, direction in enumerate(vt[:2]):
450
+ terms = tuple((int(dof), float(c)) for dof, c in zip(rotation_dofs, direction) if c != 0.0)
451
+ rows.append(TraceRow(int(node), f"t{k}", terms, tuple(float(c) for c in direction)))
452
+ return rows
453
+ raise SubmodelTransferError(
454
+ "TRACE_JUNCTION_ILL_CONDITIONED",
455
+ f"node {node}: incident normals give sigma3/sigma1 = {ratio:.3e}, between {rank2:g} and {rank3:g}",
456
+ details={"node": int(node), "ratio": ratio},
457
+ )
458
+
459
+
460
+ def _constraint_map(model: Any) -> Tuple[sparse.csr_matrix, np.ndarray, np.ndarray]:
461
+ from .assembly import build_constraint_transformation
462
+
463
+ total = int(model.mesh.dof_manager.total_dofs)
464
+ _k, _f, t, u0, independent, _info = build_constraint_transformation(
465
+ sparse.identity(total, format="csr"), np.zeros(total), model
466
+ )
467
+ t = sparse.csr_matrix(t)
468
+ t.sort_indices()
469
+ return t, np.asarray(u0, dtype=float), np.asarray(independent, dtype=int)
470
+
471
+
472
+ def _physical_rows(model: Any, exclude_supports=(), exclude_equations=()):
473
+ """Physical retained constraint rows: (kind, origin, {dof: coef}, value)."""
474
+
475
+ rows = []
476
+ skip_bc = {id(bc) for bc in exclude_supports}
477
+ skip_eq = set(exclude_equations)
478
+ dm = model.mesh.dof_manager
479
+ for bc in model.boundary_conditions:
480
+ if id(bc) in skip_bc:
481
+ continue
482
+ for dof, value in bc.get_constrained_dofs(dm):
483
+ rows.append(("support", str(bc.name), {int(dof): 1.0}, float(value)))
484
+ for position, equation in enumerate(getattr(model, "constraint_equations", ())):
485
+ if position in skip_eq:
486
+ continue
487
+ terms: Dict[int, float] = {}
488
+ for dof, coefficient in equation.coefficients:
489
+ terms[int(dof)] = terms.get(int(dof), 0.0) + float(coefficient)
490
+ rows.append(("equation", str(equation.origin), terms, float(equation.value)))
491
+ for element_id, element in sorted(model.mesh.elements.items()):
492
+ getter = getattr(element, "get_mpc_constraints", None)
493
+ if getter is None:
494
+ continue
495
+ for record in getter(model.mesh) or ():
496
+ terms = {int(record["slave"]): 1.0}
497
+ for master, coefficient in record.get("masters", {}).items():
498
+ terms[int(master)] = terms.get(int(master), 0.0) - float(coefficient)
499
+ rows.append(("mpc", f"{element_id}:{record.get('label', '')}", terms, float(record.get("value", 0.0))))
500
+ return rows
501
+
502
+
503
+ def _rows_fingerprint(model: Any, rows) -> str:
504
+ digest = hashlib.sha256()
505
+ digest.update(repr(int(model.mesh.dof_manager.total_dofs)).encode())
506
+ signature = model.mesh.revision_signature()
507
+ digest.update(repr([(k, signature.get(k)) for k in ("topology", "geometry", "activity")]).encode())
508
+ for kind, origin, terms, value in rows:
509
+ digest.update(repr((kind, origin, sorted(terms.items()), value)).encode())
510
+ return digest.hexdigest()
511
+
512
+
513
+ def _row_value(row: TraceRow, six: np.ndarray) -> float:
514
+ if row.direction is not None:
515
+ return float(np.dot(np.asarray(row.direction), six[3:]))
516
+ return float(six[DOF_NAMES.index(row.label)])
517
+
518
+
519
+ def _row_allowance(row: TraceRow, allowance: Optional[Mapping[int, np.ndarray]]) -> float:
520
+ if allowance is None or row.node not in allowance:
521
+ return 0.0
522
+ node_allow = allowance[row.node]
523
+ if row.direction is not None:
524
+ return float(np.abs(np.asarray(row.direction)) @ node_allow[3:])
525
+ return float(node_allow[DOF_NAMES.index(row.label)])
526
+
527
+
528
+ def _reduced(rows: Sequence[TraceRow], g: np.ndarray, t: sparse.csr_matrix, c: np.ndarray):
529
+ reduced: List[Dict[int, float]] = []
530
+ h = np.empty(len(rows))
531
+ offset_size = np.empty(len(rows))
532
+ for index, row in enumerate(rows):
533
+ acc: Dict[int, float] = {}
534
+ offset = 0.0
535
+ size = 0.0
536
+ for dof, coefficient in row.b:
537
+ start, end = t.indptr[dof], t.indptr[dof + 1]
538
+ for col, value in zip(t.indices[start:end], t.data[start:end]):
539
+ acc[int(col)] = acc.get(int(col), 0.0) + coefficient * float(value)
540
+ offset += coefficient * float(c[dof])
541
+ size += abs(coefficient) * abs(float(c[dof]))
542
+ reduced.append({col: value for col, value in acc.items() if value != 0.0})
543
+ h[index] = float(g[index]) - offset
544
+ offset_size[index] = size
545
+ return reduced, h, offset_size
546
+
547
+
548
+ def _validated_values(rows_nodes: Iterable[int], values: Mapping[int, Any]) -> Dict[int, np.ndarray]:
549
+ out = {}
550
+ for node in rows_nodes:
551
+ if node not in values:
552
+ raise SubmodelTransferError("TRACE_VALUES", f"no driven values for node {node}")
553
+ out[int(node)] = _six(values[node], "TRACE_VALUES", f"driven values of node {node}")
554
+ return out
555
+
556
+
557
+ def _validated_allowance(allowance: Optional[Mapping[int, Any]]) -> Optional[Dict[int, np.ndarray]]:
558
+ if allowance is None:
559
+ return None
560
+ return {int(k): _six(v, "ALLOWANCE_INVALID", f"allowance of node {k}", non_negative=True) for k, v in allowance.items()}
561
+
562
+
563
+ def _uncertainty(rows, g, offset_size, allowance) -> np.ndarray:
564
+ out = np.array([_row_allowance(row, allowance) + 4.0 * _EPS * (abs(g[i]) + offset_size[i]) for i, row in enumerate(rows)])
565
+ if not np.all(np.isfinite(out)):
566
+ raise SubmodelTransferError("ALLOWANCE_NONFINITE", "trace uncertainty is not finite")
567
+ return out
568
+
569
+
570
+ def _combination_tolerance(combo: Mapping[int, float], h_scaled: np.ndarray, unc_scaled: np.ndarray) -> float:
571
+ weight = sum(abs(c) for c in combo.values())
572
+ tol = (sum(abs(c) * unc_scaled[i] for i, c in combo.items())
573
+ + 16.0 * _EPS * max(weight, 1.0) * sum(abs(c * h_scaled[i]) for i, c in combo.items()))
574
+ if not np.isfinite(tol):
575
+ raise SubmodelTransferError("ALLOWANCE_NONFINITE", "a redundant-row tolerance is not finite")
576
+ return float(tol)
577
+
578
+
579
+ def build_driven_trace(
580
+ model: Any,
581
+ values: Mapping[int, Sequence[float]],
582
+ *,
583
+ policy: str,
584
+ normals: Optional[Mapping[int, Sequence[Sequence[float]]]] = None,
585
+ allowance: Optional[Mapping[int, Sequence[float]]] = None,
586
+ ) -> DrivenTrace:
587
+ """Build the constraint-reduced driven trace for ``model`` (not yet applied).
588
+
589
+ ``values`` maps each driven node to its six transferred values; ``policy`` is
590
+ ``"drive_all"`` (P2) or ``"release_normal_rotation"`` (P1, needs ``normals``
591
+ per node). There is no default policy. ``model`` must carry its retained
592
+ supports and internal constraints but not the trace. ``allowance`` (per node,
593
+ six non-negative components) is the transfer allowance of the driven values.
594
+
595
+ Rows are equilibrated (divided by their largest reduced coefficient) and
596
+ eliminated with per-entry tracking of the accumulated operand magnitude; an
597
+ entry is zero only below its own roundoff bound. A surviving row between that
598
+ bound and ``1e-8`` refuses as numerically ambiguous.
599
+ """
600
+
601
+ if policy not in TRACE_POLICIES:
602
+ raise SubmodelTransferError("TRACE_POLICY", f"unknown policy {policy!r}; expected one of {TRACE_POLICIES}")
603
+ if not values:
604
+ raise SubmodelTransferError("TRACE_EMPTY", "no driven nodes")
605
+ _require_target_shells(model)
606
+ nodes = sorted(int(n) for n in values)
607
+ checked = _validated_values(nodes, values)
608
+ allowance_map = _validated_allowance(allowance)
609
+ dm = model.mesh.dof_manager
610
+ rows: List[TraceRow] = []
611
+ row_values: List[float] = []
612
+ for node in nodes:
613
+ dofs = dm.get_node_dofs(node)
614
+ if len(dofs) != 6:
615
+ raise SubmodelTransferError("TRACE_NODE_DOFS", f"driven node {node} is not in the target model")
616
+ node_rows = _unit_rows(node, dofs[:3], DOF_NAMES[:3])
617
+ if policy == "drive_all":
618
+ node_rows += _unit_rows(node, dofs[3:], DOF_NAMES[3:])
619
+ else:
620
+ incident = None if normals is None else normals.get(node)
621
+ if not incident:
622
+ raise SubmodelTransferError("TRACE_NORMAL_MISSING", f"P1 needs incident normals for node {node}")
623
+ node_rows += rotation_rows(node, dofs[3:], incident)
624
+ for row in node_rows:
625
+ rows.append(row)
626
+ row_values.append(_row_value(row, checked[node]))
627
+ g = np.asarray(row_values, dtype=float)
628
+ t, c, independent = _constraint_map(model)
629
+ reduced, h, offset_size = _reduced(rows, g, t, c)
630
+ uncertainty = _uncertainty(rows, g, offset_size, allowance_map)
631
+ scale = np.array([max((abs(v) for v in row.values()), default=0.0) for row in reduced])
632
+ safe = np.where(scale > 0.0, scale, 1.0)
633
+ h_scaled = h / safe
634
+ unc_scaled = uncertainty / safe
635
+
636
+ pivot_rows: Dict[int, Tuple[Dict[int, float], Dict[int, float], Dict[int, float]]] = {}
637
+ kept: List[int] = []
638
+ echelon: List[Dict[int, float]] = []
639
+ combinations: List[Dict[int, float]] = []
640
+ pivots: List[int] = []
641
+ redundant: List[int] = []
642
+ consistency: Dict[int, Tuple[float, float]] = {}
643
+ redundant_combinations: Dict[int, Dict[int, float]] = {}
644
+ for index, original in enumerate(reduced):
645
+ if scale[index] == 0.0:
646
+ work: Dict[int, float] = {}
647
+ magnitude: Dict[int, float] = {}
648
+ else:
649
+ work = {k: v / scale[index] for k, v in original.items()}
650
+ magnitude = {k: abs(v) for k, v in work.items()}
651
+ combo = {index: 1.0}
652
+ while True:
653
+ hits = [col for col in work if col in pivot_rows and work[col] != 0.0]
654
+ if not hits:
655
+ break
656
+ for col in hits:
657
+ factor = work.get(col, 0.0)
658
+ if factor == 0.0:
659
+ continue
660
+ prow, pmag, pcombo = pivot_rows[col]
661
+ for key, value in prow.items():
662
+ if key == col:
663
+ continue
664
+ work[key] = work.get(key, 0.0) - factor * value
665
+ magnitude[key] = magnitude.get(key, 0.0) + abs(factor) * (pmag.get(key, 0.0) + abs(value))
666
+ for key, value in pcombo.items():
667
+ combo[key] = combo.get(key, 0.0) - factor * value
668
+ work.pop(col, None)
669
+ magnitude.pop(col, None)
670
+ survivors = {k: v for k, v in work.items() if abs(v) > 16.0 * _EPS * magnitude.get(k, 0.0)}
671
+ size = max((abs(v) for v in survivors.values()), default=0.0)
672
+ remaining = float(sum(coef * h_scaled[i] for i, coef in combo.items()))
673
+ if size == 0.0:
674
+ tol = _combination_tolerance(combo, h_scaled, unc_scaled)
675
+ consistency[index] = (remaining, tol)
676
+ if not np.isfinite(remaining) or abs(remaining) > tol:
677
+ row = rows[index]
678
+ raise SubmodelTransferError(
679
+ "TRACE_INCONSISTENT",
680
+ f"driven row {row.label} of node {row.node} contradicts retained constraints or other driven rows "
681
+ f"(remaining {remaining:.3e}, tolerance {tol:.3e}, equilibrated)",
682
+ details={"node": row.node, "label": row.label, "remaining": remaining, "tolerance": tol},
683
+ )
684
+ redundant.append(index)
685
+ redundant_combinations[index] = dict(combo)
686
+ continue
687
+ if size < _RANK_INDEPENDENT:
688
+ row = rows[index]
689
+ raise SubmodelTransferError(
690
+ "TRACE_RANK_AMBIGUOUS",
691
+ f"driven row {row.label} of node {row.node} is nearly dependent on earlier rows "
692
+ f"(equilibrated surviving size {size:.3e})",
693
+ )
694
+ pivot = max(survivors, key=lambda key: (abs(survivors[key]), -key))
695
+ norm = survivors[pivot]
696
+ pivot_rows[pivot] = (
697
+ {k: v / norm for k, v in survivors.items()},
698
+ {k: magnitude.get(k, 0.0) / abs(norm) for k in survivors},
699
+ {k: v / norm for k, v in combo.items()},
700
+ )
701
+ kept.append(index)
702
+ echelon.append(dict(survivors))
703
+ combinations.append(dict(combo))
704
+ pivots.append(pivot)
705
+ return DrivenTrace(
706
+ policy=policy, rows=tuple(rows), values=g, uncertainty=uncertainty, transformation=t, offset=c,
707
+ independent_dofs=independent, reduced_rows=tuple(reduced), row_scale=scale, kept=tuple(kept),
708
+ redundant=tuple(redundant), combinations=tuple(combinations), echelon=tuple(echelon), pivots=tuple(pivots),
709
+ redundant_combinations=redundant_combinations, consistency=consistency, model_token=id(model),
710
+ retained_fingerprint=_rows_fingerprint(model, _physical_rows(model)),
711
+ )
712
+
713
+
714
+ def _scaled_h(trace: DrivenTrace, g: np.ndarray, allowance_map=None):
715
+ _rows, h, offset_size = _reduced(trace.rows, g, trace.transformation, trace.offset)
716
+ safe = np.where(trace.row_scale > 0.0, trace.row_scale, 1.0)
717
+ uncertainty = _uncertainty(trace.rows, g, offset_size, allowance_map)
718
+ return h / safe, uncertainty / safe, uncertainty
719
+
720
+
721
+ def _emitted(trace: DrivenTrace, h_scaled: np.ndarray):
722
+ prescribed: Dict[int, float] = {}
723
+ equations: List[Tuple[Tuple[Tuple[int, float], ...], float, int]] = []
724
+ for row, combo, pivot in zip(trace.echelon, trace.combinations, trace.pivots):
725
+ rhs = float(sum(coef * h_scaled[i] for i, coef in combo.items()))
726
+ terms = tuple((int(trace.independent_dofs[col]), float(value)) for col, value in sorted(row.items()))
727
+ dependent = int(trace.independent_dofs[pivot])
728
+ if len(terms) == 1:
729
+ prescribed[dependent] = rhs / terms[0][1]
730
+ else:
731
+ equations.append((terms, rhs, dependent))
732
+ for value in list(prescribed.values()) + [rhs for _t, rhs, _d in equations]:
733
+ if not np.isfinite(value):
734
+ raise SubmodelTransferError("TRACE_NONFINITE", "emitted trace value is not finite")
735
+ return prescribed, equations
736
+
737
+
738
+ def _check_redundant(trace: DrivenTrace, h_scaled: np.ndarray, unc_scaled: np.ndarray) -> None:
739
+ for index in trace.redundant:
740
+ combo = trace.redundant_combinations[index]
741
+ remaining = float(sum(coef * h_scaled[i] for i, coef in combo.items()))
742
+ tol = _combination_tolerance(combo, h_scaled, unc_scaled)
743
+ if not np.isfinite(remaining) or abs(remaining) > tol:
744
+ row = trace.rows[index]
745
+ raise SubmodelTransferError(
746
+ "TRACE_INCONSISTENT",
747
+ f"row {row.label} of node {row.node} contradicts the trace (remaining {remaining:.3e}, tolerance {tol:.3e})",
748
+ )
749
+
750
+
751
+ def _require_bound(model: Any, trace: DrivenTrace, *, applied: bool) -> None:
752
+ """The trace must belong to ``model``, whose retained constraints and trace
753
+ constraints must be exactly as recorded."""
754
+
755
+ if id(model) != trace.model_token:
756
+ raise SubmodelTransferError("TRACE_MODEL_MISMATCH", "this trace was built for a different model")
757
+ if not applied:
758
+ if trace.applied:
759
+ raise SubmodelTransferError("TRACE_ALREADY_APPLIED", "this trace is already applied")
760
+ rows = _physical_rows(model)
761
+ else:
762
+ if not trace.applied:
763
+ raise SubmodelTransferError("TRACE_NOT_APPLIED", "the trace has not been applied to this model")
764
+ supports = trace.applied["supports"]
765
+ present = {id(bc) for bc in model.boundary_conditions}
766
+ if any(id(bc) not in present for bc in supports.values()):
767
+ raise SubmodelTransferError("TRACE_MODEL_CHANGED", "trace supports are no longer in the model")
768
+ for node, bc in supports.items():
769
+ if bc.node_ids != [node] or set(bc.dof_constraints) != set(trace.applied["support_keys"][node]):
770
+ raise SubmodelTransferError("TRACE_MODEL_CHANGED", f"trace support of node {node} was modified")
771
+ positions = []
772
+ for (position, origin), (terms, dependent) in zip(trace.applied["equations"], trace.applied["equation_structure"]):
773
+ if position >= len(model.constraint_equations):
774
+ raise SubmodelTransferError("TRACE_MODEL_CHANGED", "trace equations are no longer where they were applied")
775
+ equation = model.constraint_equations[position]
776
+ current = tuple((int(d), float(c)) for d, c in equation.coefficients)
777
+ if equation.origin != origin or int(equation.dependent_dof) != dependent or sorted(current) != sorted(terms):
778
+ raise SubmodelTransferError("TRACE_MODEL_CHANGED", f"trace equation {origin} was modified")
779
+ positions.append(position)
780
+ rows = _physical_rows(model, exclude_supports=supports.values(), exclude_equations=positions)
781
+ if _rows_fingerprint(model, rows) != trace.retained_fingerprint:
782
+ raise SubmodelTransferError("TRACE_MODEL_CHANGED", "the model's retained constraints or topology changed since the trace was built")
783
+
784
+
785
+ def apply_driven_trace(model: Any, trace: DrivenTrace, *, name: str = "submodel_trace") -> DrivenTrace:
786
+ """Add the trace to ``model`` as supports and constraint equations."""
787
+
788
+ from .boundary import BoundaryCondition
789
+
790
+ from .constraint_audit import COEFFICIENT_ATOL
791
+
792
+ _require_bound(model, trace, applied=False)
793
+ h_scaled, _unc_fresh, _u = _scaled_h(trace, trace.values)
794
+ unc_scaled = trace.uncertainty / np.where(trace.row_scale > 0.0, trace.row_scale, 1.0)
795
+ prescribed, equations = _emitted(trace, h_scaled)
796
+ for terms, _rhs, _dependent in equations:
797
+ if any(abs(c) <= COEFFICIENT_ATOL for _d, c in terms):
798
+ raise SubmodelTransferError(
799
+ "TRACE_AUDIT_PRUNING",
800
+ f"an emitted trace coefficient is at or below the audit threshold {COEFFICIENT_ATOL:g} and would be dropped",
801
+ )
802
+ dm = model.mesh.dof_manager
803
+ by_node: Dict[int, Dict[str, float]] = {}
804
+ for dof, value in prescribed.items():
805
+ node, local, _name = dm.get_dof_info(dof)
806
+ by_node.setdefault(int(node), {})[DOF_NAMES[int(local)]] = float(value)
807
+ # Transaction: every unsuccessful exit restores the model's constraint lists and
808
+ # the DOF manager's constrained set, then re-raises the original error.
809
+ saved_supports = list(model.boundary_conditions)
810
+ saved_equations = list(model.constraint_equations)
811
+ saved_constrained = set(getattr(dm, "_constrained_dofs", set()))
812
+ supports = {}
813
+ placed, structure = [], []
814
+ try:
815
+ for node, constraints in sorted(by_node.items()):
816
+ bc = BoundaryCondition(name=f"{name}:{node}", node_ids=[node], dof_constraints=dict(constraints))
817
+ model.add_boundary_condition(bc)
818
+ supports[node] = bc
819
+ for k, (terms, rhs, dependent) in enumerate(equations):
820
+ origin = f"{name}:eq{k}"
821
+ model.add_constraint_equation(terms=terms, rhs=rhs, source_id=origin, dependent_dof=dependent)
822
+ added = model.constraint_equations[-1]
823
+ placed.append((len(model.constraint_equations) - 1, added.origin))
824
+ structure.append((tuple((int(d), float(c)) for d, c in added.coefficients), int(added.dependent_dof)))
825
+ _verify_applied(model, trace, h_scaled, unc_scaled)
826
+ except BaseException:
827
+ model.boundary_conditions[:] = saved_supports
828
+ model.constraint_equations[:] = saved_equations
829
+ if hasattr(dm, "_constrained_dofs"):
830
+ dm._constrained_dofs = saved_constrained
831
+ model.bump_revision("boundary")
832
+ raise
833
+ trace.applied = {
834
+ "supports": supports, "support_keys": {n: tuple(bc.dof_constraints) for n, bc in supports.items()},
835
+ "equations": placed, "equation_structure": structure, "name": name,
836
+ }
837
+ return trace
838
+
839
+
840
+ def _verify_applied(model: Any, trace: DrivenTrace, h_scaled: np.ndarray, unc_scaled: np.ndarray) -> None:
841
+ """Every trace row must be enforced by the constraint map the solver actually builds."""
842
+
843
+ t2, c2, _independent = _constraint_map(model)
844
+ safe = np.where(trace.row_scale > 0.0, trace.row_scale, 1.0)
845
+ for i, row in enumerate(trace.rows):
846
+ coefficient: Dict[int, float] = {}
847
+ magnitude: Dict[int, float] = {}
848
+ value = 0.0
849
+ value_size = 0.0
850
+ for dof, coef in row.b:
851
+ start, end = t2.indptr[dof], t2.indptr[dof + 1]
852
+ for col, entry in zip(t2.indices[start:end], t2.data[start:end]):
853
+ coefficient[int(col)] = coefficient.get(int(col), 0.0) + coef * float(entry)
854
+ magnitude[int(col)] = magnitude.get(int(col), 0.0) + abs(coef * float(entry))
855
+ value += coef * float(c2[dof])
856
+ value_size += abs(coef * float(c2[dof]))
857
+ # A row is enforced only when every free coordinate cancels to roundoff of
858
+ # its own operands; any surviving dependence refuses.
859
+ if any(abs(v) > 64.0 * _EPS * magnitude[col] for col, v in coefficient.items()):
860
+ raise SubmodelTransferError(
861
+ "TRACE_AUDIT_CHANGED", f"row {row.label} of node {row.node} is not fully enforced by the applied constraints"
862
+ )
863
+ if i in trace.redundant_combinations:
864
+ tol = _combination_tolerance(trace.redundant_combinations[i], h_scaled, unc_scaled) * safe[i]
865
+ else:
866
+ tol = trace.uncertainty[i]
867
+ tol += 64.0 * _EPS * (value_size + abs(trace.values[i]))
868
+ if abs(value - trace.values[i]) > tol:
869
+ raise SubmodelTransferError(
870
+ "TRACE_AUDIT_CHANGED",
871
+ f"row {row.label} of node {row.node} is enforced at {value:.6e} instead of {trace.values[i]:.6e}",
872
+ )
873
+
874
+
875
+ def update_driven_trace_values(
876
+ model: Any,
877
+ trace: DrivenTrace,
878
+ values: Mapping[int, Sequence[float]],
879
+ *,
880
+ allowance: Optional[Mapping[int, Sequence[float]]] = None,
881
+ ) -> DrivenTrace:
882
+ """Replace only the driven values of an applied trace, atomically.
883
+
884
+ Everything is validated and computed before the model is touched; a refused
885
+ update leaves supports, equations and the trace unchanged. The constraint
886
+ structure is unchanged, so a session refreshes the prescribed offset without
887
+ refactorizing.
888
+ """
889
+
890
+ from .constraint_audit import ConstraintEquation
891
+
892
+ _require_bound(model, trace, applied=True)
893
+ nodes = sorted({row.node for row in trace.rows})
894
+ checked = _validated_values(nodes, values)
895
+ allowance_map = _validated_allowance(allowance)
896
+ g = np.array([_row_value(row, checked[row.node]) for row in trace.rows])
897
+ h_scaled, unc_scaled, uncertainty = _scaled_h(trace, g, allowance_map)
898
+ _check_redundant(trace, h_scaled, unc_scaled)
899
+ prescribed, equations = _emitted(trace, h_scaled)
900
+ dm = model.mesh.dof_manager
901
+ support_updates = []
902
+ for dof, value in prescribed.items():
903
+ node, local, _name = dm.get_dof_info(dof)
904
+ support_updates.append((trace.applied["supports"][int(node)], DOF_NAMES[int(local)], float(value)))
905
+ equation_updates = []
906
+ for (position, origin), (terms, rhs, dependent) in zip(trace.applied["equations"], equations):
907
+ equation_updates.append((position, ConstraintEquation(terms=terms, rhs=rhs, source_id=origin, dependent_dof=dependent)))
908
+ # Commit: direct public-object edits without a revision bump (values only).
909
+ for bc, name, value in support_updates:
910
+ bc.dof_constraints[name] = value
911
+ for position, equation in equation_updates:
912
+ model.constraint_equations[position] = equation
913
+ trace.values = g
914
+ trace.uncertainty = uncertainty
915
+ return trace
916
+
917
+
918
+ # ----------------------------------------------------------------------
919
+ # interface forces
920
+ # ----------------------------------------------------------------------
921
+ @dataclass(frozen=True)
922
+ class InterfaceForces:
923
+ """Accepted work-conjugate interface forces of an applied trace (global frame).
924
+
925
+ ``node_forces``: force and moment the removed structure exerts on the target
926
+ model at each driven node. ``retained_support_reactions``: external reactions
927
+ of the target model's own retained restraints (supports, and model equations
928
+ or couplings that act on rigid motion), for a free-body balance. Constraints
929
+ that every rigid motion satisfies are internal; their self-equilibrated
930
+ forces are not reported. Physical and numerical
931
+ (stabilisation) parts are not partitioned (``partitioned`` is False).
932
+ """
933
+
934
+ node_forces: Dict[int, np.ndarray]
935
+ retained_support_reactions: Dict[int, np.ndarray]
936
+ multipliers: np.ndarray
937
+ equilibrium_residual: float
938
+ equilibrium_ratio: float
939
+ trace_residual_ratio: float
940
+ partitioned: bool = False
941
+
942
+
943
+ def _assembled(model: Any, load_case: Any):
944
+ from .analysis_session import AnalysisSession
945
+ from .matrix_assembly import assemble_load_vector
946
+
947
+ with AnalysisSession(model) as session:
948
+ stiffness = sparse.csr_matrix(session.stiffness_plan().matrix)
949
+ load, _info = assemble_load_vector(model, load_case)
950
+ return stiffness, _finite(load, "FORCE_NONFINITE", "load vector").reshape(-1)
951
+
952
+
953
+ def _check_reconstruction(model: Any, u: np.ndarray, session: Any = None) -> np.ndarray:
954
+ """Component-wise check that ``u`` satisfies the model's current constraints.
955
+
956
+ Returns the accepted per-DOF discrepancy (roundoff level), which callers add
957
+ to their allowance.
958
+ """
959
+
960
+ from .analysis_session import AnalysisSession
961
+
962
+ owned = session is None
963
+ active = AnalysisSession(model) if owned else session
964
+ try:
965
+ active._require_model(model)
966
+ plan = active.constraint_plan()
967
+ t = sparse.csr_matrix(plan.T)
968
+ independent = np.asarray(plan.independent_dofs, dtype=int)
969
+ u0 = np.asarray(plan.u0, dtype=float)
970
+ finally:
971
+ if owned:
972
+ active.close()
973
+ q = u[independent]
974
+ rebuilt = t @ q + u0
975
+ discrepancy = np.abs(rebuilt - u)
976
+ nnz = np.diff(t.indptr).astype(float)
977
+ allowed = 8.0 * _EPS * (np.abs(u0) + (abs(t) @ np.abs(q)) + np.abs(u)) * np.maximum(nnz, 1.0)
978
+ if np.any(discrepancy > allowed):
979
+ worst = int(np.argmax(discrepancy - allowed))
980
+ raise SubmodelTransferError(
981
+ "ALLOWANCE_RECONSTRUCTION",
982
+ f"displacements violate the model's constraints at DOF {worst} by {discrepancy[worst]:.3e}",
983
+ )
984
+ return discrepancy
985
+
986
+
987
+ def interface_forces(
988
+ model: Any,
989
+ displacements: Any,
990
+ load_case: Any,
991
+ trace: DrivenTrace,
992
+ *,
993
+ displacement_allowance: Optional[Any] = None,
994
+ ) -> InterfaceForces:
995
+ """Recover and accept the interface forces and retained reactions (contract section 5).
996
+
997
+ All multipliers are solved together from ``K u - f = C^T mu`` over the
998
+ physical constraint rows ``C``: retained supports, model equations, element
999
+ couplings and the kept trace rows. Support multipliers are the retained
1000
+ reactions; trace multipliers give the interface forces; equation and coupling
1001
+ multipliers are internal. The result is refused unless ``u`` satisfies the
1002
+ current constraints, every trace row holds within its allowance (redundant
1003
+ rows within their combination tolerance), the constraint rows have full rank,
1004
+ and the residual not carried by any constraint lies within the force
1005
+ allowance. Without ``displacement_allowance``, ``u`` must be a certified solve.
1006
+ """
1007
+
1008
+ _require_bound(model, trace, applied=True)
1009
+ u = _vector(model, displacements, "FORCE_INPUT")
1010
+ discrepancy = _check_reconstruction(model, u)
1011
+ if displacement_allowance is None:
1012
+ estimate = estimate_static_error_allowance(model, u, load_case)
1013
+ if estimate.inconclusive or estimate.eta_scaled > _CERTIFIED_BACKWARD_ERROR:
1014
+ raise SubmodelTransferError(
1015
+ "FORCE_UNCERTIFIED",
1016
+ f"displacements are not a certified solve (scaled backward error {estimate.eta_scaled:.3e}, "
1017
+ f"kappa*eta {estimate.kappa_scaled * estimate.eta_scaled:.3e})",
1018
+ )
1019
+ displacement_allowance = estimate.displacement
1020
+ du = _finite(displacement_allowance, "ALLOWANCE_INVALID", "displacement allowance").reshape(-1)
1021
+ if du.shape != u.shape or np.any(du < 0.0):
1022
+ raise SubmodelTransferError("ALLOWANCE_INVALID", "displacement allowance must match the DOFs and be non-negative")
1023
+ du = du + discrepancy
1024
+ stiffness, load = _assembled(model, load_case)
1025
+ residual = stiffness @ u - load
1026
+ floor = force_allowance(model, u, load_case, du, assembled=(stiffness, load))
1027
+
1028
+ # Trace rows: kept rows are enforced exactly; redundant rows within their combination tolerance.
1029
+ h_scaled, _unc_fresh, _unc = _scaled_h(trace, trace.values)
1030
+ safe = np.where(trace.row_scale > 0.0, trace.row_scale, 1.0)
1031
+ unc_scaled = trace.uncertainty / safe # the same uncertainty the build and updates used
1032
+ trace_ratio = 0.0
1033
+ for i, row in enumerate(trace.rows):
1034
+ value = sum(coef * u[dof] for dof, coef in row.b)
1035
+ solve_part = sum(abs(coef) * du[dof] for dof, coef in row.b) + 8.0 * _EPS * sum(abs(coef * u[dof]) for dof, coef in row.b)
1036
+ if i in trace.redundant_combinations:
1037
+ base = _combination_tolerance(trace.redundant_combinations[i], h_scaled, unc_scaled) * safe[i]
1038
+ else:
1039
+ base = trace.uncertainty[i]
1040
+ trace_ratio = max(trace_ratio, abs(value - trace.values[i]) / (base + solve_part + 1.0e-300))
1041
+ if not np.isfinite(trace_ratio) or trace_ratio > 1.0:
1042
+ raise SubmodelTransferError("FORCE_TRACE_VIOLATED", f"displacements violate the trace (ratio {trace_ratio:.3e})")
1043
+
1044
+ retained = _physical_rows(
1045
+ model, exclude_supports=trace.applied["supports"].values(),
1046
+ exclude_equations=[p for p, _o in trace.applied["equations"]],
1047
+ )
1048
+ # Retained supports are unit rows: their reactions follow as remainders. The
1049
+ # other multipliers (model equations, element couplings, kept trace rows) are
1050
+ # solved from the DOFs no retained support fixes, per connected component of
1051
+ # rows sharing such DOFs.
1052
+ supported = set()
1053
+ other_rows: List[Dict[int, float]] = []
1054
+ external_rows: List[bool] = []
1055
+ rigid = _rigid_modes(model)
1056
+ for kind, _origin, terms, _value in retained:
1057
+ if kind == "support":
1058
+ supported.add(next(iter(terms)))
1059
+ else:
1060
+ other_rows.append(terms)
1061
+ external_rows.append(_is_external(terms, rigid))
1062
+ trace_start = len(other_rows)
1063
+ for i in trace.kept:
1064
+ other_rows.append({int(d): float(c) for d, c in trace.rows[i].b})
1065
+ for k, row in enumerate(other_rows):
1066
+ if not any(dof not in supported for dof in row):
1067
+ raise SubmodelTransferError(
1068
+ "FORCE_RANK", "a constraint acts only on supported DOFs; its force cannot be separated from the reactions"
1069
+ )
1070
+ parent = list(range(len(other_rows)))
1071
+
1072
+ def find(k: int) -> int:
1073
+ while parent[k] != k:
1074
+ parent[k] = parent[parent[k]]
1075
+ k = parent[k]
1076
+ return k
1077
+
1078
+ owner: Dict[int, int] = {}
1079
+ for k, row in enumerate(other_rows):
1080
+ for dof in row:
1081
+ if dof in supported:
1082
+ continue
1083
+ if dof in owner:
1084
+ parent[find(k)] = find(owner[dof])
1085
+ else:
1086
+ owner[dof] = k
1087
+ components: Dict[int, List[int]] = {}
1088
+ for k in range(len(other_rows)):
1089
+ components.setdefault(find(k), []).append(k)
1090
+ mu = np.zeros(len(other_rows))
1091
+ for members in components.values():
1092
+ dofs = sorted({dof for k in members for dof in other_rows[k] if dof not in supported})
1093
+ local = {dof: j for j, dof in enumerate(dofs)}
1094
+ block = np.zeros((len(dofs), len(members)))
1095
+ for column, k in enumerate(members):
1096
+ for dof, coef in other_rows[k].items():
1097
+ if dof in local:
1098
+ block[local[dof], column] += coef
1099
+ norms = np.linalg.norm(block, axis=0)
1100
+ if np.any(norms == 0.0):
1101
+ raise SubmodelTransferError("FORCE_RANK", "a constraint has no unsupported DOF")
1102
+ solution, _res, rank, _sv = np.linalg.lstsq(block / norms, residual[dofs], rcond=None)
1103
+ if rank != len(members):
1104
+ raise SubmodelTransferError(
1105
+ "FORCE_RANK", f"{len(members)} coupled constraints have rank {rank} (dependent constraints)"
1106
+ )
1107
+ mu[members] = solution / norms
1108
+ carried = np.zeros_like(residual)
1109
+ for k, row in enumerate(other_rows):
1110
+ for dof, coef in row.items():
1111
+ carried[dof] += coef * mu[k]
1112
+ unsupported = np.ones(residual.shape, dtype=bool)
1113
+ unsupported[list(supported)] = False
1114
+ leftover = np.where(unsupported, np.abs(residual - carried), 0.0)
1115
+ ratio = float(np.max(leftover / (floor + 1.0e-300), initial=0.0))
1116
+ if not np.isfinite(ratio) or ratio > 1.0:
1117
+ raise SubmodelTransferError(
1118
+ "FORCE_EQUILIBRIUM",
1119
+ f"residual not carried by the constraints exceeds the force allowance (ratio {ratio:.3e})",
1120
+ )
1121
+ dm = model.mesh.dof_manager
1122
+ forces: Dict[int, np.ndarray] = {row.node: np.zeros(6) for row in trace.rows}
1123
+ for k, i in enumerate(trace.kept):
1124
+ for dof, coefficient in trace.rows[i].b:
1125
+ node, local, _ = dm.get_dof_info(dof)
1126
+ forces[int(node)][int(local)] += coefficient * float(mu[trace_start + k])
1127
+ reactions: Dict[int, np.ndarray] = {}
1128
+ for dof in sorted(supported):
1129
+ node, local, _ = dm.get_dof_info(int(dof))
1130
+ reactions.setdefault(int(node), np.zeros(6))[int(local)] += float(residual[dof] - carried[dof])
1131
+ # Retained equations and couplings that act on rigid motion are external restraints.
1132
+ omitted = np.zeros(6)
1133
+ omitted_bound = np.zeros(6)
1134
+ for k, external in enumerate(external_rows):
1135
+ for dof, coef in other_rows[k].items():
1136
+ node, local, _ = dm.get_dof_info(int(dof))
1137
+ force = coef * float(mu[k])
1138
+ if external:
1139
+ reactions.setdefault(int(node), np.zeros(6))[int(local)] += force
1140
+ else:
1141
+ mode = rigid.get(int(dof), np.zeros(6))
1142
+ omitted += force * mode
1143
+ omitted_bound += np.abs(force * mode)
1144
+ # The forces of internal constraints must have a zero resultant (to roundoff).
1145
+ if np.any(np.abs(omitted) > 64.0 * _EPS * max(len(other_rows), 1) * omitted_bound + 1.0e-300):
1146
+ raise SubmodelTransferError(
1147
+ "FORCE_INTERNAL_RESULTANT", "forces of constraints classified internal do not cancel"
1148
+ )
1149
+ return InterfaceForces(forces, reactions, np.asarray(mu[trace_start:], dtype=float),
1150
+ float(np.max(leftover, initial=0.0)), ratio, float(trace_ratio))
1151
+
1152
+
1153
+ def _rigid_modes(model: Any) -> Dict[int, np.ndarray]:
1154
+ """Rigid-body modes per DOF: rows (6,) = translations x, y, z and rotations about
1155
+ x, y, z through the model centroid."""
1156
+
1157
+ dm = model.mesh.dof_manager
1158
+ nodes = model.mesh.nodes
1159
+ centroid = np.mean([node.coords() for node in nodes.values()], axis=0) if nodes else np.zeros(3)
1160
+ modes: Dict[int, np.ndarray] = {}
1161
+ for node_id, node in nodes.items():
1162
+ x = np.asarray(node.coords(), dtype=float) - centroid
1163
+ dofs = dm.get_node_dofs(node_id)
1164
+ for local, dof in enumerate(dofs):
1165
+ row = np.zeros(6)
1166
+ if local < 3:
1167
+ row[local] = 1.0
1168
+ for axis in range(3):
1169
+ a = np.zeros(3)
1170
+ a[axis] = 1.0
1171
+ row[3 + axis] = np.cross(a, x)[local]
1172
+ else:
1173
+ row[local] = 1.0
1174
+ modes[int(dof)] = row
1175
+ return modes
1176
+
1177
+
1178
+ def _is_external(terms: Mapping[int, float], rigid: Mapping[int, np.ndarray]) -> bool:
1179
+ """A constraint row is internal only when every rigid mode satisfies it to the
1180
+ roundoff of that mode's own products; then its reaction is self-equilibrated.
1181
+ Anything else, including undecidable cases, is treated as an external restraint
1182
+ (conservative: reporting a self-equilibrated force as external changes no
1183
+ resultant)."""
1184
+
1185
+ action = np.zeros(6)
1186
+ bound = np.zeros(6)
1187
+ for dof, coef in terms.items():
1188
+ mode = rigid.get(int(dof), np.zeros(6))
1189
+ action += coef * mode
1190
+ bound += np.abs(coef * mode)
1191
+ return bool(np.any(np.abs(action) > 16.0 * _EPS * len(terms) * bound))
1192
+
1193
+
1194
+ def interface_resultant(model: Any, forces: Mapping[int, Sequence[float]], about: Sequence[float]) -> np.ndarray:
1195
+ """Force and moment resultant of nodal six-vectors about a point (global frame)."""
1196
+
1197
+ point = _finite(about, "FORCE_INPUT", "reference point").reshape(3)
1198
+ total = np.zeros(6)
1199
+ for node, six in forces.items():
1200
+ f = _six(six, "FORCE_INPUT", f"force of node {node}")
1201
+ arm = np.asarray(model.mesh.get_node(int(node)).coords(), dtype=float) - point
1202
+ total[:3] += f[:3]
1203
+ total[3:] += f[3:] + np.cross(arm, f[:3])
1204
+ return total
1205
+
1206
+
1207
+ # ----------------------------------------------------------------------
1208
+ # error allowance
1209
+ # ----------------------------------------------------------------------
1210
+ @dataclass(frozen=True)
1211
+ class StaticErrorAllowance:
1212
+ """First-order estimated allowance of a linear static solve (not a bound)."""
1213
+
1214
+ eta_scaled: float
1215
+ kappa_scaled: float
1216
+ displacement: np.ndarray # per global DOF, metres or radians
1217
+ inconclusive: bool
1218
+ threshold: float
1219
+
1220
+
1221
+ def estimate_static_error_allowance(
1222
+ model: Any,
1223
+ displacements: Any,
1224
+ load_case: Any,
1225
+ *,
1226
+ inconclusive_threshold: float = 1.0e-6,
1227
+ session: Any = None,
1228
+ ) -> StaticErrorAllowance:
1229
+ """Allowance on the solver's own equilibrated reduced operator (contract section 6).
1230
+
1231
+ The backward error and the condition estimate are both computed for the
1232
+ equilibrated matrix the solver factorizes; the inverse norm is estimated
1233
+ through that factorization. ``u`` must satisfy the model's constraints
1234
+ component-wise; the accepted roundoff discrepancy is added to the allowance.
1235
+ """
1236
+
1237
+ from .analysis_session import AnalysisSession
1238
+ from .matrix_assembly import assemble_load_vector
1239
+
1240
+ threshold = _control(inconclusive_threshold, "inconclusive_threshold", positive=True)
1241
+ u = _vector(model, displacements, "ALLOWANCE_INPUT")
1242
+ load, _info = assemble_load_vector(model, load_case)
1243
+ load = _finite(load, "ALLOWANCE_NONFINITE", "load vector").reshape(-1)
1244
+ owned = session is None
1245
+ active = AnalysisSession(model) if owned else session
1246
+ try:
1247
+ active._require_model(model)
1248
+ discrepancy = _check_reconstruction(model, u, active)
1249
+ plan = active.static_operator_plan()
1250
+ if plan.augmented:
1251
+ raise SubmodelTransferError("ALLOWANCE_UNSUPPORTED", "nullspace-augmented (free-free) operators are not supported")
1252
+ constraint = plan.constraint
1253
+ t = sparse.csr_matrix(constraint.T)
1254
+ independent = np.asarray(constraint.independent_dofs, dtype=int)
1255
+ if independent.size == 0:
1256
+ return StaticErrorAllowance(0.0, 1.0, discrepancy, False, threshold)
1257
+ stiffness = sparse.csr_matrix(active.stiffness_plan().matrix)
1258
+ q = u[independent]
1259
+ scaled = sparse.csr_matrix(plan.matrix)
1260
+ norm = float(abs(scaled).sum(axis=1).max())
1261
+ if float(abs(scaled - scaled.T).max()) > 1.0e-12 * norm:
1262
+ raise SubmodelTransferError("ALLOWANCE_UNSUPPORTED", "the equilibrated operator is not symmetric")
1263
+ scale = np.asarray(plan.scaling, dtype=float)
1264
+ reduced_load = constraint.reduce_load(stiffness, load)
1265
+ y = q / scale
1266
+ residual = scaled @ y - scale * reduced_load
1267
+ denominator = norm * float(np.max(np.abs(y))) + float(np.max(np.abs(scale * reduced_load)))
1268
+ eta = float(np.max(np.abs(residual)) / denominator) if denominator > 0.0 else 0.0
1269
+ handle = plan.handle
1270
+ if handle is None or handle.status != "ok":
1271
+ raise SubmodelTransferError("ALLOWANCE_FACTORIZATION", "the solver's factorization is unavailable")
1272
+ n = scaled.shape[0]
1273
+ inverse = LinearOperator((n, n), matvec=handle.solve, rmatvec=handle.solve, dtype=float)
1274
+ kappa = norm * float(onenormest(inverse))
1275
+ finally:
1276
+ if owned:
1277
+ active.close()
1278
+ dq = scale * kappa * eta * float(np.max(np.abs(y)))
1279
+ du = np.asarray(abs(t) @ dq, dtype=float).reshape(-1) + discrepancy
1280
+ if not (np.isfinite(eta) and np.isfinite(kappa) and np.all(np.isfinite(du))):
1281
+ raise SubmodelTransferError("ALLOWANCE_NONFINITE", "the error allowance is not finite")
1282
+ return StaticErrorAllowance(eta, kappa, du, bool(kappa * eta > threshold), threshold)
1283
+
1284
+
1285
+ def force_allowance(
1286
+ model: Any,
1287
+ displacements: Any,
1288
+ load_case: Any,
1289
+ displacement_allowance: Any,
1290
+ *,
1291
+ assembled: Optional[Tuple[sparse.csr_matrix, np.ndarray]] = None,
1292
+ ) -> np.ndarray:
1293
+ """Per-DOF allowance of ``K u - f``: propagated error plus a matvec roundoff floor."""
1294
+
1295
+ u = _vector(model, displacements, "FORCE_INPUT")
1296
+ du = _finite(displacement_allowance, "ALLOWANCE_INVALID", "displacement allowance").reshape(-1)
1297
+ if du.shape != u.shape or np.any(du < 0.0):
1298
+ raise SubmodelTransferError("ALLOWANCE_INVALID", "displacement allowance must match the DOFs and be non-negative")
1299
+ stiffness, load = _assembled(model, load_case) if assembled is None else assembled
1300
+ absolute = abs(stiffness)
1301
+ nnz = np.diff(stiffness.indptr).astype(float)
1302
+ gamma = nnz * _EPS / (1.0 - nnz * _EPS)
1303
+ out = np.asarray(absolute @ du + gamma * (absolute @ np.abs(u)) + _EPS * np.abs(load), dtype=float).reshape(-1)
1304
+ if not np.all(np.isfinite(out)):
1305
+ raise SubmodelTransferError("ALLOWANCE_NONFINITE", "the force allowance is not finite")
1306
+ return out