From 92d8f5789ab6fa359d3994c1a0b79522cf8cd019 Mon Sep 17 00:00:00 2001 From: henry Date: Fri, 24 Jul 2009 11:04:05 +0100 Subject: [PATCH 01/25] Moved the ThirdParty build scripts to bin so that they are under the git. --- Allwmake | 2 +- bin/AllcleanThirdParty | 41 +++++++++ bin/AllwmakeLibccmio | 64 ++++++++++++++ bin/AllwmakeThirdParty | 184 +++++++++++++++++++++++++++++++++++++++++ bin/foamMakeGcc | 132 +++++++++++++++++++++++++++++ bin/foamMakeQt | 69 ++++++++++++++++ 6 files changed, 491 insertions(+), 1 deletion(-) create mode 100755 bin/AllcleanThirdParty create mode 100755 bin/AllwmakeLibccmio create mode 100755 bin/AllwmakeThirdParty create mode 100755 bin/foamMakeGcc create mode 100755 bin/foamMakeQt diff --git a/Allwmake b/Allwmake index ca2113e522..bb2f5ef504 100755 --- a/Allwmake +++ b/Allwmake @@ -6,7 +6,7 @@ set -x ( cd wmake/src && make ) # build ThirdParty sources -( cd $WM_THIRD_PARTY_DIR && ./Allwmake ) +( cd $WM_THIRD_PARTY_DIR && AllwmakeThirdParty ) src/Allwmake applications/Allwmake diff --git a/bin/AllcleanThirdParty b/bin/AllcleanThirdParty new file mode 100755 index 0000000000..8e2a87eab2 --- /dev/null +++ b/bin/AllcleanThirdParty @@ -0,0 +1,41 @@ +#---------------------------------*- 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 +# AllwcleanThirdParty +# +# Description +# Distribution clean script for ThirdParty +# +#------------------------------------------------------------------------------ +set -x + +(cd gmp-4.2.4 && rm -rf build) +(cd mpfr-2.4.1 && rm -rf build) +(cd gcc-4.3.3 && rm -rf build) +(cd metis-5.0pre2 && make distclean) +(cd openmpi-1.3.3 && make distclean) +(cd paraview-3.6.1 && make distclean) + +# ----------------------------------------------------------------- end-of-file diff --git a/bin/AllwmakeLibccmio b/bin/AllwmakeLibccmio new file mode 100755 index 0000000000..352a4bff0c --- /dev/null +++ b/bin/AllwmakeLibccmio @@ -0,0 +1,64 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 1991-2007 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 +# AllwmakeLibccmio +# +# Description +# Get and build CD-adapco's ccmio library +# +#------------------------------------------------------------------------------ +set -x + +packageDir=libccmio-2.6.1 + +if [ ! -d ${packageDir} ] +then + if [ ! -e ${packageDir}.tar.gz ] + then + wget --no-check-certificate \ + https://wci.llnl.gov/codes/visit/3rd_party/${packageDir}.tar.gz + fi + + if [ -e ${packageDir}.tar.gz ] + then + tar -xzf ${packageDir}.tar.gz + else + echo "no ${packageDir}.tar.gz to unpack" + fi +fi + +if [ -d ${packageDir} -a ! -d ${packageDir}/Make ] +then + cp -r wmakeFiles/libccmio/Make ${packageDir}/Make +fi + +if [ -d ${packageDir}/Make ] +then + wmake libso ${packageDir} +fi + + +# ----------------------------------------------------------------- end-of-file diff --git a/bin/AllwmakeThirdParty b/bin/AllwmakeThirdParty new file mode 100755 index 0000000000..f8066ff06f --- /dev/null +++ b/bin/AllwmakeThirdParty @@ -0,0 +1,184 @@ +#---------------------------------*- 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 +# AllwmakeThirdParty +# +# Description +# Build script for ThirdParty +# +#------------------------------------------------------------------------------ +set -x + +# export WM settings in a form that GNU configure recognizes +[ -n "$WM_CC" ] && export CC="$WM_CC" +[ -n "$WM_CXX" ] && export CXX="$WM_CXX" +[ -n "$WM_CFLAGS" ] && export CFLAGS="$WM_CFLAGS" +[ -n "$WM_CXXFLAGS" ] && export CXXFLAGS="$WM_CXXFLAGS" +[ -n "$WM_LDFLAGS" ] && export LDFLAGS="$WM_LDFLAGS" + +# wmake libso zlib-1.2.3 + +( cd malloc && ./Allwmake ) + +# +# compile specific mpi libraries +# +case "$WM_MPLIB" in +OPENMPI) + if [ -r $MPI_ARCH_PATH/lib/libmpi.so ] + then + echo "have $WM_MPLIB shared library" + elif [ -r $MPI_ARCH_PATH/lib/libmpi.a ] + then + echo "have $WM_MPLIB static library" + else + ( + cd $MPI_HOME + + make distclean + rm -rf $MPI_ARCH_PATH + + ./configure \ + --prefix=$MPI_ARCH_PATH \ + --disable-mpirun-prefix-by-default \ + --disable-orterun-prefix-by-default \ + --enable-shared --disable-static \ + --disable-mpi-f77 --disable-mpi-f90 --disable-mpi-cxx \ + --disable-mpi-profile + # These lines enable Infiniband support + # --with-openib=/usr/local/ofed \ + # --with-openib-libdir=/usr/local/ofed/lib64 + + make + make install + make distclean + ) + fi + ;; + +LAM) + if [ -r $MPI_ARCH_PATH/lib/libmpi.so ] + then + echo "have $WM_MPLIB shared library" + elif [ -r $MPI_ARCH_PATH/lib/libmpi.a ] + then + echo "have $WM_MPLIB static library" + else + ( + cd $MPI_HOME + + make distclean + rm -rf $MPI_ARCH_PATH + + ./configure \ + --prefix=$MPI_ARCH_PATH \ + --enable-shared \ + --disable-static \ + --without-romio \ + --without-mpi2cpp \ + --without-profiling \ + --without-fc + + make + make install + make distclean + ) + fi + ;; + +MPICH) + if [ -r $MPI_ARCH_PATH/lib/libmpich.so ] + then + echo "have $WM_MPLIB shared library" + elif [ -r $MPI_ARCH_PATH/lib/libmpich.a ] + then + echo "have $WM_MPLIB static library" + else + ( + cd $MPI_HOME + + make distclean + rm -rf $MPI_ARCH_PATH + rm util/machines/machines.* + + ./configure \ + --without-mpe \ + --disable-f77 \ + --disable-f90 \ + --disable-f90modules \ + --disable-c++ \ + --disable-mpedbg \ + --disable-devdebug \ + --disable-debug \ + --enable-sharedlib=$MPI_ARCH_PATH/lib \ + --with-device=ch_p4 \ + -prefix=$MPI_ARCH_PATH + make + make install + make distclean + + if [ -r $MPI_ARCH_PATH ] + then + cd $MPI_ARCH_PATH/bin + for file in * + do + sed s%$MPI_ARCH_PATH%'$MPI_ARCH_PATH'%g $file > temp.$$ + mv temp.$$ $file + chmod ugo+rx $file + done + + cd $MPI_ARCH_PATH/lib + + if [ -r libmpich.so.1.0 ] + then + rm *.so + ln -s libmpich.so.1.0 libmpich.so + fi + fi + ) + fi + ;; + +esac + +# Build scotch +( cd scotch_5.1 && wmake libso src/libscotch ) + +# Build Metis +( cd metis-5.0pre2 && wmake libso GKlib && wmake libso libmetis ) + +# Build parMetis. Requires mpi! +if [ "$WM_MPLIB" = "MPI" -o -d $MPI_ARCH_PATH ] +then + ( cd ParMetis-3.1 && WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB && wmake libso METISLib && wmake libso ParMETISLib ) +fi + + +# Build ParMGridGen +wmake libso ParMGridGen-1.0/MGridGen/IMlib +wmake libso ParMGridGen-1.0/MGridGen/Lib + + +# ----------------------------------------------------------------- end-of-file diff --git a/bin/foamMakeGcc b/bin/foamMakeGcc new file mode 100755 index 0000000000..544825b0b1 --- /dev/null +++ b/bin/foamMakeGcc @@ -0,0 +1,132 @@ +#---------------------------------*- 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 +# foamMakeGcc +# +# Description +# Build script for gmp, mpfr and gcc-4.3.? and gcc-4.4.? +# +#------------------------------------------------------------------------------ +usage() { + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat< ... + +* build gmp, mpfr and gcc-4.3.? and gcc-4.4.? + +USAGE + exit 1 +} + +if [ $# -ne 1 ] +then + usage "gcc version not provided" +fi + +# +# Set the number of cores to build on +# +WM_NCOMPPROCS=1 + +if [ -r /proc/cpuinfo ] +then + WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l) + [ $WM_NCOMPPROCS -le 8 ] || WM_NCOMPPROCS=8 +fi + +echo "Building on " $WM_NCOMPPROCS " cores" + +GMP_DIR=$WM_THIRD_PARTY_DIR/gmp-4.2.4 +MPFR_DIR=$WM_THIRD_PARTY_DIR/mpfr-2.4.1 +GCC_DIR=$WM_THIRD_PARTY_DIR/$1 + +GMPROOT=${GMP_DIR}/platforms/$WM_ARCH$WM_COMPILER_ARCH +MPFRROOT=${MPFR_DIR}/platforms/$WM_ARCH$WM_COMPILER_ARCH +GCCROOT=${GCC_DIR}/platforms/$WM_ARCH$WM_COMPILER_ARCH + +# +# Bulid GMP +# +if [ ! -d $GMPROOT ] +then + ( + make distclean \ + && mkdir $GMP_DIR/build \ + && cd $GMP_DIR/build \ + && ../configure ABI=$ABI --prefix=$GMPROOT \ + && make -j $WM_NCOMPPROCS \ + && make install + ) + echo " Finished building gmp." +else + echo " gmp already built." +fi + +export LD_LIBRARY_PATH="$GMPROOT/lib:$LD_LIBRARY_PATH" + +# +# Build MPFR +# +if [ ! -d $MPFRROOT ] +then + ( + make distclean \ + && mkdir $MPFR_DIR/build \ + && cd $MPFR_DIR/build \ + && ../configure ABI=$ABI --prefix=$MPFRROOT --with-gmp=$GMPROOT \ + && make -j $WM_NCOMPPROCS \ + && make install + ) + echo " Finished building mpfr." +else + echo " mprf already built." +fi + +export LD_LIBRARY_PATH="$MPFRROOT/lib:$LD_LIBRARY_PATH" + +# +# Build GCC +# +if [ ! -d $GCCROOT ] +then + ( + make distclean \ + && mkdir $GCC_DIR/build \ + && cd $GCC_DIR/build \ + && ../configure --enable-languages=c,c++ --with-pkgversion='OpenFOAM' \ + --enable-__cxa_atexit --enable-libstdcxx-allocator=new \ + --with-system-zlib --prefix=$GCCROOT \ + --with-mpfr=$MPFRROOT --with-gmp=$GMPROOT \ + && make -j $WM_NCOMPPROCS \ + && make install + ) + echo " Finished building gcc." +else + echo " gcc already built." +fi + + +# ----------------------------------------------------------------- end-of-file diff --git a/bin/foamMakeQt b/bin/foamMakeQt new file mode 100755 index 0000000000..3ce6ea0e9d --- /dev/null +++ b/bin/foamMakeQt @@ -0,0 +1,69 @@ +#---------------------------------*- 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 +# foamMakeQt +# +# Description +# Build script for Qt-4.3.5 +# +#------------------------------------------------------------------------------ + +QT_VERSION=4.3.5 +QT_HOME=${WM_THIRD_PARTY_DIR}/qt-x11-opensource-src-${QT_VERSION} +QT_ARCH_PATH=${QT_HOME}/platforms/${WM_OPTIONS} + +if [ ! -d $QT_ARCH_PATH ] +then + cd ${QT_HOME} + + make distclean + + rm -rf ${QT_ARCH_PATH} + + ./configure \ + --prefix=${QT_ARCH_PATH} \ + -nomake demos \ + -nomake examples + + if [ -r /proc/cpuinfo ] + then + WM_NCOMPPROCS=$(egrep "^processor" /proc/cpuinfo | wc -l) + [ $WM_NCOMPPROCS -le 8 ] || WM_NCOMPPROCS=8 + + echo "Building on " $WM_NCOMPPROCS " cores" + + time make -j $WM_NCOMPPROCS + else + time make + fi + + make install + + echo " Finished building Qt-4.3.5." +else + echo " Qt-4.3.5 already built." +fi + +# ----------------------------------------------------------------- end-of-file From 481fd3e2e12f1c4404da3b6e12b013f1c44a1152 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 24 Jul 2009 11:15:41 +0100 Subject: [PATCH 02/25] caching yPlusLam locally --- .../mutRoughWallFunctionFvPatchScalarField.C | 111 +++++----- ...ndardRoughWallFunctionFvPatchScalarField.C | 72 +++--- ...asStandardWallFunctionFvPatchScalarField.C | 62 +++--- ...rtAllmarasWallFunctionFvPatchScalarField.C | 30 +-- .../mutWallFunctionFvPatchScalarField.C | 192 ++++++++-------- .../mutWallFunctionFvPatchScalarField.H | 6 + .../nutRoughWallFunctionFvPatchScalarField.C | 127 ++++++----- ...ndardRoughWallFunctionFvPatchScalarField.C | 76 ++++--- ...asStandardWallFunctionFvPatchScalarField.C | 62 +++--- ...rtAllmarasWallFunctionFvPatchScalarField.C | 30 +-- .../nutWallFunctionFvPatchScalarField.C | 205 ++++++++++-------- .../nutWallFunctionFvPatchScalarField.H | 6 + 12 files changed, 512 insertions(+), 467 deletions(-) diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C index ed4acb4da0..a23f1d1682 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutRoughWallFunction/mutRoughWallFunctionFvPatchScalarField.C @@ -40,7 +40,7 @@ namespace RASModels { -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // scalar mutRoughWallFunctionFvPatchScalarField::fnRough ( @@ -65,6 +65,60 @@ scalar mutRoughWallFunctionFvPatchScalarField::fnRough } +tmp mutRoughWallFunctionFvPatchScalarField::calcMut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; + const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; + const tmp tk = rasModel.k(); + const volScalarField& k = tk(); + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; + + const scalar Cmu25 = pow(Cmu_, 0.25); + + tmp tmutw(new scalarField(patch().size(), 0.0)); + scalarField& mutw = tmutw(); + + forAll(mutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar uStar = Cmu25*sqrt(k[faceCellI]); + + scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]); + + scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]); + + scalar Edash = E_; + scalar yPlusLamNew = yPlusLam_; + if (KsPlus > 2.25) + { + Edash /= fnRough(KsPlus, Cs_[faceI]); + yPlusLamNew = rasModel.yPlusLam(kappa_, Edash); + } + + if (debug) + { + Info<< "yPlus = " << yPlus + << ", KsPlus = " << KsPlus + << ", Edash = " << Edash + << ", yPlusLam = " << yPlusLam_ + << endl; + } + + if (yPlus > yPlusLamNew) + { + mutw[faceI] = + muw[faceI]*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1); + } + } + + return tmutw; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // mutRoughWallFunctionFvPatchScalarField::mutRoughWallFunctionFvPatchScalarField @@ -158,61 +212,6 @@ void mutRoughWallFunctionFvPatchScalarField::rmap } -tmp mutRoughWallFunctionFvPatchScalarField::calcMut() const -{ - const label patchI = patch().index(); - - const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const scalarField& y = rasModel.y()[patchI]; - const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; - const tmp tk = rasModel.k(); - const volScalarField& k = tk(); - const scalarField& muw = rasModel.mu().boundaryField()[patchI]; - - const scalar Cmu25 = pow(Cmu_, 0.25); - - tmp tmutw(new scalarField(patch().size(), 0.0)); - scalarField& mutw = tmutw(); - - forAll(mutw, faceI) - { - label faceCellI = patch().faceCells()[faceI]; - - scalar uStar = Cmu25*sqrt(k[faceCellI]); - - scalar yPlus = uStar*y[faceI]/(muw[faceI]/rhow[faceI]); - - scalar KsPlus = uStar*Ks_[faceI]/(muw[faceI]/rhow[faceI]); - - scalar Edash = E_; - scalar yPlusLamNew = yPlusLam; - if (KsPlus > 2.25) - { - Edash /= fnRough(KsPlus, Cs_[faceI]); - yPlusLamNew = rasModel.yPlusLam(kappa_, Edash); - } - - if (debug) - { - Info<< "yPlus = " << yPlus - << ", KsPlus = " << KsPlus - << ", Edash = " << Edash - << ", yPlusLam = " << yPlusLam - << endl; - } - - if (yPlus > yPlusLamNew) - { - mutw[faceI] = - muw[faceI]*(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1); - } - } - - return tmutw; -} - - void mutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField::write(os); diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C index c187661095..3a1d0b7ab0 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardRoughWallFunction/mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -39,6 +39,8 @@ namespace compressible namespace RASModels { +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + tmp mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus ( @@ -48,7 +50,6 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus const label patchI = patch().index(); const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patchI]; const scalarField& muw = rasModel.mu().boundaryField()[patchI]; const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI]; @@ -74,7 +75,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei]; const scalar kappaRe = kappa_*Re; - scalar yp = yPlusLam; + scalar yp = yPlusLam_; const scalar ryPlusLam = 1.0/yp; int iter = 0; @@ -146,7 +147,7 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus const scalar Re = rho[facei]*magUpara*y[facei]/muw[facei]; const scalar kappaRe = kappa_*Re; - scalar yp = yPlusLam; + scalar yp = yPlusLam_; const scalar ryPlusLam = 1.0/yp; int iter = 0; @@ -171,6 +172,38 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus } +tmp +mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcMut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; + const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI]; + + scalarField magUp = mag(Uw.patchInternalField() - Uw); + + tmp tyPlus = calcYPlus(magUp); + scalarField& yPlus = tyPlus(); + + tmp tmutw(new scalarField(patch().size(), 0.0)); + scalarField& mutw = tmutw(); + + forAll(yPlus, facei) + { + if (yPlus[facei] > yPlusLam_) + { + const scalar Re = rho[facei]*magUp[facei]*y[facei]/muw[facei]; + mutw[facei] = muw[facei]*(sqr(yPlus[facei])/Re - 1); + } + } + + return tmutw; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField:: @@ -247,39 +280,6 @@ mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp -mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcMut() const -{ - const label patchI = patch().index(); - - const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const scalarField& y = rasModel.y()[patchI]; - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField& muw = rasModel.mu().boundaryField()[patchI]; - const fvPatchScalarField& rho = rasModel.rho().boundaryField()[patchI]; - - scalarField magUp = mag(Uw.patchInternalField() - Uw); - - tmp tyPlus = calcYPlus(magUp); - scalarField& yPlus = tyPlus(); - - tmp tmutw(new scalarField(patch().size(), 0.0)); - scalarField& mutw = tmutw(); - - forAll(yPlus, facei) - { - if (yPlus[facei] > yPlusLam) - { - const scalar Re = rho[facei]*magUp[facei]*y[facei]/muw[facei]; - mutw[facei] = muw[facei]*(sqr(yPlus[facei])/Re - 1); - } - } - - return tmutw; -} - - tmp mutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus() const { diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C index 052b22664b..c2a49ac751 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasStandardWallFunction/mutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -50,7 +50,6 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus const label patchI = patch().index(); const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patchI]; const fvPatchScalarField& rhow = rasModel.rho().boundaryField()[patchI]; const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI]; @@ -62,7 +61,7 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus { scalar kappaRe = kappa_*magUp[faceI]*y[faceI]/(muw[faceI]/rhow[faceI]); - scalar yp = yPlusLam; + scalar yp = yPlusLam_; scalar ryPlusLam = 1.0/yp; int iter = 0; @@ -82,6 +81,35 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus } +tmp +mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magUp = mag(Uw.patchInternalField() - Uw); + const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI]; + + tmp tyPlus = calcYPlus(magUp); + scalarField& yPlus = tyPlus(); + + tmp tmutw(new scalarField(patch().size(), 0.0)); + scalarField& mutw = tmutw(); + + forAll(yPlus, faceI) + { + if (yPlus[faceI] > yPlusLam_) + { + mutw[faceI] = + muw[faceI]*(yPlus[faceI]*kappa_/log(E_*yPlus[faceI]) - 1.0); + } + } + + return tmutw; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // mutSpalartAllmarasStandardWallFunctionFvPatchScalarField:: @@ -143,36 +171,6 @@ mutSpalartAllmarasStandardWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp -mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcMut() const -{ - const label patchI = patch().index(); - - const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField magUp = mag(Uw.patchInternalField() - Uw); - const fvPatchScalarField& muw = rasModel.mu().boundaryField()[patchI]; - - tmp tyPlus = calcYPlus(magUp); - scalarField& yPlus = tyPlus(); - - tmp tmutw(new scalarField(patch().size(), 0.0)); - scalarField& mutw = tmutw(); - - forAll(yPlus, faceI) - { - if (yPlus[faceI] > yPlusLam) - { - mutw[faceI] = - muw[faceI]*(yPlus[faceI]*kappa_/log(E_*yPlus[faceI]) - 1.0); - } - } - - return tmutw; -} - - tmp mutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const { diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C index 23874146ea..85e9c7e60a 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutSpalartAllmarasWallFunction/mutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -105,6 +105,21 @@ tmp mutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau } +tmp +mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magGradU = mag(Uw.snGrad()); + const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; + const scalarField& muw = rasModel.mu().boundaryField()[patchI]; + + return max(0.0, rhow*sqr(calcUTau(magGradU))/magGradU - muw); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // mutSpalartAllmarasWallFunctionFvPatchScalarField:: @@ -166,21 +181,6 @@ mutSpalartAllmarasWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp -mutSpalartAllmarasWallFunctionFvPatchScalarField::calcMut() const -{ - const label patchI = patch().index(); - - const RASModel& rasModel = db().lookupObject("RASProperties"); - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField magGradU = mag(Uw.snGrad()); - const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; - const scalarField& muw = rasModel.mu().boundaryField()[patchI]; - - return max(0.0, rhow*sqr(calcUTau(magGradU))/magGradU - muw); -} - - tmp mutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const { diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C index dcd52cc4e1..10813c9a05 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.C @@ -40,7 +40,7 @@ namespace compressible namespace RASModels { -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // void mutWallFunctionFvPatchScalarField::checkType() { @@ -56,82 +56,20 @@ void mutWallFunctionFvPatchScalarField::checkType() } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField +scalar mutWallFunctionFvPatchScalarField::calcYPlusLam ( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(p, iF), - Cmu_(0.09), - kappa_(0.41), - E_(9.8) -{} - - -mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField -( - const mutWallFunctionFvPatchScalarField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedValueFvPatchScalarField(ptf, p, iF, mapper), - Cmu_(ptf.Cmu_), - kappa_(ptf.kappa_), - E_(ptf.E_) -{} - - -mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValueFvPatchScalarField(p, iF, dict), - Cmu_(dict.lookupOrDefault("Cmu", 0.09)), - kappa_(dict.lookupOrDefault("kappa", 0.41)), - E_(dict.lookupOrDefault("E", 9.8)) -{} - - -mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField -( - const mutWallFunctionFvPatchScalarField& wfpsf -) -: - fixedValueFvPatchScalarField(wfpsf), - Cmu_(wfpsf.Cmu_), - kappa_(wfpsf.kappa_), - E_(wfpsf.E_) -{} - - -mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField -( - const mutWallFunctionFvPatchScalarField& wfpsf, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(wfpsf, iF), - Cmu_(wfpsf.Cmu_), - kappa_(wfpsf.kappa_), - E_(wfpsf.E_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void mutWallFunctionFvPatchScalarField::updateCoeffs() + const scalar kappa, + const scalar E +) const { - operator==(calcMut()); + scalar ypl = 11.0; - fixedValueFvPatchScalarField::updateCoeffs(); + for (int i=0; i<10; i++) + { + ypl = log(E*ypl)/kappa; + } + + return ypl; } @@ -139,7 +77,6 @@ tmp mutWallFunctionFvPatchScalarField::calcMut() const { const label patchI = patch().index(); const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patchI]; const scalarField& rhow = rasModel.rho().boundaryField()[patchI]; const tmp tk = rasModel.k(); @@ -156,10 +93,9 @@ tmp mutWallFunctionFvPatchScalarField::calcMut() const label faceCellI = patch().faceCells()[faceI]; scalar yPlus = - Cmu25*y[faceI]*sqrt(k[faceCellI]) - /(muw[faceI]/rhow[faceI]); + Cmu25*y[faceI]*sqrt(k[faceCellI])/(muw[faceI]/rhow[faceI]); - if (yPlus > yPlusLam) + if (yPlus > yPlusLam_) { mutw[faceI] = muw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1); } @@ -169,6 +105,98 @@ tmp mutWallFunctionFvPatchScalarField::calcMut() const } +void mutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const +{ + os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; + os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; + os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + Cmu_(0.09), + kappa_(0.41), + E_(9.8), + yPlusLam_(calcYPlusLam(kappa_, E_)) +{} + + +mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField +( + const mutWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + Cmu_(ptf.Cmu_), + kappa_(ptf.kappa_), + E_(ptf.E_), + yPlusLam_(ptf.yPlusLam_) +{} + + +mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + Cmu_(dict.lookupOrDefault("Cmu", 0.09)), + kappa_(dict.lookupOrDefault("kappa", 0.41)), + E_(dict.lookupOrDefault("E", 9.8)), + yPlusLam_(calcYPlusLam(kappa_, E_)) +{} + + +mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField +( + const mutWallFunctionFvPatchScalarField& wfpsf +) +: + fixedValueFvPatchScalarField(wfpsf), + Cmu_(wfpsf.Cmu_), + kappa_(wfpsf.kappa_), + E_(wfpsf.E_), + yPlusLam_(wfpsf.yPlusLam_) +{} + + +mutWallFunctionFvPatchScalarField::mutWallFunctionFvPatchScalarField +( + const mutWallFunctionFvPatchScalarField& wfpsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(wfpsf, iF), + Cmu_(wfpsf.Cmu_), + kappa_(wfpsf.kappa_), + E_(wfpsf.E_), + yPlusLam_(wfpsf.yPlusLam_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void mutWallFunctionFvPatchScalarField::updateCoeffs() +{ + operator==(calcMut()); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + tmp mutWallFunctionFvPatchScalarField::yPlus() const { const label patchI = patch().index(); @@ -194,14 +222,6 @@ void mutWallFunctionFvPatchScalarField::write(Ostream& os) const } -void mutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const -{ - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField(fvPatchScalarField, mutWallFunctionFvPatchScalarField); diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H index 3945c345e9..6134256e23 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutWallFunction/mutWallFunctionFvPatchScalarField.H @@ -70,12 +70,18 @@ protected: //- E coefficient scalar E_; + //- Y+ at the edge of the laminar sublayer + scalar yPlusLam_; + // Protected member functions //- Check the type of the patch virtual void checkType(); + //- Calculate the Y+ at the edge of the laminar sublayer + virtual scalar calcYPlusLam(const scalar kappa, const scalar E) const; + //- Calculate the turbulence viscosity virtual tmp calcMut() const; diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C index e26e652a1a..9ef3051f82 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutRoughWallFunction/nutRoughWallFunctionFvPatchScalarField.C @@ -39,7 +39,7 @@ namespace incompressible namespace RASModels { -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // scalar nutRoughWallFunctionFvPatchScalarField::fnRough ( @@ -64,6 +64,68 @@ scalar nutRoughWallFunctionFvPatchScalarField::fnRough } +tmp nutRoughWallFunctionFvPatchScalarField::calcNut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; + const tmp tk = rasModel.k(); + const volScalarField& k = tk(); + const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; + + const scalar Cmu25 = pow(Cmu_, 0.25); + + tmp tnutw(new scalarField(patch().size(), 0.0)); + scalarField& nutw = tnutw(); + + forAll(nutw, faceI) + { + label faceCellI = patch().faceCells()[faceI]; + + scalar uStar = Cmu25*sqrt(k[faceCellI]); + scalar yPlus = uStar*y[faceI]/nuw[faceI]; + scalar KsPlus = uStar*Ks_[faceI]/nuw[faceI]; + + scalar Edash = E_; + + if (KsPlus > 2.25) + { + Edash /= fnRough(KsPlus, Cs_[faceI]); + } + + if (yPlus > yPlusLam_) + { + scalar limitingNutw = max(nutw[faceI], nuw[faceI]); + + // To avoid oscillations limit the change in the wall viscosity + // which is particularly important if it temporarily becomes zero + nutw[faceI] = + max + ( + min + ( + nuw[faceI] + *(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1), + 2*limitingNutw + ), 0.5*limitingNutw + ); + } + + if (debug) + { + Info<< "yPlus = " << yPlus + << ", KsPlus = " << KsPlus + << ", Edash = " << Edash + << ", nutw = " << nutw[faceI] + << endl; + } + } + + return tnutw; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // nutRoughWallFunctionFvPatchScalarField::nutRoughWallFunctionFvPatchScalarField @@ -157,69 +219,6 @@ void nutRoughWallFunctionFvPatchScalarField::rmap } -tmp nutRoughWallFunctionFvPatchScalarField::calcNut() const -{ - const label patchI = patch().index(); - - const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const scalarField& y = rasModel.y()[patchI]; - const tmp tk = rasModel.k(); - const volScalarField& k = tk(); - const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; - - const scalar Cmu25 = pow(Cmu_, 0.25); - - tmp tnutw(new scalarField(patch().size(), 0.0)); - scalarField& nutw = tnutw(); - - forAll(nutw, faceI) - { - label faceCellI = patch().faceCells()[faceI]; - - scalar uStar = Cmu25*sqrt(k[faceCellI]); - scalar yPlus = uStar*y[faceI]/nuw[faceI]; - scalar KsPlus = uStar*Ks_[faceI]/nuw[faceI]; - - scalar Edash = E_; - - if (KsPlus > 2.25) - { - Edash /= fnRough(KsPlus, Cs_[faceI]); - } - - if (yPlus > yPlusLam) - { - scalar limitingNutw = max(nutw[faceI], nuw[faceI]); - - // To avoid oscillations limit the change in the wall viscosity - // which is particularly important if it temporarily becomes zero - nutw[faceI] = - max - ( - min - ( - nuw[faceI] - *(yPlus*kappa_/log(max(Edash*yPlus, 1+1e-4)) - 1), - 2*limitingNutw - ), 0.5*limitingNutw - ); - } - - if (debug) - { - Info<< "yPlus = " << yPlus - << ", KsPlus = " << KsPlus - << ", Edash = " << Edash - << ", nutw = " << nutw[faceI] - << endl; - } - } - - return tnutw; -} - - void nutRoughWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchField::write(os); diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C index e2de2dae71..760559f679 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardRoughWallFunction/nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField.C @@ -39,7 +39,39 @@ namespace incompressible namespace RASModels { -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +tmp +nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcNut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; + + // The flow velocity at the adjacent cell centre + const scalarField magUp = mag(Uw.patchInternalField() - Uw); + + tmp tyPlus = calcYPlus(magUp); + scalarField& yPlus = tyPlus(); + + tmp tnutw(new scalarField(patch().size(), 0.0)); + scalarField& nutw = tnutw(); + + forAll(yPlus, facei) + { + if (yPlus[facei] > yPlusLam_) + { + const scalar Re = magUp[facei]*y[facei]/nuw[facei]; + nutw[facei] = nuw[facei]*(sqr(yPlus[facei])/Re - 1); + } + } + + return tnutw; +} + tmp nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus @@ -50,7 +82,6 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus const label patchI = patch().index(); const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patchI]; const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; @@ -75,7 +106,7 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus const scalar Re = magUpara*y[facei]/nuw[facei]; const scalar kappaRe = kappa_*Re; - scalar yp = yPlusLam; + scalar yp = yPlusLam_; const scalar ryPlusLam = 1.0/yp; int iter = 0; @@ -133,7 +164,7 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus && yp > VSMALL ); - yPlus[facei] = yp; + yPlus[facei] = max(0.0, yp); } } } @@ -146,7 +177,7 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus const scalar Re = magUpara*y[facei]/nuw[facei]; const scalar kappaRe = kappa_*Re; - scalar yp = yPlusLam; + scalar yp = yPlusLam_; const scalar ryPlusLam = 1.0/yp; int iter = 0; @@ -159,7 +190,7 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcYPlus } while(mag(ryPlusLam*(yp - yPlusLast)) > 0.0001 && ++iter < 10); - yPlus[facei] = yp; + yPlus[facei] = max(0.0, yp); } } @@ -243,39 +274,6 @@ nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp -nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::calcNut() const -{ - const label patchI = patch().index(); - - const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const scalarField& y = rasModel.y()[patchI]; - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; - - // The flow velocity at the adjacent cell centre - const scalarField magUp = mag(Uw.patchInternalField() - Uw); - - tmp tyPlus = calcYPlus(magUp); - scalarField& yPlus = tyPlus(); - - tmp tnutw(new scalarField(patch().size(), 0.0)); - scalarField& nutw = tnutw(); - - forAll(yPlus, facei) - { - if (yPlus[facei] > yPlusLam) - { - const scalar Re = magUp[facei]*y[facei]/nuw[facei]; - nutw[facei] = nuw[facei]*(sqr(yPlus[facei])/Re - 1); - } - } - - return tnutw; -} - - tmp nutSpalartAllmarasStandardRoughWallFunctionFvPatchScalarField::yPlus() const { diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C index 7bea1742fb..e3c3e55671 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasStandardWallFunction/nutSpalartAllmarasStandardWallFunctionFvPatchScalarField.C @@ -41,6 +41,35 @@ namespace RASModels // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // +tmp +nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcNut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magUp = mag(Uw.patchInternalField() - Uw); + const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; + + tmp tyPlus = calcYPlus(magUp); + scalarField& yPlus = tyPlus(); + + tmp tnutw(new scalarField(patch().size(), 0.0)); + scalarField& nutw = tnutw(); + + forAll(yPlus, facei) + { + if (yPlus[facei] > yPlusLam_) + { + nutw[facei] = + nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0); + } + } + + return tnutw; +} + + tmp nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus ( @@ -50,7 +79,6 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus const label patchI = patch().index(); const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patchI]; const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; @@ -61,7 +89,7 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcYPlus { scalar kappaRe = kappa_*magUp[facei]*y[facei]/nuw[facei]; - scalar yp = yPlusLam; + scalar yp = yPlusLam_; scalar ryPlusLam = 1.0/yp; int iter = 0; @@ -142,36 +170,6 @@ nutSpalartAllmarasStandardWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp -nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::calcNut() const -{ - const label patchI = patch().index(); - - const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField magUp = mag(Uw.patchInternalField() - Uw); - const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; - - tmp tyPlus = calcYPlus(magUp); - scalarField& yPlus = tyPlus(); - - tmp tnutw(new scalarField(patch().size(), 0.0)); - scalarField& nutw = tnutw(); - - forAll(yPlus, facei) - { - if (yPlus[facei] > yPlusLam) - { - nutw[facei] = - nuw[facei]*(yPlus[facei]*kappa_/log(E_*yPlus[facei]) - 1.0); - } - } - - return tnutw; -} - - tmp nutSpalartAllmarasStandardWallFunctionFvPatchScalarField::yPlus() const { diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C index 99187abb64..a2d4b746a8 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutSpalartAllmarasWallFunction/nutSpalartAllmarasWallFunctionFvPatchScalarField.C @@ -39,7 +39,21 @@ namespace incompressible namespace RASModels { -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +tmp +nutSpalartAllmarasWallFunctionFvPatchScalarField::calcNut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject("RASProperties"); + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magGradU = mag(Uw.snGrad()); + const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; + + return max(0.0, sqr(calcUTau(magGradU))/magGradU - nuw); +} + tmp nutSpalartAllmarasWallFunctionFvPatchScalarField::calcUTau ( @@ -159,20 +173,6 @@ nutSpalartAllmarasWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -tmp -nutSpalartAllmarasWallFunctionFvPatchScalarField::calcNut() const -{ - const label patchI = patch().index(); - - const RASModel& rasModel = db().lookupObject("RASProperties"); - const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; - const scalarField magGradU = mag(Uw.snGrad()); - const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; - - return max(0.0, sqr(calcUTau(magGradU))/magGradU - nuw); -} - - tmp nutSpalartAllmarasWallFunctionFvPatchScalarField::yPlus() const { diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C index 0fdefb2b51..1417f3b64c 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.C @@ -56,92 +56,20 @@ void nutWallFunctionFvPatchScalarField::checkType() } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField +scalar nutWallFunctionFvPatchScalarField::calcYPlusLam ( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(p, iF), - Cmu_(0.09), - kappa_(0.41), - E_(9.8) + const scalar kappa, + const scalar E +) const { - checkType(); -} + scalar ypl = 11.0; + for (int i=0; i<10; i++) + { + ypl = log(E*ypl)/kappa; + } -nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField -( - const nutWallFunctionFvPatchScalarField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedValueFvPatchScalarField(ptf, p, iF, mapper), - Cmu_(ptf.Cmu_), - kappa_(ptf.kappa_), - E_(ptf.E_) -{ - checkType(); -} - - -nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValueFvPatchScalarField(p, iF, dict), - Cmu_(dict.lookupOrDefault("Cmu", 0.09)), - kappa_(dict.lookupOrDefault("kappa", 0.41)), - E_(dict.lookupOrDefault("E", 9.8)) -{ - checkType(); -} - - -nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField -( - const nutWallFunctionFvPatchScalarField& wfpsf -) -: - fixedValueFvPatchScalarField(wfpsf), - Cmu_(wfpsf.Cmu_), - kappa_(wfpsf.kappa_), - E_(wfpsf.E_) -{ - checkType(); -} - - -nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField -( - const nutWallFunctionFvPatchScalarField& wfpsf, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(wfpsf, iF), - Cmu_(wfpsf.Cmu_), - kappa_(wfpsf.kappa_), - E_(wfpsf.E_) -{ - checkType(); -} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void nutWallFunctionFvPatchScalarField::updateCoeffs() -{ - operator==(calcNut()); - - fixedValueFvPatchScalarField::updateCoeffs(); + return ypl; } @@ -150,7 +78,6 @@ tmp nutWallFunctionFvPatchScalarField::calcNut() const const label patchI = patch().index(); const RASModel& rasModel = db().lookupObject("RASProperties"); - const scalar yPlusLam = rasModel.yPlusLam(kappa_, E_); const scalarField& y = rasModel.y()[patchI]; const tmp tk = rasModel.k(); const volScalarField& k = tk(); @@ -167,7 +94,7 @@ tmp nutWallFunctionFvPatchScalarField::calcNut() const scalar yPlus = Cmu25*y[faceI]*sqrt(k[faceCellI])/nuw[faceI]; - if (yPlus > yPlusLam) + if (yPlus > yPlusLam_) { nutw[faceI] = nuw[faceI]*(yPlus*kappa_/log(E_*yPlus) - 1.0); } @@ -177,6 +104,108 @@ tmp nutWallFunctionFvPatchScalarField::calcNut() const } +void nutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const +{ + os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; + os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; + os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + Cmu_(0.09), + kappa_(0.41), + E_(9.8), + yPlusLam_(calcYPlusLam(kappa_, E_)) +{ + checkType(); +} + + +nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField +( + const nutWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + Cmu_(ptf.Cmu_), + kappa_(ptf.kappa_), + E_(ptf.E_), + yPlusLam_(ptf.yPlusLam_) +{ + checkType(); +} + + +nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + Cmu_(dict.lookupOrDefault("Cmu", 0.09)), + kappa_(dict.lookupOrDefault("kappa", 0.41)), + E_(dict.lookupOrDefault("E", 9.8)), + yPlusLam_(calcYPlusLam(kappa_, E_)) +{ + checkType(); +} + + +nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField +( + const nutWallFunctionFvPatchScalarField& wfpsf +) +: + fixedValueFvPatchScalarField(wfpsf), + Cmu_(wfpsf.Cmu_), + kappa_(wfpsf.kappa_), + E_(wfpsf.E_), + yPlusLam_(wfpsf.yPlusLam_) +{ + checkType(); +} + + +nutWallFunctionFvPatchScalarField::nutWallFunctionFvPatchScalarField +( + const nutWallFunctionFvPatchScalarField& wfpsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(wfpsf, iF), + Cmu_(wfpsf.Cmu_), + kappa_(wfpsf.kappa_), + E_(wfpsf.E_), + yPlusLam_(wfpsf.yPlusLam_) +{ + checkType(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void nutWallFunctionFvPatchScalarField::updateCoeffs() +{ + operator==(calcNut()); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + tmp nutWallFunctionFvPatchScalarField::yPlus() const { const label patchI = patch().index(); @@ -201,14 +230,6 @@ void nutWallFunctionFvPatchScalarField::write(Ostream& os) const } -void nutWallFunctionFvPatchScalarField::writeLocalEntries(Ostream& os) const -{ - os.writeKeyword("Cmu") << Cmu_ << token::END_STATEMENT << nl; - os.writeKeyword("kappa") << kappa_ << token::END_STATEMENT << nl; - os.writeKeyword("E") << E_ << token::END_STATEMENT << nl; -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // makePatchTypeField(fvPatchScalarField, nutWallFunctionFvPatchScalarField); diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H index cb68c36f1f..490d14cd01 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutWallFunction/nutWallFunctionFvPatchScalarField.H @@ -70,12 +70,18 @@ protected: //- E coefficient scalar E_; + //- Y+ at the edge of the laminar sublayer + scalar yPlusLam_; + // Protected member functions //- Check the type of the patch virtual void checkType(); + //- Calculate the Y+ at the edge of the laminar sublayer + virtual scalar calcYPlusLam(const scalar kappa, const scalar E) const; + //- Calculate the turbulence viscosity virtual tmp calcNut() const; From ceaaabab56a603caeba536c5197b1b69ea20bc3a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 23 Jul 2009 22:46:52 +0200 Subject: [PATCH 03/25] 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