From 1ee83d90669fd29d37820d87633d7ffdd68b6e97 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 29 Jun 2011 09:52:37 +0100 Subject: [PATCH 1/6] STYLE:triSurfaceMesh.C: extraneous expression --- src/meshTools/searchableSurface/triSurfaceMesh.C | 1 - 1 file changed, 1 deletion(-) diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.C b/src/meshTools/searchableSurface/triSurfaceMesh.C index c532ac3d39..aa117c2794 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.C +++ b/src/meshTools/searchableSurface/triSurfaceMesh.C @@ -738,7 +738,6 @@ void Foam::triSurfaceMesh::findLineAll // we need something bigger since we're doing calculations) // - if the start-end vector is zero we still progress const vectorField dirVec(end-start); - const scalarField magSqrDirVec(magSqr(dirVec)); const vectorField smallVec ( indexedOctree::perturbTol()*dirVec From 0b18291a9818dc7b12cb7c39e6aa49abd58a0840 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 29 Jun 2011 09:53:43 +0100 Subject: [PATCH 2/6] BUG: triSurfaceSearch: did not clear hits --- src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index b24c482b25..0f695cb1d8 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -201,9 +201,8 @@ const if (inter.hit()) { - label sz = hits.size(); - hits.setSize(sz+1); - hits[sz] = inter; + hits.setSize(1); + hits[0] = inter; const vector dirVec(end-start); const scalar magSqrDirVec(magSqr(dirVec)); From ec67450164757302869e7a6f6dcd58d9c16f678d Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 29 Jun 2011 09:54:18 +0100 Subject: [PATCH 3/6] ENH: orientedSurface: added orienting based on intersection test --- .../orientedSurface/orientedSurface.C | 95 +++++++++++-------- .../orientedSurface/orientedSurface.H | 3 + 2 files changed, 59 insertions(+), 39 deletions(-) diff --git a/src/meshTools/triSurface/orientedSurface/orientedSurface.C b/src/meshTools/triSurface/orientedSurface/orientedSurface.C index 2b32604972..d72eba5f92 100644 --- a/src/meshTools/triSurface/orientedSurface/orientedSurface.C +++ b/src/meshTools/triSurface/orientedSurface/orientedSurface.C @@ -255,7 +255,6 @@ void Foam::orientedSurface::findZoneSide zoneFaceI = -1; isOutside = false; - List hits; forAll(faceZone, faceI) @@ -305,7 +304,6 @@ void Foam::orientedSurface::findZoneSide { isOutside = ((n & d) > 0); } - break; } } @@ -354,6 +352,50 @@ bool Foam::orientedSurface::flipSurface } +bool Foam::orientedSurface::orientConsistent(triSurface& s) +{ + bool anyFlipped = false; + + // Do initial flipping to make triangles consistent. Otherwise if the + // nearest is e.g. on an edge inbetween inconsistent triangles it might + // make the wrong decision. + if (s.size() > 0) + { + // Whether face has to be flipped. + // UNVISITED: unvisited + // NOFLIP: no need to flip + // FLIP: need to flip + labelList flipState(s.size(), UNVISITED); + + label faceI = 0; + while (true) + { + label startFaceI = -1; + while (faceI < s.size()) + { + if (flipState[faceI] == UNVISITED) + { + startFaceI = faceI; + break; + } + faceI++; + } + + if (startFaceI == -1) + { + break; + } + + flipState[startFaceI] = NOFLIP; + walkSurface(s, startFaceI, flipState); + } + + anyFlipped = flipSurface(s, flipState); + } + return anyFlipped; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // Null constructor @@ -404,44 +446,10 @@ bool Foam::orientedSurface::orient const bool orientOutside ) { - bool anyFlipped = false; - // Do initial flipping to make triangles consistent. Otherwise if the // nearest is e.g. on an edge inbetween inconsistent triangles it might // make the wrong decision. - if (s.size() > 0) - { - // Whether face has to be flipped. - // UNVISITED: unvisited - // NOFLIP: no need to flip - // FLIP: need to flip - labelList flipState(s.size(), UNVISITED); - - label faceI = 0; - while (true) - { - label startFaceI = -1; - while (faceI < s.size()) - { - if (flipState[faceI] == UNVISITED) - { - startFaceI = faceI; - break; - } - faceI++; - } - - if (startFaceI == -1) - { - break; - } - - flipState[startFaceI] = NOFLIP; - walkSurface(s, startFaceI, flipState); - } - - anyFlipped = flipSurface(s, flipState); - } + bool topoFlipped = orientConsistent(s); // Whether face has to be flipped. @@ -497,7 +505,7 @@ bool Foam::orientedSurface::orient // Now finally flip triangles according to flipState. bool geomFlipped = flipSurface(s, flipState); - return anyFlipped || geomFlipped; + return topoFlipped || geomFlipped; } @@ -509,6 +517,11 @@ bool Foam::orientedSurface::orient const bool orientOutside ) { + // Do initial flipping to make triangles consistent. Otherwise if the + // nearest is e.g. on an edge inbetween inconsistent triangles it might + // make the wrong decision. + bool topoFlipped = orientConsistent(s); + // Determine disconnected parts of surface boolList borderEdge(s.nEdges(), false); forAll(s.edgeFaces(), edgeI) @@ -549,7 +562,11 @@ bool Foam::orientedSurface::orient } walkSurface(s, zoneFaceI, flipState); } - return flipSurface(s, flipState); + + // Now finally flip triangles according to flipState. + bool geomFlipped = flipSurface(s, flipState); + + return topoFlipped || geomFlipped; } diff --git a/src/meshTools/triSurface/orientedSurface/orientedSurface.H b/src/meshTools/triSurface/orientedSurface/orientedSurface.H index 209673a187..ea69ca1ebb 100644 --- a/src/meshTools/triSurface/orientedSurface/orientedSurface.H +++ b/src/meshTools/triSurface/orientedSurface/orientedSurface.H @@ -128,6 +128,9 @@ class orientedSurface // anything flipped. static bool flipSurface(triSurface& s, const labelList& flipState); + //- Make surface surface has consistent orientation across connected + // triangles. + static bool orientConsistent(triSurface& s); public: ClassName("orientedSurface"); From 9fa370f54a9de845fab0f980bbf4f7bb45d82934 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 29 Jun 2011 09:56:01 +0100 Subject: [PATCH 4/6] ENH: calcEntry: new functionEntry method --- src/OpenFOAM/Make/files | 1 + .../functionEntries/calcEntry/calcEntry.C | 99 ++++++++++++++++ .../functionEntries/calcEntry/calcEntry.H | 111 ++++++++++++++++++ .../functionEntries/codeStream/codeStream.C | 50 +++++--- .../functionEntries/codeStream/codeStream.H | 16 +++ 5 files changed, 259 insertions(+), 18 deletions(-) create mode 100644 src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C create mode 100644 src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.H diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 52de21702b..1f1e25341e 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -160,6 +160,7 @@ $(dictionaryEntry)/dictionaryEntry.C $(dictionaryEntry)/dictionaryEntryIO.C functionEntries = $(dictionary)/functionEntries +$(functionEntries)/calcEntry/calcEntry.C $(functionEntries)/codeStream/codeStream.C $(functionEntries)/functionEntry/functionEntry.C $(functionEntries)/includeEntry/includeEntry.C diff --git a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C new file mode 100644 index 0000000000..fceccc4d35 --- /dev/null +++ b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.C @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "calcEntry.H" +#include "addToMemberFunctionSelectionTable.H" +#include "dictionary.H" +#include "dynamicCode.H" +#include "codeStream.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace functionEntries +{ + defineTypeNameAndDebug(calcEntry, 0); + + addToMemberFunctionSelectionTable + ( + functionEntry, + calcEntry, + execute, + primitiveEntryIstream + ); + +} +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionEntries::calcEntry::execute +( + const dictionary& parentDict, + primitiveEntry& thisEntry, + Istream& is +) +{ + Info<< "Using #calcEntry at line " << is.lineNumber() + << " in file " << parentDict.name() << endl; + + dynamicCode::checkSecurity + ( + "functionEntries::calcEntry::execute(..)", + parentDict + ); + + // Read string + string s(is); + // Make sure we stop this entry + //is.putBack(token(token::END_STATEMENT, is.lineNumber())); + + // Construct codeDict for codeStream + // must reference parent for stringOps::expand to work nicely. + dictionary codeSubDict; + codeSubDict.add("code", "os << (" + s + ");"); + dictionary codeDict(parentDict, codeSubDict); + + codeStream::streamingFunctionType function = codeStream::getFunction + ( + parentDict, + codeDict + ); + + // use function to write stream + OStringStream os(is.format()); + (*function)(os, parentDict); + + // get the entry from this stream + IStringStream resultStream(os.str()); + thisEntry.read(parentDict, resultStream); + + return true; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.H new file mode 100644 index 0000000000..235210e798 --- /dev/null +++ b/src/OpenFOAM/db/dictionary/functionEntries/calcEntry/calcEntry.H @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2011 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 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::functionEntries::calcEntry + +Description + Uses dynamic compilation to provide calculating functionality + for entering dictionary entries. + + E.g. + + \verbatim + a 1.0; + b 3; + c #calc "$a/$b"; + \endverbatim + + Note the explicit trailing 0 ('1.0') to force a to be read (and written) + as a floating point number. + +Note + Internally this is just a wrapper around codeStream functionality - the + #calc string gets used to construct a dictionary for codeStream. + +SourceFiles + calcEntry.C + +\*---------------------------------------------------------------------------*/ + +#ifndef calcEntry_H +#define calcEntry_H + +#include "functionEntry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +class dlLibraryTable; + +namespace functionEntries +{ + +/*---------------------------------------------------------------------------*\ + Class calcEntry Declaration +\*---------------------------------------------------------------------------*/ + +class calcEntry +: + public functionEntry +{ + + // Private Member Functions + + //- Disallow default bitwise copy construct + calcEntry(const calcEntry&); + + //- Disallow default bitwise assignment + void operator=(const calcEntry&); + + +public: + + //- Runtime type information + ClassName("calc"); + + + // Member Functions + + //- Execute the functionEntry in a sub-dict context + static bool execute + ( + const dictionary& parentDict, + primitiveEntry&, + Istream& + ); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace functionEntries +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index 8eefcb86d9..bab7ac3901 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -92,28 +92,13 @@ Foam::dlLibraryTable& Foam::functionEntries::codeStream::libs } -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool Foam::functionEntries::codeStream::execute +Foam::functionEntries::codeStream::streamingFunctionType +Foam::functionEntries::codeStream::getFunction ( const dictionary& parentDict, - primitiveEntry& entry, - Istream& is + const dictionary& codeDict ) { - Info<< "Using #codeStream at line " << is.lineNumber() - << " in file " << parentDict.name() << endl; - - dynamicCode::checkSecurity - ( - "functionEntries::codeStream::execute(..)", - parentDict - ); - - // get code dictionary - // must reference parent for stringOps::expand to work nicely - dictionary codeDict("#codeStream", parentDict, is); - // get code, codeInclude, codeOptions dynamicCodeContext context(codeDict); @@ -260,6 +245,34 @@ bool Foam::functionEntries::codeStream::execute << " in library " << lib << exit(FatalIOError); } + return function; +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::functionEntries::codeStream::execute +( + const dictionary& parentDict, + primitiveEntry& entry, + Istream& is +) +{ + Info<< "Using #codeStream at line " << is.lineNumber() + << " in file " << parentDict.name() << endl; + + dynamicCode::checkSecurity + ( + "functionEntries::codeStream::execute(..)", + parentDict + ); + + // get code dictionary + // must reference parent for stringOps::expand to work nicely + dictionary codeDict("#codeStream", parentDict, is); + + streamingFunctionType function = getFunction(parentDict, codeDict); + // use function to write stream OStringStream os(is.format()); (*function)(os, parentDict); @@ -268,6 +281,7 @@ bool Foam::functionEntries::codeStream::execute IStringStream resultStream(os.str()); entry.read(parentDict, resultStream); + return true; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H index 4da11839f1..6c93af8690 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H @@ -103,6 +103,9 @@ class dlLibraryTable; namespace functionEntries { +// Forward declaration of friend classes +class calcEntry; + /*---------------------------------------------------------------------------*\ Class codeStream Declaration \*---------------------------------------------------------------------------*/ @@ -123,6 +126,14 @@ class codeStream //- Helper function: access to dlLibraryTable of Time static dlLibraryTable& libs(const dictionary& dict); + //- Construct, compile, load and return streaming function + static streamingFunctionType getFunction + ( + const dictionary& parentDict, + const dictionary& codeDict + ); + + //- Disallow default bitwise copy construct codeStream(const codeStream&); @@ -137,6 +148,11 @@ public: //- Name of the C code template to be used static const word codeTemplateC; + // Related types + + //- Declare friendship with the calcEntry class + friend class calcEntry; + //- Runtime type information ClassName("codeStream"); From 77077a83e59fcf335ccb345f9f7cc62a7c596449 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 29 Jun 2011 09:56:51 +0100 Subject: [PATCH 5/6] ENH: stringOps: open OStringStream with fixed precision so floating point numbers get preserved --- src/OpenFOAM/primitives/strings/stringOps/stringOps.C | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C index ebbc47ca3b..bd0ae2c334 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C @@ -328,6 +328,10 @@ Foam::string& Foam::stringOps::inplaceExpand if (ePtr) { OStringStream buf; + // Force floating point numbers to be printed with at least + // some decimal digits. + buf << fixed; + buf.precision(IOstream::defaultPrecision()); if (ePtr->isDict()) { ePtr->dict().write(buf, false); From 0e940e379c38c3e2f9db02eaa1a92d859052949c Mon Sep 17 00:00:00 2001 From: sergio Date: Wed, 29 Jun 2011 12:13:16 +0100 Subject: [PATCH 6/6] ENH: Adding references for the SST-SAS model --- .../LES/kOmegaSSTSAS/kOmegaSSTSAS.H | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/turbulenceModels/incompressible/LES/kOmegaSSTSAS/kOmegaSSTSAS.H b/src/turbulenceModels/incompressible/LES/kOmegaSSTSAS/kOmegaSSTSAS.H index 37d82f4ccb..9fea19fe8e 100644 --- a/src/turbulenceModels/incompressible/LES/kOmegaSSTSAS/kOmegaSSTSAS.H +++ b/src/turbulenceModels/incompressible/LES/kOmegaSSTSAS/kOmegaSSTSAS.H @@ -25,14 +25,23 @@ Class Foam::incompressible::LESModels::kOmegaSSTSAS Description - kOmegaSSTSAS LES turbulence model for incompressible flows + kOmegaSSTSAS LES turbulence model for incompressible flows + based on: + "Evaluation of the SST-SAS model: channel flow, asymmetric diffuser + and axi-symmetric hill". + European Conference on Computational Fluid Dynamics ECCOMAS CFD 2006. + Lars Davidson + + + The first term of the Qsas expression is corrected following: DESider A European Effort on Hybrid RANS-LES Modelling: Results of the European-Union Funded Project, 2004 - 2007 (Notes on Numerical Fluid Mechanics and Multidisciplinary Design). - Chapter 8 Formulation of the Scale-Adaptive Simulation (SAS) Model during - the DESIDER Project. Published in Springer-Verlag Berlin Heidelberg 2009. + Chapter 2, section 8 Formulation of the Scale-Adaptive Simulation (SAS) + Model during the DESIDER Project. Published in Springer-Verlag Berlin + Heidelberg 2009. F. R. Menter and Y. Egorov. SourceFiles