/usr/bin/freefoam-para is in freefoam 0.1.0+dfsg+1-3.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | #! /usr/bin/python
#-------------------------------------------------------------------------------
# ______ _ ____ __ __
# | ____| _| |_ / __ \ /\ | \/ |
# | |__ _ __ ___ ___ / \| | | | / \ | \ / |
# | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
# | | | | | __/ __/\_ _/| |__| / ____ \| | | |
# |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
#
# FreeFOAM: The Cross-Platform CFD Toolkit
#
# Copyright (C) 2008-2012 Michael Wild <themiwi@users.sf.net>
# Gerber van der Graaf <gerber_graaf@users.sf.net>
#-------------------------------------------------------------------------------
# License
# This file is part of FreeFOAM.
#
# FreeFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# FreeFOAM 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 General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with FreeFOAM. If not, see <http://www.gnu.org/licenses/>.
#
# Script
# freefoam-para
#
# Description
# Start ParaView with the OpenFOAM plugin
#
#------------------------------------------------------------------------------
"""Usage: freefoam para [-case <dir>] [-touch] [-h, -help]
Visualize the case <dir> with ParaView.
Options
-------
-case <dir> Specify alternative case or processor directory
-touch Only create the .foam file
"""
import os
import os.path
import sys
import glob
import subprocess
# want to be future proof
sys.path.insert(0, '/usr/lib/python2.7/site-packages')
from FreeFOAM.compat import *
# parse options
case = '.'
touchOnly = False
args = sys.argv[1:]
while len(args) > 0:
a = args[0]
if a == '-case':
if len(args) < 2:
sys.stderr.write('Error: The -case option requires an argument\n')
sys.exit(1)
case = args[1]
del args[0:2]
elif a == '-touch':
touchOnly = True
del args[0]
else:
sys.stderr.write('Error: unknown option/argument "%s"\n'%a)
sys.stderr.write(__doc__+'\n')
sys.exit(1)
case = os.path.abspath(case)
# get a sensible caseName
caseName = os.path.basename(case)
caseFile = "%s.foam"%caseName
if touchOnly:
open(caseFile, 'at')
echo('created "%s"'%os.path.relpath(caseFile, os.getcwd()))
sys.exit(0)
# parent directory for normal or parallel results
parentDir = case
if caseName[:9] == 'processor':
parentDir = os.path.dirname(case)
# check existence of essential files
for check in 'controlDict fvSchemes fvSolution'.split():
f = os.path.join(parentDir, 'system', check)
if not os.path.isfile(f):
sys.stderr.write('Error: File does not exist "%s"\n'%f)
sys.exit(1)
try:
if os.path.exists(caseFile):
doDelete = False
else:
# only create/remove caseFile if it didn't already exist
doDelete = True
open(caseFile, 'at')
echo('created temporary "%s"'%caseFile)
# Try to find ParaView:
paraview = None
if 'FREEFOAM_PARAVIEW_APP' in os.environ:
# Using a environment variable the user can set...
paraview=os.environ['FREEFOAM_PARAVIEW_APP']
elif os.path.exists('/usr/bin/paraview'):
# Using the CMake configure value...
paraview="/usr/bin/paraview"
if not paraview and os.uname()[0] == 'Darwin':
# On Darwin it might also be an app-bundle
pv_dirs = []
if 'FREEFOAM_PARAVIEW_APP' in os.environ:
pv_dirs.append(os.environ['FREEFOAM_PARAVIEW_APP'])
pv_dirs.extend('/Applications ~/Applications'.split())
for d in pv_dirs:
d = os.path.expanduser(d)
for n in reversed(glob.glob(os.path.join(d, '[Pp]ara[Vv]iew*.app'))):
tmp = os.path.join(n, 'Contents', 'MacOS', 'paraview')
if os.path.isfile(tmp):
paraview = tmp
break
if not paraview:
# Otherwise notify the user
sys.stderr.write('Error: Could not find ParaView 3. Either compile it or point\n' +
'FREEFOAM_PARAVIEW_APP to the full path of the paraview application.\n')
sys.exit(1)
# We want to do nice exit when running paraview to give paraview opportunity
# to clean up
if 'FOAM_ABORT' in os.environ:
del os.environ['FOAM_ABORT']
sys.exit(subprocess.call([paraview, '--data=%s'%caseFile]))
finally:
if doDelete:
os.remove(caseFile)
# ------------------- vim: set sw=3 sts=3 ft=python et: ------------ end-of-file
|