TUT: relocate tutorial log analysis as functions for reuse in modules
- removed some unneeded tutorial files
This commit is contained in:
parent
2fe7d0c00b
commit
9c38ad6ae4
@ -6,20 +6,8 @@
|
||||
# \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM.
|
||||
#
|
||||
# OpenFOAM 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.
|
||||
#
|
||||
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Script
|
||||
# CleanFunctions
|
||||
@ -158,6 +146,7 @@ cleanFaMesh ()
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
cleanApplication()
|
||||
{
|
||||
echo "Cleaning application $PWD"
|
||||
|
120
bin/tools/LogFunctions
Normal file
120
bin/tools/LogFunctions
Normal file
@ -0,0 +1,120 @@
|
||||
#!/bin/sh
|
||||
#------------------------------------------------------------------------------
|
||||
# ========= |
|
||||
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
# \\ / O peration |
|
||||
# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||
# \\/ M anipulation |
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Script
|
||||
# LogFunctions
|
||||
#
|
||||
# Description
|
||||
# Miscellaneous functions for running tutorials in a loop and for
|
||||
# analyzing the output.
|
||||
#
|
||||
# Output is normally summarized as 'testLoopReport'
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# logReport <logfile>
|
||||
# Extracts useful info from log file.
|
||||
logReport()
|
||||
{
|
||||
local logfile=$1
|
||||
|
||||
# logfile is path/to/case/log.application
|
||||
caseName=$(dirname $logfile | sed -e 's/\(.*\)\.\///g')
|
||||
app=$(echo $logfile | sed -e 's/\(.*\)log\.//g')
|
||||
appAndCase="Application $app - case $caseName"
|
||||
|
||||
if grep -q "FOAM FATAL" $logfile
|
||||
then
|
||||
echo "$appAndCase: ** FOAM FATAL ERROR **"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check for solution singularity on U equation
|
||||
for eqn in Ux Uy Uz
|
||||
do
|
||||
if grep -q -E "${eqn}[:| ]*solution singularity" $logfile
|
||||
then
|
||||
if [ "$eqn" = Uz ]
|
||||
then
|
||||
# Can only get here if Ux,Uy,Uz all failed
|
||||
echo "$appAndCase: ** Solution singularity **"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if grep -q -E "^[\t ]*[Ee]nd" $logfile
|
||||
then
|
||||
# Extract time from this type of content
|
||||
## ExecutionTime = 60.2 s ClockTime = 63 s --> "60.2 s"
|
||||
completionTime=$(tail -10 $logfile | \
|
||||
sed -n -e '/Execution/{s/^[^=]*=[ \t]*//; s/\( s\) .*$/\1/; p}')
|
||||
|
||||
echo "$appAndCase: completed${completionTime:+ in }$completionTime"
|
||||
else
|
||||
echo "$appAndCase: unconfirmed completion"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# Collect and analyse all log files
|
||||
collectLogs()
|
||||
{
|
||||
echo "Collecting log files..." 1>&2
|
||||
rm -f logs testLoopReport > /dev/null 2>&1
|
||||
touch logs testLoopReport
|
||||
|
||||
local appDir log logFiles
|
||||
|
||||
for appDir in *
|
||||
do
|
||||
[ -d $appDir ] || continue
|
||||
echo -n " $appDir..." 1>&2
|
||||
|
||||
logFiles=$(find -L $appDir -name 'log.*' -type f)
|
||||
if [ -n "$logFiles" ]
|
||||
then
|
||||
echo 1>&2
|
||||
else
|
||||
echo " (no logs)" 1>&2
|
||||
continue
|
||||
fi
|
||||
|
||||
# Sort logs by time-stamp
|
||||
for log in $(echo $logFiles | xargs ls -rt)
|
||||
do
|
||||
# Concatenate and summarize logs
|
||||
cat "$log" >> logs 2>/dev/null
|
||||
logReport $log
|
||||
done
|
||||
echo
|
||||
done > testLoopReport
|
||||
}
|
||||
|
||||
|
||||
removeLogs()
|
||||
{
|
||||
echo "Removing backup files"
|
||||
|
||||
find . \( \
|
||||
-name '*~' -o -name '*.bak' \
|
||||
-name core -o -name 'core.[1-9]*' \
|
||||
-name '*.pvs' -o -name '*.foam' -o -name '*.OpenFOAM' \
|
||||
\) -type f -delete
|
||||
|
||||
rm -f logs testLoopReport > /dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------
|
@ -6,26 +6,15 @@
|
||||
# \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM.
|
||||
#
|
||||
# OpenFOAM 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.
|
||||
#
|
||||
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Script
|
||||
# RunFunctions
|
||||
#
|
||||
# Description
|
||||
# Miscellaneous functions for running tutorial cases
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# The normal locations
|
||||
|
@ -1,18 +1,11 @@
|
||||
#!/bin/sh
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
. $WM_PROJECT_DIR/bin/tools/LogFunctions # Tutorial log-file functions
|
||||
|
||||
echo "--------"
|
||||
removeLogs
|
||||
|
||||
echo "Cleaning tutorials ..."
|
||||
echo "Removing backup files"
|
||||
|
||||
find . \( \
|
||||
-name '*~' -o -name '*.bak' \
|
||||
-name core -o -name 'core.[1-9]*' \
|
||||
-name '*.pvs' -o -name '*.OpenFOAM' \
|
||||
\) -type f -delete
|
||||
|
||||
rm -f logs testLoopReport > /dev/null 2>&1
|
||||
|
||||
foamCleanTutorials cases
|
||||
|
||||
echo "--------"
|
||||
|
113
tutorials/Allrun
113
tutorials/Allrun
@ -7,26 +7,14 @@
|
||||
# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd.
|
||||
#------------------------------------------------------------------------------
|
||||
# License
|
||||
# This file is part of OpenFOAM.
|
||||
#
|
||||
# OpenFOAM 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.
|
||||
#
|
||||
# OpenFOAM 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 OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
# This file is part of OpenFOAM, licensed under GNU General Public License
|
||||
# <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Script
|
||||
# Allrun
|
||||
#
|
||||
# Description
|
||||
# Runs tutorial cases and summarizes the outcome as 'testLoopReport'
|
||||
# Run tutorial cases and summarize the outcome as 'testLoopReport'
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
cd ${0%/*} || exit 1 # Run from this directory
|
||||
@ -43,27 +31,26 @@ options:
|
||||
-collect Collect logs only. Can be useful for aborted runs.
|
||||
-help print the usage
|
||||
|
||||
* Runs tutorial cases and summarizes the outcome as 'testLoopReport'
|
||||
Run tutorial cases and summarize the outcome as 'testLoopReport'
|
||||
|
||||
USAGE
|
||||
exit 1
|
||||
}
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
unset optCollect
|
||||
|
||||
unset optCollectOnly
|
||||
|
||||
# parse options
|
||||
# Parse options
|
||||
while [ "$#" -gt 0 ]
|
||||
do
|
||||
case "$1" in
|
||||
-h | -help)
|
||||
-h | -help*)
|
||||
usage
|
||||
;;
|
||||
-collect)
|
||||
optCollectOnly=true
|
||||
optCollect=true
|
||||
;;
|
||||
-test) # Known options that should be passed through
|
||||
-test) # Known options to pass through
|
||||
break
|
||||
;;
|
||||
-*)
|
||||
@ -77,87 +64,13 @@ do
|
||||
done
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
. $WM_PROJECT_DIR/bin/tools/LogFunctions # Tutorial log-file functions
|
||||
|
||||
# logReport <logfile>
|
||||
# Extracts useful info from log file.
|
||||
logReport()
|
||||
{
|
||||
local logfile=$1
|
||||
|
||||
# logfile is path/to/case/log.application
|
||||
caseName=$(dirname $logfile | sed -e 's/\(.*\)\.\///g')
|
||||
app=$(echo $logfile | sed -e 's/\(.*\)log\.//g')
|
||||
appAndCase="Application $app - case $caseName"
|
||||
|
||||
if grep -q "FOAM FATAL" $logfile
|
||||
then
|
||||
echo "$appAndCase: ** FOAM FATAL ERROR **"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Check for solution singularity on U equation
|
||||
for eqn in Ux Uy Uz
|
||||
do
|
||||
if grep -q -E "${eqn}[:| ]*solution singularity" $logfile
|
||||
then
|
||||
if [ "$eqn" = Uz ]
|
||||
then
|
||||
# Can only get here if Ux,Uy,Uz all failed
|
||||
echo "$appAndCase: ** Solution singularity **"
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if grep -q -E "^[\t ]*[Ee]nd" $logfile
|
||||
then
|
||||
# Extract time from this type of content
|
||||
## ExecutionTime = 60.2 s ClockTime = 63 s --> "60.2 s"
|
||||
completionTime=$(tail -10 $logfile | \
|
||||
sed -n -e '/Execution/{s/^[^=]*=[ \t]*//; s/\( s\) .*$/\1/; p}')
|
||||
|
||||
echo "$appAndCase: completed${completionTime:+ in }$completionTime"
|
||||
else
|
||||
echo "$appAndCase: unconfirmed completion"
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -z "$optCollectOnly" ]
|
||||
if [ -z "$optCollect" ]
|
||||
then
|
||||
# Recursively run all tutorials
|
||||
foamRunTutorials -skipFirst $*
|
||||
foamRunTutorials -skipFirst $* # Run tutorials recursively
|
||||
fi
|
||||
|
||||
|
||||
# Analyse all log files
|
||||
echo "Collecting log files..." 1>&2
|
||||
rm -f logs testLoopReport > /dev/null 2>&1
|
||||
touch logs testLoopReport
|
||||
|
||||
for appDir in *
|
||||
do
|
||||
[ -d $appDir ] || continue
|
||||
echo -n " $appDir..." 1>&2
|
||||
|
||||
logs=$(find -L $appDir -name 'log.*' -type f)
|
||||
if [ -n "$logs" ]
|
||||
then
|
||||
echo 1>&2
|
||||
else
|
||||
echo " (no logs)" 1>&2
|
||||
continue
|
||||
fi
|
||||
|
||||
# Sort logs by time-stamp
|
||||
for log in $(echo $logs | xargs ls -rt)
|
||||
do
|
||||
# Concatenate and summarize logs
|
||||
cat "$log" >> logs 2>/dev/null
|
||||
logReport $log
|
||||
done
|
||||
echo
|
||||
done > testLoopReport
|
||||
collectLogs
|
||||
|
||||
#------------------------------------------------------------------------------
|
||||
|
@ -1,212 +0,0 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: plus |
|
||||
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class faBoundaryMesh;
|
||||
location "constant/faMesh";
|
||||
object faBoundary;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
3
|
||||
(
|
||||
inlet
|
||||
{
|
||||
type patch;
|
||||
edgeLabels List<label>
|
||||
20
|
||||
(
|
||||
2321
|
||||
2322
|
||||
2323
|
||||
2324
|
||||
2325
|
||||
2326
|
||||
2327
|
||||
2328
|
||||
2329
|
||||
2330
|
||||
2331
|
||||
2332
|
||||
2333
|
||||
2334
|
||||
2335
|
||||
2336
|
||||
2337
|
||||
2338
|
||||
2339
|
||||
2341
|
||||
)
|
||||
;
|
||||
ngbPolyPatchIndex 0;
|
||||
}
|
||||
outlet
|
||||
{
|
||||
type patch;
|
||||
edgeLabels List<label>
|
||||
20
|
||||
(
|
||||
2459
|
||||
2460
|
||||
2461
|
||||
2462
|
||||
2463
|
||||
2464
|
||||
2465
|
||||
2466
|
||||
2467
|
||||
2468
|
||||
2469
|
||||
2470
|
||||
2471
|
||||
2472
|
||||
2473
|
||||
2474
|
||||
2475
|
||||
2476
|
||||
2477
|
||||
2478
|
||||
)
|
||||
;
|
||||
ngbPolyPatchIndex 2;
|
||||
}
|
||||
bound
|
||||
{
|
||||
type symmetry;
|
||||
edgeLabels List<label>
|
||||
120
|
||||
(
|
||||
2320
|
||||
2340
|
||||
2342
|
||||
2343
|
||||
2344
|
||||
2345
|
||||
2346
|
||||
2347
|
||||
2348
|
||||
2349
|
||||
2350
|
||||
2351
|
||||
2352
|
||||
2353
|
||||
2354
|
||||
2355
|
||||
2356
|
||||
2357
|
||||
2358
|
||||
2359
|
||||
2360
|
||||
2361
|
||||
2362
|
||||
2363
|
||||
2364
|
||||
2365
|
||||
2366
|
||||
2367
|
||||
2368
|
||||
2369
|
||||
2370
|
||||
2371
|
||||
2372
|
||||
2373
|
||||
2374
|
||||
2375
|
||||
2376
|
||||
2377
|
||||
2378
|
||||
2379
|
||||
2380
|
||||
2381
|
||||
2382
|
||||
2383
|
||||
2384
|
||||
2385
|
||||
2386
|
||||
2387
|
||||
2388
|
||||
2389
|
||||
2390
|
||||
2391
|
||||
2392
|
||||
2393
|
||||
2394
|
||||
2395
|
||||
2396
|
||||
2397
|
||||
2398
|
||||
2399
|
||||
2400
|
||||
2401
|
||||
2402
|
||||
2403
|
||||
2404
|
||||
2405
|
||||
2406
|
||||
2407
|
||||
2408
|
||||
2409
|
||||
2410
|
||||
2411
|
||||
2412
|
||||
2413
|
||||
2414
|
||||
2415
|
||||
2416
|
||||
2417
|
||||
2418
|
||||
2419
|
||||
2420
|
||||
2421
|
||||
2422
|
||||
2423
|
||||
2424
|
||||
2425
|
||||
2426
|
||||
2427
|
||||
2428
|
||||
2429
|
||||
2430
|
||||
2431
|
||||
2432
|
||||
2433
|
||||
2434
|
||||
2435
|
||||
2436
|
||||
2437
|
||||
2438
|
||||
2439
|
||||
2440
|
||||
2441
|
||||
2442
|
||||
2443
|
||||
2444
|
||||
2445
|
||||
2446
|
||||
2447
|
||||
2448
|
||||
2449
|
||||
2450
|
||||
2451
|
||||
2452
|
||||
2453
|
||||
2454
|
||||
2455
|
||||
2456
|
||||
2457
|
||||
2458
|
||||
2479
|
||||
)
|
||||
;
|
||||
ngbPolyPatchIndex 1;
|
||||
}
|
||||
)
|
||||
|
||||
// ************************************************************************* //
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user