File size: 1,678 Bytes
e84c74f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python3
"""
DeepJEB++ v1.0 -> v1.1 torsion patch.
Corrects the torsion moment axis (Y -> Z, matching the SimJEB reference torsion
condition) and adds `tor_maxvm`, updating ONLY the torsion fields in each
3_fea_fields/<case>.npz in place. Vertical/horizontal/diagonal loads and all
geometry are left untouched.

Usage:
    python apply_torsion_patch.py <your 3_fea_fields dir> <extracted patch dir>

Also update deepjebpp_labels.csv and metadata.json from the v1.1 release
(these small files are included in the release directly).
"""
import numpy as np, sys, os, glob
if len(sys.argv) != 3:
    print(__doc__); sys.exit(1)
fields_dir, patch_dir = sys.argv[1], sys.argv[2]
TOR_KEYS = ['tor_U', 'tor_vm', 'tor_maxu', 'tor_p95vm', 'tor_maxvm']
patches = sorted(glob.glob(os.path.join(patch_dir, '*.npz')))
n_ok = n_missing = n_mismatch = 0
for pf in patches:
    case = os.path.basename(pf)
    ff = os.path.join(fields_dir, case)
    if not os.path.exists(ff):
        n_missing += 1; continue
    old = dict(np.load(ff)); pat = np.load(pf)
    if 'surface_points' in old and 'surface_points' in pat.files \
       and not np.array_equal(old['surface_points'], pat['surface_points']):
        print('SKIP surface mismatch:', case); n_mismatch += 1; continue
    for k in TOR_KEYS:
        if k in pat.files:
            old[k] = pat[k]
    tmp = ff + '.tmp'
    np.savez_compressed(tmp, **old); os.replace(tmp, ff)
    n_ok += 1
print(f'patched={n_ok}  missing_in_your_dir={n_missing}  surface_mismatch={n_mismatch}')
print('Done. Torsion labels are now Z-axis (SimJEB-matching). Also replace '
      'deepjebpp_labels.csv and metadata.json with the v1.1 copies.')