Implement Gre24 reproduction and freeze v5 preparation evidence
This commit is contained in:
1 parent
baf2ac8145
commit
8409910b1e
49 files changed
+30910
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
HTTP/1.1 403 Forbidden
|
||||||
|
server: nginx
|
||||||
|
date: Sun, 15 Nov 2026 15:22:16 GMT
|
||||||
|
content-type: text/html; charset=utf-8
|
||||||
|
content-length: 763
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
<html>
|
||||||
|
<head><title>403 Forbidden</title></head>
|
||||||
|
<body style="max-width: 600px; margin: 40px auto; padding: 0 20px; line-height: 1.6;">
|
||||||
|
<h1>403 Forbidden</h1>
|
||||||
|
<hr>
|
||||||
|
<p>Access to this resource has been restricted due to unusual traffic from your network.</p>
|
||||||
|
<p>If you believe this is a mistake, please <a href="/support?ref=9a2629626a906815923bdd84a38a7efe&category=problem-report">contact our support line</a> and we will look into your request.</p>
|
||||||
|
<p>
|
||||||
|
<strong>Reference:</strong> <code>9a2629626a906815923bdd84a38a7efe</code><br>
|
||||||
|
<strong>Timestamp:</strong> <code>2026-11-15T16:22:16+01:00</code><br>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
HTTP/1.1 403 Forbidden
|
||||||
|
server: nginx
|
||||||
|
date: Sun, 15 Nov 2026 15:24:29 GMT
|
||||||
|
content-type: text/html; charset=utf-8
|
||||||
|
content-length: 763
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
<html>
|
||||||
|
<head><title>403 Forbidden</title></head>
|
||||||
|
<body style="max-width: 600px; margin: 40px auto; padding: 0 20px; line-height: 1.6;">
|
||||||
|
<h1>403 Forbidden</h1>
|
||||||
|
<hr>
|
||||||
|
<p>Access to this resource has been restricted due to unusual traffic from your network.</p>
|
||||||
|
<p>If you believe this is a mistake, please <a href="/support?ref=3d6b428b96545309116ee2463e2153b4&category=problem-report">contact our support line</a> and we will look into your request.</p>
|
||||||
|
<p>
|
||||||
|
<strong>Reference:</strong> <code>3d6b428b96545309116ee2463e2153b4</code><br>
|
||||||
|
<strong>Timestamp:</strong> <code>2026-11-15T16:24:29+01:00</code><br>
|
||||||
|
</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
HTTP/1.1 403 Forbidden
|
||||||
|
server: nginx
|
||||||
|
date: Sun, 15 Nov 2026 15:21:15 GMT
|
||||||
|
content-type: text/html; charset=utf-8
|
||||||
|
content-length: 763
|
||||||
|
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
Processing ./artifacts/gre24-reproduction-2026-11-15/environment/fim-python-1.2.2-source
|
||||||
|
Preparing metadata (pyproject.toml): started
|
||||||
|
Preparing metadata (pyproject.toml): finished with status 'done'
|
||||||
|
Building wheels for collected packages: fim-python
|
||||||
|
Building wheel for fim-python (pyproject.toml): started
|
||||||
|
Building wheel for fim-python (pyproject.toml): finished with status 'done'
|
||||||
|
Created wheel for fim-python: filename=fim_python-1.2.2-cp310-cp310-linux_x86_64.whl size=296346 sha256=3709630159b47483c6f8efd99cad925025e2952fbef8fd7c92d38e9391678ac1
|
||||||
|
Stored in directory: /tmp/pip-ephem-wheel-cache-tikjm498/wheels/42/95/64/01fe078123ee2bd0c28bf13ce5cd7f01e2025e6bff2bfdfb67
|
||||||
|
Successfully built fim-python
|
||||||
|
Installing collected packages: fim-python
|
||||||
|
Successfully installed fim-python-1.2.2
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/fim_cupy.py": "ca7634d57f3b3ee8793577ddab47ddf4a7680f4700140099bb0cddc31c32b8a6",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/solver.py": "5a960ebbe603ed7c625b522d95bcb40652623c239d59c7cc0375894701d0257c",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/fim_np.py": "cc87c73d02c1441438043f07e8c9e38a446409f183e5b7c41a3d6beb67b19788",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/fim_base.py": "cb013ea9bf7a2e50b864c5c2dd9a9c731b25088134b9c2b31a1a9ee6724a5e92",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/cupy_kernels.py": "e81a760ba34ea56cd9a6c6cd5f9df6fbac3e187a5689d638a84abdcdf52cb086",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/__init__.py": "06f8eb151aa22fb54b66c9c1da3963ac4d7f79da903685b21b452e89ccd626c5",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/utils/tsitsiklis.py": "9655cbcab9540995ca7f4f170d14e08cd6990998fca0f940d5fc429461cf41db",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/utils/comp.py": "c65a83c80693ec2c45308c3a62a0330118052c8a06ecfb93a4191b1677388bd3",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/utils/__init__.py": "570aa2774fe79e6691faf9551268416f6a1e939a79fb70051e8b8f74d798bd2a",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/utils/cython/comp.cpython-310-x86_64-linux-gnu.so": "34ae99e30c22c2de9cdde79a3c97eabc514502fc60eaa95b5687df451efcdfc4",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/utils/cython/__init__.py": "a56e679b74e8d3ceef85597aeda7db5f4812ba6079ac79a3928fd8136747aa03",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/fim_cutils/fim_cutils.cpython-310-x86_64-linux-gnu.so": "edd8f9e6b6072d8e4ef460e2dd80f49ded7d294460438baafc7da39e13da2157",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/lib/python3.10/site-packages/fimpy/fim_cutils/__init__.py": "73f25cebd7387ad67a8255b52875268344cb7c34ada75dfe3911d2dd54c81652"
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
numpy==1.26.4
|
||||||
|
scipy==1.15.3
|
||||||
|
scikit-learn==1.7.2
|
||||||
|
xgboost==2.1.4
|
||||||
|
psutil==5.9.0
|
||||||
|
PyYAML==6.0.1
|
||||||
|
joblib==1.5.3
|
||||||
|
threadpoolctl==3.5.0
|
||||||
|
Cython==3.0.12
|
||||||
|
fim-python==1.2.2
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
...........
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Ran 11 tests in 0.199s
|
||||||
|
|
||||||
|
OK
|
||||||
|
Import of Cupy failed. The GPU version of fimpy will be unavailable. Message: No module named 'cupy'
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"tests": 13,
|
||||||
|
"failures": 0,
|
||||||
|
"errors": 0,
|
||||||
|
"passed": true,
|
||||||
|
"CPU_seconds": 1.0948849999999999,
|
||||||
|
"wall_seconds": 0.27822360600112006,
|
||||||
|
"peak_rss_bytes": 113463296
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
test_affine_gradient_and_constant (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_all_wall_tet_supplement (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_complete_pipeline_and_fail_closed (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_disk_ideal_volume_mapping (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_gate_original_id_tie (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_moment_rotation (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_planar_speed_two (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_rod_volume_mapping (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_split_then_average (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_strict_ties_volume_weights (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_three_metrics_and_undefined (test_gre24_features.Gre24Checks) ... ok
|
||||||
|
test_scale_invariance (__main__.ScaleChecks) ... ok
|
||||||
|
test_tiny_speed_reaches_same_analytic_solution (__main__.ScaleChecks) ... ok
|
||||||
|
|
||||||
|
----------------------------------------------------------------------
|
||||||
|
Ran 13 tests in 0.278s
|
||||||
|
|
||||||
|
OK
|
||||||
|
Import of Cupy failed. The GPU version of fimpy will be unavailable. Message: No module named 'cupy'
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"status": "COMPLETE",
|
||||||
|
"stop_reason": null,
|
||||||
|
"records": [
|
||||||
|
{
|
||||||
|
"worker": {
|
||||||
|
"status": "PASS",
|
||||||
|
"command": [
|
||||||
|
"/home/frank14f/optane/MeltMind/artifacts/gre24-reproduction-2026-11-15/environment/venv/bin/python",
|
||||||
|
"tools/gre24_prepare.py",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/v5-cost-test",
|
||||||
|
"0"
|
||||||
|
],
|
||||||
|
"returncode": 0,
|
||||||
|
"stop_reason": null,
|
||||||
|
"cpu_seconds": 22.684837,
|
||||||
|
"wall_seconds": 23.95351290499093,
|
||||||
|
"peak_tree_rss_bytes": 257331200,
|
||||||
|
"peak_process_count": 1,
|
||||||
|
"output_disk_bytes_before_receipt": 1703936,
|
||||||
|
"max_poll_gap_seconds": 0.5479361659963615,
|
||||||
|
"poll_target_seconds": 0.2,
|
||||||
|
"reaped_orphan_cpu_seconds": 0.0,
|
||||||
|
"supervision": "sampled process-tree monitoring; wait4 final CPU/HWM; overshoot retained as failure",
|
||||||
|
"gpu_visible": false,
|
||||||
|
"retry": false,
|
||||||
|
"monitor_errors": 0,
|
||||||
|
"last_monitor_error": null
|
||||||
|
},
|
||||||
|
"index": 0,
|
||||||
|
"case": "00001130_c2db313c2ce749d784c610d2_step_002",
|
||||||
|
"result_path": "artifacts/gre24-reproduction-2026-11-15/v5-cost-test/parts/00001130_c2db313c2ce749d784c610d2_step_002/output/result.json",
|
||||||
|
"result_sha256": "e8e7a18bdedbf58a567b9c8a39ff81937dda32fa0afe9d3e2e526ec94e86a2c2",
|
||||||
|
"guard_cpu_seconds": 2.378528
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"never_attempted": [],
|
||||||
|
"worker_cpu_seconds": 22.684837,
|
||||||
|
"initial_cpu_reserve_seconds": 60,
|
||||||
|
"coordinator_cpu_seconds": 1.060235,
|
||||||
|
"accounting_complete": true,
|
||||||
|
"wall_seconds": 25.736168545030523
|
||||||
|
}
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
"scope": "Single v5 geometry-only cost check, not v4 paper protocol",
|
||||||
|
"authorizing_ruling": "1794755993.778319",
|
||||||
|
"feature_only_cost_test": true,
|
||||||
|
"archive": "/home/frank14f/optane/MeltMind/data.zip",
|
||||||
|
"archive_stat": {
|
||||||
|
"status": "official_size_and_md5_pass",
|
||||||
|
"source": "/home/frank14f/optane/MeltMind/data.zip",
|
||||||
|
"source_url": "https://zenodo.org/records/18598121",
|
||||||
|
"bytes": 32757812726,
|
||||||
|
"md5": "75ec15002234c2cdcdf4c751bdefab85",
|
||||||
|
"sha256": "d151f018294832fd80fbd23e865642cb16c860da150f245033d010c388fa0241",
|
||||||
|
"mtime_ns": 1794548962944204621,
|
||||||
|
"inode": 12582980,
|
||||||
|
"members": 1872,
|
||||||
|
"triplets": 624,
|
||||||
|
"source_tokens": 249,
|
||||||
|
"max_group": 34,
|
||||||
|
"total_uncompressed_bytes": 43966308383,
|
||||||
|
"finished_utc": "2026-11-13T08:04:57.180660+00:00",
|
||||||
|
"wall_seconds": 97.27923265600111,
|
||||||
|
"peak_rss_kib": 32056,
|
||||||
|
"crc_scope": "ZIP stored CRC inventory only; selected members checked on read; no full decompression",
|
||||||
|
"grouping_scope": "Filename source tokens, not verified independent CAD families"
|
||||||
|
},
|
||||||
|
"parts": [
|
||||||
|
{
|
||||||
|
"case": "00001130_c2db313c2ce749d784c610d2_step_002",
|
||||||
|
"raw_nodes": 8276
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dispatch_order": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"worker_cpus": [
|
||||||
|
8
|
||||||
|
],
|
||||||
|
"coordinator_cpus": [
|
||||||
|
30,
|
||||||
|
31
|
||||||
|
],
|
||||||
|
"limits": {
|
||||||
|
"workers": 1,
|
||||||
|
"total_worker_cpu_seconds": 144000,
|
||||||
|
"per_part_cpu_seconds": 1800,
|
||||||
|
"per_part_wall_seconds": 1800,
|
||||||
|
"per_part_rss_bytes": 4294967296,
|
||||||
|
"preparation_initial_cpu_reserve_seconds": 60
|
||||||
|
},
|
||||||
|
"code_sha256": {
|
||||||
|
"tools/gre24_features.py": "92bca4d348f31246c2e931949e2ca38103881b1b784a621a42044db56a460026",
|
||||||
|
"tools/gre24_prepare.py": "23b96933e40501bd9b73ce95a2bad9f4853e7a300371f8d847281a0779f515cb",
|
||||||
|
"tools/run_gre24_preparation.py": "40cfab48cbc82d6abe6939bdb9e7142747b29769a0893a694ffd8087a72aab60",
|
||||||
|
"tools/boundary_distance.py": "a45c1cbce92521a96eb814913b4f465b926c0b3883932ab0b7c37d11db113ed7",
|
||||||
|
"tools/audit_samples.py": "a3daf70ec3bcb77bf46d9dc4887d552cf7c422117880a169969780012278cd70",
|
||||||
|
"tools/s2_recovery_supervisor.py": "f563ca3c2665f5baf0c04f296616e4640423a59b815fbb00479af0f29e57a919",
|
||||||
|
"tools/s2_recovery_monitoring.py": "442c2a9c75e8c00b30a8f2e91cb52d87c466b19a80aea9128b10c021e61b922e"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"first": "00001130_c2db313c2ce749d784c610d2_step_002",
|
||||||
|
"status": "PASS",
|
||||||
|
"projected_preparation_cpu_seconds": 28.356046250000002,
|
||||||
|
"projection_is_heuristic": true,
|
||||||
|
"total_worker_cap_seconds": 144000,
|
||||||
|
"first_result_sha256": "e8e7a18bdedbf58a567b9c8a39ff81937dda32fa0afe9d3e2e526ec94e86a2c2"
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
{
|
||||||
|
"worker": {
|
||||||
|
"status": "PASS",
|
||||||
|
"command": [
|
||||||
|
"/home/frank14f/optane/MeltMind/artifacts/gre24-reproduction-2026-11-15/environment/venv/bin/python",
|
||||||
|
"tools/gre24_prepare.py",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/v5-cost-test",
|
||||||
|
"0"
|
||||||
|
],
|
||||||
|
"returncode": 0,
|
||||||
|
"stop_reason": null,
|
||||||
|
"cpu_seconds": 22.684837,
|
||||||
|
"wall_seconds": 23.95351290499093,
|
||||||
|
"peak_tree_rss_bytes": 257331200,
|
||||||
|
"peak_process_count": 1,
|
||||||
|
"output_disk_bytes_before_receipt": 1703936,
|
||||||
|
"max_poll_gap_seconds": 0.5479361659963615,
|
||||||
|
"poll_target_seconds": 0.2,
|
||||||
|
"reaped_orphan_cpu_seconds": 0.0,
|
||||||
|
"supervision": "sampled process-tree monitoring; wait4 final CPU/HWM; overshoot retained as failure",
|
||||||
|
"gpu_visible": false,
|
||||||
|
"retry": false,
|
||||||
|
"monitor_errors": 0,
|
||||||
|
"last_monitor_error": null
|
||||||
|
},
|
||||||
|
"index": 0,
|
||||||
|
"case": "00001130_c2db313c2ce749d784c610d2_step_002",
|
||||||
|
"result_path": "artifacts/gre24-reproduction-2026-11-15/v5-cost-test/parts/00001130_c2db313c2ce749d784c610d2_step_002/output/result.json",
|
||||||
|
"result_sha256": "e8e7a18bdedbf58a567b9c8a39ff81937dda32fa0afe9d3e2e526ec94e86a2c2",
|
||||||
|
"guard_cpu_seconds": 2.378528
|
||||||
|
}
|
||||||
Whitespace-only changes.
+10
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"cpu_seconds_charged": 22.684837,
|
||||||
|
"attempts": [
|
||||||
|
{
|
||||||
|
"name": "worker",
|
||||||
|
"status": "PASS",
|
||||||
|
"cpu_seconds": 22.684837
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+21
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"raw_nodes": 8276,
|
||||||
|
"tet_nodes": 8276,
|
||||||
|
"outside_tet_nodes": 0,
|
||||||
|
"raw_cell_types": {
|
||||||
|
"10": 44778
|
||||||
|
},
|
||||||
|
"inlet_config": {
|
||||||
|
"inlet_location": [
|
||||||
|
76.91450814346175,
|
||||||
|
1.6598980997528443,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"inlet_normal": [
|
||||||
|
-0.0,
|
||||||
|
0.0,
|
||||||
|
-1.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"gate_source": "YAML inlet_location; no explicit node/face markers in this source"
|
||||||
|
}
|
||||||
BIN
Binary file not shown.
+8
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"stage": "PASS_COST_TEST_ONLY",
|
||||||
|
"case": "00001130_c2db313c2ce749d784c610d2_step_002",
|
||||||
|
"pid": 479015,
|
||||||
|
"unix": 1794756125.6953487,
|
||||||
|
"CPU_s": 21.690821098,
|
||||||
|
"wall_s": 22.834724957006983
|
||||||
|
}
|
||||||
BIN
Binary file not shown.
+112
@@ -0,0 +1,112 @@
|
|||||||
|
{
|
||||||
|
"status": "PASS",
|
||||||
|
"case": "00001130_c2db313c2ce749d784c610d2_step_002",
|
||||||
|
"index": 0,
|
||||||
|
"geometry": {
|
||||||
|
"raw_nodes": 8276,
|
||||||
|
"tet_nodes": 8276,
|
||||||
|
"outside_tet_nodes": 0,
|
||||||
|
"raw_cell_types": {
|
||||||
|
"10": 44778
|
||||||
|
},
|
||||||
|
"inlet_config": {
|
||||||
|
"inlet_location": [
|
||||||
|
76.91450814346175,
|
||||||
|
1.6598980997528443,
|
||||||
|
0.0
|
||||||
|
],
|
||||||
|
"inlet_normal": [
|
||||||
|
-0.0,
|
||||||
|
0.0,
|
||||||
|
-1.0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"gate_source": "YAML inlet_location; no explicit node/face markers in this source"
|
||||||
|
},
|
||||||
|
"features": {
|
||||||
|
"columns": [
|
||||||
|
"Vf",
|
||||||
|
"grad_Vf_x",
|
||||||
|
"grad_Vf_y",
|
||||||
|
"grad_Vf_z",
|
||||||
|
"Di_star",
|
||||||
|
"grad_Di_x",
|
||||||
|
"grad_Di_y",
|
||||||
|
"grad_Di_z",
|
||||||
|
"Dw",
|
||||||
|
"Dw_star",
|
||||||
|
"grad_Dw_x",
|
||||||
|
"grad_Dw_y",
|
||||||
|
"grad_Dw_z",
|
||||||
|
"Sxx",
|
||||||
|
"Sxy",
|
||||||
|
"Sxz",
|
||||||
|
"Syy",
|
||||||
|
"Syz",
|
||||||
|
"Szz"
|
||||||
|
],
|
||||||
|
"gate_mode": "nearest_tet_node_min_original_id_tie",
|
||||||
|
"gate_nodes": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"gate_raw_ids": [
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"wall_mode": "tet_exterior_proxy",
|
||||||
|
"all_wall_tetrahedra": 0,
|
||||||
|
"all_wall_rule": "centroid_triangle_distance_R1_supplement",
|
||||||
|
"all_wall_volume_fraction": 0.0,
|
||||||
|
"timings_cpu_seconds": {
|
||||||
|
"Dw": 4.453794401000001,
|
||||||
|
"Di": 3.541143052999999,
|
||||||
|
"cell_speed": 0.0033471099999999865,
|
||||||
|
"Df": 4.748212048000001,
|
||||||
|
"gradients": 0.07174791299999939,
|
||||||
|
"moment": 8.051094308
|
||||||
|
},
|
||||||
|
"worker_cpu_seconds": 21.205151452,
|
||||||
|
"volume": 11894.999999985002,
|
||||||
|
"hmax": 7.7945968873754605,
|
||||||
|
"moment": {
|
||||||
|
"radius": 23.38379066212638,
|
||||||
|
"coincident_centers_excluded": 0,
|
||||||
|
"component_order": [
|
||||||
|
"Sxx",
|
||||||
|
"Sxy",
|
||||||
|
"Sxz",
|
||||||
|
"Syy",
|
||||||
|
"Syz",
|
||||||
|
"Szz"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"speed_min": 0.010906419999999528,
|
||||||
|
"speed_max": 0.7211048038631592,
|
||||||
|
"flow_distance_tied_nodes": 0,
|
||||||
|
"zero_gradient_nodes": [
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"gate_mapping_distance": 3.4705475884206305e-09,
|
||||||
|
"exterior_proxy_includes_gate": true,
|
||||||
|
"precision": "float64",
|
||||||
|
"fim_device": "cpu",
|
||||||
|
"max_iterations": 100000
|
||||||
|
},
|
||||||
|
"output_sha256": {
|
||||||
|
"mass.npy": "7c977cde94ffc7ad1869c7750bc922e4f27a73a987f38a9c865143776f435972",
|
||||||
|
"Df.npy": "0821b38624f5353e2910168fcd89ca068210e5cbc51fb50a62f274835773b9f7",
|
||||||
|
"all_wall_tet_ids.npy": "e734dac55ea9fbbe782af2d8c02c3c5992131906228afb2aaaf137d6f3ed74db",
|
||||||
|
"Dw.npy": "60210f10325f973f2c1ebd8fda2eeb8c09c89031b756f9a4b50cdc9521b99e65",
|
||||||
|
"Di.npy": "a1a58892a8bdf23ef5c47c380ec2111458f4fe284bdd356658ab91f9907f00dd",
|
||||||
|
"raw_ids.npy": "839897fcf4660146d0d1cbc24a48e07cd7667b4ee5dabd637a9ddc0481a3d929",
|
||||||
|
"features.npy": "52f843db839ffe54b78002386f7d2198d6b4bddc84c40b551481b8a9105a1933",
|
||||||
|
"Vf.npy": "22b790cea882373e4ba7700f54353a63a80d7d5be464fa219dedcec3ba9db8d1"
|
||||||
|
},
|
||||||
|
"worker_cpu_seconds": 21.690594813,
|
||||||
|
"wall_seconds": 22.834499143005814,
|
||||||
|
"decoded_labels": [],
|
||||||
|
"test_scores_computed": false,
|
||||||
|
"training": false,
|
||||||
|
"cost_test_only": true
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
Import of Cupy failed. The GPU version of fimpy will be unavailable. Message: No module named 'cupy'
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"status": "PASS",
|
||||||
|
"command": [
|
||||||
|
"/home/frank14f/optane/MeltMind/artifacts/gre24-reproduction-2026-11-15/environment/venv/bin/python",
|
||||||
|
"tools/gre24_prepare.py",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/v5-cost-test",
|
||||||
|
"0"
|
||||||
|
],
|
||||||
|
"returncode": 0,
|
||||||
|
"stop_reason": null,
|
||||||
|
"cpu_seconds": 22.684837,
|
||||||
|
"wall_seconds": 23.95351290499093,
|
||||||
|
"peak_tree_rss_bytes": 257331200,
|
||||||
|
"peak_process_count": 1,
|
||||||
|
"output_disk_bytes_before_receipt": 1703936,
|
||||||
|
"max_poll_gap_seconds": 0.5479361659963615,
|
||||||
|
"poll_target_seconds": 0.2,
|
||||||
|
"reaped_orphan_cpu_seconds": 0.0,
|
||||||
|
"supervision": "sampled process-tree monitoring; wait4 final CPU/HWM; overshoot retained as failure",
|
||||||
|
"gpu_visible": false,
|
||||||
|
"retry": false,
|
||||||
|
"monitor_errors": 0,
|
||||||
|
"last_monitor_error": null
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"command": [
|
||||||
|
"/home/frank14f/optane/MeltMind/artifacts/gre24-reproduction-2026-11-15/environment/venv/bin/python",
|
||||||
|
"tools/gre24_prepare.py",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/v5-cost-test",
|
||||||
|
"0"
|
||||||
|
],
|
||||||
|
"limits": {
|
||||||
|
"total_cpu_seconds": 1801,
|
||||||
|
"job_cpu_seconds": 1800,
|
||||||
|
"job_wall_seconds": 1800,
|
||||||
|
"tree_rss_bytes": 4294967296,
|
||||||
|
"disk_bytes": 2147483648,
|
||||||
|
"max_processes": 1
|
||||||
|
},
|
||||||
|
"started_unix": 1794756101.9237354
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"completed": 1,
|
||||||
|
"attempted": 1,
|
||||||
|
"total": 1,
|
||||||
|
"active": {},
|
||||||
|
"settled_worker_cpu_seconds": 82.684837,
|
||||||
|
"reserved_active_worker_cpu_seconds": 0,
|
||||||
|
"stop_reason": null,
|
||||||
|
"first_part_checked": true,
|
||||||
|
"elapsed_seconds": 25.735798500012606
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"pid": 479012,
|
||||||
|
"unix": 1794756100.7669392,
|
||||||
|
"contract_sha256": "22de519e9c7ed51e31aa24bfc1ec7eb7ab2c7290c9eb799f1c1b799f3cbb9cd3"
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
{
|
||||||
|
"unix": 1794756443.4433107,
|
||||||
|
"processes": [
|
||||||
|
{
|
||||||
|
"pid": 479550,
|
||||||
|
"ppid": 3257,
|
||||||
|
"name": "python",
|
||||||
|
"cmdline": [
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/environment/venv/bin/python",
|
||||||
|
"tools/run_gre24_protocol_preparation.py",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/v5-protocol"
|
||||||
|
],
|
||||||
|
"create_time": 1794756410.19
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": 479551,
|
||||||
|
"ppid": 479550,
|
||||||
|
"name": "python",
|
||||||
|
"cmdline": [
|
||||||
|
"/home/frank14f/optane/MeltMind/artifacts/gre24-reproduction-2026-11-15/environment/venv/bin/python",
|
||||||
|
"/home/frank14f/optane/MeltMind/tools/run_gre24_protocol_preparation.py",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/v5-protocol",
|
||||||
|
"--guard",
|
||||||
|
"0",
|
||||||
|
"--slot",
|
||||||
|
"0"
|
||||||
|
],
|
||||||
|
"create_time": 1794756411.26
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pid": 479583,
|
||||||
|
"ppid": 479551,
|
||||||
|
"name": "python",
|
||||||
|
"cmdline": [
|
||||||
|
"/home/frank14f/optane/MeltMind/artifacts/gre24-reproduction-2026-11-15/environment/venv/bin/python",
|
||||||
|
"tools/gre24_prepare_v2.py",
|
||||||
|
"artifacts/gre24-reproduction-2026-11-15/v5-protocol",
|
||||||
|
"0"
|
||||||
|
],
|
||||||
|
"create_time": 1794756412.14
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source_pins_match": {
|
||||||
|
"tools/gre24_features_v2.py": true,
|
||||||
|
"tools/gre24_prepare_v2.py": true,
|
||||||
|
"tools/run_gre24_protocol_preparation.py": true,
|
||||||
|
"tools/boundary_distance.py": true,
|
||||||
|
"tools/audit_samples.py": true,
|
||||||
|
"tools/s2_recovery_supervisor.py": true,
|
||||||
|
"tools/s2_recovery_monitoring.py": true
|
||||||
|
},
|
||||||
|
"queue_started": {
|
||||||
|
"pid": 479550,
|
||||||
|
"unix": 1794756411.2778203,
|
||||||
|
"contract_sha256": "9f8f87cb36108d51a7bdf90f006b709fd2483a9c4d9cc6658ee8d722f634a248"
|
||||||
|
},
|
||||||
|
"progress_snapshot": {
|
||||||
|
"completed": 0,
|
||||||
|
"attempted": 1,
|
||||||
|
"total": 624,
|
||||||
|
"active": {
|
||||||
|
"0": 0
|
||||||
|
},
|
||||||
|
"settled_worker_cpu_seconds": 82.684837,
|
||||||
|
"reserved_active_worker_cpu_seconds": 1802,
|
||||||
|
"stop_reason": null,
|
||||||
|
"first_part_checked": false,
|
||||||
|
"elapsed_seconds": 32.07035375898704
|
||||||
|
},
|
||||||
|
"training_started": false,
|
||||||
|
"v4_obtained": false
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"pid": 479550,
|
||||||
|
"unix": 1794756411.2778203,
|
||||||
|
"contract_sha256": "9f8f87cb36108d51a7bdf90f006b709fd2483a9c4d9cc6658ee8d722f634a248"
|
||||||
|
}
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,17 @@
|
|||||||
|
# Gre24 今晚复现:独立实现与真实启动
|
||||||
|
|
||||||
|
用户经TRON转达“今晚你们就做复现工作就行”,Claude1794755127领队;最新规格9783a338以方法/协议一致性为标准,论文数字只作诊断。Mold R1原文件9391B已实际下载并核SHA256 55eb0d488dbdb215d7f71cbb4b759acefc754d15fd7a9ef09e2f628ac13c1cd7,Claude1794755474/5594/6243固定离散、FNN和等价单位换算。
|
||||||
|
|
||||||
|
原数据v4已核官方record11370149,629件,35,925,187,752B,MD5 4973f24e12a38c87c31cf129be1a3e3b。10027027是concept DOI,不是固定v4。Horsea对正确网页文件、API内容端点、普通UA小Range均403,原响应说明unusual traffic。未下载整包,未把网络失败称作撤回。Claude1794756165/6271明确今晚继续v5版本偏差协议,由Grok唯一中转v4;不能将v5结果称为v4忠实复现结果。
|
||||||
|
|
||||||
|
新环境是artifacts/gre24-reproduction-2026-11-15/environment/venv。固定实际运行版本numpy1.26.4、scipy1.15.3、sklearn1.7.2、xgboost2.1.4、fim-python1.2.2、torch2.5.1+cu124。依赖从本机完整包独立复制,fim-python官方源发行包本地编译;不改原环境、不启用system-site-packages。原环境过期dist-info与实际代码不一致,首轮复制遗漏SciPy运行文件导致导入失败,已在新环境补齐完整树并归档过期元数据;不把metadata旧版本冒称运行版本。复制清单、文件哈希、构建及失败记录在环境根保存。
|
||||||
|
|
||||||
|
原方法19列(无t_set输入)和三个CPU tetFIM距离实现于gre24_features_v2.py;R1的集总严格CDF、P1体积加权梯度、BallTree双严格邻域、全壁tet重心补充均显式。库要求metric特征值>1e-4;仅在原速度违反时按Claude裁量同时x和f乘1/min(f),phi及其停止单位不变,不加epsilon、不改库阈值。原11合成通过;新版本13合成通过,CPU1.094885s,含缩放不变及小速度解析解。
|
||||||
|
|
||||||
|
单v5成本件1130先完成PASS:worker22.684837CPU秒、墙钟23.953513秒、峰树RSS257331200B、monitor_errors0。无标签无评分,其固定源和原结果保留。正式队列对该兼容件核hash后复用特征,仅补全节点标签;不重新求解。
|
||||||
|
|
||||||
|
实际启动:唯一session18323/coordinator479550,root artifacts/gre24-reproduction-2026-11-15/v5-protocol,首guard479551/worker479583已在宿主核到。合同9f8f87cb36108d51a7bdf90f006b709fd2483a9c4d9cc6658ee8d722f634a248,splits76bb712f5c40c3c5bc3ec6ffc670e8259456802d36facd5f4282049704c239da。全624固定五次312/312随机几何拆分;不是5折CV,不套用617合格名单。预处理失败不替补,全部原tet节点包括壁节点,域外原ID/标签另存。v5无可靠施加Q时使用求解前t_set,明示时间尺度替代;不从真实终点拟合Q。
|
||||||
|
|
||||||
|
总40workerCPUh与2GPUh共享上限;现制备最多8worker,单件1800CPU/墙钟秒与4GiB,首件成本检查后自动续行。旧成本22.684837s计一次,合成等另作60CPU秒保守预留,环境搭建管理费用另列。FNN最多30epoch、训练几何固定留10%(ceil=32件)、patience5恢复best;fill-only是明确偏差。模型与正式评分尚未启动,后续回执不得由本文启动状态代替。
|
||||||
|
|
||||||
|
本轮仅进入原方法复现;S2/S3历史结果、失败和源码未改。v4未取得,R4未执行。论文数字命中不构成复现认证。
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# Gre24 faithful reproduction: specification and plan (Claude, 2026-11-15 night)
|
||||||
|
|
||||||
|
Source: Greif, Lechner, Meyer, Composites Part A 185 (2024) 108340, author PDF from OPUS docId 113920, full text extracted locally with pypdf (scratch_pdf/gre24.txt). Section, equation and table numbers refer to the paper. R2-G24 in S2 was an approximation and is not this reproduction. The frozen S2/S3 results stay unchanged.
|
||||||
|
|
||||||
|
## 1. Method as published (status: S = specified, A = ambiguous, M = missing)
|
||||||
|
| Item | Paper | Status |
|
||||||
|
|---|---|---|
|
||||||
|
| Data | Autodesk Moldflow simulations of 629 random ABC geometries; one random gate; PP GF30; automatic flow. Dataset DOI in footnote 1: **10.5281/zenodo.10027027** (v4 era); "Data will be made available on request" | S. Check whether the v4 record is downloadable |
|
||||||
|
| Mesh | Reuses the Moldflow tet mesh; all nodes | S |
|
||||||
|
| Distances (Table 1, eq. 5) | Eikonal on the tet mesh with **fim-python (tetFIM, Fu et al.)**, phi0 = 0. D_w: f = 1, source = wall boundary. D_i: f = 1, source = gate. D_f: **f = D_w**, source = gate | S. Gate source set (node or face) is A |
|
||||||
|
| Normalisation (eq. 8) | D*_w = D_w/max D_w, D*_i = D_i/max D_i, D*_f = D_f/max D_f | S |
|
||||||
|
| Relative flow volume (eq. 10) | V*_f(c) = vol{D_f < c}/vol(Omega), evaluated at each node's own D_f | Discretisation (nodal lumped vs element volume, ties) is A |
|
||||||
|
| Gradients (eq. 11) | Normalised gradient direction grad/norm of V*_f, D*_i, D*_w | How nodal gradients are formed on tets is A |
|
||||||
|
| Spatial moment (eqs. 6-7) | S_i = sum_j (v_j/V_i) d_ij outer d_ij over cell centres j with distance to x_i < R **and** abs(D_i(x_j) - D_i(x_i)) < R; R = 3 h_max (longest edge in the mesh); scikit-learn BallTree | S. D_i at cell centres is A; component layout is A (6 unique) |
|
||||||
|
| Feature tuple (eq. 12) | X* = (V*_f, grad*V*_f, D*_i, grad*D*_i, D_w, D*_w, grad*D*_w, S); D_w enters un-normalised as well | S (about 19 columns) |
|
||||||
|
| Target / denormalisation (eq. 17) | t*_fill = t_fill V-dot / V; t_fill = (V/V-dot) t* with the applied flow rate V-dot | A for us: does v4/v5 carry V-dot, and does V/V-dot equal our t_set? |
|
||||||
|
| Naive model (3.3.1) | t*_fill = V*_f | S |
|
||||||
|
| GBRT (3.3.3, 4) | **XGBoost**, 100 trees, max depth 8, learning rate 0.1, MSE | S. Other XGBoost parameters are library defaults, A |
|
||||||
|
| FNN (3.3.2, 4) | 4 hidden layers x 100, ReLU, Adam lr 1e-3, batch 1024 node pairs, MSE, PyTorch | Epochs / early stopping are M |
|
||||||
|
| Multi-output | Y* = (t*_fill, t*_cool, S*_vol, A); the paper trains on all of them | We reproduce fill time only. Single-output versus joint training is A for the FNN |
|
||||||
|
| Protocol (4.1) | 5 random splits, 315 test / 314 train geometries; RRMSE per test geometry over every node; curves averaged over the 5 splits | S. The **RRMSE normaliser is not defined: A** |
|
||||||
|
| Published targets | Table C.5 FNN(100,4,ReLU): t_fill RRMSE median **0.0339**, min 0.0130, max 0.2565. Table C.6 GBRT(100,8): median **0.0338**, min 0.0082, max 0.2550. Text: 300 of 314 test geometries well below 0.1; ML only slightly better than naive (Fig. 6, naive median not tabulated) | S |
|
||||||
|
| Code | None found in the paper; fim-python is public | M. Grok to search |
|
||||||
|
|
||||||
|
## 2. Plan (tonight; CPU, plus a GPU only for the FNN if useful)
|
||||||
|
- **R0 (Grok, 30 min, read-only).** Is the Zenodo 10027027 record public, how large, and what fields (V-dot or flow rate, gate)? fim-python version and tetFIM API (gate as node set or faces). Any author code (GitHub/GitLab, Greif or Meyer, "eikonal injection molding").
|
||||||
|
- **R1 (Mold, paper only, before any run).** Fix the ambiguous items with one choice each, recorded:
|
||||||
|
- V*_f measure: lumped nodal volume, strict "<", ties reported;
|
||||||
|
- nodal gradient: volume-weighted average of P1 element gradients;
|
||||||
|
- D_i at cell centres: mean of the vertex values;
|
||||||
|
- S: 6 unique components;
|
||||||
|
- RRMSE primary = RMSE / RMS(y) per geometry; also report RMSE / max(y) and RMSE / mean(y) as secondary, because the paper does not define it;
|
||||||
|
- analytic synthetic checks from Fig. 4: on a rod V*_f is linear in D_f; on a centre-gated disk it is quadratic.
|
||||||
|
- **R2 (MeltAstra, implementation).** Pinned project venv with fim-python, xgboost and scikit-learn (record the versions); feature pipeline per section 1 plus Mold's choices; synthetic tests first.
|
||||||
|
- Data: v4 (10027027) if downloadable at a reasonable size, otherwise v5 (624 parts, flagged as a version deviation).
|
||||||
|
- Target: t* = t_fill V-dot/V if V-dot is available, otherwise t_fill/t_set, flagged.
|
||||||
|
- **R3 (MeltAstra, run).** The paper protocol: 5 random 315/314 splits (seed fixed and recorded), naive + GBRT + FNN, per-geometry RRMSE over **all nodes**, and min/median/max over the 5 splits. Budget: up to 40 worker CPU-h and up to 2 GPU-h tonight; per-part guards as before; failures kept.
|
||||||
|
- **Fidelity is the core criterion (TRON clarification).** The reproduction is judged by how closely method and protocol match the paper. The published numbers are a *diagnostic reference for deviations*, not a validation gate. Landing inside the ranges below does not by itself prove a faithful reproduction, and landing outside does not refute one. The report keeps three lists separate: (1) paper facts, (2) our implementation choices for ambiguous items, (3) items that cannot be reproduced (missing or unavailable).
|
||||||
|
- **Numeric reference ranges (fixed now, before any result, diagnostic only):**
|
||||||
|
- GBRT and FNN fill-time median RRMSE (primary normaliser) in [0.028, 0.040], around the published 0.034;
|
||||||
|
- the naive model is within about 25 % of GBRT's median (the paper's "ML only slightly better than naive");
|
||||||
|
- the max stays in the same regime (0.2 to 0.3).
|
||||||
|
- Anything outside these is reported as a deviation with its likely cause (data version, RRMSE normaliser, target scaling), not tuned away.
|
||||||
|
- **R4 (after R3, possibly tomorrow).** The same method on our grouped 617/209 protocol and S2 query domain. Compare against R2-G24 and the S2 B0, both at the paper's per-geometry RRMSE and at our component-mean relative L2. Attribution must change one factor at a time, because R4 otherwise changes distance, features and protocol together. Step (a): naive V*_f with eikonal D_f versus naive V*_f with our tet-edge Dijkstra D_f, with the same V*_f measure, roster, query domain and metric. That isolates the distance construction. Step (b): naive versus GBRT on the eikonal features (the value of the features and the model). Step (c): R2-G24 versus the Gre24 GBRT. No step's difference is attributed to a factor it did not isolate.
|
||||||
|
|
||||||
|
## 3. Note on a result that matters
|
||||||
|
Gre24 reports that its learned models are **only slightly better than the naive V*_f model** on fill time. In our S2, R2 (7.30 %) is well ahead of our Dijkstra B0 (10.40 %). If the faithful eikonal naive model closes most of that gap, then our B0 was mostly a weak distance construction, and the remaining public fill-time problem is smaller than S2 suggested.
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
# Gre24 填充时间复现 · R1 数学实现规格
|
||||||
|
|
||||||
|
2026-11-15,MoldAstra。核读 Greif、Lechner、Meyer (2024) §2、§3.1–3.4、§4.1、附录 C/D;对照 Claude 规格 9783a338。本件固定数学定义、补充选择与适用范围,交 Claude 主审、Melt 实现。尚无本轮合成或训练结果。
|
||||||
|
|
||||||
|
## 1 表 1 与式 (5) 的三个距离场
|
||||||
|
|
||||||
|
**原文。** 在制件域 Ω 内求 |∇φ|=1/f,在指定源边界 φ=0。D_w 从壁面 Γ_w 出发,速度 1;D_i 从浇口 Γ_i 出发,速度 1;D_f 从同一浇口出发,速度取未归一化的 D_w。路径须留在制件内部。作者在一次四面体网格上使用 fim-python 的 tetFIM,局部更新允许穿过单元面,而非只沿原始棱边行进。门以外的外表面不再设为 D_i/D_f 的零源。式 (8) 的归一化均按单件全域最大值。
|
||||||
|
|
||||||
|
**求解器接口。** fim-python 解 ∇φᵀD∇φ=1,传入每单元一个张量。等方速度 f_K 对应 D_K=f_K²I;常速 1 对应 I。公开 API 的源参数是离散节点及其源值。Greif 没有给出程序提交、求解精度、停止容差、源节点复原方式、单元速度插值或壁上零速处理。固定实际采用的库版本、精度和停止条件,连同单位和节点 ID 写入产物。
|
||||||
|
|
||||||
|
**R1 补充选择。**
|
||||||
|
|
||||||
|
- 有明确浇口面/节点标记时按该标记取源并集;只有坐标时取最近的保留 tet 顶点,等距按原始 ID 升序,记录映射距离及单位。壁面优先用实际壁标记;无标记时,以只出现一次的外三角面代理,记录是否包含浇口。不要因一个表面门点而任意剔除周围整圈三角面。
|
||||||
|
- 在线性 tet K 内令 f_K 为四个节点 D_w 的均值,再平方。四顶点全为壁点时均值可能为 0,而非退化单元仍有内部体积。该情形以重心到上述壁三角集的最短欧氏距离给出正的单元代表速度,记录触发的单元数、体积占比和最小速度。若仍非正、非有限或源无法传播,则记录原因。该重心处理属于本项目的可复现补充;作者是否做过同样处理未知。不要把节点零值全局替换成常数。连续理想模型在壁附近 f=D_w 可退化,离散单元得到有限值不构成连续壁上旅行时间精确复原的证明。
|
||||||
|
- 对退化网格、非有限场或未到达点核查身份并报告。按式 (8) 遇到整件某个距离最大值等于零时,原公式无定义;该件在依赖此列的结果单列,不能以掩码删除这些节点后声称全域匹配。非负距离应保留物理长度单位;D_f 是传播顺序代理,不具备独立的注塑秒制。
|
||||||
|
|
||||||
|
## 2 体积分位、节点梯度、空间矩
|
||||||
|
|
||||||
|
**原文。** 式 (9) 的等值集明确使用严格小于,式 (10) 是等值集占整件的几何体积。式 (11) 指梯度方向,即梯度除以其模。式 (6) 以单元重心方向的单位向量外积作体积平均;式 (7) 同时要求重心欧氏距离与注射距离差的绝对值严格小于 R。R=3h_max,h_max 是该件网格最长单元边。作者用 BallTree 找候选,几何筛选是定义的一部分。
|
||||||
|
|
||||||
|
**R1 离散定义。** V=Σ_K v_K,节点容量 m_i=Σ_{K含i}v_K/4。对节点 i 取
|
||||||
|
|
||||||
|
F_i = Σ_j m_j 1[D_f(j) < D_f(i)] / V .
|
||||||
|
|
||||||
|
比较同一缓存的原 D_f;最大值为正时与以 D_f/max(D_f) 作相同排序在精确算术下等价。全部保留 tet 节点参加,包括壁节点;相同值共享相同分位,记录并列质量。最大节点分位可小于 1。集总积分是我们选的单元顶点求积,并不等于对 P1 场严格切割每个四面体后做精确体积积分。也不等于按节点个数计算经验分位。Naive 模型按 §3.3.1 输出 t*=F。
|
||||||
|
|
||||||
|
对 u∈{F,D_i*,D_w*} 先求每个单元的 P1 梯度 g_K:以三条顶点差为行的矩阵 E,解 E g_K=(u_1−u_0,u_2−u_0,u_3−u_0)ᵀ。再求节点 g_i=Σ_{K含i}v_K g_K/Σ_{K含i}v_K,最后归一为方向。不能先把每个 g_K 单位化再平均。模确为零时输出零向量并计数。若实现需要数值零容差,应在看真实评分前记录规则。原文未指定节点梯度重构或零方向约定。
|
||||||
|
|
||||||
|
对空间矩用重心 x̄_K 与 P1 重心值 D_i(x̄_K)=Σ_{a∈K}D_i(a)/4;严格双筛选后保留 x̄_K≠x_i 的单元,以筛后总体积重新归一化。d=(x̄_K−x_i)/‖x̄_K−x_i‖,S_i=Σ v_K ddᵀ/Σ v_K。非空时 S 对称半正定、迹为 1;空邻域应报告。六列顺序固定 xx,xy,xz,yy,yz,zz,不作剪切缩放。重心处 D_i 的插值、重合中心处理、六列布局均为补充选择。
|
||||||
|
|
||||||
|
式 (12) 对应 19 列:F(1)、其方向(3)、D_i*(1)、其方向(3)、原 D_w(1)、D_w*(1)、其方向(3)、S(6)。D_f 用于构建 F,不另入列;t_set 也不是式 (12) 的输入特征。附录 B 冷却时间拟合的尺度不要替代此处式 (7) 的特征半径。
|
||||||
|
|
||||||
|
## 3 秒制和 RRMSE
|
||||||
|
|
||||||
|
**原文。** 式 (17) 为 T=(V/Q)t*,Q 是施加在该件浇口的体积流量,V 是整件体积。§4.1 对每个测试几何的全部节点评分,计算相对均方根误差 RRMSE。§4.1、图 6 和表 C.5/C.6 没有给出可唯一识别分母的公式。不能用表中数字反推作者采用了哪个定义。
|
||||||
|
|
||||||
|
**复现选择。** 优先用可核单位和来源的施加 Q,和同单位 V 组成秒尺度;条件是 Q>0。没有可靠 Q 时按 Claude 规格用求解前设定的 t_set 秒,记录来源、替代件数和相应数据版本,通过 T/t_set 训练并乘回秒。不要由真实到达终点反拟合 Q,也不把打印的 0.000 当作已知流量。各模型在同一件上统一目标和秒尺度。对同一预测/真值同比例换单位时,下述相对分数不变;改动训练尺度仍可改变拟合模型。
|
||||||
|
|
||||||
|
令 y 是单件全 tet 节点的真值,ŷ 是同一节点预测,N 是节点数。e=√[Σ(ŷ_i−y_i)²/N]。主 RRMSE_RMS=e/√(Σy_i²/N)=‖ŷ−y‖₂/‖y‖₂;同时报 e/max(y) 与 e/mean(y)。三者均用节点等权;不使用体积权、不做逐点相对误差平均。零分母则该指标 NA 并记录,不能加 ε 或按结果挑分母。原 VTU 若存在 tet 域外辅助节点,保留 ID 对照、域外数量及标签状态;不能静默缩成 S2 查询域。
|
||||||
|
|
||||||
|
**聚合。** §4.1 明确 629 几何,五次随机拆分,每次 315 测试、314 训练。它们可重叠,不是五折交叉验证。每个 split 先得到逐件误差,再独立取 min/median/max;附录 C 表逐项平均这五组三统计。图 6 表示各 split 内先排序,再逐秩平均。保留逐 split 名单、实际几何数、逐件指标及失败;分割随机种子未给出。论文后文个别“314 个测试件”的叙述与 §4.1 不一致,以方法段为协议。若实际只能使用 624 件数据,可另报等分 312/312,标为版本及件数偏差,不伪称做到了 315+314。来源:论文脚注 DOI 与确切版本的对应,以 R0 下载核对为准。
|
||||||
|
|
||||||
|
FNN 原文四层、每层 100、ReLU、Adam、lr=0.001、batch=1024、MSE;GBRT 是 XGBoost,100 棵、深度 8、lr=0.1。本文只核填充时间;完整原训练轮数、精确 seed、模型版本及填充单目标与原多输出训练的等价性均未知。表 C.5 的填充 min/median/max=0.0130/0.0339/0.2565,C.6=0.0082/0.0338/0.2550。它们是偏差诊断参照。方法、数据、协议以及未确定项的如实记录决定复现忠实度。
|
||||||
|
|
||||||
|
## 4 实现可直接使用的解析检查
|
||||||
|
|
||||||
|
1. 平面入口、常速 c、平直长方体:φ=x/c,源面 φ=0。用 c=2 可识别把速度张量误写成 cI 或 I/c²。杆取理想轴向顺序 x,连续分位为 x/L;中心浇口等厚圆盘取径向顺序 r,连续分位为 (r/R)²。图 4 的形状关系用于检验体积映射;一般三维 f=D_w、有限网格、集总与并列不会逐点精确等于这两式。用解析顺序检 CDF,另用常速场检求解器,两项独立。
|
||||||
|
2. 单个 tet 的 4 个节点容量相同,顺序分数取 (0,1,1,2),严格 F 应为 (0,1/4,1/4,3/4)。连续 P1 半空间切割不必得到同样的结果。多单元不等体积网格应按 m_i 算。
|
||||||
|
3. 仿射 u=a·x+b 时 P1 单元和节点梯度均应复得 a;常数场给零方向。对任意非空单元集,空间矩迹为 1;共同旋转网格与方向时,S 应按 R S Rᵀ 变换。
|
||||||
|
4. 给 y=(1,3)、ŷ=(2,3),三种相对误差依次为 1/√10、1/(3√2)、1/(2√2)。可在读模型输出前锁定分母选择及标签。
|
||||||
|
|
||||||
|
**R4 单因素边界。** 若要归因 tetFIM 对 Dijkstra 的贡献,固定同件、同门源、同壁几何与 D_w 速度信息、同 F 求积、同钟、同评价节点/权重、同划分和同模型,并注明节点速度到单元/棱边的对应。若使用各方法原有的不同 D_w 构造,只能归为整体距离构造差异。Naive→GBRT 同时改变输入和学习方式时估计组合增量。绝不把协议、特征、模型一起更换后的差距归给 Dijkstra。
|
||||||
|
|
||||||
|
**原始来源。** [Greif 等作者 PDF](https://opus.bibliothek.uni-augsburg.de/opus4/files/113920/113920.pdf) · [期刊 DOI](https://doi.org/10.1016/j.compositesa.2024.108340) · [fim-python 方法论文](https://doi.org/10.21105/joss.03641) · [fim-python 接口](https://fim-python.readthedocs.io/en/latest/interface.html) · [Claude 复现规格 9783a338](https://gitea.frank14f.online/Frank14f/MeltMind/src/commit/9783a338/docs/claude/gre24-reproduction-spec-2026-11-15.md)
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
"""Gre24 fill-time reproduction; explicit R1 choices, no fitted state or labels.
|
||||||
|
|
||||||
|
Author method and our discretisation choices are kept distinct in receipts.
|
||||||
|
This module never changes the historical R2-G24 approximation.
|
||||||
|
"""
|
||||||
|
from itertools import combinations
|
||||||
|
import time
|
||||||
|
import numpy as np
|
||||||
|
from sklearn.neighbors import BallTree
|
||||||
|
from boundary_distance import SurfaceDistance
|
||||||
|
|
||||||
|
COLUMNS = ('Vf', 'grad_Vf_x', 'grad_Vf_y', 'grad_Vf_z', 'Di_star',
|
||||||
|
'grad_Di_x', 'grad_Di_y', 'grad_Di_z', 'Dw', 'Dw_star',
|
||||||
|
'grad_Dw_x', 'grad_Dw_y', 'grad_Dw_z',
|
||||||
|
'Sxx', 'Sxy', 'Sxz', 'Syy', 'Syz', 'Szz')
|
||||||
|
|
||||||
|
|
||||||
|
def mesh(points, tetra):
|
||||||
|
x = np.asarray(points, dtype=np.float64)
|
||||||
|
t = np.asarray(tetra)
|
||||||
|
if x.ndim != 2 or x.shape[1] != 3 or not np.isfinite(x).all():
|
||||||
|
raise ValueError('Invalid points')
|
||||||
|
if t.ndim != 2 or t.shape[1] != 4 or t.dtype.kind not in 'iu' or not len(t):
|
||||||
|
raise ValueError('Invalid tetrahedra')
|
||||||
|
if t.min() < 0 or t.max() >= len(x) or not np.array_equal(np.unique(t), np.arange(len(x))):
|
||||||
|
raise ValueError('Tet domain must explicitly contain every supplied node')
|
||||||
|
t = np.asarray(t, dtype=np.int32)
|
||||||
|
cells = x[t]
|
||||||
|
matrix = cells[:, 1:] - cells[:, :1]
|
||||||
|
volume = np.abs(np.linalg.det(matrix)) / 6
|
||||||
|
if not np.isfinite(volume).all() or np.any(volume <= 0):
|
||||||
|
raise ValueError('Nonpositive tetrahedron volume')
|
||||||
|
mass = np.bincount(t.ravel(), weights=np.repeat(volume / 4, 4), minlength=len(x))
|
||||||
|
hmax = max(float(np.linalg.norm(cells[:, i]-cells[:, j], axis=1).max())
|
||||||
|
for i, j in combinations(range(4), 2))
|
||||||
|
return dict(x=x, t=t, matrix=matrix, volume=volume, mass=mass,
|
||||||
|
centers=cells.mean(1), hmax=hmax)
|
||||||
|
|
||||||
|
|
||||||
|
def exterior_faces(tetra):
|
||||||
|
faces = np.sort(tetra[:, np.array([[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]])].reshape(-1, 3), axis=1)
|
||||||
|
faces, counts = np.unique(faces, axis=0, return_counts=True)
|
||||||
|
if np.any(counts > 2):
|
||||||
|
raise ValueError('Nonmanifold tetrahedron faces')
|
||||||
|
return faces[counts == 1]
|
||||||
|
|
||||||
|
|
||||||
|
def gate_nodes(x, raw_ids, gate, marked=None):
|
||||||
|
raw_ids = np.asarray(raw_ids)
|
||||||
|
if len(raw_ids) != len(x) or len(np.unique(raw_ids)) != len(x):
|
||||||
|
raise ValueError('Invalid original node IDs')
|
||||||
|
if marked is not None:
|
||||||
|
marked = np.asarray(marked, dtype=np.int64)
|
||||||
|
if not len(marked) or marked.min() < 0 or marked.max() >= len(x):
|
||||||
|
raise ValueError('Invalid explicit inlet node set')
|
||||||
|
return np.unique(marked), 'explicit_marked_nodes'
|
||||||
|
gate = np.asarray(gate, dtype=float)
|
||||||
|
if gate.shape != (3,) or not np.isfinite(gate).all():
|
||||||
|
raise ValueError('Invalid inlet location')
|
||||||
|
d2 = np.sum((x-gate)**2, axis=1)
|
||||||
|
tied = np.flatnonzero(d2 == d2.min())
|
||||||
|
return np.array([tied[np.argmin(raw_ids[tied])]]), 'nearest_tet_node_min_original_id_tie'
|
||||||
|
|
||||||
|
|
||||||
|
def solve_eikonal(g, sources, speed, max_iterations=100000):
|
||||||
|
from fimpy.solver import create_fim_solver
|
||||||
|
speed = np.broadcast_to(np.asarray(speed, dtype=float), (len(g['t']),))
|
||||||
|
if not np.isfinite(speed).all() or np.any(speed <= 0):
|
||||||
|
raise ValueError('Nonpositive or nonfinite cell speed; no epsilon replacement')
|
||||||
|
metric = speed[:, None, None]**2 * np.eye(3)[None]
|
||||||
|
# Preserve upstream SPD check rather than silently weakening its threshold.
|
||||||
|
solver = create_fim_solver(g['x'], g['t'], metric, precision=np.float64,
|
||||||
|
device='cpu', use_active_list=True)
|
||||||
|
phi = solver.comp_fim(np.asarray(sources, dtype=np.int32), np.zeros(len(sources)),
|
||||||
|
max_iterations=max_iterations)
|
||||||
|
if np.any(solver.active_list):
|
||||||
|
raise RuntimeError('tetFIM iteration limit with active nodes')
|
||||||
|
if not np.isfinite(phi).all() or np.any(phi < 0) or np.any(phi >= solver.undef_val):
|
||||||
|
raise ValueError('Nonfinite, negative or unreached eikonal node')
|
||||||
|
if np.any(phi[sources] != 0):
|
||||||
|
raise ValueError('Eikonal source values changed')
|
||||||
|
return phi.copy()
|
||||||
|
|
||||||
|
|
||||||
|
def cell_flow_speed(g, dw, wall_faces):
|
||||||
|
if not np.isfinite(dw).all() or np.any(dw < 0):
|
||||||
|
raise ValueError('Invalid wall field')
|
||||||
|
speed = dw[g['t']].mean(1)
|
||||||
|
zero = np.flatnonzero(np.all(dw[g['t']] == 0, axis=1))
|
||||||
|
if len(zero):
|
||||||
|
surface = SurfaceDistance(g['x'][wall_faces])
|
||||||
|
speed[zero] = surface.query(g['centers'][zero])
|
||||||
|
if not np.isfinite(speed).all() or np.any(speed <= 0):
|
||||||
|
raise ValueError('Nonpositive flow speed after declared all-wall supplement')
|
||||||
|
return speed, zero
|
||||||
|
|
||||||
|
|
||||||
|
def strict_volume_cdf(field, mass):
|
||||||
|
d = np.asarray(field, dtype=float); w = np.asarray(mass, dtype=float)
|
||||||
|
if d.ndim != 1 or w.shape != d.shape or not len(d) or not np.isfinite(d).all() or not np.isfinite(w).all() or np.any(w <= 0):
|
||||||
|
raise ValueError('Invalid lumped-volume CDF')
|
||||||
|
order = np.argsort(d, kind='stable')
|
||||||
|
prefix = np.r_[0., np.cumsum(w[order], dtype=np.float64)]
|
||||||
|
return prefix[np.searchsorted(d[order], d, side='left')] / w.sum()
|
||||||
|
|
||||||
|
|
||||||
|
def nodal_gradient(g, values, normalize=True):
|
||||||
|
v = np.asarray(values, dtype=float)
|
||||||
|
if v.shape != (len(g['x']),) or not np.isfinite(v).all():
|
||||||
|
raise ValueError('Invalid nodal scalar')
|
||||||
|
t = g['t']
|
||||||
|
cell_grad = np.linalg.solve(g['matrix'], (v[t[:, 1:]]-v[t[:, :1]])[..., None])[..., 0]
|
||||||
|
grad = np.zeros((len(v), 3))
|
||||||
|
for k in range(4):
|
||||||
|
np.add.at(grad, t[:, k], cell_grad*g['volume'][:, None])
|
||||||
|
grad /= 4*g['mass'][:, None]
|
||||||
|
if normalize:
|
||||||
|
norm = np.linalg.norm(grad, axis=1)
|
||||||
|
np.divide(grad, norm[:, None], out=grad, where=norm[:, None] > 0)
|
||||||
|
return grad
|
||||||
|
|
||||||
|
|
||||||
|
def spatial_moment(g, di, progress=lambda *a, **kw: None):
|
||||||
|
radius = 3*g['hmax']; centers = g['centers']; cell_di = di[g['t']].mean(1)
|
||||||
|
tree = BallTree(centers); result = np.empty((len(di), 6)); coincident = 0
|
||||||
|
for i, p in enumerate(g['x']):
|
||||||
|
ids = tree.query_radius(p[None], r=radius)[0]
|
||||||
|
delta = centers[ids]-p; dist = np.linalg.norm(delta, axis=1)
|
||||||
|
selected = (dist < radius) & (np.abs(cell_di[ids]-di[i]) < radius)
|
||||||
|
coincident += int(np.sum(selected & (dist == 0)))
|
||||||
|
selected &= dist > 0
|
||||||
|
ids = ids[selected]; delta = delta[selected]; dist = dist[selected]
|
||||||
|
if not len(ids):
|
||||||
|
raise ValueError(f'Empty moment neighbourhood at node {i}')
|
||||||
|
direction = delta/dist[:, None]
|
||||||
|
weight = g['volume'][ids]; weight = weight/weight.sum()
|
||||||
|
tensor = np.einsum('n,ni,nj->ij', weight, direction, direction)
|
||||||
|
result[i] = tensor[[0, 0, 0, 1, 1, 2], [0, 1, 2, 1, 2, 2]]
|
||||||
|
if i % 4096 == 0:
|
||||||
|
progress('SPATIAL_MOMENT', completed=i, total=len(di))
|
||||||
|
return result, dict(radius=radius, coincident_centers_excluded=coincident,
|
||||||
|
component_order=list(COLUMNS[13:]))
|
||||||
|
|
||||||
|
|
||||||
|
def features(points, tetra, raw_ids, gate, wall_faces=None, marked_gate=None,
|
||||||
|
progress=lambda *a, **kw: None):
|
||||||
|
start = time.process_time(); g = mesh(points, tetra)
|
||||||
|
faces = exterior_faces(g['t']) if wall_faces is None else np.asarray(wall_faces)
|
||||||
|
sources, gate_mode = gate_nodes(g['x'], raw_ids, gate, marked_gate)
|
||||||
|
wall = np.unique(faces)
|
||||||
|
timings = {}; tick = time.process_time()
|
||||||
|
def finish(name):
|
||||||
|
nonlocal tick
|
||||||
|
now = time.process_time(); timings[name] = now-tick; tick = now
|
||||||
|
progress('EIKONAL_DW'); dw = solve_eikonal(g, wall, 1.); finish('Dw')
|
||||||
|
progress('EIKONAL_DI'); di = solve_eikonal(g, sources, 1.); finish('Di')
|
||||||
|
progress('CELL_SPEED'); speed, zero = cell_flow_speed(g, dw, faces); finish('cell_speed')
|
||||||
|
progress('EIKONAL_DF'); df = solve_eikonal(g, sources, speed); finish('Df')
|
||||||
|
if dw.max() <= 0 or di.max() <= 0:
|
||||||
|
raise ValueError('Zero feature normalisation scale')
|
||||||
|
vf = strict_volume_cdf(df, g['mass']); dis = di/di.max(); dws = dw/dw.max()
|
||||||
|
grads = [nodal_gradient(g, a) for a in (vf, dis, dws)]; finish('gradients')
|
||||||
|
moment, moment_meta = spatial_moment(g, di, progress); finish('moment')
|
||||||
|
x = np.column_stack([vf, grads[0], dis, grads[1], dw, dws, grads[2], moment])
|
||||||
|
if x.shape != (len(points), 19) or not np.isfinite(x).all():
|
||||||
|
raise ValueError('Invalid final 19-column features')
|
||||||
|
metadata = dict(columns=list(COLUMNS), gate_mode=gate_mode, gate_nodes=sources.tolist(),
|
||||||
|
gate_raw_ids=np.asarray(raw_ids)[sources].tolist(),
|
||||||
|
wall_mode='tet_exterior_proxy' if wall_faces is None else 'explicit_supplied_wall_faces',
|
||||||
|
all_wall_tetrahedra=len(zero), all_wall_rule='centroid_triangle_distance_R1_supplement',
|
||||||
|
all_wall_volume_fraction=float(g['volume'][zero].sum()/g['volume'].sum()),
|
||||||
|
timings_cpu_seconds=timings, worker_cpu_seconds=time.process_time()-start,
|
||||||
|
volume=float(g['volume'].sum()), hmax=g['hmax'], moment=moment_meta,
|
||||||
|
speed_min=float(speed.min()), speed_max=float(speed.max()),
|
||||||
|
flow_distance_tied_nodes=int(len(df)-len(np.unique(df))),
|
||||||
|
zero_gradient_nodes=[int(np.sum(np.linalg.norm(v, axis=1) == 0)) for v in grads],
|
||||||
|
gate_mapping_distance=float(np.linalg.norm(g['x'][sources]-np.asarray(gate), axis=1).min()),
|
||||||
|
exterior_proxy_includes_gate=bool(np.any(np.isin(sources, wall))),
|
||||||
|
precision='float64', fim_device='cpu', max_iterations=100000)
|
||||||
|
return dict(features=x, Dw=dw, Di=di, Df=df, Vf=vf,
|
||||||
|
mass=g['mass'], all_wall_tet_ids=zero), metadata
|
||||||
|
|
||||||
|
|
||||||
|
def per_geometry_metrics(y, predicted):
|
||||||
|
y = np.asarray(y, dtype=float); predicted = np.asarray(predicted, dtype=float)
|
||||||
|
if y.ndim != 1 or predicted.shape != y.shape or not len(y) or not np.isfinite(y).all() or not np.isfinite(predicted).all() or np.any(y < 0):
|
||||||
|
raise ValueError('Invalid all-node score inputs')
|
||||||
|
rmse = float(np.sqrt(np.mean((predicted-y)**2)))
|
||||||
|
denom = dict(rms=float(np.sqrt(np.mean(y*y))), maximum=float(y.max()), mean=float(y.mean()))
|
||||||
|
return dict(nodes=len(y), rmse=rmse, denominators=denom,
|
||||||
|
undefined_metrics=[k for k, v in denom.items() if v <= 0],
|
||||||
|
**{'rrmse_'+k: rmse/v if v > 0 else None for k, v in denom.items()})
|
||||||
|
|
||||||
|
|
||||||
|
def appendix_summary(splits):
|
||||||
|
if len(splits) != 5 or any(not len(s) for s in splits):
|
||||||
|
raise ValueError('Five nonempty split score lists required')
|
||||||
|
rows = [dict(min=float(np.min(s)), median=float(np.median(s)), max=float(np.max(s))) for s in splits]
|
||||||
|
return dict(per_split=rows, mean_of_split_summaries={k:float(np.mean([r[k] for r in rows])) for k in rows[0]})
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
"""Gre24 fill-time reproduction; explicit R1 choices, no fitted state or labels.
|
||||||
|
|
||||||
|
Author method and our discretisation choices are kept distinct in receipts.
|
||||||
|
This module never changes the historical R2-G24 approximation.
|
||||||
|
"""
|
||||||
|
from itertools import combinations
|
||||||
|
import time
|
||||||
|
import numpy as np
|
||||||
|
from sklearn.neighbors import BallTree
|
||||||
|
from boundary_distance import SurfaceDistance
|
||||||
|
|
||||||
|
COLUMNS = ('Vf', 'grad_Vf_x', 'grad_Vf_y', 'grad_Vf_z', 'Di_star',
|
||||||
|
'grad_Di_x', 'grad_Di_y', 'grad_Di_z', 'Dw', 'Dw_star',
|
||||||
|
'grad_Dw_x', 'grad_Dw_y', 'grad_Dw_z',
|
||||||
|
'Sxx', 'Sxy', 'Sxz', 'Syy', 'Syz', 'Szz')
|
||||||
|
|
||||||
|
|
||||||
|
def mesh(points, tetra):
|
||||||
|
x = np.asarray(points, dtype=np.float64)
|
||||||
|
t = np.asarray(tetra)
|
||||||
|
if x.ndim != 2 or x.shape[1] != 3 or not np.isfinite(x).all():
|
||||||
|
raise ValueError('Invalid points')
|
||||||
|
if t.ndim != 2 or t.shape[1] != 4 or t.dtype.kind not in 'iu' or not len(t):
|
||||||
|
raise ValueError('Invalid tetrahedra')
|
||||||
|
if t.min() < 0 or t.max() >= len(x) or not np.array_equal(np.unique(t), np.arange(len(x))):
|
||||||
|
raise ValueError('Tet domain must explicitly contain every supplied node')
|
||||||
|
t = np.asarray(t, dtype=np.int32)
|
||||||
|
cells = x[t]
|
||||||
|
matrix = cells[:, 1:] - cells[:, :1]
|
||||||
|
volume = np.abs(np.linalg.det(matrix)) / 6
|
||||||
|
if not np.isfinite(volume).all() or np.any(volume <= 0):
|
||||||
|
raise ValueError('Nonpositive tetrahedron volume')
|
||||||
|
mass = np.bincount(t.ravel(), weights=np.repeat(volume / 4, 4), minlength=len(x))
|
||||||
|
hmax = max(float(np.linalg.norm(cells[:, i]-cells[:, j], axis=1).max())
|
||||||
|
for i, j in combinations(range(4), 2))
|
||||||
|
return dict(x=x, t=t, matrix=matrix, volume=volume, mass=mass,
|
||||||
|
centers=cells.mean(1), hmax=hmax)
|
||||||
|
|
||||||
|
|
||||||
|
def exterior_faces(tetra):
|
||||||
|
faces = np.sort(tetra[:, np.array([[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]])].reshape(-1, 3), axis=1)
|
||||||
|
faces, counts = np.unique(faces, axis=0, return_counts=True)
|
||||||
|
if np.any(counts > 2):
|
||||||
|
raise ValueError('Nonmanifold tetrahedron faces')
|
||||||
|
return faces[counts == 1]
|
||||||
|
|
||||||
|
|
||||||
|
def gate_nodes(x, raw_ids, gate, marked=None):
|
||||||
|
raw_ids = np.asarray(raw_ids)
|
||||||
|
if len(raw_ids) != len(x) or len(np.unique(raw_ids)) != len(x):
|
||||||
|
raise ValueError('Invalid original node IDs')
|
||||||
|
if marked is not None:
|
||||||
|
marked = np.asarray(marked, dtype=np.int64)
|
||||||
|
if not len(marked) or marked.min() < 0 or marked.max() >= len(x):
|
||||||
|
raise ValueError('Invalid explicit inlet node set')
|
||||||
|
return np.unique(marked), 'explicit_marked_nodes'
|
||||||
|
gate = np.asarray(gate, dtype=float)
|
||||||
|
if gate.shape != (3,) or not np.isfinite(gate).all():
|
||||||
|
raise ValueError('Invalid inlet location')
|
||||||
|
d2 = np.sum((x-gate)**2, axis=1)
|
||||||
|
tied = np.flatnonzero(d2 == d2.min())
|
||||||
|
return np.array([tied[np.argmin(raw_ids[tied])]]), 'nearest_tet_node_min_original_id_tie'
|
||||||
|
|
||||||
|
|
||||||
|
def solve_eikonal(g, sources, speed, max_iterations=100000, *, scale_override=None):
|
||||||
|
from fimpy.solver import create_fim_solver
|
||||||
|
speed = np.broadcast_to(np.asarray(speed, dtype=float), (len(g['t']),))
|
||||||
|
if not np.isfinite(speed).all() or np.any(speed <= 0):
|
||||||
|
raise ValueError('Nonpositive or nonfinite cell speed; no epsilon replacement')
|
||||||
|
# Claude1794756243: exact common change of coordinates/speed, phi unchanged.
|
||||||
|
scale = 1./float(speed.min()) if float(speed.min())**2 <= 1e-4 else 1.
|
||||||
|
if scale_override is not None:
|
||||||
|
scale=float(scale_override) # Synthetic invariance test only; worker never passes this.
|
||||||
|
if not np.isfinite(scale) or scale<=0:raise ValueError('Invalid coordinate/speed scale')
|
||||||
|
metric = (speed[:, None, None]*scale)**2 * np.eye(3)[None]
|
||||||
|
solver = create_fim_solver(g['x']*scale, g['t'], metric, precision=np.float64,
|
||||||
|
device='cpu', use_active_list=True)
|
||||||
|
phi = solver.comp_fim(np.asarray(sources, dtype=np.int32), np.zeros(len(sources)),
|
||||||
|
max_iterations=max_iterations)
|
||||||
|
if np.any(solver.active_list):
|
||||||
|
raise RuntimeError('tetFIM iteration limit with active nodes')
|
||||||
|
if not np.isfinite(phi).all() or np.any(phi < 0) or np.any(phi >= solver.undef_val):
|
||||||
|
raise ValueError('Nonfinite, negative or unreached eikonal node')
|
||||||
|
if np.any(phi[sources] != 0):
|
||||||
|
raise ValueError('Eikonal source values changed')
|
||||||
|
return phi.copy()
|
||||||
|
|
||||||
|
|
||||||
|
def cell_flow_speed(g, dw, wall_faces):
|
||||||
|
if not np.isfinite(dw).all() or np.any(dw < 0):
|
||||||
|
raise ValueError('Invalid wall field')
|
||||||
|
speed = dw[g['t']].mean(1)
|
||||||
|
zero = np.flatnonzero(np.all(dw[g['t']] == 0, axis=1))
|
||||||
|
if len(zero):
|
||||||
|
surface = SurfaceDistance(g['x'][wall_faces])
|
||||||
|
speed[zero] = surface.query(g['centers'][zero])
|
||||||
|
if not np.isfinite(speed).all() or np.any(speed <= 0):
|
||||||
|
raise ValueError('Nonpositive flow speed after declared all-wall supplement')
|
||||||
|
return speed, zero
|
||||||
|
|
||||||
|
|
||||||
|
def strict_volume_cdf(field, mass):
|
||||||
|
d = np.asarray(field, dtype=float); w = np.asarray(mass, dtype=float)
|
||||||
|
if d.ndim != 1 or w.shape != d.shape or not len(d) or not np.isfinite(d).all() or not np.isfinite(w).all() or np.any(w <= 0):
|
||||||
|
raise ValueError('Invalid lumped-volume CDF')
|
||||||
|
order = np.argsort(d, kind='stable')
|
||||||
|
prefix = np.r_[0., np.cumsum(w[order], dtype=np.float64)]
|
||||||
|
return prefix[np.searchsorted(d[order], d, side='left')] / w.sum()
|
||||||
|
|
||||||
|
|
||||||
|
def nodal_gradient(g, values, normalize=True):
|
||||||
|
v = np.asarray(values, dtype=float)
|
||||||
|
if v.shape != (len(g['x']),) or not np.isfinite(v).all():
|
||||||
|
raise ValueError('Invalid nodal scalar')
|
||||||
|
t = g['t']
|
||||||
|
cell_grad = np.linalg.solve(g['matrix'], (v[t[:, 1:]]-v[t[:, :1]])[..., None])[..., 0]
|
||||||
|
grad = np.zeros((len(v), 3))
|
||||||
|
for k in range(4):
|
||||||
|
np.add.at(grad, t[:, k], cell_grad*g['volume'][:, None])
|
||||||
|
grad /= 4*g['mass'][:, None]
|
||||||
|
if normalize:
|
||||||
|
norm = np.linalg.norm(grad, axis=1)
|
||||||
|
np.divide(grad, norm[:, None], out=grad, where=norm[:, None] > 0)
|
||||||
|
return grad
|
||||||
|
|
||||||
|
|
||||||
|
def spatial_moment(g, di, progress=lambda *a, **kw: None):
|
||||||
|
radius = 3*g['hmax']; centers = g['centers']; cell_di = di[g['t']].mean(1)
|
||||||
|
tree = BallTree(centers); result = np.empty((len(di), 6)); coincident = 0
|
||||||
|
for i, p in enumerate(g['x']):
|
||||||
|
ids = tree.query_radius(p[None], r=radius)[0]
|
||||||
|
delta = centers[ids]-p; dist = np.linalg.norm(delta, axis=1)
|
||||||
|
selected = (dist < radius) & (np.abs(cell_di[ids]-di[i]) < radius)
|
||||||
|
coincident += int(np.sum(selected & (dist == 0)))
|
||||||
|
selected &= dist > 0
|
||||||
|
ids = ids[selected]; delta = delta[selected]; dist = dist[selected]
|
||||||
|
if not len(ids):
|
||||||
|
raise ValueError(f'Empty moment neighbourhood at node {i}')
|
||||||
|
direction = delta/dist[:, None]
|
||||||
|
weight = g['volume'][ids]; weight = weight/weight.sum()
|
||||||
|
tensor = np.einsum('n,ni,nj->ij', weight, direction, direction)
|
||||||
|
result[i] = tensor[[0, 0, 0, 1, 1, 2], [0, 1, 2, 1, 2, 2]]
|
||||||
|
if i % 4096 == 0:
|
||||||
|
progress('SPATIAL_MOMENT', completed=i, total=len(di))
|
||||||
|
return result, dict(radius=radius, coincident_centers_excluded=coincident,
|
||||||
|
component_order=list(COLUMNS[13:]))
|
||||||
|
|
||||||
|
|
||||||
|
def features(points, tetra, raw_ids, gate, wall_faces=None, marked_gate=None,
|
||||||
|
progress=lambda *a, **kw: None):
|
||||||
|
start = time.process_time(); g = mesh(points, tetra)
|
||||||
|
faces = exterior_faces(g['t']) if wall_faces is None else np.asarray(wall_faces)
|
||||||
|
sources, gate_mode = gate_nodes(g['x'], raw_ids, gate, marked_gate)
|
||||||
|
wall = np.unique(faces)
|
||||||
|
timings = {}; tick = time.process_time()
|
||||||
|
def finish(name):
|
||||||
|
nonlocal tick
|
||||||
|
now = time.process_time(); timings[name] = now-tick; tick = now
|
||||||
|
progress('EIKONAL_DW'); dw = solve_eikonal(g, wall, 1.); finish('Dw')
|
||||||
|
progress('EIKONAL_DI'); di = solve_eikonal(g, sources, 1.); finish('Di')
|
||||||
|
progress('CELL_SPEED'); speed, zero = cell_flow_speed(g, dw, faces); finish('cell_speed')
|
||||||
|
progress('EIKONAL_DF'); df = solve_eikonal(g, sources, speed); finish('Df')
|
||||||
|
if dw.max() <= 0 or di.max() <= 0:
|
||||||
|
raise ValueError('Zero feature normalisation scale')
|
||||||
|
vf = strict_volume_cdf(df, g['mass']); dis = di/di.max(); dws = dw/dw.max()
|
||||||
|
grads = [nodal_gradient(g, a) for a in (vf, dis, dws)]; finish('gradients')
|
||||||
|
moment, moment_meta = spatial_moment(g, di, progress); finish('moment')
|
||||||
|
x = np.column_stack([vf, grads[0], dis, grads[1], dw, dws, grads[2], moment])
|
||||||
|
if x.shape != (len(points), 19) or not np.isfinite(x).all():
|
||||||
|
raise ValueError('Invalid final 19-column features')
|
||||||
|
metadata = dict(columns=list(COLUMNS), gate_mode=gate_mode, gate_nodes=sources.tolist(),
|
||||||
|
gate_raw_ids=np.asarray(raw_ids)[sources].tolist(),
|
||||||
|
wall_mode='tet_exterior_proxy' if wall_faces is None else 'explicit_supplied_wall_faces',
|
||||||
|
all_wall_tetrahedra=len(zero), all_wall_rule='centroid_triangle_distance_R1_supplement',
|
||||||
|
all_wall_volume_fraction=float(g['volume'][zero].sum()/g['volume'].sum()),
|
||||||
|
timings_cpu_seconds=timings, worker_cpu_seconds=time.process_time()-start,
|
||||||
|
volume=float(g['volume'].sum()), hmax=g['hmax'], moment=moment_meta,
|
||||||
|
speed_min=float(speed.min()), speed_max=float(speed.max()),
|
||||||
|
Df_coordinate_and_speed_scale=1./float(speed.min()) if float(speed.min())**2 <= 1e-4 else 1.,
|
||||||
|
scale_rule='only_if_min_f_squared_le_1e-4; x_and_f_times_reciprocal_min_f; phi_unchanged',
|
||||||
|
flow_distance_tied_nodes=int(len(df)-len(np.unique(df))),
|
||||||
|
zero_gradient_nodes=[int(np.sum(np.linalg.norm(v, axis=1) == 0)) for v in grads],
|
||||||
|
gate_mapping_distance=float(np.linalg.norm(g['x'][sources]-np.asarray(gate), axis=1).min()),
|
||||||
|
exterior_proxy_includes_gate=bool(np.any(np.isin(sources, wall))),
|
||||||
|
precision='float64', fim_device='cpu', max_iterations=100000)
|
||||||
|
return dict(features=x, Dw=dw, Di=di, Df=df, Vf=vf,
|
||||||
|
mass=g['mass'], all_wall_tet_ids=zero), metadata
|
||||||
|
|
||||||
|
|
||||||
|
def per_geometry_metrics(y, predicted):
|
||||||
|
y = np.asarray(y, dtype=float); predicted = np.asarray(predicted, dtype=float)
|
||||||
|
if y.ndim != 1 or predicted.shape != y.shape or not len(y) or not np.isfinite(y).all() or not np.isfinite(predicted).all() or np.any(y < 0):
|
||||||
|
raise ValueError('Invalid all-node score inputs')
|
||||||
|
rmse = float(np.sqrt(np.mean((predicted-y)**2)))
|
||||||
|
denom = dict(rms=float(np.sqrt(np.mean(y*y))), maximum=float(y.max()), mean=float(y.mean()))
|
||||||
|
return dict(nodes=len(y), rmse=rmse, denominators=denom,
|
||||||
|
undefined_metrics=[k for k, v in denom.items() if v <= 0],
|
||||||
|
**{'rrmse_'+k: rmse/v if v > 0 else None for k, v in denom.items()})
|
||||||
|
|
||||||
|
|
||||||
|
def appendix_summary(splits):
|
||||||
|
if len(splits) != 5 or any(not len(s) for s in splits):
|
||||||
|
raise ValueError('Five nonempty split score lists required')
|
||||||
|
rows = [dict(min=float(np.min(s)), median=float(np.median(s)), max=float(np.max(s))) for s in splits]
|
||||||
|
return dict(per_split=rows, mean_of_split_summaries={k:float(np.mean([r[k] for r in rows])) for k in rows[0]})
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
"""Independent Gre24 geometry/feature preparation; full tet nodes, no S2 mask."""
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import time
|
||||||
|
import traceback
|
||||||
|
from xml.etree import ElementTree as ET
|
||||||
|
from zipfile import ZipFile
|
||||||
|
import numpy as np
|
||||||
|
import yaml
|
||||||
|
from audit_samples import decode_array
|
||||||
|
from gre24_features import features
|
||||||
|
from s2_recovery_supervisor import save
|
||||||
|
|
||||||
|
|
||||||
|
def sha(path):
|
||||||
|
h=hashlib.sha256()
|
||||||
|
with Path(path).open('rb') as f:
|
||||||
|
for block in iter(lambda:f.read(2**20),b''):h.update(block)
|
||||||
|
return h.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def checked(root):
|
||||||
|
c=json.loads((root/'contract.json').read_text())
|
||||||
|
for p,h in c['code_sha256'].items():
|
||||||
|
if sha(p)!=h:raise ValueError('Pinned source changed: '+p)
|
||||||
|
st=Path(c['archive']).stat();a=c['archive_stat']
|
||||||
|
if (st.st_size,st.st_mtime_ns,st.st_ino)!=(a['bytes'],a['mtime_ns'],a['inode']):
|
||||||
|
raise ValueError('Immutable source archive changed')
|
||||||
|
return c
|
||||||
|
|
||||||
|
|
||||||
|
def read_geometry(archive,case):
|
||||||
|
cells={};points=None;stack=[]
|
||||||
|
with ZipFile(archive) as z:
|
||||||
|
config=yaml.safe_load(z.read(case+'.yml'))
|
||||||
|
with z.open(case+'_sim.vtu') as f:
|
||||||
|
for event,e in ET.iterparse(f,events=('start','end')):
|
||||||
|
if event=='start':
|
||||||
|
stack.append(e.tag)
|
||||||
|
if e.tag=='VTKFile':
|
||||||
|
if e.get('byte_order')!='LittleEndian' or e.get('compressor')!='vtkZLibDataCompressor':
|
||||||
|
raise ValueError('Unsupported VTU')
|
||||||
|
header=e.get('header_type','UInt32')
|
||||||
|
if e.tag in ('PointData','CellData'):
|
||||||
|
raise ValueError('Field section before complete geometry')
|
||||||
|
else:
|
||||||
|
if e.tag=='DataArray':
|
||||||
|
if stack[-2]=='Points':points=decode_array(e,header).copy()
|
||||||
|
elif stack[-2]=='Cells':cells[e.get('Name')]=decode_array(e,header).copy()
|
||||||
|
e.clear()
|
||||||
|
if points is not None and all(k in cells for k in ['connectivity','offsets','types']):break
|
||||||
|
stack.pop()
|
||||||
|
offsets=np.r_[0,cells['offsets']];indices=np.flatnonzero(cells['types']==10)
|
||||||
|
if not len(indices) or np.any(np.diff(offsets)[indices]!=4):raise ValueError('No valid tetrahedra')
|
||||||
|
raw_tet=cells['connectivity'][offsets[indices,None]+np.arange(4)]
|
||||||
|
raw_ids=np.unique(raw_tet);t=np.searchsorted(raw_ids,raw_tet)
|
||||||
|
types,counts=np.unique(cells['types'],return_counts=True)
|
||||||
|
return points[raw_ids],t,raw_ids,dict(raw_nodes=len(points),tet_nodes=len(raw_ids),
|
||||||
|
outside_tet_nodes=len(points)-len(raw_ids),raw_cell_types=dict(zip(map(str,types),map(int,counts))),
|
||||||
|
inlet_config=config,gate_source='YAML inlet_location; no explicit node/face markers in this source')
|
||||||
|
|
||||||
|
|
||||||
|
def read_targets(archive,case):
|
||||||
|
stack=[];count=None
|
||||||
|
with ZipFile(archive) as z,z.open(case+'_sim.vtu') as f:
|
||||||
|
for event,e in ET.iterparse(f,events=('start','end')):
|
||||||
|
if event=='start':
|
||||||
|
stack.append(e.tag)
|
||||||
|
if e.tag=='VTKFile':header=e.get('header_type','UInt32')
|
||||||
|
elif e.tag=='Piece':
|
||||||
|
if count is not None:raise ValueError('Multiple pieces')
|
||||||
|
count=int(e.get('NumberOfPoints'))
|
||||||
|
else:
|
||||||
|
if e.tag=='DataArray':
|
||||||
|
if stack[-2]=='PointData' and e.get('Name')=='Fill_time':
|
||||||
|
v=decode_array(e,header).copy()
|
||||||
|
if v.shape!=(count,):raise ValueError('Fill_time size mismatch')
|
||||||
|
return v
|
||||||
|
e.clear()
|
||||||
|
stack.pop()
|
||||||
|
raise ValueError('Missing Fill_time')
|
||||||
|
|
||||||
|
|
||||||
|
def worker(root,index):
|
||||||
|
c=checked(root);spec=c['parts'][index];case=spec['case'];dest=root/'parts'/case/'output'
|
||||||
|
dest.mkdir(parents=True,exist_ok=False)
|
||||||
|
start=time.process_time();wall=time.monotonic()
|
||||||
|
def progress(stage,**kw):
|
||||||
|
save(dest/'progress.json',dict(stage=stage,case=case,pid=os.getpid(),unix=time.time(),
|
||||||
|
CPU_s=time.process_time()-start,wall_s=time.monotonic()-wall,**kw))
|
||||||
|
try:
|
||||||
|
progress('READ_GEOMETRY')
|
||||||
|
x,t,raw,meta=read_geometry(c['archive'],case)
|
||||||
|
save(dest/'geometry-metadata.json',meta)
|
||||||
|
data,feature_meta=features(x,t,raw,meta['inlet_config']['inlet_location'],progress=progress)
|
||||||
|
progress('SAVE_FEATURES')
|
||||||
|
for name in ['features','Vf','Dw','Di','Df','mass','all_wall_tet_ids']:np.save(dest/(name+'.npy'),data[name])
|
||||||
|
np.save(dest/'raw_ids.npy',raw)
|
||||||
|
if c.get('feature_only_cost_test',False):
|
||||||
|
save(dest/'result.json',dict(status='PASS',case=case,index=index,geometry=meta,features=feature_meta,
|
||||||
|
output_sha256={p.name:sha(p) for p in dest.glob('*.npy')},
|
||||||
|
worker_cpu_seconds=time.process_time()-start,wall_seconds=time.monotonic()-wall,
|
||||||
|
decoded_labels=[],test_scores_computed=False,training=False,cost_test_only=True))
|
||||||
|
progress('PASS_COST_TEST_ONLY');return 0
|
||||||
|
progress('READ_FILL_TIME_AFTER_FEATURES_FIXED')
|
||||||
|
yall=read_targets(c['archive'],case);y=yall[raw]
|
||||||
|
if not np.isfinite(y).all() or np.any(y<0):raise ValueError('Invalid fill time on full tetrahedral domain')
|
||||||
|
outside=np.ones(len(yall),dtype=bool);outside[raw]=False;outside_y=yall[outside]
|
||||||
|
np.save(dest/'seconds.npy',y);np.save(dest/'target.npy',y/spec['t_scale_seconds'])
|
||||||
|
np.save(dest/'outside_tet_raw_ids.npy',np.flatnonzero(outside));np.save(dest/'outside_tet_fill_time.npy',outside_y)
|
||||||
|
outputs={p.name:sha(p) for p in dest.glob('*.npy')}
|
||||||
|
save(dest/'result.json',dict(status='PASS',case=case,index=index,geometry=meta,features=feature_meta,
|
||||||
|
t_scale_seconds=spec['t_scale_seconds'],time_scale_source=spec['time_scale_source'],
|
||||||
|
decoded_labels=['Fill_time'],outside_label_status=dict(nodes=len(outside_y),
|
||||||
|
finite=int(np.isfinite(outside_y).sum()),negative=int((outside_y<0).sum())),
|
||||||
|
output_sha256=outputs,worker_cpu_seconds=time.process_time()-start,wall_seconds=time.monotonic()-wall,
|
||||||
|
test_scores_computed=False,training=False))
|
||||||
|
progress('PASS');return 0
|
||||||
|
except Exception as exc:
|
||||||
|
save(dest/'failure.json',dict(status='FAILED',case=case,type=type(exc).__name__,message=str(exc),
|
||||||
|
traceback=traceback.format_exc(),worker_cpu_seconds=time.process_time()-start,
|
||||||
|
wall_seconds=time.monotonic()-wall,automatic_retry=False))
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
p=argparse.ArgumentParser();p.add_argument('root',type=Path);p.add_argument('index',type=int)
|
||||||
|
a=p.parse_args();raise SystemExit(worker(a.root,a.index))
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
"""Independent Gre24 geometry/feature preparation; full tet nodes, no S2 mask."""
|
||||||
|
import argparse
|
||||||
|
import hashlib
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import time
|
||||||
|
import traceback
|
||||||
|
from xml.etree import ElementTree as ET
|
||||||
|
from zipfile import ZipFile
|
||||||
|
import numpy as np
|
||||||
|
import yaml
|
||||||
|
from audit_samples import decode_array
|
||||||
|
from gre24_features_v2 import features
|
||||||
|
from s2_recovery_supervisor import save
|
||||||
|
|
||||||
|
|
||||||
|
def sha(path):
|
||||||
|
h=hashlib.sha256()
|
||||||
|
with Path(path).open('rb') as f:
|
||||||
|
for block in iter(lambda:f.read(2**20),b''):h.update(block)
|
||||||
|
return h.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
def checked(root):
|
||||||
|
c=json.loads((root/'contract.json').read_text())
|
||||||
|
for p,h in c['code_sha256'].items():
|
||||||
|
if sha(p)!=h:raise ValueError('Pinned source changed: '+p)
|
||||||
|
st=Path(c['archive']).stat();a=c['archive_stat']
|
||||||
|
if (st.st_size,st.st_mtime_ns,st.st_ino)!=(a['bytes'],a['mtime_ns'],a['inode']):
|
||||||
|
raise ValueError('Immutable source archive changed')
|
||||||
|
return c
|
||||||
|
|
||||||
|
|
||||||
|
def read_geometry(archive,case):
|
||||||
|
cells={};points=None;stack=[]
|
||||||
|
with ZipFile(archive) as z:
|
||||||
|
config=yaml.safe_load(z.read(case+'.yml'))
|
||||||
|
with z.open(case+'_sim.vtu') as f:
|
||||||
|
for event,e in ET.iterparse(f,events=('start','end')):
|
||||||
|
if event=='start':
|
||||||
|
stack.append(e.tag)
|
||||||
|
if e.tag=='VTKFile':
|
||||||
|
if e.get('byte_order')!='LittleEndian' or e.get('compressor')!='vtkZLibDataCompressor':
|
||||||
|
raise ValueError('Unsupported VTU')
|
||||||
|
header=e.get('header_type','UInt32')
|
||||||
|
if e.tag in ('PointData','CellData'):
|
||||||
|
raise ValueError('Field section before complete geometry')
|
||||||
|
else:
|
||||||
|
if e.tag=='DataArray':
|
||||||
|
if stack[-2]=='Points':points=decode_array(e,header).copy()
|
||||||
|
elif stack[-2]=='Cells':cells[e.get('Name')]=decode_array(e,header).copy()
|
||||||
|
e.clear()
|
||||||
|
if points is not None and all(k in cells for k in ['connectivity','offsets','types']):break
|
||||||
|
stack.pop()
|
||||||
|
offsets=np.r_[0,cells['offsets']];indices=np.flatnonzero(cells['types']==10)
|
||||||
|
if not len(indices) or np.any(np.diff(offsets)[indices]!=4):raise ValueError('No valid tetrahedra')
|
||||||
|
raw_tet=cells['connectivity'][offsets[indices,None]+np.arange(4)]
|
||||||
|
raw_ids=np.unique(raw_tet);t=np.searchsorted(raw_ids,raw_tet)
|
||||||
|
types,counts=np.unique(cells['types'],return_counts=True)
|
||||||
|
return points[raw_ids],t,raw_ids,dict(raw_nodes=len(points),tet_nodes=len(raw_ids),
|
||||||
|
outside_tet_nodes=len(points)-len(raw_ids),raw_cell_types=dict(zip(map(str,types),map(int,counts))),
|
||||||
|
inlet_config=config,gate_source='YAML inlet_location; no explicit node/face markers in this source')
|
||||||
|
|
||||||
|
|
||||||
|
def read_targets(archive,case):
|
||||||
|
stack=[];count=None
|
||||||
|
with ZipFile(archive) as z,z.open(case+'_sim.vtu') as f:
|
||||||
|
for event,e in ET.iterparse(f,events=('start','end')):
|
||||||
|
if event=='start':
|
||||||
|
stack.append(e.tag)
|
||||||
|
if e.tag=='VTKFile':header=e.get('header_type','UInt32')
|
||||||
|
elif e.tag=='Piece':
|
||||||
|
if count is not None:raise ValueError('Multiple pieces')
|
||||||
|
count=int(e.get('NumberOfPoints'))
|
||||||
|
else:
|
||||||
|
if e.tag=='DataArray':
|
||||||
|
if stack[-2]=='PointData' and e.get('Name')=='Fill_time':
|
||||||
|
v=decode_array(e,header).copy()
|
||||||
|
if v.shape!=(count,):raise ValueError('Fill_time size mismatch')
|
||||||
|
return v
|
||||||
|
e.clear()
|
||||||
|
stack.pop()
|
||||||
|
raise ValueError('Missing Fill_time')
|
||||||
|
|
||||||
|
|
||||||
|
def worker(root,index):
|
||||||
|
c=checked(root);spec=c['parts'][index];case=spec['case'];dest=root/'parts'/case/'output'
|
||||||
|
dest.mkdir(parents=True,exist_ok=False)
|
||||||
|
start=time.process_time();wall=time.monotonic()
|
||||||
|
def progress(stage,**kw):
|
||||||
|
save(dest/'progress.json',dict(stage=stage,case=case,pid=os.getpid(),unix=time.time(),
|
||||||
|
CPU_s=time.process_time()-start,wall_s=time.monotonic()-wall,**kw))
|
||||||
|
try:
|
||||||
|
progress('READ_GEOMETRY')
|
||||||
|
x,t,raw,meta=read_geometry(c['archive'],case)
|
||||||
|
save(dest/'geometry-metadata.json',meta)
|
||||||
|
if spec.get('reuse_feature_root'):
|
||||||
|
old=Path(spec['reuse_feature_root']);old_meta=json.loads((old/'result.json').read_text())
|
||||||
|
if sha(old/'result.json')!=spec['reuse_result_sha256'] or old_meta['case']!=case:
|
||||||
|
raise ValueError('Reused cost evidence changed')
|
||||||
|
if old_meta['features']['speed_min']**2<=1e-4:
|
||||||
|
raise ValueError('Old unscaled result is not eligible for exact reuse')
|
||||||
|
data={}
|
||||||
|
for name in ['features','Vf','Dw','Di','Df','mass','all_wall_tet_ids']:
|
||||||
|
if sha(old/(name+'.npy'))!=old_meta['output_sha256'][name+'.npy']:
|
||||||
|
raise ValueError('Reused feature changed')
|
||||||
|
data[name]=np.load(old/(name+'.npy'),allow_pickle=False)
|
||||||
|
if not np.array_equal(raw,np.load(old/'raw_ids.npy',allow_pickle=False)):
|
||||||
|
raise ValueError('Reused raw IDs changed')
|
||||||
|
feature_meta=dict(old_meta['features'],reused_from=str(old),Df_coordinate_and_speed_scale=1.)
|
||||||
|
else:
|
||||||
|
data,feature_meta=features(x,t,raw,meta['inlet_config']['inlet_location'],progress=progress)
|
||||||
|
progress('SAVE_FEATURES')
|
||||||
|
for name in ['features','Vf','Dw','Di','Df','mass','all_wall_tet_ids']:np.save(dest/(name+'.npy'),data[name])
|
||||||
|
np.save(dest/'raw_ids.npy',raw)
|
||||||
|
if c.get('feature_only_cost_test',False):
|
||||||
|
save(dest/'result.json',dict(status='PASS',case=case,index=index,geometry=meta,features=feature_meta,
|
||||||
|
output_sha256={p.name:sha(p) for p in dest.glob('*.npy')},
|
||||||
|
worker_cpu_seconds=time.process_time()-start,wall_seconds=time.monotonic()-wall,
|
||||||
|
decoded_labels=[],test_scores_computed=False,training=False,cost_test_only=True))
|
||||||
|
progress('PASS_COST_TEST_ONLY');return 0
|
||||||
|
progress('READ_FILL_TIME_AFTER_FEATURES_FIXED')
|
||||||
|
yall=read_targets(c['archive'],case);y=yall[raw]
|
||||||
|
if not np.isfinite(y).all() or np.any(y<0):raise ValueError('Invalid fill time on full tetrahedral domain')
|
||||||
|
outside=np.ones(len(yall),dtype=bool);outside[raw]=False;outside_y=yall[outside]
|
||||||
|
np.save(dest/'seconds.npy',y);np.save(dest/'target.npy',y/spec['t_scale_seconds'])
|
||||||
|
np.save(dest/'outside_tet_raw_ids.npy',np.flatnonzero(outside));np.save(dest/'outside_tet_fill_time.npy',outside_y)
|
||||||
|
outputs={p.name:sha(p) for p in dest.glob('*.npy')}
|
||||||
|
save(dest/'result.json',dict(status='PASS',case=case,index=index,geometry=meta,features=feature_meta,
|
||||||
|
t_scale_seconds=spec['t_scale_seconds'],time_scale_source=spec['time_scale_source'],
|
||||||
|
decoded_labels=['Fill_time'],outside_label_status=dict(nodes=len(outside_y),
|
||||||
|
finite=int(np.isfinite(outside_y).sum()),negative=int((outside_y<0).sum())),
|
||||||
|
output_sha256=outputs,worker_cpu_seconds=time.process_time()-start,wall_seconds=time.monotonic()-wall,
|
||||||
|
test_scores_computed=False,training=False))
|
||||||
|
progress('PASS');return 0
|
||||||
|
except Exception as exc:
|
||||||
|
save(dest/'failure.json',dict(status='FAILED',case=case,type=type(exc).__name__,message=str(exc),
|
||||||
|
traceback=traceback.format_exc(),worker_cpu_seconds=time.process_time()-start,
|
||||||
|
wall_seconds=time.monotonic()-wall,automatic_retry=False))
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
p=argparse.ArgumentParser();p.add_argument('root',type=Path);p.add_argument('index',type=int)
|
||||||
|
a=p.parse_args();raise SystemExit(worker(a.root,a.index))
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
"""Freeze authorised v5 fallback independently of all historical S2 splits."""
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import time
|
||||||
|
from zipfile import ZipFile
|
||||||
|
import numpy as np
|
||||||
|
from gre24_prepare_v2 import sha
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
root=Path('artifacts/gre24-reproduction-2026-11-15/v5-protocol')
|
||||||
|
root.mkdir(exist_ok=False)
|
||||||
|
archive=Path('data.zip').resolve()
|
||||||
|
prior=json.loads(Path('artifacts/intake-2026-11-13/archive_verification.json').read_text())
|
||||||
|
st=archive.stat()
|
||||||
|
assert (st.st_size,st.st_mtime_ns,st.st_ino)==(prior['bytes'],prior['mtime_ns'],prior['inode'])
|
||||||
|
with ZipFile(archive) as z:
|
||||||
|
cases=sorted(n[:-4] for n in z.namelist() if n.endswith('.yml'))
|
||||||
|
assert len(cases)==624 and len(set(cases))==624
|
||||||
|
assert all(c+'_sim.vtu' in z.namelist() and c+'.log' in z.namelist() for c in cases)
|
||||||
|
settings_file=Path('artifacts/s2-e1-2026-11-14/log-flow-setting-check/fill-time-setting-context.json')
|
||||||
|
settings={r['member'][:-4]:r for r in json.loads(settings_file.read_text())}
|
||||||
|
inventory_file=Path('artifacts/intake-2026-11-13/geometry_log_census.json')
|
||||||
|
inventory={r['case']:r for r in json.loads(inventory_file.read_text())}
|
||||||
|
parts=[]
|
||||||
|
for case in cases:
|
||||||
|
s=settings[case];assert s['setting_before_filling_phase'] and s['setting']['seconds']>0
|
||||||
|
parts.append(dict(case=case,raw_nodes=inventory[case]['points'],t_scale_seconds=s['setting']['seconds'],
|
||||||
|
time_scale_source=dict(mode='t_set_substitute_Q_unavailable_declared_deviation',
|
||||||
|
setting=s['setting'],pre_solver_setting=True,source=str(settings_file),source_sha256=sha(settings_file))))
|
||||||
|
cost_root=Path('artifacts/gre24-reproduction-2026-11-15/v5-cost-test')
|
||||||
|
cost=json.loads((cost_root/'complete.json').read_text());assert cost['status']=='COMPLETE'
|
||||||
|
r=cost['records'][0];assert r['worker']['status']=='PASS'
|
||||||
|
p=next(p for p in parts if p['case']==r['case']);p.update(reuse_feature_root=str(Path(r['result_path']).parent),reuse_result_sha256=r['result_sha256'])
|
||||||
|
splits=[]
|
||||||
|
for index,seed in enumerate(range(2026111501,2026111506)):
|
||||||
|
order=np.random.Generator(np.random.PCG64(seed)).permutation(len(cases))
|
||||||
|
test=sorted(cases[i] for i in order[:312]);train=sorted(cases[i] for i in order[312:])
|
||||||
|
vi=np.random.Generator(np.random.PCG64(seed+1000)).permutation(len(train))[:32]
|
||||||
|
val=sorted(train[i] for i in vi);learning=sorted(set(train)-set(val))
|
||||||
|
assert len(learning)==280 and not set(train)&set(test)
|
||||||
|
splits.append(dict(index=index,seed=seed,train=train,test=test,fnn_validation=val,fnn_learning=learning,
|
||||||
|
fnn_validation_seed=seed+1000,validation_rounding='ceil(10percent training geometries)'))
|
||||||
|
(root/'splits.json').write_text(json.dumps(splits,indent=2)+'\n')
|
||||||
|
paths=['tools/gre24_features_v2.py','tools/gre24_prepare_v2.py','tools/run_gre24_protocol_preparation.py',
|
||||||
|
'tools/boundary_distance.py','tools/audit_samples.py','tools/s2_recovery_supervisor.py','tools/s2_recovery_monitoring.py']
|
||||||
|
contract=dict(version='Gre24-v5-fallback-R1-unit-scale-v2',dataset_version='v5',
|
||||||
|
authorizing_rulings=['1794755474.778649','1794755594.435869','1794756165.827889','1794756243.638289','1794756271.768399'],
|
||||||
|
archive=str(archive),archive_stat=prior,parts=parts,dispatch_order=list(range(624)),
|
||||||
|
worker_cpus=[8,10,12,14,16,18,20,22],coordinator_cpus=[30,31],
|
||||||
|
limits=dict(workers=8,total_worker_cpu_seconds=144000,per_part_cpu_seconds=1800,per_part_wall_seconds=1800,
|
||||||
|
per_part_rss_bytes=4*2**30,preparation_initial_cpu_reserve_seconds=60+cost['worker_cpu_seconds'],
|
||||||
|
total_disk_bytes=60*10**9,total_gpu_seconds=7200),
|
||||||
|
preparation_setup_reserve_note='60 CPU-s conservative allowance covers analytic tests; setup/library copy overhead separately recorded',
|
||||||
|
historical_cost_result=str(cost_root/'complete.json'),historical_cost_sha256=sha(cost_root/'complete.json'),
|
||||||
|
historical_cost_worker_cpu_seconds=cost['worker_cpu_seconds'],
|
||||||
|
code_sha256={p:sha(p) for p in paths},splits_sha256=sha(root/'splits.json'),
|
||||||
|
protocol='Five independent 312test/312train random geometry splits; NOT five-fold CV; v5 version deviation',
|
||||||
|
failure_policy='No replacement, no automatic retries; retain every requested case in coverage reporting',
|
||||||
|
data_domain='Every retained tet node including wall; original IDs/outside-tet labels separately retained',
|
||||||
|
features='Eq12 19 columns; no t_set feature; R1 discretisations and conditional exact unit change',
|
||||||
|
timestamp=time.time())
|
||||||
|
(root/'contract.json').write_text(json.dumps(contract,indent=2)+'\n')
|
||||||
|
print(json.dumps(dict(root=str(root),parts=624,contract_sha256=sha(root/'contract.json'),splits_sha256=sha(root/'splits.json'))))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':main()
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
"""One guarded Gre24 preparation queue, preserving failed attempts and total CPU."""
|
||||||
|
import argparse
|
||||||
|
import fcntl
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import resource
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from gre24_prepare import checked,sha
|
||||||
|
from s2_recovery_supervisor import save,supervise,stop_group
|
||||||
|
|
||||||
|
|
||||||
|
def guard(root,index,slot):
|
||||||
|
c=checked(root);os.sched_setaffinity(0,[c['worker_cpus'][slot]])
|
||||||
|
part=c['parts'][index];dest=root/'parts'/part['case'];dest.mkdir(parents=True,exist_ok=True)
|
||||||
|
cap=c['limits']['per_part_cpu_seconds']
|
||||||
|
r=supervise([sys.executable,'tools/gre24_prepare.py',str(root),str(index)],dest,'worker',
|
||||||
|
dict(total_cpu_seconds=cap+1,job_cpu_seconds=cap,job_wall_seconds=c['limits']['per_part_wall_seconds'],
|
||||||
|
tree_rss_bytes=c['limits']['per_part_rss_bytes'],disk_bytes=2*2**30,max_processes=1),poll=.2)
|
||||||
|
result=dest/'output/result.json'
|
||||||
|
if r['status']=='PASS' and (not result.exists() or json.loads(result.read_text())['status']!='PASS'):
|
||||||
|
r.update(status='STOPPED_OR_FAILED',stop_reason='MISSING_COMPLETE_RESULT')
|
||||||
|
save(dest/'guard-result.json',dict(worker=r,index=index,case=part['case'],result_path=str(result) if result.exists() else None,
|
||||||
|
result_sha256=sha(result) if result.exists() else None,guard_cpu_seconds=sum(resource.getrusage(resource.RUSAGE_SELF)[:2])))
|
||||||
|
return 0 if r['status']=='PASS' else 1
|
||||||
|
|
||||||
|
|
||||||
|
def run(root):
|
||||||
|
with (root/'queue.lock').open('a') as lock:
|
||||||
|
fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
|
||||||
|
return run_locked(root)
|
||||||
|
|
||||||
|
|
||||||
|
def run_locked(root):
|
||||||
|
c=checked(root)
|
||||||
|
if (root/'queue-started.json').exists():raise FileExistsError('Never restart this queue')
|
||||||
|
os.sched_setaffinity(0,c['coordinator_cpus'])
|
||||||
|
save(root/'queue-started.json',dict(pid=os.getpid(),unix=time.time(),contract_sha256=sha(root/'contract.json')))
|
||||||
|
active={};done=[];next_i=0;reason=None;first=False;started=time.monotonic()
|
||||||
|
cap=c['limits']['total_worker_cpu_seconds'];per=c['limits']['per_part_cpu_seconds']
|
||||||
|
def interrupted(*_):
|
||||||
|
nonlocal reason
|
||||||
|
reason='COORDINATOR_INTERRUPTED'
|
||||||
|
signal.signal(signal.SIGTERM,interrupted);signal.signal(signal.SIGINT,interrupted)
|
||||||
|
env=dict(os.environ,OMP_NUM_THREADS='1',OPENBLAS_NUM_THREADS='1',MKL_NUM_THREADS='1',NUMEXPR_NUM_THREADS='1',CUDA_VISIBLE_DEVICES='')
|
||||||
|
try:
|
||||||
|
while active or (next_i<len(c['parts']) and reason is None):
|
||||||
|
for slot,item in list(active.items()):
|
||||||
|
if item['process'].poll() is None:continue
|
||||||
|
receipt=root/'parts'/c['parts'][item['index']]['case']/'guard-result.json'
|
||||||
|
if not receipt.exists():
|
||||||
|
reason='MISSING_GUARD_RECEIPT';raise RuntimeError(reason)
|
||||||
|
r=json.loads(receipt.read_text());done.append(r);item['log'].close();del active[slot]
|
||||||
|
print(json.dumps(dict(event='PREPARATION_TERMINAL',index=r['index'],case=r['case'],status=r['worker']['status'],completed=len(done))),flush=True)
|
||||||
|
spent=c['limits']['preparation_initial_cpu_reserve_seconds']+sum(r['worker']['cpu_seconds'] for r in done)
|
||||||
|
if not first and done and not active:
|
||||||
|
first=True;r=done[0];spec=c['parts'][r['index']]
|
||||||
|
projection=r['worker']['cpu_seconds']*sum(p['raw_nodes'] for p in c['parts'])/spec['raw_nodes']*1.25
|
||||||
|
save(root/'first-part-checkpoint.json',dict(first=r['case'],status=r['worker']['status'],
|
||||||
|
projected_preparation_cpu_seconds=projection,projection_is_heuristic=True,
|
||||||
|
total_worker_cap_seconds=cap,first_result_sha256=r.get('result_sha256')))
|
||||||
|
if r['worker']['status']!='PASS':reason='FIRST_PART_FAILED'
|
||||||
|
elif projection>cap:reason='FIRST_PART_PROJECTED_PREPARATION_OVER_TOTAL_CAP'
|
||||||
|
ceiling=len(c['parts']) if first else 1
|
||||||
|
while reason is None and len(active)<c['limits']['workers'] and next_i<ceiling:
|
||||||
|
# Reserve each active job's full cap plus one sampling margin.
|
||||||
|
if spent+(len(active)+1)*(per+2)>cap:
|
||||||
|
if not active:reason='REMAINING_CPU_INSUFFICIENT_FOR_ANOTHER_CAPPED_ATTEMPT'
|
||||||
|
break
|
||||||
|
slot=next(s for s in range(c['limits']['workers']) if s not in active)
|
||||||
|
index=c['dispatch_order'][next_i];dest=root/'parts'/c['parts'][index]['case'];dest.mkdir(parents=True,exist_ok=True)
|
||||||
|
log=(dest/'guard.log').open('x')
|
||||||
|
process=subprocess.Popen([sys.executable,__file__,str(root),'--guard',str(index),'--slot',str(slot)],
|
||||||
|
stdout=log,stderr=subprocess.STDOUT,env=env,start_new_session=True)
|
||||||
|
active[slot]=dict(process=process,log=log,index=index);next_i+=1
|
||||||
|
save(root/'progress.json',dict(completed=len(done),attempted=next_i,total=len(c['parts']),
|
||||||
|
active={str(k):v['index'] for k,v in active.items()},settled_worker_cpu_seconds=spent,
|
||||||
|
reserved_active_worker_cpu_seconds=len(active)*(per+2),stop_reason=reason,
|
||||||
|
first_part_checked=first,elapsed_seconds=time.monotonic()-started))
|
||||||
|
if active:time.sleep(.5)
|
||||||
|
finally:
|
||||||
|
for item in active.values():
|
||||||
|
stop_group(item['process'].pid);item['process'].wait();item['log'].close()
|
||||||
|
attempted={r['index'] for r in done}
|
||||||
|
save(root/'complete.json',dict(status='COMPLETE' if len(done)==len(c['parts']) else 'STOPPED',stop_reason=reason,
|
||||||
|
records=done,never_attempted=[i for i in c['dispatch_order'] if i not in attempted],
|
||||||
|
worker_cpu_seconds=sum(r['worker']['cpu_seconds'] for r in done),
|
||||||
|
initial_cpu_reserve_seconds=c['limits']['preparation_initial_cpu_reserve_seconds'],
|
||||||
|
coordinator_cpu_seconds=sum(resource.getrusage(resource.RUSAGE_SELF)[:2]),
|
||||||
|
accounting_complete=not active,wall_seconds=time.monotonic()-started))
|
||||||
|
return 0 if len(done)==len(c['parts']) else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
p=argparse.ArgumentParser();p.add_argument('root',type=Path);p.add_argument('--guard',type=int);p.add_argument('--slot',type=int,default=0)
|
||||||
|
a=p.parse_args();raise SystemExit(run(a.root) if a.guard is None else guard(a.root,a.guard,a.slot))
|
||||||
@@ -0,0 +1,99 @@
|
|||||||
|
"""One guarded Gre24 preparation queue, preserving failed attempts and total CPU."""
|
||||||
|
import argparse
|
||||||
|
import fcntl
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
from pathlib import Path
|
||||||
|
import resource
|
||||||
|
import signal
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
from gre24_prepare_v2 import checked,sha
|
||||||
|
from s2_recovery_supervisor import save,supervise,stop_group
|
||||||
|
|
||||||
|
|
||||||
|
def guard(root,index,slot):
|
||||||
|
c=checked(root);os.sched_setaffinity(0,[c['worker_cpus'][slot]])
|
||||||
|
part=c['parts'][index];dest=root/'parts'/part['case'];dest.mkdir(parents=True,exist_ok=True)
|
||||||
|
cap=c['limits']['per_part_cpu_seconds']
|
||||||
|
r=supervise([sys.executable,'tools/gre24_prepare_v2.py',str(root),str(index)],dest,'worker',
|
||||||
|
dict(total_cpu_seconds=cap+1,job_cpu_seconds=cap,job_wall_seconds=c['limits']['per_part_wall_seconds'],
|
||||||
|
tree_rss_bytes=c['limits']['per_part_rss_bytes'],disk_bytes=2*2**30,max_processes=1),poll=.2)
|
||||||
|
result=dest/'output/result.json'
|
||||||
|
if r['status']=='PASS' and (not result.exists() or json.loads(result.read_text())['status']!='PASS'):
|
||||||
|
r.update(status='STOPPED_OR_FAILED',stop_reason='MISSING_COMPLETE_RESULT')
|
||||||
|
save(dest/'guard-result.json',dict(worker=r,index=index,case=part['case'],result_path=str(result) if result.exists() else None,
|
||||||
|
result_sha256=sha(result) if result.exists() else None,guard_cpu_seconds=sum(resource.getrusage(resource.RUSAGE_SELF)[:2])))
|
||||||
|
return 0 if r['status']=='PASS' else 1
|
||||||
|
|
||||||
|
|
||||||
|
def run(root):
|
||||||
|
with (root/'queue.lock').open('a') as lock:
|
||||||
|
fcntl.flock(lock,fcntl.LOCK_EX|fcntl.LOCK_NB)
|
||||||
|
return run_locked(root)
|
||||||
|
|
||||||
|
|
||||||
|
def run_locked(root):
|
||||||
|
c=checked(root)
|
||||||
|
if (root/'queue-started.json').exists():raise FileExistsError('Never restart this queue')
|
||||||
|
os.sched_setaffinity(0,c['coordinator_cpus'])
|
||||||
|
save(root/'queue-started.json',dict(pid=os.getpid(),unix=time.time(),contract_sha256=sha(root/'contract.json')))
|
||||||
|
active={};done=[];next_i=0;reason=None;first=False;started=time.monotonic()
|
||||||
|
cap=c['limits']['total_worker_cpu_seconds'];per=c['limits']['per_part_cpu_seconds']
|
||||||
|
def interrupted(*_):
|
||||||
|
nonlocal reason
|
||||||
|
reason='COORDINATOR_INTERRUPTED'
|
||||||
|
signal.signal(signal.SIGTERM,interrupted);signal.signal(signal.SIGINT,interrupted)
|
||||||
|
env=dict(os.environ,OMP_NUM_THREADS='1',OPENBLAS_NUM_THREADS='1',MKL_NUM_THREADS='1',NUMEXPR_NUM_THREADS='1',CUDA_VISIBLE_DEVICES='')
|
||||||
|
try:
|
||||||
|
while active or (next_i<len(c['parts']) and reason is None):
|
||||||
|
for slot,item in list(active.items()):
|
||||||
|
if item['process'].poll() is None:continue
|
||||||
|
receipt=root/'parts'/c['parts'][item['index']]['case']/'guard-result.json'
|
||||||
|
if not receipt.exists():
|
||||||
|
reason='MISSING_GUARD_RECEIPT';raise RuntimeError(reason)
|
||||||
|
r=json.loads(receipt.read_text());done.append(r);item['log'].close();del active[slot]
|
||||||
|
print(json.dumps(dict(event='PREPARATION_TERMINAL',index=r['index'],case=r['case'],status=r['worker']['status'],completed=len(done))),flush=True)
|
||||||
|
spent=c['limits']['preparation_initial_cpu_reserve_seconds']+sum(r['worker']['cpu_seconds'] for r in done)
|
||||||
|
if not first and done and not active:
|
||||||
|
first=True;r=done[0];spec=c['parts'][r['index']]
|
||||||
|
projection=r['worker']['cpu_seconds']*sum(p['raw_nodes'] for p in c['parts'])/spec['raw_nodes']*1.25
|
||||||
|
save(root/'first-part-checkpoint.json',dict(first=r['case'],status=r['worker']['status'],
|
||||||
|
projected_preparation_cpu_seconds=projection,projection_is_heuristic=True,
|
||||||
|
total_worker_cap_seconds=cap,first_result_sha256=r.get('result_sha256')))
|
||||||
|
if r['worker']['status']!='PASS':reason='FIRST_PART_FAILED'
|
||||||
|
elif projection>cap:reason='FIRST_PART_PROJECTED_PREPARATION_OVER_TOTAL_CAP'
|
||||||
|
ceiling=len(c['parts']) if first else 1
|
||||||
|
while reason is None and len(active)<c['limits']['workers'] and next_i<ceiling:
|
||||||
|
# Reserve each active job's full cap plus one sampling margin.
|
||||||
|
if spent+(len(active)+1)*(per+2)>cap:
|
||||||
|
if not active:reason='REMAINING_CPU_INSUFFICIENT_FOR_ANOTHER_CAPPED_ATTEMPT'
|
||||||
|
break
|
||||||
|
slot=next(s for s in range(c['limits']['workers']) if s not in active)
|
||||||
|
index=c['dispatch_order'][next_i];dest=root/'parts'/c['parts'][index]['case'];dest.mkdir(parents=True,exist_ok=True)
|
||||||
|
log=(dest/'guard.log').open('x')
|
||||||
|
process=subprocess.Popen([sys.executable,__file__,str(root),'--guard',str(index),'--slot',str(slot)],
|
||||||
|
stdout=log,stderr=subprocess.STDOUT,env=env,start_new_session=True)
|
||||||
|
active[slot]=dict(process=process,log=log,index=index);next_i+=1
|
||||||
|
save(root/'progress.json',dict(completed=len(done),attempted=next_i,total=len(c['parts']),
|
||||||
|
active={str(k):v['index'] for k,v in active.items()},settled_worker_cpu_seconds=spent,
|
||||||
|
reserved_active_worker_cpu_seconds=len(active)*(per+2),stop_reason=reason,
|
||||||
|
first_part_checked=first,elapsed_seconds=time.monotonic()-started))
|
||||||
|
if active:time.sleep(.5)
|
||||||
|
finally:
|
||||||
|
for item in active.values():
|
||||||
|
stop_group(item['process'].pid);item['process'].wait();item['log'].close()
|
||||||
|
attempted={r['index'] for r in done}
|
||||||
|
save(root/'complete.json',dict(status='COMPLETE' if len(done)==len(c['parts']) else 'STOPPED',stop_reason=reason,
|
||||||
|
records=done,never_attempted=[i for i in c['dispatch_order'] if i not in attempted],
|
||||||
|
worker_cpu_seconds=sum(r['worker']['cpu_seconds'] for r in done),
|
||||||
|
initial_cpu_reserve_seconds=c['limits']['preparation_initial_cpu_reserve_seconds'],
|
||||||
|
coordinator_cpu_seconds=sum(resource.getrusage(resource.RUSAGE_SELF)[:2]),
|
||||||
|
accounting_complete=not active,wall_seconds=time.monotonic()-started))
|
||||||
|
return 0 if len(done)==len(c['parts']) else 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
p=argparse.ArgumentParser();p.add_argument('root',type=Path);p.add_argument('--guard',type=int);p.add_argument('--slot',type=int,default=0)
|
||||||
|
a=p.parse_args();raise SystemExit(run(a.root) if a.guard is None else guard(a.root,a.guard,a.slot))
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
"""Analytic acceptance for the new reproduction, independent of real labels."""
|
||||||
|
import unittest
|
||||||
|
from itertools import permutations
|
||||||
|
import numpy as np
|
||||||
|
from gre24_features import (mesh, exterior_faces, gate_nodes, solve_eikonal,
|
||||||
|
cell_flow_speed, strict_volume_cdf, nodal_gradient, spatial_moment,
|
||||||
|
per_geometry_metrics, appendix_summary, features)
|
||||||
|
|
||||||
|
|
||||||
|
def box(nx=5, ny=3, nz=3):
|
||||||
|
axes = [np.linspace(0, 2, nx), np.linspace(0, 1, ny), np.linspace(0, 1, nz)]
|
||||||
|
x = np.stack(np.meshgrid(*axes, indexing='ij'), axis=-1).reshape(-1, 3)
|
||||||
|
ids = np.arange(len(x)).reshape(nx, ny, nz); t=[]
|
||||||
|
for i in range(nx-1):
|
||||||
|
for j in range(ny-1):
|
||||||
|
for k in range(nz-1):
|
||||||
|
for perm in permutations(range(3)):
|
||||||
|
v=np.array([i,j,k]); row=[ids[tuple(v)]]
|
||||||
|
for a in perm:
|
||||||
|
v=v.copy();v[a]+=1;row.append(ids[tuple(v)])
|
||||||
|
t.append(row)
|
||||||
|
return x, np.array(t, dtype=np.int32)
|
||||||
|
|
||||||
|
|
||||||
|
class Gre24Checks(unittest.TestCase):
|
||||||
|
def test_planar_speed_two(self):
|
||||||
|
x,t=box();g=mesh(x,t);source=np.flatnonzero(x[:,0]==0)
|
||||||
|
phi=solve_eikonal(g,source,2.)
|
||||||
|
np.testing.assert_allclose(phi,x[:,0]/2,atol=1e-7,rtol=1e-7)
|
||||||
|
|
||||||
|
def test_strict_ties_volume_weights(self):
|
||||||
|
np.testing.assert_allclose(strict_volume_cdf([0,1,1,2],[1,1,1,1]),[0,.25,.25,.75])
|
||||||
|
np.testing.assert_allclose(strict_volume_cdf([0,1,1,2],[1,2,3,4]),[0,.1,.1,.6])
|
||||||
|
|
||||||
|
def test_rod_volume_mapping(self):
|
||||||
|
x,t=box(21,2,2);g=mesh(x,t)
|
||||||
|
f=strict_volume_cdf(x[:,0],g['mass'])
|
||||||
|
self.assertLessEqual(np.max(np.abs(f-x[:,0]/2)),1/20+1e-12)
|
||||||
|
|
||||||
|
def test_disk_ideal_volume_mapping(self):
|
||||||
|
# Annular volume quadrature of the analytic radial order, not a tetFIM claim.
|
||||||
|
edges=np.linspace(0,1,101);radius=(edges[:-1]+edges[1:])/2
|
||||||
|
mass=np.pi*np.diff(edges**2)
|
||||||
|
f=strict_volume_cdf(radius,mass)
|
||||||
|
self.assertLess(np.max(np.abs(f-radius**2)),.011)
|
||||||
|
|
||||||
|
def test_affine_gradient_and_constant(self):
|
||||||
|
x,t=box();g=mesh(x,t);a=np.array([2.,-3.,.7])
|
||||||
|
grad=nodal_gradient(g,x@a+4,normalize=False)
|
||||||
|
np.testing.assert_allclose(grad,np.tile(a,(len(x),1)),atol=1e-12)
|
||||||
|
np.testing.assert_array_equal(nodal_gradient(g,np.full(len(x),7.)),np.zeros_like(x))
|
||||||
|
|
||||||
|
def test_moment_rotation(self):
|
||||||
|
x,t=box(3,3,3);g=mesh(x,t);di=x[:,0]
|
||||||
|
s,_=spatial_moment(g,di)
|
||||||
|
theta=.37;rot=np.array([[np.cos(theta),-np.sin(theta),0],[np.sin(theta),np.cos(theta),0],[0,0,1.]])
|
||||||
|
sr,_=spatial_moment(mesh(x@rot.T,t),di)
|
||||||
|
def matrix(a):
|
||||||
|
return a[:,np.array([[0,1,2],[1,3,4],[2,4,5]])]
|
||||||
|
sm=matrix(s);np.testing.assert_allclose(np.trace(sm,axis1=1,axis2=2),1,atol=1e-12)
|
||||||
|
self.assertTrue(np.all(np.linalg.eigvalsh(sm)>=-1e-12))
|
||||||
|
np.testing.assert_allclose(matrix(sr),rot@sm@rot.T,atol=1e-12)
|
||||||
|
|
||||||
|
def test_all_wall_tet_supplement(self):
|
||||||
|
x=np.array([[0,0,0],[1,0,0],[0,1,0],[0,0,1.]])
|
||||||
|
t=np.array([[0,1,2,3]]);g=mesh(x,t)
|
||||||
|
speed,zero=cell_flow_speed(g,np.zeros(4),exterior_faces(t))
|
||||||
|
np.testing.assert_allclose(speed,[1/(4*np.sqrt(3))],atol=1e-12)
|
||||||
|
np.testing.assert_array_equal(zero,[0])
|
||||||
|
|
||||||
|
def test_gate_original_id_tie(self):
|
||||||
|
x=np.array([[-1.,0,0],[1.,0,0]])
|
||||||
|
ids,mode=gate_nodes(x,[17,3],[0,0,0]);np.testing.assert_array_equal(ids,[1])
|
||||||
|
|
||||||
|
def test_three_metrics_and_undefined(self):
|
||||||
|
r=per_geometry_metrics([1,3],[2,3])
|
||||||
|
np.testing.assert_allclose([r['rrmse_rms'],r['rrmse_maximum'],r['rrmse_mean']],
|
||||||
|
[1/np.sqrt(10),1/(3*np.sqrt(2)),1/(2*np.sqrt(2))])
|
||||||
|
z=per_geometry_metrics([0,0],[0,1]);self.assertIsNone(z['rrmse_rms'])
|
||||||
|
|
||||||
|
def test_split_then_average(self):
|
||||||
|
r=appendix_summary([[0,1,2],[10,20,30],[2,3,4],[0,0,100],[7,8,9]])
|
||||||
|
self.assertEqual(r['mean_of_split_summaries']['median'],6.4)
|
||||||
|
|
||||||
|
def test_complete_pipeline_and_fail_closed(self):
|
||||||
|
x,t=box();a,m=features(x,t,np.arange(len(x)),x[0])
|
||||||
|
self.assertEqual(a['features'].shape,(len(x),19))
|
||||||
|
self.assertGreater(m['all_wall_tetrahedra'],0)
|
||||||
|
self.assertTrue(np.isfinite(a['features']).all())
|
||||||
|
with self.assertRaises(ValueError):solve_eikonal(mesh(x,t),np.array([0]),0.)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':unittest.main()
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
"""Accepted unit-change checks, with original eleven checks on new adapter."""
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
import resource
|
||||||
|
import time
|
||||||
|
import unittest
|
||||||
|
import numpy as np
|
||||||
|
import gre24_features_v2 as v2
|
||||||
|
import test_gre24_features as original
|
||||||
|
|
||||||
|
# Route the existing analytic tests to the new module without editing old evidence.
|
||||||
|
for name in ('mesh','exterior_faces','gate_nodes','solve_eikonal','cell_flow_speed','strict_volume_cdf',
|
||||||
|
'nodal_gradient','spatial_moment','per_geometry_metrics','appendix_summary','features'):
|
||||||
|
setattr(original,name,getattr(v2,name))
|
||||||
|
|
||||||
|
|
||||||
|
class ScaleChecks(unittest.TestCase):
|
||||||
|
def test_scale_invariance(self):
|
||||||
|
x,t=original.box();g=v2.mesh(x,t);src=np.flatnonzero(x[:,0]==0)
|
||||||
|
a=v2.solve_eikonal(g,src,2.,scale_override=1.)
|
||||||
|
b=v2.solve_eikonal(g,src,2.,scale_override=100.)
|
||||||
|
np.testing.assert_allclose(a,b,atol=1e-9,rtol=1e-9)
|
||||||
|
|
||||||
|
def test_tiny_speed_reaches_same_analytic_solution(self):
|
||||||
|
x,t=original.box();g=v2.mesh(x,t);src=np.flatnonzero(x[:,0]==0)
|
||||||
|
a=v2.solve_eikonal(g,src,.001)
|
||||||
|
np.testing.assert_allclose(a,x[:,0]/.001,atol=1e-6,rtol=1e-9)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
start=time.monotonic()
|
||||||
|
suite=unittest.TestSuite([unittest.defaultTestLoader.loadTestsFromTestCase(original.Gre24Checks),
|
||||||
|
unittest.defaultTestLoader.loadTestsFromTestCase(ScaleChecks)])
|
||||||
|
result=unittest.TextTestRunner(verbosity=2).run(suite)
|
||||||
|
usage=resource.getrusage(resource.RUSAGE_SELF)
|
||||||
|
Path('artifacts/gre24-reproduction-2026-11-15/synthetic-v2-receipt.json').write_text(json.dumps(dict(
|
||||||
|
tests=result.testsRun,failures=len(result.failures),errors=len(result.errors),passed=result.wasSuccessful(),
|
||||||
|
CPU_seconds=usage.ru_utime+usage.ru_stime,wall_seconds=time.monotonic()-start,peak_rss_bytes=usage.ru_maxrss*1024),indent=2))
|
||||||
|
raise SystemExit(0 if result.wasSuccessful() else 1)
|
||||||
Reference in new issue
Block a user