refresh_mb_output.py 1.85 KB
Newer Older
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
41
42
43
44
45
46
47
48
49
50
51
52
# MigFlow - Copyright (C) <2010-2018>
# <Universite catholique de Louvain (UCL), Belgium
#  Universite de Montpellier, France>
# 	
# List of the contributors to the development of MigFlow: see AUTHORS file.
# Description and complete License: see LICENSE file.
# 	
# This program (MigFlow) is free software: 
# you can redistribute it and/or modify it under the terms of the GNU Lesser General 
# Public License as published by the Free Software Foundation, either version
# 3 of the License, or (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Lesser General Public License for more details.
# 
# You should have received a copy of the GNU Lesser General Public License
# along with this program (see COPYING and COPYING.LESSER files).  If not, 
# see <http://www.gnu.org/licenses/>.

import glob
import os
from paraview.simple import *

for sname,sid in GetSources() :
    s = FindSource(sname)
    if not hasattr(s,'FileName') :
        continue
    l = s.FileName.GetData()
    for ext in [".vtu",".vtp",".vtm"] :
        if l and l[0][-4:]==ext:
            p = l[0].rfind("_")
            basename = l[0][:p]
            idname = l[0][p+1:-4]
            idnamelength = len(idname)    
            fmt = basename+"_%0"+str(idnamelength)+"i"+ext
            t0 = os.path.getmtime(l[0])
            allfiles = []
            i = 1
            while True :
                fname = fmt%i
                try :
                    mt = os.path.getmtime(fname)
                    if mt < t0 :
                        break
                except :
                    break
                allfiles += [fname]
                i += 1
            if allfiles :
                s.FileName.SetData(allfiles)