diff --git a/applications/Allwmake b/applications/Allwmake index a734704b28b1140deb093e74ad819ee89576d319..7437e4f9b04f4bbe4514e75609894b60225e9eb7 100755 --- a/applications/Allwmake +++ b/applications/Allwmake @@ -1,5 +1,5 @@ #!/bin/sh set -x -(cd solvers ; wmake all) -(cd utilities ; wmake all) +( cd solvers && wmake all ) +( cd utilities && wmake all ) diff --git a/applications/solvers/incompressible/icoDyMFoam/icoDyMFoam.C b/applications/solvers/incompressible/icoDyMFoam/icoDyMFoam.C index 39774a3373f93ce10a9fafe1ef96d30bdc2671a4..d76d8c9ce484e2ba907036a09dadfe46d80940ac 100644 --- a/applications/solvers/incompressible/icoDyMFoam/icoDyMFoam.C +++ b/applications/solvers/incompressible/icoDyMFoam/icoDyMFoam.C @@ -56,32 +56,35 @@ int main(int argc, char *argv[]) { # include "readControls.H" # include "CourantNo.H" - - p.storePrevIter(); - - // Make the fluxes absolute - fvc::makeAbsolute(phi, U); - # include "setDeltaT.H" runTime++; Info<< "Time = " << runTime.timeName() << nl << endl; - bool meshChanged = mesh.update(); + // Make the fluxes absolute + if (mesh.changing()) + { + phi = fvc::interpolate(U) & mesh.Sf(); + } + + mesh.update(); - if (correctPhi && meshChanged) + if (mesh.changing() && correctPhi) { # include "correctPhi.H" } // Keep the absolute fluxes for use in ddtPhiCorr - surfaceScalarField phiAbs("phiAbs", phi); + surfaceScalarField phiAbs0("phiAbs0", phi); // Make the fluxes relative to the mesh motion - fvc::makeRelative(phi, U); + if (mesh.changing()) + { + fvc::makeRelative(phi, U); + } - if (meshChanged && checkMeshCourantNo) + if (mesh.changing() && checkMeshCourantNo) { # include "meshCourantNo.H" } @@ -89,6 +92,8 @@ int main(int argc, char *argv[]) // --- PIMPLE loop for (int ocorr=0; ocorr<nOuterCorr; ocorr++) { + p.storePrevIter(); + # include "UEqn.H" // --- PISO loop @@ -101,10 +106,50 @@ int main(int argc, char *argv[]) if (ddtPhiCorr) { - phi += fvc::ddtPhiCorr(rAU, U, phiAbs); + if (mesh.changing()) + { + dimensionedScalar rDeltaT = 1.0/mesh.time().deltaT(); + + volScalarField V0byV + ( + IOobject + ( + "V0byV", + mesh.time().timeName(), + mesh + ), + mesh, + dimensionedScalar("V0byV", dimless, 1), + zeroGradientFvPatchScalarField::typeName + ); + V0byV.dimensionedInternalField() = mesh.V0()/mesh.V(); + V0byV.correctBoundaryConditions(); + + phi += rDeltaT* + ( + fvc::interpolate(rAU*V0byV)*phiAbs0 + - (fvc::interpolate(rAU*V0byV*U.oldTime()) & mesh.Sf()) + ); + } + else + { + phi += fvc::ddtPhiCorr(rAU, U, phiAbs0); + } } - adjustPhi(phi, U, p); + if (p.needReference()) + { + if (mesh.changing()) + { + fvc::makeRelative(phi, U); + adjustPhi(phi, U, p); + fvc::makeAbsolute(phi, U); + } + else + { + adjustPhi(phi, U, p); + } + } for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { @@ -138,11 +183,11 @@ int main(int argc, char *argv[]) p.relax(); } - // Make the fluxes relative to the mesh motion - fvc::makeRelative(phi, U); - U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); + + // Make the fluxes relative to the mesh motion + fvc::makeRelative(phi, U); } } diff --git a/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C index e46cba7db9a72752fef3c213accdba95658d49ef..f0631fdd9949147ddb35b3ff0ec0b59dfe1b4b25 100644 --- a/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interDyMFoam/interDyMFoam.C @@ -41,6 +41,7 @@ Description #include "twoPhaseMixture.H" #include "incompressible/turbulenceModel/turbulenceModel.H" #include "probes.H" +#include "EulerDdtScheme.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -66,7 +67,6 @@ int main(int argc, char *argv[]) { #include "readControls.H" #include "CourantNo.H" - #include "setDeltaT.H" runTime++; @@ -76,7 +76,7 @@ int main(int argc, char *argv[]) // Make the fluxes absolute if (mesh.changing()) { - fvc::makeAbsolute(phi, U); + phi = fvc::interpolate(U) & mesh.Sf(); } scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) } // Keep the absolute fluxes for use in ddtPhiCorr - surfaceScalarField phiAbs("phiAbs", phi); + surfaceScalarField phiAbs0("phiAbs0", phi); // Make the fluxes relative to the mesh motion if (mesh.changing()) @@ -125,8 +125,6 @@ int main(int argc, char *argv[]) #include "pEqn.H" } - #include "continuityErrs.H" - p = pd + rho*gh; if (pd.needReference()) diff --git a/applications/solvers/multiphase/interDyMFoam/pEqn.H b/applications/solvers/multiphase/interDyMFoam/pEqn.H index d4afbae6f49f9f9abd227b2afbb87a7615c4c889..74c301af6ebc650fcb57e23d529aa846230352c7 100644 --- a/applications/solvers/multiphase/interDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interDyMFoam/pEqn.H @@ -2,21 +2,42 @@ volScalarField rAU = 1.0/UEqn.A(); surfaceScalarField rAUf = fvc::interpolate(rAU); - volVectorField HU = UEqn.H(); - U = rAU*HU; - + U = rAU*UEqn.H(); surfaceScalarField phiU("phiU", (fvc::interpolate(U) & mesh.Sf())); if (ddtPhiCorr) { - phiU += fvc::ddtPhiCorr(rAU, rho, U, phiAbs); + //phiU += fvc::ddtPhiCorr(rAU, rho, U, phiAbs0); + + dimensionedScalar rDeltaT = 1.0/mesh.time().deltaT(); + + volScalarField V0byV + ( + IOobject + ( + "V0byV", + mesh.time().timeName(), + mesh + ), + mesh, + dimensionedScalar("V0byV", dimless, 1), + zeroGradientFvPatchScalarField::typeName + ); + V0byV.dimensionedInternalField() = mesh.V0()/mesh.V(); + V0byV.correctBoundaryConditions(); + + phiU += rDeltaT* + ( + fvc::interpolate(rAU*rho.oldTime()*V0byV)*phiAbs0 + - (fvc::interpolate(rAU*rho.oldTime()*V0byV*U.oldTime()) & mesh.Sf()) + ); } phi = phiU + - ( - fvc::interpolate(interface.sigmaK())*fvc::snGrad(gamma) - - ghf*fvc::snGrad(rho) - )*rAUf*mesh.magSf(); + ( + fvc::interpolate(interface.sigmaK())*fvc::snGrad(gamma) + - ghf*fvc::snGrad(rho) + )*rAUf*mesh.magSf(); if (pd.needReference()) { @@ -59,6 +80,8 @@ U += rAU*fvc::reconstruct((phi - phiU)/rAUf); U.correctBoundaryConditions(); + #include "continuityErrs.H" + // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); } diff --git a/applications/utilities/mesh/conversion/ccm26ToFoam/Allwmake b/applications/utilities/mesh/conversion/ccm26ToFoam/Allwmake index 876f5dd4555868c3e100426959eb77484cf8caff..d9b55b3b5f09ece5b47adc382c5c8df54af1da96 100755 --- a/applications/utilities/mesh/conversion/ccm26ToFoam/Allwmake +++ b/applications/utilities/mesh/conversion/ccm26ToFoam/Allwmake @@ -1,9 +1,9 @@ #!/bin/sh set -x -# Some fun: prostar uses ccmio2.3, Star-ccm+ uses ccmio2.4 +# compile cd-adapco's CCM library +wmake libso libccmio/libadf +wmake libso libccmio/libccmio +wmake libso libccmio/libcgns -(cd libccmio; wmake libso libadf) -(cd libccmio; wmake libso libccmio) -(cd libccmio; wmake libso libcgns) -(cd ccm26ToFoam; wmake) +wmake ccm26ToFoam diff --git a/bin/foamDiffSourceList b/bin/foamDiffSourceList index 435eda9a1c89722a6b9e8488d87e198cbd431ba7..b713573890990f4063a32f18ac9586f2da48b9db 100755 --- a/bin/foamDiffSourceList +++ b/bin/foamDiffSourceList @@ -72,6 +72,7 @@ find -H $newDir \ ! -type d -type f \ ! -name "*~" \ -a ! -name ".*~" \ + -a ! -name ".#*" \ -a ! -name "*.orig" \ -a ! -name "*.dep" \ -a ! -name "*.o" \ @@ -83,10 +84,11 @@ find -H $newDir \ -a ! -name "log[0-9]*" \ | sed \ -e "\@$newDir/lib/@d" \ - -e "\@$newDir/src/mico-[0-9.]*/platforms@d" \ - -e "\@$newDir/src/mpich-[0-9.]*/platforms@d" \ - -e "\@$newDir/src/mpich-[0-9.]*/lib@d" \ - -e "\@$newDir/src/lam-[0-9.]*/platforms@d" \ + -e "\@$newDir/src/other/mico-*/platforms@d" \ + -e "\@$newDir/src/other/mpich-*/platforms@d" \ + -e "\@$newDir/src/other/mpich-*/lib@d" \ + -e "\@$newDir/src/other/lam-*/platforms@d" \ + -e "\@$newDir/src/other/openmpi-*/platforms@d" \ -e '\@applications/bin/@d' \ -e '\@/t/@d' \ -e '\@Make[.A-Za-z]*/[^/]*/@d' \ @@ -118,7 +120,7 @@ find -H $newDir \ done ) -# file fileCount +# file fileCount fileCount=$(cat $tmpFile | wc -l) echo "----------------------------------------------------------------------" echo "pack $fileCount changed/new files" diff --git a/bin/foamPack b/bin/foamPack index 1ac1175d7161e0ba39cfab250b25bf85dfe7e4d4..5122b252afb40415b7dc3f512bac6450b8b965c5 100755 --- a/bin/foamPack +++ b/bin/foamPack @@ -86,10 +86,11 @@ find -H $packDir \ -a ! -name "so_locations" \ | sed \ -e "\@$packDir/lib/@d" \ - -e "\@$packDir/src/mico-[0-9.]*/platforms@d" \ - -e "\@$packDir/src/mpich-[0-9.]*/platforms@d" \ - -e "\@$packDir/src/mpich-[0-9.]*/lib@d" \ - -e "\@$packDir/src/lam-[0-9.]*/platforms@d" \ + -e "\@$packDir/src/other/mico-*/platforms@d" \ + -e "\@$packDir/src/other/mpich-*/platforms@d" \ + -e "\@$packDir/src/other/mpich-*/lib@d" \ + -e "\@$packDir/src/other/lam-*/platforms@d" \ + -e "\@$packDir/src/other/openmpi-*/platforms@d" \ -e '\@applications/bin/@d' \ -e '\@/t/@d' \ -e '\@Make[.A-Za-z]*/[^/]*/@d' \ diff --git a/bin/foamPackSource b/bin/foamPackSource index 1a643bdf8be1d9388247a4ae57d263cd04af1fb4..9e1141972e3659bfb43df49885b7238f8ac6f58f 100755 --- a/bin/foamPackSource +++ b/bin/foamPackSource @@ -75,11 +75,11 @@ find -H $packDir \ -a ! -name "log[0-9]*" \ | sed \ -e "\@$packDir/lib/@d" \ - -e "\@$packDir/src/other/mico-[0-9.]*/platforms@d" \ - -e "\@$packDir/src/other/mpich-[0-9.]*/platforms@d" \ - -e "\@$packDir/src/other/mpich-[0-9.]*/lib@d" \ - -e "\@$packDir/src/other/lam-[0-9.]*/platforms@d" \ - -e "\@$packDir/src/other/openmpi-[0-9.]*/platforms@d" \ + -e "\@$packDir/src/other/mico-*/platforms@d" \ + -e "\@$packDir/src/other/mpich-*/platforms@d" \ + -e "\@$packDir/src/other/mpich-*/lib@d" \ + -e "\@$packDir/src/other/lam-*/platforms@d" \ + -e "\@$packDir/src/other/openmpi-*/platforms@d" \ -e '\@applications/bin/@d' \ -e '\@/t/@d' \ -e '\@Make[.A-Za-z]*/[^/]*/@d' \ diff --git a/bin/paraFoam b/bin/paraFoam index e58290507d7e022065a98efcda94b324f522347f..a049d9748407a33c18c7f2215480e0a6b7280b9c 100755 --- a/bin/paraFoam +++ b/bin/paraFoam @@ -33,33 +33,33 @@ Script=${0##*/} usage() { - while [ "$#" -ge 1 ]; do echo "$1"; shift; done - cat<<USAGE + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat<<USAGE usage: $Script [-case dir] * start paraview $ParaView_VERSION with the OpenFOAM libraries USAGE - exit 1 + exit 1 } # parse options if [ "$#" -gt 0 ]; then - case "$1" in - -h | -help) - usage - ;; - -case) - shift - caseDir=$1 - [ "$#" -ge 1 ] || usage "'-case' option requires an argument" - cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'" - ;; - *) - usage "unknown option/argument: '$*'" - ;; - esac + case "$1" in + -h | -help) + usage + ;; + -case) + shift + caseDir=$1 + [ "$#" -ge 1 ] || usage "'-case' option requires an argument" + cd "$caseDir" 2>/dev/null || usage "directory does not exist: '$caseDir'" + ;; + *) + usage "unknown option/argument: '$*'" + ;; + esac fi # get a sensible caseName @@ -67,41 +67,38 @@ caseName=${PWD##*/} # parent directory for normal or parallel results case "$caseName" in - processor*) parentDir=".." ;; - *) parentDir="." ;; + processor*) parentDir=".." ;; + *) parentDir="." ;; esac # check existence of essential files for check in system/controlDict system/fvSchemes system/fvSolution do - [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'" + [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'" done -OpenFoamExt="foam" -# OpenFoamExt="OpenFOAM" +caseFile="$caseName.foam" +# caseFile="$caseName.OpenFOAM" -if [ "$ParaView_VERSION" = "3" ]; then +case "$ParaView_VERSION" in +2*) + # Clean up on termination and on Ctrl-C + trap "rm -f paraFoam.pvs $caseFile 2>/dev/null; exit 0" EXIT TERM INT + touch $caseFile - # check existence of essential files - for check in system/controlDict system/fvSchemes system/fvSolution - do - [ -s "$parentDir/$check" ] || usage "file does not exist: '$parentDir/$check'" - done + # since we are now in the cwd, %CASE% is '$PWD/$caseFile' + sed -e s@%CASE%@$PWD/$caseFile@g \ + $WM_PROJECT_DIR/bin/paraFoam.pvs > paraFoam.pvs - touch $caseName.$OpenFoamExt - paraview --data=$caseName.$OpenFoamExt - rm $caseName.$OpenFoamExt 2>/dev/null + paraview paraFoam.pvs + ;; -else - - # since we are now in the cwd, FOAM_ROOT/FOAM_CASE is '$PWD' - sed -e s%FOAM_ROOT/FOAM_CASE%$PWD%g \ - -e s%FOAM_CASE%$caseName%g $WM_PROJECT_DIR/bin/paraFoam.pvs > paraFoam.pvs - - touch $caseName.$OpenFoamExt - paraview paraFoam.pvs - rm paraFoam.pvs $caseName.$OpenFoamExt 2>/dev/null - -fi +*) + # Clean up on termination and on Ctrl-C + trap "rm -f $caseFile 2>/dev/null; exit 0" EXIT TERM INT + touch $caseFile + paraview --data=$caseFile + ;; +esac #------------------------------------------------------------------------------ diff --git a/etc/apps/paraview3/bashrc b/etc/apps/paraview3/bashrc index c02b490abb8f9674109f8f85e4a6ca379364caa3..3d197f43f3750b59085b3a92e3c8ab8564012c15 100644 --- a/etc/apps/paraview3/bashrc +++ b/etc/apps/paraview3/bashrc @@ -41,18 +41,26 @@ export CMAKE_HOME=$WM_PROJECT_INST_DIR/$WM_ARCH/cmake-2.4.6 if [ -r $CMAKE_HOME ]; then export PATH=$CMAKE_HOME/bin:$PATH +else + unset CMAKE_HOME fi -export ParaView_VERSION=3 +# export ParaView_VERSION="3.3-cvs" +export ParaView_VERSION=3.3 -export ParaView_INST_DIR=$WM_PROJECT_INST_DIR/ParaView3.3-cvs +export ParaView_INST_DIR=$WM_PROJECT_INST_DIR/paraview-$ParaView_VERSION export ParaView_DIR=$ParaView_INST_DIR/platforms/$WM_OPTIONS -export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/bin:$ParaView_DIR/Utilities/VTKPythonWrapping +if [ "$PYTHONPATH" ]; then + export PYTHONPATH=$PYTHONPATH:$ParaView_DIR/Utilities/VTKPythonWrapping +else + export PYTHONPATH=$ParaView_DIR/Utilities/VTKPythonWrapping +fi + if [ -r $ParaView_DIR ]; then export PATH=$ParaView_DIR/bin:$PATH - export LD_LIBRARY_PATH=${ParaView_DIR}/bin:${LD_LIBRARY_PATH} + export LD_LIBRARY_PATH=$ParaView_DIR/lib/paraview-$ParaView_VERSION:$LD_LIBRARY_PATH export PV_PLUGIN_PATH=$FOAM_LIBBIN fi diff --git a/etc/apps/paraview3/cshrc b/etc/apps/paraview3/cshrc index c4192592795432ba66ea1077879f9900ad2b28e7..e3d3c87ea2bdc02ebd673b7c85d6f1b01b07cd10 100644 --- a/etc/apps/paraview3/cshrc +++ b/etc/apps/paraview3/cshrc @@ -41,11 +41,14 @@ setenv CMAKE_HOME $WM_PROJECT_INST_DIR/$WM_ARCH/cmake-2.4.6 if ( -r $CMAKE_HOME ) then set path=($CMAKE_HOME/bin $path) +else + unset CMAKE_HOME endif -setenv ParaView_VERSION 3 +# setenv ParaView_VERSION 3.3-cvs +setenv ParaView_VERSION 3.3 -setenv ParaView_INST_DIR $WM_PROJECT_INST_DIR/ParaView3.3-cvs +export ParaView_INST_DIR=$WM_PROJECT_INST_DIR/paraview-$ParaView_VERSION setenv ParaView_DIR $ParaView_INST_DIR/platforms/$WM_OPTIONS if ($?PYTHONPATH) then @@ -56,7 +59,7 @@ endif if ( -r $ParaView_INST_DIR ) then set path=($ParaView_DIR/bin $path) - setenv LD_LIBRARY_PATH ${ParaView_DIR}/bin:${LD_LIBRARY_PATH} + setenv LD_LIBRARY_PATH $ParaView_DIR/lib/paraview-$ParaView_VERSION:$LD_LIBRARY_PATH setenv PV_PLUGIN_PATH $FOAM_LIBBIN endif diff --git a/etc/bashrc b/etc/bashrc index 298849ed793966fc49502c9ad87192d0496a14f8..e060b264ce02ac85885ce846179b1624177b2c16 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -63,7 +63,7 @@ export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION # Compiler (if set to "" use the system compiler) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -export WM_COMPILER=Gcc +export WM_COMPILER=Gcc43 export WM_COMPILER_ARCH= export WM_COMPILER_LIB_ARCH= diff --git a/etc/settings.sh b/etc/settings.sh index 8535ad64da396e6938c224737c044b4b4e51713f..ebf715f0be8dda9026bc67e8d80595021b9f56aa 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -97,7 +97,14 @@ WM_COMPILER_INST=OpenFOAM case "$WM_COMPILER_INST" in OpenFOAM) - export WM_COMPILER_DIR=$FOAM_INST_DIR/$WM_ARCH/gcc-4.2.2$WM_COMPILER_ARCH + case "$WM_COMPILER" in + Gcc43) + export WM_COMPILER_DIR=$FOAM_INST_DIR/$WM_ARCH/gcc-4.3.0$WM_COMPILER_ARCH + ;; + Gcc) + export WM_COMPILER_DIR=$FOAM_INST_DIR/$WM_ARCH/gcc-4.2.2$WM_COMPILER_ARCH + ;; + esac # Check that the compiler directory can be found if [ ! -d "$WM_COMPILER_DIR" ] diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index 072fe7077c7d7d7349cd27d8bdd50be3883cb6cf..0e0d7d58f931f943594b744969448d8c12619941 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -202,7 +202,12 @@ List<Key> HashTable<T, Key, Hash>::toc() const template<class T, class Key, class Hash> -bool HashTable<T, Key, Hash>::insert(const Key& key, const T& newEntry) +bool HashTable<T, Key, Hash>::set +( + const Key& key, + const T& newEntry, + const bool protect +) { if (tableSize_ == 0) { @@ -210,40 +215,70 @@ bool HashTable<T, Key, Hash>::insert(const Key& key, const T& newEntry) } label ii = Hash()(key, tableSize_); + hashedEntry* existing = 0; + hashedEntry* prev = 0; - for (hashedEntry* n=table_[ii]; n; n=n->next_) + for (hashedEntry* curr = table_[ii]; curr; curr = curr->next_) { - if (key == n->key_) + if (key == curr->key_) + { + existing = curr; + break; + } + prev = curr; + } + + // not found, insert it at the head + if (!existing) + { + table_[ii] = new hashedEntry(key, table_[ii], newEntry); + nElmts_++; + + if (double(nElmts_)/tableSize_ > 0.8) { # ifdef FULLDEBUG if (debug) { - Info<< "HashTable<T, Key, Hash>::insert" - "(const Key& key, T newEntry) : " - "Cannot insert " << key << " already in hash table\n"; + Info<< "HashTable<T, Key, Hash>::set" + "(const Key& key, T newEntry) : " + "Doubling table size\n"; } # endif - return false; + resize(2*tableSize_); } } - - table_[ii] = new hashedEntry(key, table_[ii], newEntry); - - nElmts_++; - - if (double(nElmts_)/tableSize_ > 0.8) + else if (protect) { + // found - but protected from overwriting + // this corresponds to the STL 'insert' convention # ifdef FULLDEBUG if (debug) { - Info<< "HashTable<T, Key, Hash>::insert" - "(const Key& key, T newEntry) : " - "Doubling table size\n"; + Info<< "HashTable<T, Key, Hash>::set" + "(const Key& key, T newEntry, false) : " + "Cannot insert " << key << " already in hash table\n"; } # endif + return false; + } + else + { + // found - overwrite existing entry + // this corresponds to the Perl convention + hashedEntry* elemPtr = new hashedEntry(key, existing->next_, newEntry); + + // replace existing element - within list or insert at the head + if (prev) + { + prev->next_ = elemPtr; + } + else + { + table_[ii] = elemPtr; + } - resize(2*tableSize_); + delete existing; } return true; diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index b74ac01d33624a76dcd06caae9cdbf0cb88f33c8..29dd037e54750fac50c74bcac223d13e768a0168 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -123,6 +123,11 @@ class HashTable label nElmts_; + // Private Member Functions + + //- Assign a new hashedEntry to a possibly already existing key + bool set(const Key& key, const T& newElmt, bool protect); + public: //- Declare friendship with the HashPtrTable class @@ -181,7 +186,10 @@ public: // Edit //- Insert a new hashedEntry - bool insert(const Key& key, const T& newElmt); + inline bool insert(const Key& key, const T& newElmt); + + //- Assign a new hashedEntry, overwriting existing entries + inline bool set(const Key& key, const T& newElmt); //- Erase an hashedEntry specified by given iterator bool erase(const iterator& it); diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index e934aaa31681121120ee5e24b932cf3bdaf6228f..61c5115fa3178509ae75659ae4ffe46ccac7374b 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -56,6 +56,19 @@ inline label HashTable<T, Key, Hash>::size() const } +template<class T, class Key, class Hash> +inline bool HashTable<T, Key, Hash>::insert(const Key& key, const T& newEntry) +{ + return set(key, newEntry, true); +} + + +template<class T, class Key, class Hash> +inline bool HashTable<T, Key, Hash>::set(const Key& key, const T& newEntry) +{ + return set(key, newEntry, false); +} + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template<class T, class Key, class Hash> @@ -292,7 +305,7 @@ inline HashTable<T, Key, Hash>::const_iterator::const_iterator template<class T, class Key, class Hash> inline HashTable<T, Key, Hash>::const_iterator::const_iterator -( +( const iterator& iter ) : diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C index a932c788d1f6d278779e7a56406aa0507392430f..077040d466ca1f037ee8f6459f54270e2fb01cba 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.C @@ -229,6 +229,43 @@ DLListBase::link* DLListBase::remove(DLListBase::link* l) } +DLListBase::link* DLListBase::replace +( + DLListBase::link* oldLink, + DLListBase::link* newLink +) +{ + link* ret = oldLink; + + newLink->prev_ = oldLink->prev_; + newLink->next_ = oldLink->next_; + + if (oldLink == first_ && first_ == last_) + { + first_ = newLink; + last_ = newLink; + } + else if (oldLink == first_) + { + first_ = newLink; + newLink->next_->prev_ = newLink; + } + else if (oldLink == last_) + { + last_ = newLink; + newLink->prev_->next_ = newLink; + } + else + { + newLink->prev_->next_ = newLink; + newLink->next_->prev_ = newLink; + } + + ret->deregister(); + return ret; +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H index 5c7fe6e2c3dbc7f39596b971d5f0dc0430328699..1e51ac5c18c27c088cb6cd64b757c705f8809127 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBase.H @@ -158,6 +158,12 @@ public: // Remove and return element specified by iterator inline link* remove(iterator&); + //- Replace oldLink with newLink and return element + link* replace(link* oldLink, link* newLink); + + //- Replace oldIter with newLink and return element + inline link* replace(iterator& oldIter, link* newLink); + //- Clear the list inline void clear(); diff --git a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H index 84eec49d3364b80053879edf898345ecf83bedf7..617253c5e33faf9daa8230dc8e6576e2e82d270b 100644 --- a/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H +++ b/src/OpenFOAM/containers/LinkedLists/linkTypes/DLListBase/DLListBaseI.H @@ -148,6 +148,16 @@ inline DLListBase::link* DLListBase::remove(DLListBase::iterator& it) } +inline DLListBase::link* DLListBase::replace +( + DLListBase::iterator& oldIter, + DLListBase::link* newLink +) +{ + return replace(oldIter.curElmt_, newLink); +} + + // * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * * // inline DLListBase::iterator::iterator(DLListBase& s, link* elmt) diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index 3eecd8c0555916aaceccbe41827fcd8a1b306ec2..6884f8de403d8c843c415015f367f3449cf65afe 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -435,6 +435,20 @@ void sort(List<T>& a, const Cmp& cmp) } +template<class T> +void stableSort(List<T>& a) +{ + std::stable_sort(a.begin(), a.end()); +} + + +template<class T, class Cmp> +void stableSort(List<T>& a, const Cmp& cmp) +{ + std::stable_sort(a.begin(), a.end(), cmp); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // // Assignment to UList operator. Takes linear time. diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index 50db82f0a315636d2400dccd7b0c0090127e28d2..52e285418e518326c8af34db23e8d549630aa6e1 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -28,7 +28,7 @@ Class Description A 1D array of objects of type \<T\>, where the size of the vector is known and used for subscript bounds checking, etc. - + Storage is allocated on free-store during construction. SourceFiles @@ -195,6 +195,12 @@ void sort(List<T>& a); template<class T, class Cmp> void sort(List<T>& a, const Cmp&); +template<class T> +void stableSort(List<T>& a); + +template<class T, class Cmp> +void stableSort(List<T>& a, const Cmp&); + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C index b20baf4645af15347d650f4647102ab816d6e768..78e9553d96d7ac2d32132e12e5d822732985c047 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.C +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.C @@ -28,14 +28,11 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Construct from List template <class Type> -SortableList<Type>::SortableList(const List<Type>& values) +Foam::SortableList<Type>::SortableList(const List<Type>& values) : List<Type>(values), indices_(values.size()) @@ -46,7 +43,7 @@ SortableList<Type>::SortableList(const List<Type>& values) // Construct given size. Sort later on. template <class Type> -SortableList<Type>::SortableList(const label size) +Foam::SortableList<Type>::SortableList(const label size) : List<Type>(size), indices_(size) @@ -55,7 +52,7 @@ SortableList<Type>::SortableList(const label size) // Construct given size and initial value. Sort later on. template <class Type> -SortableList<Type>::SortableList(const label size, const Type& val) +Foam::SortableList<Type>::SortableList(const label size, const Type& val) : List<Type>(size, val), indices_(size) @@ -64,7 +61,7 @@ SortableList<Type>::SortableList(const label size, const Type& val) // Construct as copy. template <class Type> -SortableList<Type>::SortableList(const SortableList<Type>& lst) +Foam::SortableList<Type>::SortableList(const SortableList<Type>& lst) : List<Type>(lst), indices_(lst.indices()) @@ -74,7 +71,7 @@ SortableList<Type>::SortableList(const SortableList<Type>& lst) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template <class Type> -void SortableList<Type>::setSize(const label newSize) +void Foam::SortableList<Type>::setSize(const label newSize) { List<Type>::setSize(newSize); indices_.setSize(newSize); @@ -82,7 +79,7 @@ void SortableList<Type>::setSize(const label newSize) template <class Type> -void SortableList<Type>::sort() +void Foam::SortableList<Type>::sort() { forAll(indices_, i) { @@ -98,7 +95,29 @@ void SortableList<Type>::sort() tmpValues[i] = this->operator[](indices_[i]); } - List<Type>::operator=(tmpValues); + List<Type>::transfer(tmpValues); +} + + + +template <class Type> +void Foam::SortableList<Type>::stableSort() +{ + forAll(indices_, i) + { + indices_[i] = i; + } + + Foam::stableSort(indices_, less(*this)); + + List<Type> tmpValues(this->size()); + + forAll(indices_, i) + { + tmpValues[i] = this->operator[](indices_[i]); + } + + List<Type>::transfer(tmpValues); } @@ -114,6 +133,4 @@ void Foam::SortableList<Type>::operator=(const SortableList<Type>& rhs) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H index 6a242180c295f27e42ffe462aac9401bb012f944..389f98215e89cfc655f77d8362e440e3f7dd82a6 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/SortableList.H +++ b/src/OpenFOAM/containers/Lists/SortableList/SortableList.H @@ -100,7 +100,7 @@ public: // Member Functions - //- Return the list of sorted point indices. Updated every sort. + //- Return the list of sorted indices. Updated every sort. const labelList& indices() const { return indices_; @@ -112,6 +112,9 @@ public: //- Sort the list (if changed after construction time) void sort(); + //- Sort the list (if changed after construction time) + void stableSort(); + // Member Operators diff --git a/src/OpenFOAM/db/dictionary/dictionary.C b/src/OpenFOAM/db/dictionary/dictionary.C index aea31e72c776a850189fffe392cdbf9ff9414edc..df4fbd8e5652634e205cf88a9fa4cbfbc9e8bf33 100644 --- a/src/OpenFOAM/db/dictionary/dictionary.C +++ b/src/OpenFOAM/db/dictionary/dictionary.C @@ -34,6 +34,7 @@ defineTypeNameAndDebug(Foam::dictionary, 0); const Foam::dictionary Foam::dictionary::null; +#undef DICTIONARY_INPLACE_MERGE // * * * * * * * * * * * * * Private member functions * * * * * * * * * * * // @@ -53,7 +54,27 @@ bool Foam::dictionary::add(entry* ePtr, bool mergeEntry) } else { +#ifdef DICTIONARY_INPLACE_MERGE + if (hashedEntries_.set(ePtr->keyword(), ePtr)) + { + ePtr->name() = name_ + "::" + ePtr->keyword(); + replace(iter(), ePtr); + + return true; + } + else + { + IOWarningIn("dictionary::add(entry* ePtr)", (*this)) + << "problem replacing entry in dictionary " + << name() + << endl; + + delete ePtr; + return false; + } +#else remove(ePtr->keyword()); +#endif } } @@ -517,8 +538,12 @@ bool Foam::dictionary::merge(const dictionary& dict) } else { +#ifdef DICTIONARY_INPLACE_MERGE + add(iter().clone(*this).ptr(), true); +#else remove(keyword); add(iter().clone(*this)()); +#endif changed = true; } } @@ -526,6 +551,7 @@ bool Foam::dictionary::merge(const dictionary& dict) { // not found - just add add(iter().clone(*this)()); + changed = true; } } diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edge.H b/src/OpenFOAM/meshes/meshShapes/edge/edge.H index ccef92bf41eb78e8a0a690595ea6d11d34bfef05..f8fb2696b6aa6a6186793f8748bca89b6971cebc 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edge.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edge.H @@ -119,6 +119,12 @@ public: //- Return edge line inline linePointRef line(const pointField&) const; + //- compare edges + // - 0: different + // - +1: identical + // - -1: same edge, but different orientation + static inline int compare(const edge&, const edge&); + // Friend Operators @@ -127,7 +133,7 @@ public: }; -//- Hash<edge> specialisation +//- Hash<edge> specialisation // Simple commutative hash. template<> inline label Hash<edge>::operator()(const edge& e) const diff --git a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H index 8aa88ebe7887fa62fb5a9f99bdd768270fe3efc2..bd3bd339fd1eeeb7da7f2b9139b864ed15ee7d7c 100644 --- a/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H +++ b/src/OpenFOAM/meshes/meshShapes/edge/edgeI.H @@ -26,6 +26,30 @@ License #include "IOstreams.H" +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + + +// return +// - 0: different +// - +1: identical +// - -1: same edge, but different orientation +inline int Foam::edge::compare(const edge& a, const edge& b) +{ + if (a[0] == b[0] && a[1] == b[1]) + { + return 1; + } + else if (a[0] == b[1] && a[1] == b[0]) + { + return -1; + } + else + { + return 0; + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // inline Foam::edge::edge() @@ -146,17 +170,13 @@ inline Foam::linePointRef Foam::edge::line(const pointField& p) const inline bool Foam::operator==(const edge& a, const edge& b) { - return - ( - (a[0] == b[0] && a[1] == b[1]) - || (a[0] == b[1] && a[1] == b[0]) - ); + return edge::compare(a,b) != 0; } inline bool Foam::operator!=(const edge& a, const edge& b) { - return !(a == b); + return edge::compare(a,b) == 0; } diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index dda506d78986b288aa2bb0fc684a23ba9421d4cc..2d06d0db28f6f7530b65cf84dda998fdd9527fe0 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -438,7 +438,7 @@ int Foam::face::compare(const face& a, const face& b) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::face::collapse() +Foam::label Foam::face::collapse() { if (size() > 1) { @@ -458,6 +458,8 @@ void Foam::face::collapse() setSize(ci); } + + return size(); } @@ -696,6 +698,47 @@ Foam::edgeList Foam::face::edges() const } +int Foam::face::edgeDirection(const edge& e) const +{ + if (size() > 2) + { + edge found(-1,-1); + + // find start/end points - this breaks down for degenerate faces + forAll (*this, i) + { + if (operator[](i) == e.start()) + { + found.start() = i; + } + else if (operator[](i) == e.end()) + { + found.end() = i; + } + } + + label diff = found.end() - found.start(); + if (!diff || found.start() < 0 || found.end() < 0) + { + return 0; + } + + // forward direction + if (diff == 1 || diff == 1 - size()) + { + return 1; + } + // reverse direction + if (diff == -1 || diff == -1 + size()) + { + return -1; + } + } + + return 0; +} + + // Number of triangles directly known from number of vertices Foam::label Foam::face::nTriangles ( diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.H b/src/OpenFOAM/meshes/meshShapes/face/face.H index f56919647aa05edc9dcd17cb982fb1a16e431a78..9325801c41ffc0abdf8dbf30e370ae102f30e3b2 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.H +++ b/src/OpenFOAM/meshes/meshShapes/face/face.H @@ -145,7 +145,8 @@ public: // Member Functions //- Collapse face by removing duplicate point labels - void collapse(); + // return the collapsed size + label collapse(); //- Return the points corresponding to this face inline pointField points(const pointField& meshPoints) const; @@ -251,6 +252,11 @@ public: //- Return n-th face edge inline edge faceEdge(const label n) const; + //- Return the edge direction on the face + // - 0: edge not found on the face + // - +1: forward (counter-clockwise) on the face + // - -1: reverse (clockwise) on the face + int edgeDirection(const edge&) const; // Face splitting utilities diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H index aad4ee455f76b4eee987e7fd4bac811cb4e23a31..9672b931477e8d1d1f06ec00dfb36238a76f8c5c 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFace.H @@ -81,18 +81,35 @@ public: const label c ); + //- Construct from a face, discarding excess points + inline triFace(const face&); + + //- Construct from a labelList, discarding excess points + explicit inline triFace(const labelList&); + //- Construct from Istream inline triFace(Istream&); // Member Functions + //- Collapse face by removing duplicate point labels + // return the collapsed size, set collapsed point labels to -1 + inline label collapse(); + + //- Return the edge direction on the face + // - +1: forward (counter-clockwise) on the face + // - -1: reverse (clockwise) on the face + // - 0: edge not found on the face + inline int edgeDirection(const edge&) const; + + // Properties //- Return the points corresponding to this face inline pointField points(const pointField& points) const; - //- Return triagle as a face + //- Return triangle as a face inline face triFaceFace() const; //- Return number of edges @@ -128,9 +145,14 @@ public: const intersection::direction dir = intersection::VECTOR ) const; - //- Return the tetrahedron + //- Return the triangle inline triPointRef tri(const pointField&) const; + //- compare triFaces + // - 0: different + // - +1: identical + // - -1: same face, but different orientation + static inline int compare(const triFace&, const triFace&); // Friend Operators @@ -139,7 +161,7 @@ public: }; -//- Hash<triFace> specialisation +//- Hash<triFace> specialisation // Simple commutative hash. template<> inline label Hash<triFace>::operator()(const triFace& t) const diff --git a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H index c92e1e47e747c79ca791808dfe91679971eb78ff..9574a06cbfdc27d25c8a43d8e30636adab11ea70 100644 --- a/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H +++ b/src/OpenFOAM/meshes/meshShapes/triFace/triFaceI.H @@ -33,14 +33,45 @@ License namespace Foam { +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + + +inline int triFace::compare(const triFace& a, const triFace& b) +{ + if + ( + (a[0] == b[0] && a[1] == b[1] && a[2] == b[2]) + || (a[0] == b[1] && a[1] == b[2] && a[2] == b[0]) + || (a[0] == b[2] && a[1] == b[0] && a[2] == b[1]) + ) + { + // identical + return 1; + } + else if + ( + (a[0] == b[2] && a[1] == b[1] && a[2] == b[0]) + || (a[0] == b[1] && a[1] == b[0] && a[2] == b[2]) + || (a[0] == b[0] && a[1] == b[2] && a[2] == b[1]) + ) + { + // same face, but reversed orientation + return -1; + } + else + { + return 0; + } +} + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -//- Construct null +// Construct null inline triFace::triFace() {} -//- Construct from components +// Construct from components inline triFace::triFace ( const label a, @@ -53,6 +84,18 @@ inline triFace::triFace operator[](2) = c; } +// Construct from a face +inline triFace::triFace(const face& f) +: + FixedList<label, 3>(SubList<label>(f,3)) +{} + +// Construct from a labelList +inline triFace::triFace(const labelList& l) +: + FixedList<label, 3>(SubList<label>(l,3)) +{} + inline triFace::triFace(Istream& is) : @@ -62,6 +105,34 @@ inline triFace::triFace(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline Foam::label Foam::triFace::collapse() +{ + // we cannot resize a FixedList, so mark duplicates with '-1' + // (the lower vertex is retained) + // catch any '-1' - ie, if called twice + + label n = 3; + if (operator[](0) == operator[](1) || operator[](1) == -1) + { + operator[](1) = -1; + n--; + } + else if (operator[](1) == operator[](2) || operator[](2) == -1) + { + operator[](2) = -1; + n--; + } + if (operator[](0) == operator[](2)) + { + operator[](2) = -1; + n--; + } + + return n; +} + + // Return the points associated with this face inline pointField triFace::points(const pointField& points) const { @@ -111,6 +182,37 @@ inline edgeList triFace::edges() const } +// return +// - +1: forward (counter-clockwise) on the face +// - -1: reverse (clockwise) on the face +// - 0: edge not found on the face +inline int triFace::edgeDirection(const edge& e) const +{ + if + ( + (operator[](0) == e.start() && operator[](1) == e.end()) + || (operator[](1) == e.start() && operator[](2) == e.end()) + || (operator[](2) == e.start() && operator[](0) == e.end()) + ) + { + return 1; + } + else if + ( + (operator[](0) == e.end() && operator[](1) == e.start()) + || (operator[](1) == e.end() && operator[](2) == e.start()) + || (operator[](2) == e.end() && operator[](0) == e.start()) + ) + { + return -1; + } + else + { + return 0; + } +} + + inline point triFace::centre(const pointField& points) const { return (1.0/3.0)* @@ -202,23 +304,15 @@ inline triPointRef triFace::tri(const pointField& points) const // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // -inline bool operator==(const triFace& tf1, const triFace& tf2) +inline bool operator==(const triFace& a, const triFace& b) { - return - ( - (tf1[0] == tf2[0] && tf1[1] == tf2[1] && tf1[2] == tf2[2]) - || (tf1[0] == tf2[1] && tf1[1] == tf2[2] && tf1[2] == tf2[0]) - || (tf1[0] == tf2[2] && tf1[1] == tf2[0] && tf1[2] == tf2[1]) - || (tf1[0] == tf2[2] && tf1[1] == tf2[1] && tf1[2] == tf2[0]) - || (tf1[0] == tf2[1] && tf1[1] == tf2[0] && tf1[2] == tf2[2]) - || (tf1[0] == tf2[0] && tf1[1] == tf2[2] && tf1[2] == tf2[1]) - ); + return triFace::compare(a,b) != 0; } -inline bool operator!=(const triFace& tf1, const triFace& tf2) +inline bool operator!=(const triFace& a, const triFace& b) { - return !(tf1 == tf2); + return triFace::compare(a,b) == 0; } diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C index 920ad0f080bc918f76c15e3066913d8f3d9869aa..0a90edc9c01608b377a9d1f1b7e637fdf7346e02 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C @@ -76,12 +76,12 @@ void ZoneMesh<ZoneType>::calcZoneMap() const // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Read constructor given IOobject and a polyMesh reference +// Read constructor given IOobject and a MeshType reference template<class ZoneType> ZoneMesh<ZoneType>::ZoneMesh ( const IOobject& io, - const polyMesh& mesh + const MeshType& mesh ) : PtrList<ZoneType>(), @@ -122,7 +122,7 @@ ZoneMesh<ZoneType>::ZoneMesh is.check ( "ZoneMesh::ZoneMesh" - "(const IOobject&, const polyMesh&)" + "(const IOobject&, const MeshType&)" ); close(); @@ -140,7 +140,7 @@ template<class ZoneType> ZoneMesh<ZoneType>::ZoneMesh ( const IOobject& io, - const polyMesh& mesh, + const MeshType& mesh, const label size ) : @@ -175,8 +175,8 @@ const Map<label>& ZoneMesh<ZoneType>::zoneMap() const } -// Given a global object index, return the zone it is in. If -//object does not belong to any zones, return -1 +// Given a global object index, return the zone it is in. +// If object does not belong to any zones, return -1 template<class ZoneType> label ZoneMesh<ZoneType>::whichZone(const label objectIndex) const { diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H index d5d6fa32446b1c3ecd291b75cf8a3a8349733e12..841b36c90a6496c0d00e504ce35ca57ca6d5b631 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H @@ -69,8 +69,11 @@ class ZoneMesh { // Private data + //- Typedef in preparation of a second template parameter + typedef polyMesh MeshType; + //- Reference to mesh - const polyMesh& mesh_; + const MeshType& mesh_; //- Map of zone labels for given element mutable Map<label>* zoneMapPtr_; @@ -93,18 +96,18 @@ public: // Constructors - //- Read constructor given IOobject and a polyMesh reference + //- Read constructor given IOobject and a MeshType reference ZoneMesh ( const IOobject&, - const polyMesh& + const MeshType& ); //- Construct given size ZoneMesh ( const IOobject&, - const polyMesh&, + const MeshType&, const label size ); @@ -116,7 +119,7 @@ public: // Member functions //- Return the mesh reference - const polyMesh& mesh() const + const MeshType& mesh() const { return mesh_; } diff --git a/src/OpenFOAM/primitives/strings/word/word.H b/src/OpenFOAM/primitives/strings/word/word.H index cd75979c69d217b58b0eb26268118d3fc57fa8cb..42bbc57b6dc69b437cf77e2a198cf702a9558282 100644 --- a/src/OpenFOAM/primitives/strings/word/word.H +++ b/src/OpenFOAM/primitives/strings/word/word.H @@ -84,11 +84,14 @@ public: inline word(); //- Construct as copy - inline word(const word& w); + inline word(const word&); //- Construct as copy of character array inline word(const char*); + //- Construct as copy with a maximum number of characters + inline word(const char*, const size_type); + //- Construct as copy of string inline word(const string&); @@ -96,7 +99,7 @@ public: inline word(const std::string&); //- Construct from Istream - word(Istream& is); + word(Istream&); // Member functions diff --git a/src/OpenFOAM/primitives/strings/word/wordI.H b/src/OpenFOAM/primitives/strings/word/wordI.H index 02acb1ce0cc61fe761b24b61933ebee2d2d745c4..406525c16e40c5ec9b80b4970b9d2ba604e5a550 100644 --- a/src/OpenFOAM/primitives/strings/word/wordI.H +++ b/src/OpenFOAM/primitives/strings/word/wordI.H @@ -39,7 +39,7 @@ inline void Foam::word::stripInvalid() std::cerr << "word::stripInvalid() called for word " << this->c_str() << std::endl; - + if (debug > 1) { std::cerr @@ -65,25 +65,32 @@ inline Foam::word::word() {} -inline Foam::word::word(const string& str) +inline Foam::word::word(const string& s) : - string(str) + string(s) { stripInvalid(); } -inline Foam::word::word(const std::string& stdStr) +inline Foam::word::word(const std::string& s) : - string(stdStr) + string(s) { stripInvalid(); } -inline Foam::word::word(const char* chars) +inline Foam::word::word(const char* s) +: + string(s) +{ + stripInvalid(); +} + +inline Foam::word::word(const char* s, const size_type n) : - string(chars) + string(s, n) { stripInvalid(); } diff --git a/src/engine/engineTime/engineTime.C b/src/engine/engineTime/engineTime.C index 10827455afcd388f3eaf1bbde25c4b1288ff3fb7..313a53c0680c1c5c52cafef6ef71ef5875338cf0 100644 --- a/src/engine/engineTime/engineTime.C +++ b/src/engine/engineTime/engineTime.C @@ -27,21 +27,35 @@ License #include "engineTime.H" #include "mathematicalConstants.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -namespace Foam +void Foam::engineTime::timeAdjustment() { + deltaT_ = degToTime(deltaT_); + endTime_ = degToTime(endTime_); + + if + ( + writeControl_ == wcRunTime + || writeControl_ == wcAdjustableRunTime + ) + { + writeInterval_ = degToTime(writeInterval_); + } +} + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // //- Construct from objectRegistry arguments -engineTime::engineTime +Foam::engineTime::engineTime ( const word& name, const fileName& rootPath, const fileName& caseName, const fileName& systemName, - const fileName& constantName + const fileName& constantName, + const fileName& dictName ) : Time @@ -52,7 +66,7 @@ engineTime::engineTime systemName, constantName ), - engineGeometry_ + dict_ ( IOobject ( @@ -64,78 +78,84 @@ engineTime::engineTime false ) ), - conRodLength_(engineGeometry_.lookup("conRodLength")), - bore_(engineGeometry_.lookup("bore")), - stroke_(engineGeometry_.lookup("stroke")), - clearance_(engineGeometry_.lookup("clearance")), - rpm_(engineGeometry_.lookup("rpm")) + rpm_(dict_.lookup("rpm")), + conRodLength_(dimensionedScalar("conRodLength", dimLength, 0)), + bore_(dimensionedScalar("bore", dimLength, 0)), + stroke_(dimensionedScalar("stroke", dimLength, 0)), + clearance_(dimensionedScalar("clearance", dimLength, 0)) { - value() = degToTime(value()); - - startTime_ = degToTime(startTime_); - endTime_ = degToTime(endTime_); - - deltaT_ = degToTime(deltaT_); - deltaT0_ = deltaT_; - - if - ( - writeControl_ == wcRunTime - || writeControl_ == wcAdjustableRunTime - ) + // the geometric parameters are not strictly required for Time + if (dict_.found("conRodLength")) { - writeInterval_ = degToTime(writeInterval_); + dict_.lookup("conRodLength") >> conRodLength_; } + if (dict_.found("bore")) + { + dict_.lookup("bore") >> bore_; + } + if (dict_.found("stroke")) + { + dict_.lookup("stroke") >> stroke_; + } + if (dict_.found("clearance")) + { + dict_.lookup("clearance") >> clearance_; + } + + timeAdjustment(); + + startTime_ = degToTime(startTime_); + value() = degToTime(value()); + deltaT0_ = deltaT_; } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // Read the controlDict and set all the parameters -bool engineTime::read() +void Foam::engineTime::readDict() +{ + Time::readDict(); + timeAdjustment(); +} + + +// Read the controlDict and set all the parameters +bool Foam::engineTime::read() { - if (!Time::read()) + if (Time::read()) { - return false; + timeAdjustment(); + return true; } else { - deltaT_ = degToTime(deltaT_); - endTime_ = degToTime(endTime_); - - if - ( - writeControl_ == wcRunTime - || writeControl_ == wcAdjustableRunTime - ) - { - writeInterval_ = degToTime(writeInterval_); - } - - return true; + return false; } } -scalar engineTime::degToRad(const scalar deg) const +Foam::scalar Foam::engineTime::degToRad(const scalar deg) const { return mathematicalConstant::pi*deg/180.0; } -scalar engineTime::degToTime(const scalar theta) const +Foam::scalar Foam::engineTime::degToTime(const scalar theta) const { - return theta/(360.0*rpm_.value()/60.0); + // 6 * rpm => deg/s + return theta/(6.0*rpm_.value()); } -scalar engineTime::timeToDeg(const scalar t) const +Foam::scalar Foam::engineTime::timeToDeg(const scalar t) const { - return t*(360.0*rpm_.value()/60.0); + // 6 * rpm => deg/s + return t*(6.0*rpm_.value()); } -scalar engineTime::theta() const +Foam::scalar Foam::engineTime::theta() const { return timeToDeg(value()); } @@ -143,7 +163,7 @@ scalar engineTime::theta() const // Return current crank-angle translated to a single revolution // (value between -180 and 180 with 0 = top dead centre) -scalar engineTime::thetaRevolution() const +Foam::scalar Foam::engineTime::thetaRevolution() const { scalar t = theta(); @@ -161,13 +181,13 @@ scalar engineTime::thetaRevolution() const } -scalar engineTime::deltaTheta() const +Foam::scalar Foam::engineTime::deltaTheta() const { return timeToDeg(deltaT().value()); } -scalar engineTime::pistonPosition(const scalar theta) const +Foam::scalar Foam::engineTime::pistonPosition(const scalar theta) const { return ( @@ -186,7 +206,7 @@ scalar engineTime::pistonPosition(const scalar theta) const } -dimensionedScalar engineTime::pistonPosition() const +Foam::dimensionedScalar Foam::engineTime::pistonPosition() const { return dimensionedScalar ( @@ -197,7 +217,7 @@ dimensionedScalar engineTime::pistonPosition() const } -dimensionedScalar engineTime::pistonDisplacement() const +Foam::dimensionedScalar Foam::engineTime::pistonDisplacement() const { return dimensionedScalar ( @@ -208,24 +228,24 @@ dimensionedScalar engineTime::pistonDisplacement() const } -dimensionedScalar engineTime::pistonSpeed() const +Foam::dimensionedScalar Foam::engineTime::pistonSpeed() const { return dimensionedScalar ( "pistonSpeed", - dimLength/dimTime, + dimVelocity, pistonDisplacement().value()/(deltaT().value() + VSMALL) ); } -scalar engineTime::userTimeToTime(const scalar theta) const +Foam::scalar Foam::engineTime::userTimeToTime(const scalar theta) const { return degToTime(theta); } -scalar engineTime::timeToUserTime(const scalar t) const +Foam::scalar Foam::engineTime::timeToUserTime(const scalar t) const { return timeToDeg(t); } @@ -233,6 +253,4 @@ scalar engineTime::timeToUserTime(const scalar t) const // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/engine/engineTime/engineTime.H b/src/engine/engineTime/engineTime.H index 3a78aa7ab63ab16932d1025ee452539954ddf950..5ecf2c9022f5c1733884e1528c0bec1e6378d795 100644 --- a/src/engine/engineTime/engineTime.H +++ b/src/engine/engineTime/engineTime.H @@ -26,7 +26,25 @@ Class Foam::engineTime Description - Foam::engineTime + Manage time in terms of engine RPM and crank-angle. + + When engineTime is in effect, the userTime is reported in degrees + crank-angle instead of in seconds. The RPM to be used is specified in + @c constant/engineGeometry. If only a time conversion is required, + the geometric engine parameters can be dropped or set to zero. + + For example, + @verbatim + rpm rpm [0 0 -1 0 0] 2000; + + conRodLength conRodLength [0 1 0 0 0] 0.0; + bore bore [0 1 0 0 0] 0.0; + stroke stroke [0 1 0 0 0] 0.0; + clearance clearance [0 1 0 0 0] 0.0; + @endverbatim + +Note + The engineTime can currently only be selected at compile-time. SourceFiles engineTime.C @@ -46,7 +64,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class engineTime Declaration + Class engineTime Declaration \*---------------------------------------------------------------------------*/ class engineTime @@ -55,13 +73,16 @@ class engineTime { // Private data - IOdictionary engineGeometry_; + IOdictionary dict_; + //- RPM is required + dimensionedScalar rpm_; + + //- Optional engine geometry parameters dimensionedScalar conRodLength_; dimensionedScalar bore_; dimensionedScalar stroke_; dimensionedScalar clearance_; - dimensionedScalar rpm_; // Private Member Functions @@ -72,6 +93,8 @@ class engineTime //- Disallow default bitwise assignment void operator=(const engineTime&); + //- adjust read time values + void timeAdjustment(); public: @@ -84,7 +107,8 @@ public: const fileName& rootPath, const fileName& caseName, const fileName& systemName = "system", - const fileName& constantName = "constant" + const fileName& constantName = "constant", + const fileName& dictName = "engineGeometry" ); // Destructor @@ -116,7 +140,13 @@ public: //- Return the engine geometry dictionary const dictionary& engineDict() const { - return engineGeometry_; + return dict_; + } + + //- Return the engines current operating RPM + const dimensionedScalar& rpm() const + { + return rpm_; } //- Return the engines connecting-rod length @@ -143,12 +173,6 @@ public: return clearance_; } - //- Return the engines current operating RPM - const dimensionedScalar& rpm() const - { - return rpm_; - } - //- Return current crank-angle scalar theta() const; @@ -173,16 +197,19 @@ public: // Member functions overriding the virtual functions in time //- Convert the user-time (CA deg) to real-time (s). - scalar userTimeToTime(const scalar theta) const; + virtual scalar userTimeToTime(const scalar theta) const; //- Convert the real-time (s) into user-time (CA deg) - scalar timeToUserTime(const scalar t) const; + virtual scalar timeToUserTime(const scalar t) const; + + //- Read the control dictionary and set the write controls etc. + virtual void readDict(); // Edit //- Read the controlDict and set all the parameters - bool read(); + virtual bool read(); }; diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C index ee3381932e5f0faecf8f0e7f881b681eeb67d737..3e0d85a3f6f6093ae58d2835393bbb34fbea8a3a 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C @@ -471,8 +471,8 @@ EulerDdtScheme<Type>::fvcDdtPhiCorr ( rA*rho.oldTime()*U.oldTime() ) & mesh().Sf() - ) - ) + ) + ) ) ); } diff --git a/src/lagrangian/basic/Make/files b/src/lagrangian/basic/Make/files old mode 100755 new mode 100644 diff --git a/src/lagrangian/basic/Make/options b/src/lagrangian/basic/Make/options old mode 100755 new mode 100644 diff --git a/src/lagrangian/dieselSpray/Make/files b/src/lagrangian/dieselSpray/Make/files old mode 100755 new mode 100644 diff --git a/src/lagrangian/dieselSpray/Make/options b/src/lagrangian/dieselSpray/Make/options old mode 100755 new mode 100644 diff --git a/src/lagrangian/dieselSpray/parcel/parcel.C b/src/lagrangian/dieselSpray/parcel/parcel.C index fb4349fec00f7409004d658b135368dbbdcf9824..6a560dcd47ff5751f301c0ef04ca6e7116dfae10 100644 --- a/src/lagrangian/dieselSpray/parcel/parcel.C +++ b/src/lagrangian/dieselSpray/parcel/parcel.C @@ -38,21 +38,20 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - defineParticleTypeNameAndDebug(parcel, 0); defineTemplateTypeNameAndDebug(Cloud<parcel>, 0); +} // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -parcel::parcel +Foam::parcel::parcel ( const Cloud<parcel>& cloud, const vector& position, - const label celli, + const label cellI, const vector& n, const scalar d, const scalar T, @@ -67,14 +66,13 @@ parcel::parcel const vector& U, const vector& Uturb, const scalarField& X, - const List<word>& fuelNames + const List<word>& liquidNames ) : - Particle<parcel>(cloud, position, celli), - - fuelNames_ + Particle<parcel>(cloud, position, cellI), + liquidComponents_ ( - fuelNames + liquidNames ), d_(d), T_(T), @@ -96,7 +94,7 @@ parcel::parcel // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool parcel::move(spray& sDB) +bool Foam::parcel::move(spray& sDB) { const polyMesh& mesh = cloud().pMesh(); const polyBoundaryMesh& pbMesh = mesh.boundaryMesh(); @@ -329,7 +327,7 @@ bool parcel::move(spray& sDB) } -void parcel::updateParcelProperties +void Foam::parcel::updateParcelProperties ( const scalar dt, spray& sDB, @@ -638,18 +636,16 @@ void parcel::updateParcelProperties } -void parcel::transformProperties(const tensor& T) +void Foam::parcel::transformProperties(const tensor& T) { U_ = transform(T, U_); } -void parcel::transformProperties(const vector&) +void Foam::parcel::transformProperties(const vector&) {} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace Foam - // ************************************************************************* // diff --git a/src/lagrangian/dieselSpray/parcel/parcel.H b/src/lagrangian/dieselSpray/parcel/parcel.H index ab5a1f36844037a370d259ea0a30e42a6b79b871..9a6603e7651aa89fc077092a3b6e7fde78977a9b 100644 --- a/src/lagrangian/dieselSpray/parcel/parcel.H +++ b/src/lagrangian/dieselSpray/parcel/parcel.H @@ -54,7 +54,7 @@ class parcel // Private member data // Reference to the names of the liquid components - List<word> fuelNames_; + List<word> liquidComponents_; // Defining data (read and written to field files) @@ -85,7 +85,7 @@ class parcel //- Part of liquid core (1-fully liquid, 0-droplet) scalar liquidCore_; - //- injected from injector + //- injected from injector // Should really be a label, but is scalar due to // post-processing reasons scalar injector_; @@ -100,7 +100,7 @@ class parcel // in which the particle moves vector n_; - //- Liquid fuel molar fractions + //- Liquid components molar fractions scalarField X_; // Derived state information (not read or written) @@ -166,7 +166,7 @@ public: const vector& U, const vector& Uturb, const scalarField& X, - const List<word>& fuelNames + const List<word>& liquidNames ); //- Construct from Istream reading field values if required @@ -182,7 +182,10 @@ public: // Access - //- Return the names of the liquid fuel components + //- Return the names of the liquid components + inline const List<word>& liquidNames() const; + + //- Return the names of the liquid fuel components - identical with liquidNames inline const List<word>& fuelNames() const; //- Return diameter of droplets in parcel @@ -265,10 +268,10 @@ public: //- Return the normal used for 2D purposes inline vector& n(); - //- Return the liquid fuel molar fractions + //- Return the liquid components molar fractions inline const scalarField& X() const; - //- Return the liquid fuel molar fractions + //- Return the liquid components molar fractions inline scalarField& X(); //- Return the momentum relaxation time of droplets in parcel @@ -355,7 +358,7 @@ public: void transformProperties(const vector& separation); //- fix the 2D plane normal, - // when particle hits a face it is slightly perturbed + // when particle hits a face it is slightly perturbed // towards the face centre and n_ will no longer be valid inline void correctNormal(const vector& sym); diff --git a/src/lagrangian/dieselSpray/parcel/parcelI.H b/src/lagrangian/dieselSpray/parcel/parcelI.H index a51e452b3c45e8997cd0eaf32230633a92bf6d79..8aaf418a304d6a95f0abc38eda4e9b335b9bee24 100644 --- a/src/lagrangian/dieselSpray/parcel/parcelI.H +++ b/src/lagrangian/dieselSpray/parcel/parcelI.H @@ -31,9 +31,14 @@ namespace Foam // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +inline const List<word>& parcel::liquidNames() const +{ + return liquidComponents_; +} + inline const List<word>& parcel::fuelNames() const { - return fuelNames_; + return liquidComponents_; } inline scalar parcel::d() const @@ -115,7 +120,7 @@ inline scalar parcel::tTurb() const { return tTurb_; } - + inline scalar& parcel::liquidCore() { return liquidCore_; @@ -135,7 +140,7 @@ inline scalar parcel::injector() const { return injector_; } - + inline const vector& parcel::U() const { return U_; diff --git a/src/lagrangian/dieselSpray/parcel/parcelIO.C b/src/lagrangian/dieselSpray/parcel/parcelIO.C index 8334d9ca0d823c178db0debbfc84baa527c6c843..301fc5b928f030b6d567bc715a7d9b4962fe0c8e 100644 --- a/src/lagrangian/dieselSpray/parcel/parcelIO.C +++ b/src/lagrangian/dieselSpray/parcel/parcelIO.C @@ -38,17 +38,17 @@ Foam::parcel::parcel : Particle<parcel>(cloud, is), - fuelNames_ + liquidComponents_ ( (cloud.pMesh().lookupObject<dictionary>("thermophysicalProperties")) - .lookup("liquidFuelComponents") + .lookup("liquidComponents") ), - X_(fuelNames_.size(), 0.0), + X_(liquidComponents_.size(), 0.0), tMom_(GREAT) { - label nX = fuelNames_.size(); + label nX = X_.size(); if (readFields) { @@ -67,7 +67,7 @@ Foam::parcel::parcel is >> U_; is >> Uturb_; is >> n_; - for(label j=0; j<nX; j++) + for (label j=0; j<nX; j++) { X_[j] = readScalar(is); } @@ -79,7 +79,7 @@ Foam::parcel::parcel reinterpret_cast<char*>(&d_), sizeof(d_) + sizeof(T_) + sizeof(m_) + sizeof(y_) + sizeof(yDot_) + sizeof(ct_) + sizeof(ms_) + sizeof(tTurb_) - + sizeof(liquidCore_) + sizeof(injector_) + + sizeof(liquidCore_) + sizeof(injector_) + sizeof(U_) + sizeof(Uturb_) + sizeof(n_) ); @@ -175,11 +175,10 @@ void Foam::parcel::readFields const parcel& p0 = iter(); label nX = p0.X().size(); - List<word> names(p0.fuelNames()); + const List<word>& names = p0.liquidNames(); for (label j=0; j<nX; j++) { - IOField<scalar> X(c.fieldIOobject(names[j])); label i = 0; @@ -262,8 +261,7 @@ void Foam::parcel::writeFields const parcel& p0 = iter(); label nX = p0.X().size(); - - List<word> names(p0.fuelNames()); + const List<word>& names = p0.liquidNames(); for (label j=0; j<nX; j++) { @@ -312,7 +310,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const parcel& p) ( reinterpret_cast<const char*>(&p.d_), sizeof(p.d_) + sizeof(p.T_) + sizeof(p.m_) + sizeof(p.y_) - + sizeof(p.yDot_) + sizeof(p.ct_) + sizeof(p.ms_) + sizeof(p.tTurb_) + + sizeof(p.yDot_) + sizeof(p.ct_) + sizeof(p.ms_) + sizeof(p.tTurb_) + sizeof(p.liquidCore_) + sizeof(p.injector_) + sizeof(p.U_) + sizeof(p.Uturb_) + sizeof(p.n_) ); diff --git a/src/lagrangian/dieselSpray/spray/spray.C b/src/lagrangian/dieselSpray/spray/spray.C index 5f36578bee7f437d037a39179924d80b2d82d0a5..bb51c0d299d537cc4bd0db5b502ab52e65091fc7 100644 --- a/src/lagrangian/dieselSpray/spray/spray.C +++ b/src/lagrangian/dieselSpray/spray/spray.C @@ -63,7 +63,7 @@ Foam::spray::spray const dictionary& environmentalProperties ) : - Cloud<parcel>(U.mesh()), + Cloud<parcel>(U.mesh(), false), // suppress className checking on positions runTime_(U.time()), time0_(runTime_.value()), mesh_(U.mesh()), diff --git a/src/lagrangian/intermediate/Make/options b/src/lagrangian/intermediate/Make/options old mode 100755 new mode 100644 diff --git a/src/lagrangian/solidParticle/Make/files b/src/lagrangian/solidParticle/Make/files old mode 100755 new mode 100644 diff --git a/src/lagrangian/solidParticle/Make/options b/src/lagrangian/solidParticle/Make/options old mode 100755 new mode 100644 diff --git a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.C b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.C index e738b16533ba420f1e219b145c555ab03b693485..7705c401b612bcd5a8983e2efbfd683af55de104 100644 --- a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.C +++ b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.C @@ -29,10 +29,8 @@ License #include "specie.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -namespace Foam -{ - const scalar liquidMixture::TrMax = 0.999; -} + +const Foam::scalar Foam::liquidMixture::TrMax = 0.999; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -42,17 +40,35 @@ Foam::liquidMixture::liquidMixture const dictionary& thermophysicalProperties ) : - components_(thermophysicalProperties.lookup("liquidFuelComponents")), + components_(thermophysicalProperties.lookup("liquidComponents")), properties_(components_.size()) { - + // use sub-dictionary "liquidProperties" if possible to avoid + // collisions with identically named gas-phase entries + // (eg, H2O liquid vs. gas) forAll(components_, i) { - properties_.set + const dictionary* subDictPtr = thermophysicalProperties.subDictPtr ( - i, - liquid::New(thermophysicalProperties.lookup(components_[i])) + "liquidProperties" ); + + if (subDictPtr) + { + properties_.set + ( + i, + liquid::New(subDictPtr->lookup(components_[i])) + ); + } + else + { + properties_.set + ( + i, + liquid::New(thermophysicalProperties.lookup(components_[i])) + ); + } } } @@ -347,7 +363,7 @@ Foam::scalar Foam::liquidMixture::mu mu += x[i]*log(properties_[i].mu(p, Ti)); } } - + return exp(mu); } @@ -390,7 +406,7 @@ Foam::scalar Foam::liquidMixture::K K += phii[i]*phii[j]*Kij; } } - + return K; } @@ -412,7 +428,7 @@ Foam::scalar Foam::liquidMixture::D Dinv += x[i]/properties_[i].D(p, Ti); } } - + return 1.0/Dinv; } diff --git a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H index 227197cca78d941252390cd921c0b9c05a3bf2c3..4b03c2efc37048b58841bbd7f04c8980a6c5fa66 100644 --- a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H +++ b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H @@ -34,6 +34,48 @@ Description For now it does not do much, since the perfect gas equation is used. + The dictionary constructor searches for the entry @c liquidComponents, + which is a wordList. The liquid properties of each component can either + be contained within a @c liquidProperties sub-dictionary or (for legacy + purposes) can be found directly in the dictionary. + The @c liquidProperties sub-dictionary entry should be used when possible + to avoid conflicts with identically named gas-phase entries. + + A simple example of a single-component liquidMixture: + @verbatim + liquidComponents + ( + H2O + ); + + // the gas-phase species + species + ( + AIR H2O + ); + + // thermo values from BurcatCpData + AIR + AIR 1 28.96518 // specie: name/nMoles/MolWt + 200 6000 1000 // low/high/common temperature + 3.0879272 0.0012459718 -4.2371895e-07 6.7477479e-11 -3.9707697e-15 -995.26275 5.9596093 // 7 upper Temp. coeffs + 3.5683962 -0.00067872943 1.5537148e-06 -3.2993706e-12 -4.6639539e-13 -1062.3466 3.7158296 // 7 lower Temp. coeffs + 1.4792e-06 116 // sutherlandTransport for AIR (STAR-CD) + ; + H2O + H2O 1 18.01528 // specie: name/nMoles/MolWt + 200 6000 1000 // low/high/common temperature + 2.6770389 0.0029731816 -7.7376889e-07 9.4433514e-11 -4.2689991e-15 -29885.894 6.88255 // 7 upper Temp. coeffs + 4.1986352 -0.0020364017 6.5203416e-06 -5.4879269e-09 1.771968e-12 -30293.726 -0.84900901 // 7 lower Temp. coeffs + 1.4792e-06 116 // sutherlandTransport for AIR (STAR-CD) + ; + + liquidProperties + { + H2O H2O defaultCoeffs; + } + @endverbatim + \*---------------------------------------------------------------------------*/ #ifndef liquidMixture_H @@ -51,7 +93,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class liquidMixture Declaration + Class liquidMixture Declaration \*---------------------------------------------------------------------------*/ class liquidMixture diff --git a/src/thermophysicalModels/radiation/Make/files b/src/thermophysicalModels/radiation/Make/files old mode 100755 new mode 100644 diff --git a/src/thermophysicalModels/radiation/Make/options b/src/thermophysicalModels/radiation/Make/options old mode 100755 new mode 100644 diff --git a/tutorials/dieselFoam/aachenBomb/constant/chemistryProperties b/tutorials/dieselFoam/aachenBomb/constant/chemistryProperties index 3996112f54026fde9aa21d53dea3997a2c303071..06093fea0aa5728a54c9dcc29f938008c376e9f8 100644 --- a/tutorials/dieselFoam/aachenBomb/constant/chemistryProperties +++ b/tutorials/dieselFoam/aachenBomb/constant/chemistryProperties @@ -1,23 +1,17 @@ -/*---------------------------------------------------------------------------*\ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.4 | +| \\ / O peration | Version: 1.4.2 | | \\ / A nd | Web: http://www.openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ - FoamFile { - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object chemistryProperties; + version 2.0; + format ascii; + class dictionary; + object chemistryProperties; + location "constant"; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/dieselFoam/aachenBomb/constant/combustionProperties b/tutorials/dieselFoam/aachenBomb/constant/combustionProperties index 73082b6d72e11bd0fcb981ca34a23d124d69b518..43bef0bdd74bd026d1b48443879675a718d953df 100644 --- a/tutorials/dieselFoam/aachenBomb/constant/combustionProperties +++ b/tutorials/dieselFoam/aachenBomb/constant/combustionProperties @@ -1,23 +1,17 @@ -/*---------------------------------------------------------------------------*\ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.4 | +| \\ / O peration | Version: 1.4.2 | | \\ / A nd | Web: http://www.openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ - FoamFile { - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object combustionProperties; + version 2.0; + format ascii; + class dictionary; + object combustionProperties; + location "constant"; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -27,11 +21,8 @@ Cmix Cmix [ 0 0 0 0 0 0 0 ] 1.0 ; ignitionProperties1 { ignite off; - ignitionPoint ignitionPoint [ 0 1 0 0 0 0 0 ] ( 0.2 0 0.02 ) ; - timing timing [ 0 0 1 0 0 0 0 ] 0.0e-1 ; - duration duration [ 0 0 1 0 0 0 0 ] 1.0e-0 ; } diff --git a/tutorials/dieselFoam/aachenBomb/constant/environmentalProperties b/tutorials/dieselFoam/aachenBomb/constant/environmentalProperties index 5fc1e5744bd7b237aecb6c81481073026a8ea1ed..7cdfff6c15e19577f28566155f8e46e942b30f40 100644 --- a/tutorials/dieselFoam/aachenBomb/constant/environmentalProperties +++ b/tutorials/dieselFoam/aachenBomb/constant/environmentalProperties @@ -1,23 +1,17 @@ -/*---------------------------------------------------------------------------*\ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.4 | +| \\ / O peration | Version: 1.4.2 | | \\ / A nd | Web: http://www.openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ - FoamFile { - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object environmentalProperties; + version 2.0; + format ascii; + class dictionary; + object environmentalProperties; + location "constant"; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/dieselFoam/aachenBomb/constant/injectorProperties b/tutorials/dieselFoam/aachenBomb/constant/injectorProperties index 6ea83c8b2e9668e66657f610c0364fdcaa5a750b..3cf9ca8b176fbe9c2bca014e1e821515e5ca1d6c 100644 --- a/tutorials/dieselFoam/aachenBomb/constant/injectorProperties +++ b/tutorials/dieselFoam/aachenBomb/constant/injectorProperties @@ -1,23 +1,17 @@ -/*---------------------------------------------------------------------------*\ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.4 | +| \\ / O peration | Version: 1.4.2 | | \\ / A nd | Web: http://www.openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ - FoamFile { - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object injectorProperties; + version 2.0; + format ascii; + class dictionary; + object injectorProperties; + location "constant"; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/dieselFoam/aachenBomb/constant/sprayProperties b/tutorials/dieselFoam/aachenBomb/constant/sprayProperties index 6a2da5efee931dc6f5181556216d9236eaae5e1f..1da827717689290e454fb8654001998d6efa0adf 100644 --- a/tutorials/dieselFoam/aachenBomb/constant/sprayProperties +++ b/tutorials/dieselFoam/aachenBomb/constant/sprayProperties @@ -1,23 +1,17 @@ -/*---------------------------------------------------------------------------*\ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.4 | +| \\ / O peration | Version: 1.4.2 | | \\ / A nd | Web: http://www.openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ - FoamFile { - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object sprayProperties; + version 2.0; + format ascii; + class dictionary; + object sprayProperties; + location "constant"; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -61,11 +55,11 @@ wallModel reflect; specConstAtomizationCoeffs { - dropletNozzleDiameterRatio + dropletNozzleDiameterRatio ( 0.4 ); - sprayAngle + sprayAngle ( 10 ); @@ -142,9 +136,9 @@ hollowConeInjectorCoeffs { dropletPDF { - //pdfType exponential; + //pdfType exponential; pdfType RosinRammler; - + RosinRammlerPDF { minValue 1.00e-6; @@ -154,7 +148,7 @@ hollowConeInjectorCoeffs ( 1.5e-4 ); - + n ( 3 diff --git a/tutorials/dieselFoam/aachenBomb/constant/thermophysicalProperties b/tutorials/dieselFoam/aachenBomb/constant/thermophysicalProperties index 7bd933228475a5a02744cfa1fe8a9738bf304925..f3643830b8c47e31be4586a805a3bb1d19f647d9 100644 --- a/tutorials/dieselFoam/aachenBomb/constant/thermophysicalProperties +++ b/tutorials/dieselFoam/aachenBomb/constant/thermophysicalProperties @@ -1,39 +1,38 @@ -/*---------------------------------------------------------------------------*\ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.4 | +| \\ / O peration | Version: 1.4.2 | | \\ / A nd | Web: http://www.openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ - FoamFile { - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object thermodynamicProperties; + version 2.0; + format ascii; + class dictionary; + object thermodynamicProperties; + location "constant"; } /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ thermoType hMixtureThermo<reactingMixture>; -CHEMKINFile "$FOAM_ROOT/$FOAM_CASE/chemkin/chem.inp"; -CHEMKINThermoFile "$FOAM_ROOT/$FOAM_CASE/chemkin/therm.dat"; +CHEMKINFile "$FOAM_CASE/chemkin/chem.inp"; +// We use the central thermo data: +CHEMKINThermoFile "~OpenFOAM/thermoData/therm.dat"; -inertSpecie N2; +inertSpecie N2; -liquidFuelComponents +liquidComponents ( C7H16 ); -C7H16 C7H16 defaultCoeffs; +liquidProperties +{ + C7H16 C7H16 defaultCoeffs; + C7H16 +} /*********************************************************************/ diff --git a/tutorials/dieselFoam/aachenBomb/constant/turbulenceProperties b/tutorials/dieselFoam/aachenBomb/constant/turbulenceProperties index 55dc7293e0148e1101a5bb16f95fd48507a602c4..80f2b97b3091d443360aa6a286a6786dff9dd55d 100644 --- a/tutorials/dieselFoam/aachenBomb/constant/turbulenceProperties +++ b/tutorials/dieselFoam/aachenBomb/constant/turbulenceProperties @@ -1,23 +1,17 @@ -/*---------------------------------------------------------------------------*\ +/*--------------------------------*- C++ -*----------------------------------*\ | ========= | | | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: 1.4 | +| \\ / O peration | Version: 1.4.2 | | \\ / A nd | Web: http://www.openfoam.org | | \\/ M anipulation | | \*---------------------------------------------------------------------------*/ - FoamFile { - version 2.0; - format ascii; - - root ""; - case ""; - instance ""; - local ""; - - class dictionary; - object turbulenceProperties; + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; + location "constant"; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //