diff --git a/applications/utilities/postProcessing/noise/noise.C b/applications/utilities/postProcessing/noise/noise.C index 88ef922589d5f80f51bfd1592c753af392b150b0..c872b1557ce74419df4b78a0c090f64de21fe176 100644 --- a/applications/utilities/postProcessing/noise/noise.C +++ b/applications/utilities/postProcessing/noise/noise.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -106,21 +106,12 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" - fileName dictName(runTime.system()/"noiseDict"); - if (args.optionFound("dict")) - { - dictName = args["dict"]; - } + const word dictName("noiseDict"); + #include "setSystemRunTimeDictionaryIO.H" + + Info<< "Reading " << dictName << "\n" << endl; - IOdictionary dict - ( - IOobject - ( - dictName.expand(), - runTime, - IOobject::MUST_READ - ) - ); + IOdictionary dict(dictIO); autoPtr<noiseModel> model(noiseModel::New(dict)); model->calculate(); diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions old mode 100755 new mode 100644 index 59e1d66194a9db49f00046428d748736a3ab408f..b23fe06e8dc49d7e649be0f82de604e34e41fce8 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -208,19 +208,32 @@ compileApplication() wmake $1 } +# +# cloneCase srcDir dstDir +# cloneCase() { - if [ -d "$2" ] + if [ -e "$2" ] then echo "Case already cloned: remove case directory $2 to clone" - else + elif [ -d "$1" ] + then echo "Cloning $2 case from $1" mkdir $2 - cpfiles="0.orig 0 system constant" - for f in $cpfiles + # These must exist, so do not hide error messages + for f in system constant do \cp -r $1/$f $2 done + + # Either (or both) may exist, so error messages may be spurious + for f in 0 0.orig + do + \cp -r $1/$f $2 2>/dev/null + done + else + echo "Error: cannot clone from non-existent directory" + echo " $1" fi } @@ -243,7 +256,7 @@ restore0Dir() if [ -d 0.orig ] then \rm -rf 0 - \cp -r 0.orig 0 > /dev/null 2>&1 + \cp -r 0.orig 0 2>/dev/null else echo " Warning: no 0.orig/ found" fi diff --git a/etc/codeTemplates/foamCommentStyles b/etc/codeTemplates/foamCommentStyles index b55f2c2375cd5468af8d222bddb1b22bb8e4a304..db5fa120b95662673993e8294551dd16fdf2ce4e 100644 --- a/etc/codeTemplates/foamCommentStyles +++ b/etc/codeTemplates/foamCommentStyles @@ -10,12 +10,16 @@ // ------------------------------------------------------------------------- // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/include/setSystemMeshDictionaryIO.H b/src/OpenFOAM/include/setSystemMeshDictionaryIO.H index c4e5a27ae9d3c7df29908720377a40a9683a1713..b664940d1ace52fcea22624b3b69f85ffc9bc542 100644 --- a/src/OpenFOAM/include/setSystemMeshDictionaryIO.H +++ b/src/OpenFOAM/include/setSystemMeshDictionaryIO.H @@ -20,7 +20,7 @@ if (dictPath.size()) { dictIO = IOobject ( - dictPath, + dictPath.expand(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE diff --git a/src/OpenFOAM/include/setSystemRunTimeDictionaryIO.H b/src/OpenFOAM/include/setSystemRunTimeDictionaryIO.H index 510f278c6087258bb0174da8f7a7a4ab7b42726a..15a812693e1581cf347f84fd5861a5e51a02668b 100644 --- a/src/OpenFOAM/include/setSystemRunTimeDictionaryIO.H +++ b/src/OpenFOAM/include/setSystemRunTimeDictionaryIO.H @@ -20,7 +20,7 @@ if (dictPath.size()) { dictIO = IOobject ( - dictPath, + dictPath.expand(), runTime, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE diff --git a/src/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C b/src/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C index 3414c2a40bbb0bdedb3aaf15f5962221d75cce37..4353ce35632950761e5916b4b419dac81ffcdc42 100644 --- a/src/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C +++ b/src/functionObjects/field/fieldValues/fieldValue/fieldValueTemplates.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -32,26 +32,28 @@ License template<class Type> void Foam::functionObjects::fieldValue::combineFields(Field<Type>& field) { - List<Field<Type>> allValues(Pstream::nProcs()); - - allValues[Pstream::myProcNo()] = field; - - Pstream::gatherList(allValues); - Pstream::scatterList(allValues); - - field = - ListListOps::combine<Field<Type>> - ( - allValues, - accessOp<Field<Type>>() - ); + if (Pstream::parRun()) + { + List<Field<Type>> allValues(Pstream::nProcs()); + allValues[Pstream::myProcNo()] = field; + + Pstream::gatherList(allValues); + Pstream::scatterList(allValues); + + field = + ListListOps::combine<Field<Type>> + ( + allValues, + accessOp<Field<Type>>() + ); + } } template<class Type> void Foam::functionObjects::fieldValue::combineFields(tmp<Field<Type>>& field) { - combineFields(field()); + combineFields(field.ref()); } diff --git a/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C b/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C index caae10e34d3d565472fb74866dff81ffb872c5a5..d887867658482fd608c4b63ded7f47791ec48f1e 100644 --- a/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C +++ b/src/thermophysicalModels/radiation/submodels/solarCalculator/solarCalculator.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenCFD Ltd. - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -26,6 +26,9 @@ License #include "solarCalculator.H" #include "Time.H" #include "unitConversion.H" +#include "constants.H" + +using namespace Foam::constant; // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -104,6 +107,14 @@ void Foam::solarCalculator::calculateBetaTetha() beta_ = max(asin(cos(L)*cos(deltaRad)*cos(H) + sin(L)*sin(deltaRad)), 1e-3); tetha_ = acos((sin(beta_)*sin(L) - sin(deltaRad))/(cos(beta_)*cos(L))); + // theta is the angle between the SOUTH axis and the Sun + // If the hour angle is lower than zero (morning) the Sun is positioned + // on the East side. + if (H < 0) + { + tetha_ += 2*(constant::mathematical::pi - tetha_); + } + if (debug) { Info << tab << "altitude : " << radToDeg(beta_) << endl; @@ -126,9 +137,10 @@ void Foam::solarCalculator::calculateSunDirection() new coordinateSystem("grid", Zero, gridUp_, eastDir_) ); + // Assuming 'z' vertical, 'y' North and 'x' East direction_.z() = -sin(beta_); - direction_.y() = cos(beta_)*cos(tetha_); //North - direction_.x() = cos(beta_)*sin(tetha_); //East + direction_.y() = cos(beta_)*cos(tetha_); // South axis + direction_.x() = cos(beta_)*sin(tetha_); // West axis direction_ /= mag(direction_); @@ -137,6 +149,7 @@ void Foam::solarCalculator::calculateSunDirection() Info<< "Sun direction in absolute coordinates : " << direction_ <<endl; } + // Transform to actual coordinate system direction_ = coord_->R().transform(direction_); if (debug) diff --git a/tutorials/Allrun b/tutorials/Allrun index 1f8f12eec0eef92d116e823efe2b7e1680928af5..8ecef750191e65a5363682506c3e62c6be3083b0 100755 --- a/tutorials/Allrun +++ b/tutorials/Allrun @@ -4,7 +4,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | +# \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM. @@ -26,71 +26,135 @@ # Allrun # # Description +# Runs tutorial cases and summarizes the outcome as 'testLoopReport' # #------------------------------------------------------------------------------ cd ${0%/*} || exit 1 # Run from this directory -# Source tutorial run functions -. $WM_PROJECT_DIR/bin/tools/RunFunctions +usage() +{ + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE + +usage: ${0##*/} [OPTION] + +options: + -collect Collect logs only. Can be useful for aborted runs. + -help print the usage + +* Runs tutorial cases and summarizes the outcome as 'testLoopReport' + +USAGE + exit 1 +} + +#------------------------------------------------------------------------------ + +unset optCollectOnly + +# parse options +while [ "$#" -gt 0 ] +do + case "$1" in + -h | -help) + usage + ;; + -collect) + optCollectOnly=true + ;; + -*) + usage "unknown option: $1" + ;; + *) + break + ;; + esac + shift +done + +#------------------------------------------------------------------------------ # logReport <logfile> # Extracts useful info from log file. logReport() { - caseName=`dirname $1 | sed s/"\(.*\)\.\/"/""/g` - app=`echo $1 | sed s/"\(.*\)log\."/""/g` - appAndCase="Application $app - case $caseName" + local logfile=$1 - fatalError=`grep "FOAM FATAL" $1` - UxSS=`grep -E "Ux[:| ]*solution singularity" $1` - UySS=`grep -E "Uy[:| ]*solution singularity" $1` - UzSS=`grep -E "Uz[:| ]*solution singularity" $1` - completed=`grep -E "^[\t ]*[eE]nd" $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 [ "$fatalError" ] + if grep -q "FOAM FATAL" $logfile then echo "$appAndCase: ** FOAM FATAL ERROR **" - elif [ "$UxSS" -a "$UySS" -a "$UzSS" ] - then - echo "$appAndCase: ** Solution singularity **" - elif [ "$completed" ] - then - completionTime=`tail -10 $log | grep Execution | cut -d= -f2 | sed 's/^[ \t]*//'` - if [ "$completionTime" ] + 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 - completionTime="in $completionTime" + if [ "$eqn" = Uz ] + then + # Can only get here if Ux,Uy,Uz all failed + echo "$appAndCase: ** Solution singularity **" + return 1 + fi + else + break fi - echo "$appAndCase: completed $completionTime" + 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 } - -# Recursively run all tutorials -foamRunTutorials -test -skipFirst +if [ -z "$optCollectOnly" ] +then + # Recursively run all tutorials + foamRunTutorials -test -skipFirst +fi # Analyse all log files -rm testLoopReport > /dev/null 2>&1 & -touch testLoopReport +echo "Collecting log files..." 1>&2 +rm -f logs testLoopReport > /dev/null 2>&1 +touch logs testLoopReport for appDir in * do -( - [ -d $appDir ] && cd $appDir || exit + [ -d $appDir ] || continue + echo -n " $appDir..." 1>&2 - logs=`find . -name "log.*"` - [ -n "$logs" ] || exit + logs=$(find -L $appDir -type f -name 'log.*') + if [ -n "$logs" ] + then + echo 1>&2 + else + echo " (no logs)" 1>&2 + continue + fi - for log in `echo $logs | xargs ls -rt` + # Sort logs by time-stamp + for log in $(echo $logs | xargs ls -rt) do - logReport $log >> ../testLoopReport + # Concatenate and summarize logs + cat "$log" >> logs 2>/dev/null + logReport $log done - echo "" >> ../testLoopReport -) -done - -find . -name "log.*" -exec cat {} \; >> logs + echo +done > testLoopReport #------------------------------------------------------------------------------