2 #-------------------------------------------------------------------------------
4 # | ____| _| |_ / __ \ /\ | \/ |
5 # | |__ _ __ ___ ___ / \| | | | / \ | \ / |
6 # | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
7 # | | | | | __/ __/\_ _/| |__| / ____ \| | | |
8 # |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
10 # FreeFOAM: The Cross-Platform CFD Toolkit
12 # Copyright (C) 2008-2010 Michael Wild <themiwi@users.sf.net>
13 # Gerber van der Graaf <gerber_graaf@users.sf.net>
14 #-------------------------------------------------------------------------------
16 # This file is part of FreeFOAM.
18 # FreeFOAM is free software; you can redistribute it and/or modify it
19 # under the terms of the GNU General Public License as published by the
20 # Free Software Foundation; either version 2 of the License, or (at your
21 # option) any later version.
23 # FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
24 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
28 # You should have received a copy of the GNU General Public License
29 # along with FreeFOAM; if not, write to the Free Software Foundation,
30 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
33 # freefoam-copySettings
36 # Copy FreeFOAM settings from one case to another, without copying
38 #------------------------------------------------------------------------------
40 """Usage: freefoam@PY_SCRIPT_SUFFIX@ copySettings [-h, -help] <src> <dst>
42 Copy FreeFOAM settings from one case to another, without copying the mesh or
47 <src> Source case directory to copy the settings from
48 <dst> Destination case directory to copy the settings to
49 -h, -help Display this help message.
53 # want to be future proof
54 from FreeFOAM
.compat
import *
63 if sys
.argv
[1] == '-h' or sys
.argv
[1] == '-help':
67 if len(sys
.argv
[1:]) != 2:
68 sys
.stderr
.write('Error: exactly two arguments required\n')
69 sys
.stderr
.write(__doc__
+'\n')
72 srcDir
= os
.path
.abspath(sys
.argv
[1])
73 dstDir
= os
.path
.abspath(sys
.argv
[2])
75 for d
in ('constant', 'system'):
76 dd
= os
.path
.join(srcDir
, d
)
77 if not os
.path
.isdir(dd
):
78 sys
.stderr
.write('Error: no "%s" directory in "%s\n"'%(d
, srcDir
))
79 sys
.stderr
.write(' This does not appear to be a FreeFOAM case\n')
83 # - verify that it works with multiple mesh regions
84 # - special treatment for starting with negative crank angles
85 # - or even better, parse startTime in controlDict if available
87 for parent
, dirs
, files
in os
.walk(srcDir
):
88 # remove processor, time (except 0) and polyMesh directories
90 if re
.match(r
'processor[0-9]+|[1-9].*|\d+\.\d+|polyMesh$', d
):
91 print('skipped', os
.path
.join(parent
, d
))
93 # remove log and queuing system output
95 if re
.match(r
'log.*|.*\.log|foam\.[eo][1-9]*', f
):
96 print('skipped', os
.path
.join(parent
, f
))
99 subdir
= os
.path
.relpath(parent
, srcDir
)
100 s
= os
.path
.join(parent
, f
)
101 d
= os
.path
.join(dstDir
, subdir
, f
)
102 print('%s\t->\t%s'%(s
,d
))
105 # ------------------- vim: set sw=3 sts=3 ft=python et: ------------ end-of-file