From 7c3ab7620b9ab1d7a3da07c5c97e0bd5bdc693cf Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 23 Jul 2009 20:26:40 +0200 Subject: [PATCH 01/15] new script - foamEtcFile - Locate user/site/shipped file with the semantics used in the ~OpenFOAM/fileName expansion --- ReleaseNotes-1.6 | 15 ++--- bin/foamEtcFile | 143 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+), 7 deletions(-) create mode 100755 bin/foamEtcFile diff --git a/ReleaseNotes-1.6 b/ReleaseNotes-1.6 index b18ce5659a..7b6a086e92 100644 --- a/ReleaseNotes-1.6 +++ b/ReleaseNotes-1.6 @@ -396,13 +396,13 @@ + =addSubtract= - simple add/subtract field functionality ** Usage - + =timeSelector= can now combine =-time ranges= and =-latestTime= options - (e.g. -time '0.01:0.09', -time '0.01:'). More reliable behaviour for cases - missing /constant// or /0// directories. When the =-noZero= option is - enabled, =-latestTime= will not select the =0/= directory unless the - =-zeroTime= option is given. This helps avoid ill effects caused by - accidentally using the /0// directory in certain utilities (eg, - =reconstructPar=). + + =timeSelector= can now combine =-time ranges= and =-latestTime= options. + For example, -time '0.01:0.09' -latestTime vs. -time '0.01:'. + More reliable behaviour for cases missing /constant// or /0// directories. + When the =-noZero= option is enabled, =-latestTime= will not select the + =0/= directory unless the =-zeroTime= option is given. + This helps avoid ill effects caused by accidentally using the + /0// directory in certain utilities (eg, =reconstructPar=). + =-region= option added to more utilities. ** Improvements to Paraview reader module @@ -412,3 +412,4 @@ region. A *new* =-touch= option to generate the /.OpenFOAM/ file only. Only creates (and removes) /.OpenFOAM/ files if they didn't already exist, which is useful in connection with the =-touch= option. + diff --git a/bin/foamEtcFile b/bin/foamEtcFile new file mode 100755 index 0000000000..e3faab4121 --- /dev/null +++ b/bin/foamEtcFile @@ -0,0 +1,143 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. +# \\/ M anipulation | +#------------------------------------------------------------------------------- +# 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 2 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, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# Script +# foamEtcFile +# +# Description +# Locate user/site/shipped file with the semantics used in the +# ~OpenFOAM/fileName expansion +# +#------------------------------------------------------------------------------- +unset listOpt quietOpt + +usage() { + [ "$quietOpt" = true ] && exit 1 + + exec 1>&2 + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat< Date: Thu, 23 Jul 2009 22:46:52 +0200 Subject: [PATCH 02/15] bugfix PackedList for non-optimized compilation - use shift-right instead of shift-left formulation to avoid wrong behaviour with non-optimized compilation when the packed items fit exactly in the available number of bits. --- applications/test/PackedList/Make/options | 7 ++ applications/test/PackedList/PackedListTest.C | 88 +++++++++++++++++-- .../containers/Lists/PackedList/PackedList.C | 26 +++--- .../containers/Lists/PackedList/PackedListI.H | 11 ++- 4 files changed, 108 insertions(+), 24 deletions(-) diff --git a/applications/test/PackedList/Make/options b/applications/test/PackedList/Make/options index e69de29bb2..42da6e3418 100644 --- a/applications/test/PackedList/Make/options +++ b/applications/test/PackedList/Make/options @@ -0,0 +1,7 @@ +/* + check for consistent behaviour with non-optimized code + */ + +EXE_INC = \ + -DFULLDEBUG -g -O0 + diff --git a/applications/test/PackedList/PackedListTest.C b/applications/test/PackedList/PackedListTest.C index 0c8528bd1c..9bf29923fe 100644 --- a/applications/test/PackedList/PackedListTest.C +++ b/applications/test/PackedList/PackedListTest.C @@ -34,9 +34,46 @@ Description #include "IOstreams.H" #include "IFstream.H" #include "PackedBoolList.H" +#include + using namespace Foam; +template +inline void reportInfo() +{ + unsigned offset = PackedList::packing(); + + unsigned useSHL = ((1u << (nBits * offset)) - 1); + unsigned useSHR = (~0u >> (sizeof(unsigned)*CHAR_BIT - nBits * offset)); + + Info<< nl + << "PackedList<" << nBits << ">" << nl + << " max_value: " << PackedList::max_value() << nl + << " packing: " << PackedList::packing() << nl + << " utilization: " << (nBits * offset) << nl; + + Info<< " Masking:" << nl + << " shift << " << unsigned(nBits * offset) << nl + << " shift >> " << unsigned((sizeof(unsigned)*CHAR_BIT) - nBits * offset) + << nl; + + hex(Info); + Info<< " maskLower: " << PackedList::maskLower(PackedList::packing()) + << nl + << " useSHL: " << useSHL << nl + << " useSHR: " << useSHR << nl; + + if (useSHL != useSHR) + { + Info<< "WARNING: different results for SHL and SHR" << nl; + } + + Info<< nl; + dec(Info); +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -45,16 +82,56 @@ int main(int argc, char *argv[]) argList::noParallel(); argList::validArgs.insert("file .. fileN"); + argList::validOptions.insert("mask", ""); argList::validOptions.insert("count", ""); argList::validOptions.insert("info", ""); argList args(argc, argv, false, true); - if (args.additionalArgs().empty()) + + if (args.optionFound("mask")) + { + Info<< "bit width: " << unsigned(sizeof(unsigned)*CHAR_BIT) << endl; + reportInfo<1>(); + reportInfo<2>(); + reportInfo<3>(); + reportInfo<4>(); + reportInfo<5>(); + reportInfo<6>(); + reportInfo<7>(); + reportInfo<8>(); + reportInfo<9>(); + reportInfo<10>(); + reportInfo<11>(); + reportInfo<12>(); + reportInfo<13>(); + reportInfo<14>(); + reportInfo<15>(); + reportInfo<16>(); + reportInfo<17>(); + reportInfo<18>(); + reportInfo<19>(); + reportInfo<20>(); + reportInfo<21>(); + reportInfo<22>(); + reportInfo<23>(); + reportInfo<24>(); + reportInfo<25>(); + reportInfo<26>(); + reportInfo<27>(); + reportInfo<28>(); + reportInfo<29>(); + reportInfo<30>(); + reportInfo<31>(); + + return 0; + } + else if (args.additionalArgs().empty()) { args.printUsage(); } + forAll(args.additionalArgs(), argI) { const string& srcFile = args.additionalArgs()[argI]; @@ -62,6 +139,7 @@ int main(int argc, char *argv[]) IFstream ifs(srcFile); List