File size: 969 Bytes
ed552fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/usr/bin/env python3
"""清理 stokes_wave 的 processor 目录和旧时间步"""
import os, shutil, subprocess

raw = '/mnt/f/agent-workspace/paper2/Exp/data/raw/stokes_wave'
for d in sorted(os.listdir(raw)):
    if not d.startswith('t'):
        continue
    case_dir = os.path.join(raw, d)
    # 清理 processor 目录
    for e in os.listdir(case_dir):
        if e.startswith('processor'):
            path = os.path.join(case_dir, e)
            subprocess.run(['rm', '-rf', path], check=False)
    # 清理非0时间步
    for e in os.listdir(case_dir):
        if e.replace('.', '').isdigit() and e != '0':
            path = os.path.join(case_dir, e)
            if os.path.isdir(path):
                shutil.rmtree(path, ignore_errors=True)
            else:
                os.remove(path)
    # 清空 log
    log = os.path.join(case_dir, 'log.interFoam')
    if os.path.isfile(log):
        open(log, 'w').write('')
print('Cleaned stokes_wave cases')