diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C index a6ae8b76817ae687f0635a670bf737bbc385b389..a01fa988d237a3af390626a8eeed6a0f163c5c7f 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkTopology.C @@ -178,12 +178,14 @@ Foam::label Foam::checkTopology if (mesh.checkFaceFaces(true, &faces)) { noFailedChecks++; + } - label nFaces = returnReduce(faces.size(), sumOp<label>()); - + label nFaces = returnReduce(faces.size(), sumOp<label>()); + if (nFaces > 0) + { Info<< " <<Writing " << nFaces - << " faces with incorrect edges to set " << faces.name() - << endl; + << " faces with non-standard edge connectivity to set " + << faces.name() << endl; faces.instance() = mesh.pointsInstance(); faces.write(); } diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index e214e7eecabcf09054838adbc52bfe67ab84a420..7a16679511c654bd484bbdc61b499bde83b255a2 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -1161,7 +1161,7 @@ int Foam::system(const std::string& command) } -void* Foam::dlOpen(const fileName& lib) +void* Foam::dlOpen(const fileName& lib, const bool check) { if (POSIX::debug) { @@ -1170,6 +1170,13 @@ void* Foam::dlOpen(const fileName& lib) } void* handle = ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL); + if (!handle && check) + { + WarningIn("dlOpen(const fileName&, const bool)") + << "dlopen error : " << ::dlerror() + << endl; + } + if (POSIX::debug) { std::cout diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 3e52499e25f7d53c52bda5bc89d72bcf2edb3f40..6e169d64bc54fef0fde90118cdb6ab2b2405bd4f 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -193,6 +193,7 @@ dll = db/dynamicLibrary $(dll)/dlLibraryTable/dlLibraryTable.C $(dll)/dynamicCode/dynamicCode.C $(dll)/dynamicCode/dynamicCodeContext.C +$(dll)/codedBase/codedBase.C db/functionObjects/functionObject/functionObject.C db/functionObjects/functionObjectList/functionObjectList.C diff --git a/src/OpenFOAM/db/Time/Time.C b/src/OpenFOAM/db/Time/Time.C index 0051d23153104f301817f973b09f813bc0de8932..20fca2c4dbea7ff8eb8836600be3ff375697c239 100644 --- a/src/OpenFOAM/db/Time/Time.C +++ b/src/OpenFOAM/db/Time/Time.C @@ -212,6 +212,21 @@ void Foam::Time::setControls() { timeIndex_ = startTimeIndex_; } + + scalar timeValue; + if (timeDict.readIfPresent("value", timeValue)) + { + if (mag(timeValue - value()) > SMALL) + { + IOWarningIn("Time::setControls()", timeDict) + << "Time read from time dictionary " << timeValue + << " differs from actual time " << value() << '.' << nl + << " This may cause unexpected database behaviour." + << " If you are not interested" << nl + << " in preserving time state delete the time dictionary." + << endl; + } + } } diff --git a/src/OpenFOAM/db/Time/Time.H b/src/OpenFOAM/db/Time/Time.H index 0cfe4c51fa9888c5bbebfecf8d271d939207fee8..26e6b21bc7bbeef91186169940c056d17dc68153 100644 --- a/src/OpenFOAM/db/Time/Time.H +++ b/src/OpenFOAM/db/Time/Time.H @@ -416,6 +416,12 @@ public: return functionObjects_; } + //- External access to the loaded libraries + const dlLibraryTable& libs() const + { + return libs_; + } + //- External access to the loaded libraries dlLibraryTable& libs() { diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index 9ed963127d8f7eba9b3dbf92189cd64b2b7075a9..fcf0a969e2d31f3542a92ce9defb4b41fb6b8ff3 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -307,6 +307,7 @@ bool Foam::Time::writeObject ) ); + timeDict.add("value", value()); timeDict.add("index", timeIndex_); timeDict.add("deltaT", deltaT_); timeDict.add("deltaT0", deltaT0_); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index 7d78063d5e813024a384e24ad910a2f8a31f8820..de0b87d9ea9c5cd741023259edcc39dc08d42619 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -143,8 +143,8 @@ Foam::functionEntries::codeStream::getFunction } else { - // Uncached opening of libPath - lib = dlOpen(libPath); + // Uncached opening of libPath. Do not complain if cannot be loaded + lib = dlOpen(libPath, false); } } @@ -226,7 +226,7 @@ Foam::functionEntries::codeStream::getFunction else { // Uncached opening of libPath - lib = dlOpen(libPath); + lib = dlOpen(libPath, true); } } diff --git a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C new file mode 100644 index 0000000000000000000000000000000000000000..c899b97b595549b06ad603a148e7878fe96904f1 --- /dev/null +++ b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C @@ -0,0 +1,288 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "codedBase.H" +#include "SHA1Digest.H" +#include "dynamicCode.H" +#include "dynamicCodeContext.H" +#include "dlLibraryTable.H" +#include "PstreamReduceOps.H" +#include "OSspecific.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +void* Foam::codedBase::loadLibrary +( + const fileName& libPath, + const string& globalFuncName, + const dictionary& contextDict +) const +{ + void* lib = 0; + + // avoid compilation by loading an existing library + if (!libPath.empty()) + { + if (libs().open(libPath, false)) + { + lib = libs().findLibrary(libPath); + + // verify the loaded version and unload if needed + if (lib) + { + // provision for manual execution of code after loading + if (dlSymFound(lib, globalFuncName)) + { + loaderFunctionType function = + reinterpret_cast<loaderFunctionType> + ( + dlSym(lib, globalFuncName) + ); + + if (function) + { + (*function)(true); // force load + } + else + { + FatalIOErrorIn + ( + "codedBase::updateLibrary()", + contextDict + ) << "Failed looking up symbol " << globalFuncName + << nl << "from " << libPath << exit(FatalIOError); + } + } + else + { + FatalIOErrorIn + ( + "codedBase::loadLibrary()", + contextDict + ) << "Failed looking up symbol " << globalFuncName << nl + << "from " << libPath << exit(FatalIOError); + + lib = 0; + if (!libs().close(libPath, false)) + { + FatalIOErrorIn + ( + "codedBase::loadLibrary()", + contextDict + ) << "Failed unloading library " + << libPath + << exit(FatalIOError); + } + } + } + } + } + + return lib; +} + + +void Foam::codedBase::unloadLibrary +( + const fileName& libPath, + const string& globalFuncName, + const dictionary& contextDict +) const +{ + void* lib = 0; + + if (libPath.empty()) + { + return; + } + + lib = libs().findLibrary(libPath); + + if (!lib) + { + return; + } + + // provision for manual execution of code before unloading + if (dlSymFound(lib, globalFuncName)) + { + loaderFunctionType function = + reinterpret_cast<loaderFunctionType> + ( + dlSym(lib, globalFuncName) + ); + + if (function) + { + (*function)(false); // force unload + } + else + { + FatalIOErrorIn + ( + "codedBase::unloadLibrary()", + contextDict + ) << "Failed looking up symbol " << globalFuncName << nl + << "from " << libPath << exit(FatalIOError); + } + } + + if (!libs().close(libPath, false)) + { + FatalIOErrorIn + ( + "codedBase::updateLibrary()", + contextDict + ) << "Failed unloading library " << libPath + << exit(FatalIOError); + } +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::codedBase::createLibrary +( + dynamicCode& dynCode, + const dynamicCodeContext& context +) const +{ + bool create = Pstream::master(); + + if (create) + { + // Write files for new library + if (!dynCode.upToDate(context)) + { + // filter with this context + dynCode.reset(context); + + this->prepare(dynCode, context); + + if (!dynCode.copyOrCreateFiles(true)) + { + FatalIOErrorIn + ( + "codedBase::createLibrary(..)", + context.dict() + ) << "Failed writing files for" << nl + << dynCode.libRelPath() << nl + << exit(FatalIOError); + } + } + + if (!dynCode.wmakeLibso()) + { + FatalIOErrorIn + ( + "codedBase::createLibrary(..)", + context.dict() + ) << "Failed wmake " << dynCode.libRelPath() << nl + << exit(FatalIOError); + } + } + + + // all processes must wait for compile to finish + reduce(create, orOp<bool>()); +} + + +void Foam::codedBase::updateLibrary +( + const word& redirectType +) const +{ + const dictionary& dict = this->codeDict(); + + dynamicCode::checkSecurity + ( + "codedBase::updateLibrary()", + dict + ); + + dynamicCodeContext context(dict); + + // codeName: redirectType + _<sha1> + // codeDir : redirectType + dynamicCode dynCode + ( + redirectType + context.sha1().str(true), + redirectType + ); + const fileName libPath = dynCode.libPath(); + + + // the correct library was already loaded => we are done + if (libs().findLibrary(libPath)) + { + return; + } + + Info<< "Using dynamicCode for " << this->description().c_str() + << " at line " << dict.startLineNumber() + << " in " << dict.name() << endl; + + + // remove instantiation of fvPatchField provided by library + this->clearRedirect(); + + // may need to unload old library + unloadLibrary + ( + oldLibPath_, + dynamicCode::libraryBaseName(oldLibPath_), + context.dict() + ); + + // try loading an existing library (avoid compilation when possible) + if (!loadLibrary(libPath, dynCode.codeName(), context.dict())) + { + createLibrary(dynCode, context); + + loadLibrary(libPath, dynCode.codeName(), context.dict()); + } + + // retain for future reference + oldLibPath_ = libPath; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::codedBase::codedBase() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::codedBase::~codedBase() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H new file mode 100644 index 0000000000000000000000000000000000000000..391c5267c084011f0ae29de4298206305a366e87 --- /dev/null +++ b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ 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 <http://www.gnu.org/licenses/>. + +Class + Foam::codedBase + +Description + Base class for function objects and boundary conditions using dynamic code + +SourceFiles + codedBase.C + +\*---------------------------------------------------------------------------*/ + +#ifndef codedBase_H +#define codedBase_H + +#include "dictionary.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class dynamicCode; +class dynamicCodeContext; +class dlLibraryTable; + +/*---------------------------------------------------------------------------*\ + Class codedBase Declaration +\*---------------------------------------------------------------------------*/ + +class codedBase +{ + // Private data + + //- Previously loaded library + mutable fileName oldLibPath_; + + // Private Member Functions + + //- Global loader/unloader function type + typedef void (*loaderFunctionType)(bool); + + //- Load specified library and execute globalFuncName(true) + void* loadLibrary + ( + const fileName& libPath, + const string& globalFuncName, + const dictionary& contextDict + ) const; + + //- Execute globalFuncName(false) and unload specified library + void unloadLibrary + ( + const fileName& libPath, + const string& globalFuncName, + const dictionary& contextDict + ) const; + + //- Create library based on the dynamicCodeContext + void createLibrary(dynamicCode&, const dynamicCodeContext&) const; + + //- Disallow default bitwise copy construct + codedBase(const codedBase&); + + //- Disallow default bitwise assignment + void operator=(const codedBase&); + + +protected: + + //- Update library as required + void updateLibrary + ( + const word& redirectType + ) const; + + //- get the loaded dynamic libraries + virtual dlLibraryTable& libs() const = 0; + + //- adapt the context for the current object + virtual void prepare + ( + dynamicCode&, + const dynamicCodeContext & + ) const = 0; + + // Return a description (type + name) for the output + virtual string description() const = 0; + + // Clear any redirected objects + virtual void clearRedirect() const = 0; + + // Get the dictionary to initialize the codeContext + virtual const dictionary& codeDict() const = 0; + + +public: + + // Constructors + + //- Construct null + codedBase(); + + + //- Destructor + virtual ~codedBase(); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C index f3628f20813cadd3feea787deb5feda4bbb1a464..48bc178ac6a3749157d7bc35c925ba02ffaa45fa 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C +++ b/src/OpenFOAM/db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C @@ -78,7 +78,7 @@ bool Foam::dlLibraryTable::open { if (functionLibName.size()) { - void* functionLibPtr = dlOpen(functionLibName); + void* functionLibPtr = dlOpen(functionLibName, verbose); if (debug) { diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H index d39a1c54cbb2e4b931cdf768215525a23ef14e3a..14052f8a87654a2d78f452cdec44172af2de7cb8 100644 --- a/src/OpenFOAM/include/OSspecific.H +++ b/src/OpenFOAM/include/OSspecific.H @@ -197,8 +197,9 @@ bool ping(const string&, const label timeOut=10); //- Execute the specified command int system(const std::string& command); -//- open a shared library. Return handle to library -void* dlOpen(const fileName& lib); +//- open a shared library. Return handle to library. Print error message +// if library cannot be loaded (check = true) +void* dlOpen(const fileName& lib, const bool check = true); //- Close a dlopened library using handle. Return true if successful bool dlClose(void*); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C index 4b131118d22ba138e4b8cfd922183619c4819d70..acffe1a9b37a4e3fb2126fa47510822e6b350c56 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C @@ -26,19 +26,10 @@ License #include "codedFixedValueFvPatchField.H" #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" -#include "surfaceFields.H" #include "volFields.H" -#include "dlLibraryTable.H" -#include "IFstream.H" -#include "OFstream.H" -#include "SHA1Digest.H" #include "dynamicCode.H" #include "dynamicCodeContext.H" #include "stringOps.H" -#include "IOdictionary.H" - -#include <dlfcn.h> -#include <link.h> // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -53,142 +44,6 @@ const Foam::word Foam::codedFixedValueFvPatchField<Type>::codeTemplateH // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -template<class Type> -void* Foam::codedFixedValueFvPatchField<Type>::loadLibrary -( - const fileName& libPath, - const string& globalFuncName, - const dictionary& contextDict -) const -{ - void* lib = 0; - - // avoid compilation by loading an existing library - if (!libPath.empty()) - { - dlLibraryTable& libs = const_cast<Time&>(this->db().time()).libs(); - - if (libs.open(libPath, false)) - { - lib = libs.findLibrary(libPath); - - // verify the loaded version and unload if needed - if (lib) - { - // provision for manual execution of code after loading - if (dlSymFound(lib, globalFuncName)) - { - loaderFunctionType function = - reinterpret_cast<loaderFunctionType> - ( - dlSym(lib, globalFuncName) - ); - - if (function) - { - (*function)(true); // force load - } - else - { - FatalIOErrorIn - ( - "codedFixedValueFvPatchField<Type>::" - "updateLibrary()", - contextDict - ) << "Failed looking up symbol " << globalFuncName - << nl << "from " << libPath << exit(FatalIOError); - } - } - else - { - FatalIOErrorIn - ( - "codedFixedValueFvPatchField<Type>::loadLibrary()", - contextDict - ) << "Failed looking up symbol " << globalFuncName << nl - << "from " << libPath << exit(FatalIOError); - - lib = 0; - if (!libs.close(libPath, false)) - { - FatalIOErrorIn - ( - "codedFixedValueFvPatchField<Type>::loadLibrary()", - contextDict - ) << "Failed unloading library " - << libPath - << exit(FatalIOError); - } - } - } - } - } - - return lib; -} - - -template<class Type> -void Foam::codedFixedValueFvPatchField<Type>::unloadLibrary -( - const fileName& libPath, - const string& globalFuncName, - const dictionary& contextDict -) const -{ - void* lib = 0; - - if (libPath.empty()) - { - return; - } - - dlLibraryTable& libs = const_cast<Time&>(this->db().time()).libs(); - - lib = libs.findLibrary(libPath); - - if (!lib) - { - return; - } - - // provision for manual execution of code before unloading - if (dlSymFound(lib, globalFuncName)) - { - loaderFunctionType function = - reinterpret_cast<loaderFunctionType> - ( - dlSym(lib, globalFuncName) - ); - - if (function) - { - (*function)(false); // force unload - } - else - { - FatalIOErrorIn - ( - "codedFixedValueFvPatchField<Type>::unloadLibrary()", - contextDict - ) << "Failed looking up symbol " << globalFuncName << nl - << "from " << libPath << exit(FatalIOError); - } - } - - if (!libs.close(libPath, false)) - { - FatalIOErrorIn - ( - "codedFixedValueFvPatchField<Type>::" - "updateLibrary()", - contextDict - ) << "Failed unloading library " << libPath - << exit(FatalIOError); - } -} - - template<class Type> void Foam::codedFixedValueFvPatchField<Type>::setFieldTemplates ( @@ -238,144 +93,82 @@ const Foam::IOdictionary& Foam::codedFixedValueFvPatchField<Type>::dict() const template<class Type> -void Foam::codedFixedValueFvPatchField<Type>::createLibrary +Foam::dlLibraryTable& Foam::codedFixedValueFvPatchField<Type>::libs() const +{ + return const_cast<dlLibraryTable&>(this->db().time().libs()); +} + + +template<class Type> +void Foam::codedFixedValueFvPatchField<Type>::prepare ( dynamicCode& dynCode, const dynamicCodeContext& context ) const { - bool create = Pstream::master(); - - if (create) - { - // Write files for new library - if (!dynCode.upToDate(context)) - { - // filter with this context - dynCode.reset(context); + // take no chances - typeName must be identical to redirectType_ + dynCode.setFilterVariable("typeName", redirectType_); - // take no chances - typeName must be identical to redirectType_ - dynCode.setFilterVariable("typeName", redirectType_); + // set TemplateType and FieldType filter variables + // (for fvPatchField) + setFieldTemplates(dynCode); - // set TemplateType and FieldType filter variables - // (for fvPatchField) - setFieldTemplates(dynCode); + // compile filtered C template + dynCode.addCompileFile(codeTemplateC); - // compile filtered C template - dynCode.addCompileFile(codeTemplateC); + // copy filtered H template + dynCode.addCopyFile(codeTemplateH); - // copy filtered H template - dynCode.addCopyFile(codeTemplateH); - - - // debugging: make BC verbose - // dynCode.setFilterVariable("verbose", "true"); - // Info<<"compile " << redirectType_ << " sha1: " - // << context.sha1() << endl; - - // define Make/options - dynCode.setMakeOptions - ( - "EXE_INC = -g \\\n" - "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n" - + context.options() - + "\n\nLIB_LIBS = \\\n" - + " -lOpenFOAM \\\n" - + " -lfiniteVolume \\\n" - + context.libs() - ); - - if (!dynCode.copyOrCreateFiles(true)) - { - FatalIOErrorIn - ( - "codedFixedValueFvPatchField<Type>::createLibrary(..)", - context.dict() - ) << "Failed writing files for" << nl - << dynCode.libRelPath() << nl - << exit(FatalIOError); - } - } - - if (!dynCode.wmakeLibso()) - { - FatalIOErrorIn - ( - "codedFixedValueFvPatchField<Type>::createLibrary(..)", - context.dict() - ) << "Failed wmake " << dynCode.libRelPath() << nl - << exit(FatalIOError); - } - } + // debugging: make BC verbose + // dynCode.setFilterVariable("verbose", "true"); + // Info<<"compile " << redirectType_ << " sha1: " + // << context.sha1() << endl; - // all processes must wait for compile to finish - reduce(create, orOp<bool>()); + // define Make/options + dynCode.setMakeOptions + ( + "EXE_INC = -g \\\n" + "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n" + + context.options() + + "\n\nLIB_LIBS = \\\n" + + " -lOpenFOAM \\\n" + + " -lfiniteVolume \\\n" + + context.libs() + ); } template<class Type> -void Foam::codedFixedValueFvPatchField<Type>::updateLibrary() const +const Foam::dictionary& Foam::codedFixedValueFvPatchField<Type>::codeDict() +const { - dynamicCode::checkSecurity - ( - "codedFixedValueFvPatchField<Type>::updateLibrary()", - dict_ - ); - // use system/codeDict or in-line - const dictionary& codeDict = + return ( dict_.found("code") ? dict_ : this->dict().subDict(redirectType_) ); +} - dynamicCodeContext context(codeDict); - - // codeName: redirectType + _<sha1> - // codeDir : redirectType - dynamicCode dynCode - ( - redirectType_ + context.sha1().str(true), - redirectType_ - ); - const fileName libPath = dynCode.libPath(); - - - // the correct library was already loaded => we are done - if (const_cast<Time&>(this->db().time()).libs().findLibrary(libPath)) - { - return; - } - Info<< "Using dynamicCode for patch " << this->patch().name() - << " on field " << this->dimensionedInternalField().name() << nl - << "at line " << codeDict.startLineNumber() - << " in " << codeDict.name() << endl; +template<class Type> +Foam::string Foam::codedFixedValueFvPatchField<Type>::description() const +{ + return + "patch " + + this->patch().name() + + " on field " + + this->dimensionedInternalField().name(); +} +template<class Type> +void Foam::codedFixedValueFvPatchField<Type>::clearRedirect() const +{ // remove instantiation of fvPatchField provided by library redirectPatchFieldPtr_.clear(); - - // may need to unload old library - unloadLibrary - ( - oldLibPath_, - dynamicCode::libraryBaseName(oldLibPath_), - context.dict() - ); - - // try loading an existing library (avoid compilation when possible) - if (!loadLibrary(libPath, dynCode.codeName(), context.dict())) - { - createLibrary(dynCode, context); - - loadLibrary(libPath, dynCode.codeName(), context.dict()); - } - - // retain for future reference - oldLibPath_ = libPath; } @@ -389,7 +182,7 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField ) : fixedValueFvPatchField<Type>(p, iF), - oldLibPath_(), + codedBase(), redirectPatchFieldPtr_() {} @@ -404,9 +197,9 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField ) : fixedValueFvPatchField<Type>(ptf, p, iF, mapper), + codedBase(), dict_(ptf.dict_), redirectType_(ptf.redirectType_), - oldLibPath_(ptf.oldLibPath_), redirectPatchFieldPtr_() {} @@ -420,12 +213,12 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField ) : fixedValueFvPatchField<Type>(p, iF, dict), + codedBase(), dict_(dict), redirectType_(dict.lookup("redirectType")), - oldLibPath_(), redirectPatchFieldPtr_() { - updateLibrary(); + updateLibrary(redirectType_); } @@ -436,9 +229,9 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField ) : fixedValueFvPatchField<Type>(ptf), + codedBase(), dict_(ptf.dict_), redirectType_(ptf.redirectType_), - oldLibPath_(ptf.oldLibPath_), redirectPatchFieldPtr_() {} @@ -451,9 +244,9 @@ Foam::codedFixedValueFvPatchField<Type>::codedFixedValueFvPatchField ) : fixedValueFvPatchField<Type>(ptf, iF), + codedBase(), dict_(ptf.dict_), redirectType_(ptf.redirectType_), - oldLibPath_(ptf.oldLibPath_), redirectPatchFieldPtr_() {} @@ -499,7 +292,7 @@ void Foam::codedFixedValueFvPatchField<Type>::updateCoeffs() } // Make sure library containing user-defined fvPatchField is up-to-date - updateLibrary(); + updateLibrary(redirectType_); const fvPatchField<Type>& fvp = redirectPatchField(); @@ -519,7 +312,7 @@ void Foam::codedFixedValueFvPatchField<Type>::evaluate ) { // Make sure library containing user-defined fvPatchField is up-to-date - updateLibrary(); + updateLibrary(redirectType_); const fvPatchField<Type>& fvp = redirectPatchField(); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H index 86172fe86b66771d91fc78fae2bcf0653d667f0b..56fef9354e49b159835194a49a8e38c2080f38b1 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.H @@ -79,9 +79,7 @@ SourceFiles #define codedFixedValueFvPatchField_H #include "fixedValueFvPatchFields.H" - -#include <dlfcn.h> -#include <link.h> +#include "codedBase.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -100,7 +98,8 @@ class IOdictionary; template<class Type> class codedFixedValueFvPatchField : - public fixedValueFvPatchField<Type> + public fixedValueFvPatchField<Type>, + public codedBase { // Private data @@ -109,51 +108,29 @@ class codedFixedValueFvPatchField const word redirectType_; - //- Previously loaded library - mutable fileName oldLibPath_; - mutable autoPtr<fvPatchField<Type> > redirectPatchFieldPtr_; - // Private Member Functions const IOdictionary& dict() const; - //- Global loader/unloader function type - typedef void (*loaderFunctionType)(bool); - - static int collectLibsCallback - ( - struct dl_phdr_info *info, - size_t size, - void *data - ); - - //- Load specified library and execute globalFuncName(true) - void* loadLibrary - ( - const fileName& libPath, - const string& globalFuncName, - const dictionary& contextDict - ) const; - - //- Execute globalFuncName(false) and unload specified library - void unloadLibrary - ( - const fileName& libPath, - const string& globalFuncName, - const dictionary& contextDict - ) const; - //- Set the rewrite vars controlling the Type static void setFieldTemplates(dynamicCode& dynCode); - //- Create library based on the dynamicCodeContext - void createLibrary(dynamicCode&, const dynamicCodeContext&) const; + //- get the loaded dynamic libraries + virtual dlLibraryTable& libs() const; + + //- adapt the context for the current object + virtual void prepare(dynamicCode&, const dynamicCodeContext&) const; + + // Return a description (type + name) for the output + virtual string description() const; - //- Update library as required - void updateLibrary() const; + // Clear the ptr to the redirected object + virtual void clearRedirect() const; + // Get the dictionary to initialize the codeContext + virtual const dictionary& codeDict() const; public: diff --git a/src/postProcessing/functionObjects/field/streamLine/streamLine.C b/src/postProcessing/functionObjects/field/streamLine/streamLine.C index 03a5b8b539c4b803a9b050dda20a0f9cb3e43ef6..9e8896d7cc454720bcb111e06c8da9d8398b6df0 100644 --- a/src/postProcessing/functionObjects/field/streamLine/streamLine.C +++ b/src/postProcessing/functionObjects/field/streamLine/streamLine.C @@ -43,7 +43,7 @@ defineTypeNameAndDebug(Foam::streamLine, 0); void Foam::streamLine::track() { - const Time& runTime = const_cast<Time&>(obr_.time()); + const Time& runTime = obr_.time(); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); IDLList<streamLineParticle> initialParticles; @@ -383,7 +383,7 @@ void Foam::streamLine::read(const dictionary& dict) void Foam::streamLine::execute() { -// const Time& runTime = const_cast<Time&>(obr_.time()); +// const Time& runTime = obr_.time(); // Pout<< "**streamLine::execute : time:" << runTime.timeName() << endl; // // bool isOutputTime = false; @@ -418,15 +418,14 @@ void Foam::streamLine::execute() void Foam::streamLine::end() -{ -} +{} void Foam::streamLine::write() { if (active_) { - const Time& runTime = const_cast<Time&>(obr_.time()); + const Time& runTime = obr_.time(); const fvMesh& mesh = dynamic_cast<const fvMesh&>(obr_); diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C index c50fa7b64f8de12cf76e6c23f052a2f906acb408..45a915456acfecba35756ab3961db6dd692361dd 100644 --- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C +++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.C @@ -49,271 +49,71 @@ namespace Foam // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -void* Foam::codedFunctionObject::loadLibrary -( - const fileName& libPath, - const string& globalFuncName, - const dictionary& contextDict -) const -{ - void* lib = 0; - - // avoid compilation by loading an existing library - if (!libPath.empty()) - { - dlLibraryTable& libs = const_cast<Time&>(time_).libs(); - - if (libs.open(libPath, false)) - { - lib = libs.findLibrary(libPath); - - // verify the loaded version and unload if needed - if (lib) - { - // provision for manual execution of code after loading - if (dlSymFound(lib, globalFuncName)) - { - loaderFunctionType function = - reinterpret_cast<loaderFunctionType> - ( - dlSym(lib, globalFuncName) - ); - - if (function) - { - (*function)(true); // force load - } - else - { - FatalIOErrorIn - ( - "codedFunctionObject::updateLibrary()", - contextDict - ) << "Failed looking up symbol " << globalFuncName - << nl << "from " << libPath << exit(FatalIOError); - } - } - else - { - FatalIOErrorIn - ( - "codedFunctionObject::loadLibrary()", - contextDict - ) << "Failed looking up symbol " << globalFuncName << nl - << "from " << libPath << exit(FatalIOError); - - lib = 0; - if (!libs.close(libPath, false)) - { - FatalIOErrorIn - ( - "codedFunctionObject::loadLibrary()", - contextDict - ) << "Failed unloading library " - << libPath - << exit(FatalIOError); - } - } - } - } - } - - return lib; -} - - -void Foam::codedFunctionObject::unloadLibrary -( - const fileName& libPath, - const string& globalFuncName, - const dictionary& contextDict -) const -{ - void* lib = 0; - - if (libPath.empty()) - { - return; - } - - dlLibraryTable& libs = const_cast<Time&>(time_).libs(); - - lib = libs.findLibrary(libPath); - - if (!lib) - { - return; - } - - // provision for manual execution of code before unloading - if (dlSymFound(lib, globalFuncName)) - { - loaderFunctionType function = - reinterpret_cast<loaderFunctionType> - ( - dlSym(lib, globalFuncName) - ); - - if (function) - { - (*function)(false); // force unload - } - else - { - FatalIOErrorIn - ( - "codedFunctionObject::unloadLibrary()", - contextDict - ) << "Failed looking up symbol " << globalFuncName << nl - << "from " << libPath << exit(FatalIOError); - } - } - - if (!libs.close(libPath, false)) - { - FatalIOErrorIn - ( - "codedFunctionObject::" - "updateLibrary()", - contextDict - ) << "Failed unloading library " << libPath - << exit(FatalIOError); - } -} - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::codedFunctionObject::createLibrary +void Foam::codedFunctionObject::prepare ( dynamicCode& dynCode, const dynamicCodeContext& context ) const { - bool create = Pstream::master(); - - if (create) - { - // Write files for new library - if (!dynCode.upToDate(context)) - { - // filter with this context - dynCode.reset(context); - - // Set additional rewrite rules - dynCode.setFilterVariable("typeName", redirectType_); - dynCode.setFilterVariable("codeRead", codeRead_); - dynCode.setFilterVariable("codeExecute", codeExecute_); - dynCode.setFilterVariable("codeEnd", codeEnd_); - //dynCode.setFilterVariable("codeWrite", codeWrite_); - - // compile filtered C template - dynCode.addCompileFile("functionObjectTemplate.C"); - dynCode.addCompileFile("FilterFunctionObjectTemplate.C"); - - // copy filtered H template - dynCode.addCopyFile("FilterFunctionObjectTemplate.H"); - dynCode.addCopyFile("functionObjectTemplate.H"); - dynCode.addCopyFile("IOfunctionObjectTemplate.H"); - - // debugging: make BC verbose - // dynCode.setFilterVariable("verbose", "true"); - // Info<<"compile " << redirectType_ << " sha1: " - // << context.sha1() << endl; - - // define Make/options - dynCode.setMakeOptions - ( - "EXE_INC = -g \\\n" - "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n" - + context.options() - + "\n\nLIB_LIBS = \\\n" - + " -lOpenFOAM \\\n" - + " -lfiniteVolume \\\n" - + context.libs() - ); - - if (!dynCode.copyOrCreateFiles(true)) - { - FatalIOErrorIn - ( - "codedFunctionObject::createLibrary(..)", - context.dict() - ) << "Failed writing files for" << nl - << dynCode.libRelPath() << nl - << exit(FatalIOError); - } - } - - if (!dynCode.wmakeLibso()) - { - FatalIOErrorIn - ( - "codedFunctionObject::createLibrary(..)", - context.dict() - ) << "Failed wmake " << dynCode.libRelPath() << nl - << exit(FatalIOError); - } - } - - - // all processes must wait for compile to finish - reduce(create, orOp<bool>()); + // Set additional rewrite rules + dynCode.setFilterVariable("typeName", redirectType_); + dynCode.setFilterVariable("codeRead", codeRead_); + dynCode.setFilterVariable("codeExecute", codeExecute_); + dynCode.setFilterVariable("codeEnd", codeEnd_); + //dynCode.setFilterVariable("codeWrite", codeWrite_); + + // compile filtered C template + dynCode.addCompileFile("functionObjectTemplate.C"); + dynCode.addCompileFile("FilterFunctionObjectTemplate.C"); + + // copy filtered H template + dynCode.addCopyFile("FilterFunctionObjectTemplate.H"); + dynCode.addCopyFile("functionObjectTemplate.H"); + dynCode.addCopyFile("IOfunctionObjectTemplate.H"); + + // debugging: make BC verbose + // dynCode.setFilterVariable("verbose", "true"); + // Info<<"compile " << redirectType_ << " sha1: " + // << context.sha1() << endl; + + // define Make/options + dynCode.setMakeOptions + ( + "EXE_INC = -g \\\n" + "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n" + + context.options() + + "\n\nLIB_LIBS = \\\n" + + " -lOpenFOAM \\\n" + + " -lfiniteVolume \\\n" + + context.libs() + ); } -void Foam::codedFunctionObject::updateLibrary() const +Foam::dlLibraryTable& Foam::codedFunctionObject::libs() const { - dynamicCode::checkSecurity - ( - "codedFunctionObject::updateLibrary()", - dict_ - ); - - dynamicCodeContext context(dict_); - - // codeName: redirectType + _<sha1> - // codeDir : redirectType - dynamicCode dynCode - ( - redirectType_ + context.sha1().str(true), - redirectType_ - ); - const fileName libPath = dynCode.libPath(); - + return const_cast<Time&>(time_).libs(); +} - // the correct library was already loaded => we are done - if (const_cast<Time&>(time_).libs().findLibrary(libPath)) - { - return; - } - Info<< "Using dynamicCode for functionObject " << name() - << " at line " << dict_.startLineNumber() - << " in " << dict_.name() << endl; +Foam::string Foam::codedFunctionObject::description() const +{ + return "functionObject " + name(); +} - // remove instantiation of fvPatchField provided by library +void Foam::codedFunctionObject::clearRedirect() const +{ redirectFunctionObjectPtr_.clear(); +} - // may need to unload old library - unloadLibrary - ( - oldLibPath_, - dynamicCode::libraryBaseName(oldLibPath_), - context.dict() - ); - - // try loading an existing library (avoid compilation when possible) - if (!loadLibrary(libPath, dynCode.codeName(), context.dict())) - { - createLibrary(dynCode, context); - - loadLibrary(libPath, dynCode.codeName(), context.dict()); - } - // retain for future reference - oldLibPath_ = libPath; +const Foam::dictionary& Foam::codedFunctionObject::codeDict() const +{ + return dict_; } @@ -323,14 +123,18 @@ Foam::codedFunctionObject::codedFunctionObject ( const word& name, const Time& time, - const dictionary& dict + const dictionary& dict, + bool readNow ) : functionObject(name), - time_(time), - dict_(dict) + codedBase(), + time_(time) { - read(dict_); + if (readNow) + { + read(dict_); + } } @@ -363,21 +167,21 @@ Foam::codedFunctionObject::redirectFunctionObject() const bool Foam::codedFunctionObject::start() { - updateLibrary(); + updateLibrary(redirectType_); return redirectFunctionObject().start(); } bool Foam::codedFunctionObject::execute(const bool forceWrite) { - updateLibrary(); + updateLibrary(redirectType_); return redirectFunctionObject().execute(forceWrite); } bool Foam::codedFunctionObject::end() { - updateLibrary(); + updateLibrary(redirectType_); return redirectFunctionObject().end(); } @@ -440,7 +244,7 @@ bool Foam::codedFunctionObject::read(const dictionary& dict) ); } - updateLibrary(); + updateLibrary(redirectType_); return redirectFunctionObject().read(dict); } diff --git a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H index c950ea2ab6fce7850d7a63ef9f0bb2731377fd59..9f0659ac72dfe044391c7b7c4c59ea02acb1759a 100644 --- a/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H +++ b/src/postProcessing/functionObjects/utilities/codedFunctionObject/codedFunctionObject.H @@ -35,30 +35,22 @@ SourceFiles #ifndef codedFunctionObject_H #define codedFunctionObject_H -#include "pointFieldFwd.H" #include "functionObject.H" -#include "dictionary.H" +#include "codedBase.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// Forward declaration of classes -class objectRegistry; -class dictionary; -class mapPolyMesh; -class dynamicCode; -class dynamicCodeContext; -class IOdictionary; - /*---------------------------------------------------------------------------*\ Class codedFunctionObject Declaration \*---------------------------------------------------------------------------*/ class codedFunctionObject : - public functionObject + public functionObject, + public codedBase { protected: @@ -76,42 +68,28 @@ protected: string codeExecute_; string codeEnd_; - //- Previously loaded library - mutable fileName oldLibPath_; - //- Underlying functionObject mutable autoPtr<functionObject> redirectFunctionObjectPtr_; - // Private Member Functions - //- Global loader/unloader function type - typedef void (*loaderFunctionType)(bool); + // Protected Member Functions - //- Load specified library and execute globalFuncName(true) - void* loadLibrary - ( - const fileName& libPath, - const string& globalFuncName, - const dictionary& contextDict - ) const; + //- get the loaded dynamic libraries + virtual dlLibraryTable& libs() const; - //- Execute globalFuncName(false) and unload specified library - void unloadLibrary - ( - const fileName& libPath, - const string& globalFuncName, - const dictionary& contextDict - ) const; + //- adapt the context for the current object + virtual void prepare(dynamicCode &,const dynamicCodeContext&) const; + // Return a description (type + name) for the output + virtual string description() const; - //- Create library based on the dynamicCodeContext - void createLibrary(dynamicCode&, const dynamicCodeContext&) const; + // Clear any redirected objects + virtual void clearRedirect() const; - //- Update library as required - void updateLibrary() const; + // Get the dictionary to initialize the codeContext + virtual const dictionary& codeDict() const; - //- Read relevant dictionary entries - void readDict(); +private: //- Disallow default bitwise copy construct codedFunctionObject(const codedFunctionObject&); @@ -134,7 +112,8 @@ public: ( const word& name, const Time& time, - const dictionary& dict + const dictionary& dict, + bool readNow=true // allow child-classes to avoid compilation ); diff --git a/tutorials/basic/potentialFoam/cylinder/0.org/U b/tutorials/basic/potentialFoam/cylinder/0.org/U index 550f88b5a4baf24eafed5827977eda38bc2be071..4d3f4887056b3e3534a90f3c1615c1afd4df2ea5 100644 --- a/tutorials/basic/potentialFoam/cylinder/0.org/U +++ b/tutorials/basic/potentialFoam/cylinder/0.org/U @@ -37,8 +37,8 @@ boundaryField left { - type fixedValue; - value uniform (1 0 0); + type uniformFixedValue; + uniformValue (1 0 0); } cylinder diff --git a/tutorials/basic/potentialFoam/cylinder/system/controlDict b/tutorials/basic/potentialFoam/cylinder/system/controlDict index cb71c177167951986e76cb6fc87d0e06e31e698a..8bfa888ba1d36cf4a2a821ded821f7394f1bf0f2 100644 --- a/tutorials/basic/potentialFoam/cylinder/system/controlDict +++ b/tutorials/basic/potentialFoam/cylinder/system/controlDict @@ -62,19 +62,39 @@ functions Info<< "Reading inlet velocity uInfX\n" << endl; + scalar ULeft = 0.0; + label leftI = mesh().boundaryMesh().findPatchID("left"); + const fvPatchVectorField& fvp = U.boundaryField()[leftI]; + if (fvp.size()) + { + ULeft = fvp[0].x(); + } + reduce(ULeft, maxOp<scalar>()); + dimensionedScalar uInfX ( "uInfx", dimensionSet(0, 1, -1, 0, 0), - U.boundaryField()[3][0].x() + ULeft ); + Info << "U at inlet = " << uInfX.value() << " m/s" << endl; + + scalar magCylinder = 0.0; + label cylI = mesh().boundaryMesh().findPatchID("cylinder"); + const fvPatchVectorField& cylFvp = mesh().C().boundaryField()[cylI]; + if (cylFvp.size()) + { + magCylinder = mag(cylFvp[0]); + } + reduce(magCylinder, maxOp<scalar>()); + dimensionedScalar radius ( "radius", dimensionSet(0, 1, 0, 0, 0), - mag(U.mesh().boundary()[4].Cf()[0]) + magCylinder ); Info << "Cylinder radius = " << radius.value() << " m" << endl; diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/Allclean b/tutorials/incompressible/pisoFoam/les/motorBike/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..ed221771be97b912d534e7e440fcec5582b1856a --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/Allclean @@ -0,0 +1,11 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +(cd motorBike && ./Allclean) + +rm -rf motorBikeLES + +# ----------------------------------------------------------------- end-of-file diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/Allrun b/tutorials/incompressible/pisoFoam/les/motorBike/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..634e4374e3394d8b3b22835a3dfd2dc32023b775 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/Allrun @@ -0,0 +1,35 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + + +cloneParallelCase() +{ + if [ -d $2 ] + then + echo "Case already cloned: remove case directory $2 to clone" + else + echo "Cloning $2 case from $1 in parallel mode" + mkdir $2 + cpfiles="0 0.org processor* system constant" + for f in $cpfiles + do + cp -r $1/$f $2 + done + fi +} + + +# Do the Spalart-Allmaras steady-state case +(cd motorBike && foamRunTutorials) + +# Clone the steady-stae case to the LES case +cloneParallelCase motorBike motorBikeLES + +# Do the LES case +cp lesFiles/Allrun motorBikeLES/ +(cd motorBikeLES && foamRunTutorials) + +# ----------------------------------------------------------------- end-of-file diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/Allrun b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..816c0eb32fa979079d650ce3cb8953b8a9d0840f --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/Allrun @@ -0,0 +1,25 @@ +#!/bin/sh + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + + +# Set-up the LES case +cp ../lesFiles/fvS* ../lesFiles/controlDict system/ +cp ../lesFiles/LESProperties ../lesFiles/turbulenceProperties constant/ +cp ../lesFiles/nuSgs 0/ + +ls -d processor* | xargs -i rm -rf ./{}/0 $1 +ls -d processor* | xargs -i mv ./{}/500 ./{}/0 $1 +ls -d processor* | xargs -i rm -rf ./{}/0/uniform $1 + +ls -d processor* | xargs -i cp ../lesFiles/LESProperties ./{}/constant/ $1 +ls -d processor* | xargs -i cp ../lesFiles/turbulenceProperties ./{}/constant/ $1 +ls -d processor* | xargs -i cp ../lesFiles/nuSgs ./{}/0/ $1 + + +runParallel pisoFoam 8 + +runApplication reconstructParMesh -constant -mergeTol 1e-6 + +runApplication reconstructPar diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/LESProperties b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/LESProperties new file mode 100644 index 0000000000000000000000000000000000000000..9d0f065bf4f59df6525e67f281a076b303d9945b --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/LESProperties @@ -0,0 +1,203 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object LESProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +LESModel SpalartAllmarasDDES; + +delta cubeRootVol; + +printCoeffs on; + +laminarCoeffs +{ +} + +oneEqEddyCoeffs +{ + ck 0.07; + ce 1.05; +} + +dynOneEqEddyCoeffs +{ + ce 1.05; + filter simple; +} + +locDynOneEqEddyCoeffs +{ + ce 1.05; + filter simple; +} + +SmagorinskyCoeffs +{ + ce 1.05; + ck 0.07; +} + +Smagorinsky2Coeffs +{ + ce 1.05; + ck 0.07; + cD2 0.02; +} + +spectEddyViscCoeffs +{ + ce 1.05; + cB 8.22; + cK1 0.83; + cK2 1.03; + cK3 4.75; + cK4 2.55; +} + +dynSmagorinskyCoeffs +{ + ce 1.05; + filter simple; +} + +mixedSmagorinskyCoeffs +{ + ce 1.05; + ck 0.07; + filter simple; +} + +dynMixedSmagorinskyCoeffs +{ + ce 1.05; + filter simple; +} + +LRRDiffStressCoeffs +{ + ce 1.05; + ck 0.09; + c1 1.8; + c2 0.6; +} + +DeardorffDiffStressCoeffs +{ + ce 1.05; + ck 0.09; + cm 4.13; +} + +SpalartAllmarasCoeffs +{ + alphaNut 1.5; + Cb1 0.1355; + Cb2 0.622; + Cw2 0.3; + Cw3 2; + Cv1 7.1; + Cv2 5.0; + CDES 0.65; + ck 0.07; +} + +SpalartAllmarasDDESCoeffs +{ + alphaNut 1.5; + Cb1 0.1355; + Cb2 0.622; + Cw2 0.3; + Cw3 2.0; + Cv1 7.1; + Cv2 5.0; + CDES 0.65; + ck 0.07; +} + +SpalartAllmarasIDDESCoeffs +{ + alphaNut 1.5; + kappa 0.4187; + Cb1 0.1355; + Cb2 0.622; + Cw2 0.3; + Cw3 2.0; + Cv1 7.1; + Cv2 5.0; + CDES 0.65; + ck 0.07; +} + +cubeRootVolCoeffs +{ + deltaCoeff 1; +} + +PrandtlCoeffs +{ + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 1; + } + smoothCoeffs + { + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 1; + } + maxDeltaRatio 1.1; + } + Cdelta 0.158; +} + +vanDriestCoeffs +{ + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 1; + } + smoothCoeffs + { + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 1; + } + maxDeltaRatio 1.1; + } + Aplus 26; + Cdelta 0.158; +} + +smoothCoeffs +{ + delta cubeRootVol; + cubeRootVolCoeffs + { + deltaCoeff 1; + } + maxDeltaRatio 1.1; +} + +kappa 0.4187; + +wallFunctionCoeffs +{ + E 9; +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/controlDict b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..86a623e50622a3c8871605c258c17082054f4c72 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/controlDict @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +libs ("libOpenFOAM.so" "libfieldFunctionObjects.so"); + +application pisoFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.7; + +deltaT 1e-4; + +writeControl timeStep; + +writeInterval 1000; + +purgeWrite 0; + +writeFormat binary; + +writePrecision 6; + +writeCompression compressed; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + + +functions +{ + #include "readFields" + #include "cuttingPlane" + #include "streamLines" + #include "forceCoeffs" +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/fvSchemes b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..3d223e01d629d25a16d5ea038fb4d76fb4fe682d --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/fvSchemes @@ -0,0 +1,67 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default backward; +} + +d2dt2Schemes +{ +} + +gradSchemes +{ + default Gauss linear; + + grad(nuTilda) cellLimited Gauss linear 1; + grad(U) cellLimited Gauss linear 1; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss LUST unlimitedGrad(U); + //div(phi,U) Gauss linearUpwind unlimitedGrad(U); + div(phi,k) Gauss limitedLinear 1; + div(phi,nuTilda) Gauss limitedLinear 1; + + div((nuEff*dev(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear limited 0.33; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default limited 0.33; +} + +fluxRequired +{ + default no; + p; +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/fvSolution b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..b9746715211f160ea595414c9fe836b06a7a0983 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/fvSolution @@ -0,0 +1,113 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + p + { + solver GAMG; + tolerance 1e-6; + relTol 0.1; + + smoother GaussSeidel; + nPreSweeps 0; + nPostSweeps 2; + + cacheAgglomeration true; + + nCellsInCoarsestLevel 50;//10; + agglomerator faceAreaPair; + mergeLevels 1; + }; + + pFinal + { + solver GAMG; + tolerance 1e-6; + relTol 0; + + smoother GaussSeidel; + nPreSweeps 0; + nPostSweeps 2; + + cacheAgglomeration true; + + nCellsInCoarsestLevel 50;//10; + agglomerator faceAreaPair; + mergeLevels 1; + }; + + U + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-08; + relTol 0; + }; + + UFinal + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-08; + relTol 0; + }; + + k + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-07; + relTol 0; + }; + + B + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-07; + relTol 0; + }; + + nuTilda + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-07; + relTol 0; + }; +} + +PISO +{ + nCorrectors 2; + nNonOrthogonalCorrectors 1; +} + +PIMPLE +{ + nCorrectors 2; + nNonOrthogonalCorrectors 1; +} + +relaxationFactors +{ + U 1; + nuTilda 1; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/nuSgs b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/nuSgs new file mode 100644 index 0000000000000000000000000000000000000000..de6bdb62f713249faf33950b93bd6656373f7494 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/nuSgs @@ -0,0 +1,64 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object nuSgs; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 0.0544766; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform 0.0544766; + } + + outlet + { + type inletOutlet; + inletValue uniform 0.0544766; + value uniform 0.0544766; + } + + frontAndBack + { + type symmetryPlane; + } + + lowerWall + { + type nuSgsUSpaldingWallFunction; + value uniform 0.0544766; + } + + upperWall + { + type symmetryPlane; + } + + "motorBike_.*" + { + type nuSgsUSpaldingWallFunction; + value uniform 0.0544766; + } + + "proc.*" + { + type processor; + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/turbulenceProperties b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..0000f87e4389e5e490be5c0bc11727c54eb19d3d --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/lesFiles/turbulenceProperties @@ -0,0 +1,175 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType LESModel; + +turbulenceModel SpalartAllmaras; //kEpsilon; + +turbulence on; + +laminarCoeffs +{ +} + +kEpsilonCoeffs +{ + Cmu Cmu [0 0 0 0 0 0 0] 0.09; + C1 C1 [0 0 0 0 0 0 0] 1.44; + C2 C2 [0 0 0 0 0 0 0] 1.92; + alphaEps alphaEps [0 0 0 0 0 0 0] 0.76923; +} + +RNGkEpsilonCoeffs +{ + Cmu Cmu [0 0 0 0 0 0 0] 0.0845; + C1 C1 [0 0 0 0 0 0 0] 1.42; + C2 C2 [0 0 0 0 0 0 0] 1.68; + alphak alphaK [0 0 0 0 0 0 0] 1.39; + alphaEps alphaEps [0 0 0 0 0 0 0] 1.39; + eta0 eta0 [0 0 0 0 0 0 0] 4.38; + beta beta [0 0 0 0 0 0 0] 0.012; +} + +NonlinearKEShihCoeffs +{ + Cmu Cmu [0 0 0 0 0 0 0] 0.09; + C1 C1 [0 0 0 0 0 0 0] 1.44; + C2 C2 [0 0 0 0 0 0 0] 1.92; + alphak alphak [0 0 0 0 0 0 0] 1; + alphaEps alphaEps [0 0 0 0 0 0 0] 0.76932; + A1 A1 [0 0 0 0 0 0 0] 1.25; + A2 A2 [0 0 0 0 0 0 0] 1000; + Ctau1 Ctau1 [0 0 0 0 0 0 0] -4; + Ctau2 Ctau2 [0 0 0 0 0 0 0] 13; + Ctau3 Ctau3 [0 0 0 0 0 0 0] -2; + alphaKsi alphaKsi [0 0 0 0 0 0 0] 0.9; +} + +LienCubicKECoeffs +{ + C1 C1 [0 0 0 0 0 0 0] 1.44; + C2 C2 [0 0 0 0 0 0 0] 1.92; + alphak alphak [0 0 0 0 0 0 0] 1; + alphaEps alphaEps [0 0 0 0 0 0 0] 0.76923; + A1 A1 [0 0 0 0 0 0 0] 1.25; + A2 A2 [0 0 0 0 0 0 0] 1000; + Ctau1 Ctau1 [0 0 0 0 0 0 0] -4; + Ctau2 Ctau2 [0 0 0 0 0 0 0] 13; + Ctau3 Ctau3 [0 0 0 0 0 0 0] -2; + alphaKsi alphaKsi [0 0 0 0 0 0 0] 0.9; +} + +QZetaCoeffs +{ + Cmu Cmu [0 0 0 0 0 0 0] 0.09; + C1 C1 [0 0 0 0 0 0 0] 1.44; + C2 C2 [0 0 0 0 0 0 0] 1.92; + alphaZeta alphaZeta [0 0 0 0 0 0 0] 0.76923; + anisotropic no; +} + +LaunderSharmaKECoeffs +{ + Cmu Cmu [0 0 0 0 0 0 0] 0.09; + C1 C1 [0 0 0 0 0 0 0] 1.44; + C2 C2 [0 0 0 0 0 0 0] 1.92; + alphaEps alphaEps [0 0 0 0 0 0 0] 0.76923; +} + +LamBremhorstKECoeffs +{ + Cmu Cmu [0 0 0 0 0 0 0] 0.09; + C1 C1 [0 0 0 0 0 0 0] 1.44; + C2 C2 [0 0 0 0 0 0 0] 1.92; + alphaEps alphaEps [0 0 0 0 0 0 0] 0.76923; +} + +LienCubicKELowReCoeffs +{ + Cmu Cmu [0 0 0 0 0 0 0] 0.09; + C1 C1 [0 0 0 0 0 0 0] 1.44; + C2 C2 [0 0 0 0 0 0 0] 1.92; + alphak alphak [0 0 0 0 0 0 0] 1; + alphaEps alphaEps [0 0 0 0 0 0 0] 0.76923; + A1 A1 [0 0 0 0 0 0 0] 1.25; + A2 A2 [0 0 0 0 0 0 0] 1000; + Ctau1 Ctau1 [0 0 0 0 0 0 0] -4; + Ctau2 Ctau2 [0 0 0 0 0 0 0] 13; + Ctau3 Ctau3 [0 0 0 0 0 0 0] -2; + alphaKsi alphaKsi [0 0 0 0 0 0 0] 0.9; + Am Am [0 0 0 0 0 0 0] 0.016; + Aepsilon Aepsilon [0 0 0 0 0 0 0] 0.263; + Amu Amu [0 0 0 0 0 0 0] 0.00222; +} + +LienLeschzinerLowReCoeffs +{ + Cmu Cmu [0 0 0 0 0 0 0] 0.09; + C1 C1 [0 0 0 0 0 0 0] 1.44; + C2 C2 [0 0 0 0 0 0 0] 1.92; + alphak alphak [0 0 0 0 0 0 0] 1; + alphaEps alphaEps [0 0 0 0 0 0 0] 0.76923; + Am Am [0 0 0 0 0 0 0] 0.016; + Aepsilon Aepsilon [0 0 0 0 0 0 0] 0.263; + Amu Amu [0 0 0 0 0 0 0] 0.00222; +} + +LRRCoeffs +{ + Cmu Cmu [0 0 0 0 0 0 0] 0.09; + Clrr1 Clrr1 [0 0 0 0 0 0 0] 1.8; + Clrr2 Clrr2 [0 0 0 0 0 0 0] 0.6; + C1 C1 [0 0 0 0 0 0 0] 1.44; + C2 C2 [0 0 0 0 0 0 0] 1.92; + Cs Cs [0 0 0 0 0 0 0] 0.25; + Ceps Ceps [0 0 0 0 0 0 0] 0.15; + alphaEps alphaEps [0 0 0 0 0 0 0] 0.76923; +} + +LaunderGibsonRSTMCoeffs +{ + Cmu Cmu [0 0 0 0 0 0 0] 0.09; + Clg1 Clg1 [0 0 0 0 0 0 0] 1.8; + Clg2 Clg2 [0 0 0 0 0 0 0] 0.6; + C1 C1 [0 0 0 0 0 0 0] 1.44; + C2 C2 [0 0 0 0 0 0 0] 1.92; + C1Ref C1Ref [0 0 0 0 0 0 0] 0.5; + C2Ref C2Ref [0 0 0 0 0 0 0] 0.3; + Cs Cs [0 0 0 0 0 0 0] 0.25; + Ceps Ceps [0 0 0 0 0 0 0] 0.15; + alphaEps alphaEps [0 0 0 0 0 0 0] 0.76923; + alphaR alphaR [0 0 0 0 0 0 0] 1.22; +} + +SpalartAllmarasCoeffs +{ + alphaNut alphaNut [0 0 0 0 0 0 0] 1.5; + Cb1 Cb1 [0 0 0 0 0 0 0] 0.1355; + Cb2 Cb2 [0 0 0 0 0 0 0] 0.622; + Cw2 Cw2 [0 0 0 0 0 0 0] 0.3; + Cw3 Cw3 [0 0 0 0 0 0 0] 2; + Cv1 Cv1 [0 0 0 0 0 0 0] 7.1; + //Next line Modified vorticity factor by Ashford 1996 + Cv2 Cv2 [0 0 0 0 0 0 0] 5.0; +} + +wallFunctionCoeffs +{ + kappa kappa [0 0 0 0 0 0 0] 0.4187; + E E [0 0 0 0 0 0 0] 9; +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/U b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/U new file mode 100644 index 0000000000000000000000000000000000000000..8cbb63e11608b0080a911f2591fc31af47ef1a9b --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/U @@ -0,0 +1,68 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +flowVelocity ( 20 0 0 ); + +pressure 0; + +turbulentKE 0.24; + +turbulentOmega 1.78; + +dimensions [ 0 1 -1 0 0 0 0 ]; + +internalField uniform ( 20 0 0 ); + +boundaryField +{ + inlet + { + type fixedValue; + value uniform ( 20 0 0 ); + } + outlet + { + type inletOutlet; + inletValue uniform ( 0 0 0 ); + value uniform ( 20 0 0 ); + } + lowerWall + { + type fixedValue; + value uniform ( 20 0 0 ); + } + "motorBike_.*" + { + type fixedValue; + value uniform ( 0 0 0 ); + } + upperWall + { + type symmetryPlane; + } + frontAndBack + { + type symmetryPlane; + } + "proc.*" + { + type processor; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/include/fixedInlet b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/include/fixedInlet new file mode 100644 index 0000000000000000000000000000000000000000..f88cacb61ee8fec3dd996a90e9e92436e2fa569d --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/include/fixedInlet @@ -0,0 +1,15 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +inlet +{ + type fixedValue; + value $internalField; +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/include/frontBackUpperPatches b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/include/frontBackUpperPatches new file mode 100644 index 0000000000000000000000000000000000000000..69519e55ad077a0426254a46a79e65935e095f54 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/include/frontBackUpperPatches @@ -0,0 +1,19 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +upperWall +{ + type symmetryPlane; +} + +frontAndBack +{ + type symmetryPlane; +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/include/initialConditions b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/include/initialConditions new file mode 100644 index 0000000000000000000000000000000000000000..43b32387cf3a54b3994dbf18b754289e524a87f3 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/include/initialConditions @@ -0,0 +1,15 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +flowVelocity (20 0 0); +pressure 0; +turbulentKE 0.24; +turbulentOmega 1.78; +#inputMode merge + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/k b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/k new file mode 100644 index 0000000000000000000000000000000000000000..17fb5eca6d05e1702952e9b9bf20ac7d11889c8d --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/k @@ -0,0 +1,60 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 2 -2 0 0 0 0 ]; + +internalField uniform 0.24; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform 0.24; + } + outlet + { + type inletOutlet; + inletValue uniform 0.24; + value uniform 0.24; + } + lowerWall + { + type kqRWallFunction; + value uniform 0.24; + } + "motorBike_.*" + { + type kqRWallFunction; + value uniform 0.24; + } + upperWall + { + type symmetryPlane; + } + frontAndBack + { + type symmetryPlane; + } + "proc.*" + { + type processor; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/nuTilda b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/nuTilda new file mode 100644 index 0000000000000000000000000000000000000000..8fb0fba67ec954e8fcc9436c52270edd5f2512cb --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/nuTilda @@ -0,0 +1,60 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object nuTilda; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 2 -1 0 0 0 0 ]; + +internalField uniform 0.05; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform 0.05; + } + outlet + { + type inletOutlet; + inletValue uniform 0.05; + value uniform 0.05; + } + lowerWall + { + type fixedValue; + value uniform 0; + } + "motorBike_.*" + { + type fixedValue; + value uniform 0; + } + upperWall + { + type symmetryPlane; + } + frontAndBack + { + type symmetryPlane; + } + "proc.*" + { + type processor; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/nut b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/nut new file mode 100644 index 0000000000000000000000000000000000000000..9f5768c2e73c9231f2b6a5e86171b814217b6b2b --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/nut @@ -0,0 +1,61 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object nut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 2 -1 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + frontAndBack + { + type symmetryPlane; + value uniform 0; + } + inlet + { + type calculated; + value uniform 0; + } + outlet + { + type calculated; + value uniform 0; + } + lowerWall + { + type nutUSpaldingWallFunction; + value uniform 0; + } + upperWall + { + type symmetryPlane; + value uniform 0; + } + "motorBike_.*" + { + type nutUSpaldingWallFunction; + value uniform 0; + } + "proc.*" + { + type processor; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/p b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/p new file mode 100644 index 0000000000000000000000000000000000000000..ea47d98bd969451e359de3dab54bf8477d8ecab5 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/0.org/p @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 2 -2 0 0 0 0 ]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type zeroGradient; + } + outlet + { + type fixedValue; + value uniform 0; + } + lowerWall + { + type zeroGradient; + } + "motorBike_.*" + { + type zeroGradient; + } + upperWall + { + type symmetryPlane; + } + frontAndBack + { + type symmetryPlane; + } + "proc.*" + { + type processor; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/Allclean b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..51722330009f7c61c22ef6b77695c20eabc0e829 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/Allclean @@ -0,0 +1,14 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +rm -rf 0 > /dev/null 2>&1 + +cleanCase + +# Reset decomposeParDict +cp system/decomposeParDict.hierarchical system/decomposeParDict + +# ----------------------------------------------------------------- end-of-file diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/Allrun b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..a49569ec1494e46e3d72cb724ea5b58d63e61d2c --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/Allrun @@ -0,0 +1,31 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + + +# Make dummy 0 directory +mkdir 0 + +runApplication blockMesh + +cp system/decomposeParDict.hierarchical system/decomposeParDict + +runApplication decomposePar + +cp system/decomposeParDict.ptscotch system/decomposeParDict + +runParallel snappyHexMesh 8 -overwrite -parallel + +find . -type f -iname "*level*" -exec rm {} \; + +ls -d processor* | xargs -i cp -r 0.org/* ./{}/0/ $1 + +runParallel renumberMesh 8 -overwrite + +runParallel potentialFoam 8 -initialiseUBCs -noFunctionObjects + +runParallel `getApplication` 8 + +# ----------------------------------------------------------------- end-of-file diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/RASProperties b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/RASProperties new file mode 100644 index 0000000000000000000000000000000000000000..d76eff61b45de9bd893feffcac2124a15a592133 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/RASProperties @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +RASModel SpalartAllmaras; + +turbulence on; + +printCoeffs on; + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/polyMesh/blockMeshDict b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/polyMesh/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..ecd71ab96cbc821f0b2d3aa7f006578aca6009d6 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/polyMesh/blockMeshDict @@ -0,0 +1,86 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (-5 -4 0) + (15 -4 0) + (15 4 0) + (-5 4 0) + (-5 -4 8) + (15 -4 8) + (15 4 8) + (-5 4 8) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (20 8 8) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + frontAndBack + { + type symmetryPlane; + faces + ( + (3 7 6 2) + (1 5 4 0) + ); + } + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + outlet + { + type patch; + faces + ( + (2 6 5 1) + ); + } + lowerWall + { + type wall; + faces + ( + (0 3 2 1) + ); + } + upperWall + { + type symmetryPlane; + faces + ( + (4 5 6 7) + ); + } +); + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/polyMesh/blockMeshDict.8pSmall b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/polyMesh/blockMeshDict.8pSmall new file mode 100644 index 0000000000000000000000000000000000000000..9272e69301522a40d59f915a105738c04dbf38b7 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/polyMesh/blockMeshDict.8pSmall @@ -0,0 +1,86 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (-5 -4 0) + (15 -4 0) + (15 4 0) + (-5 4 0) + (-5 -4 8) + (15 -4 8) + (15 4 8) + (-5 4 8) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (20 10 10) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + frontAndBack + { + type symmetryPlane; + faces + ( + (3 7 6 2) + (1 5 4 0) + ); + } + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + outlet + { + type patch; + faces + ( + (2 6 5 1) + ); + } + lowerWall + { + type wall; + faces + ( + (0 3 2 1) + ); + } + upperWall + { + type symmetryPlane; + faces + ( + (4 5 6 7) + ); + } +); + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/polyMesh/boundary b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/polyMesh/boundary new file mode 100644 index 0000000000000000000000000000000000000000..42ee5fbee4ef5ee3fe94affed563830335f56f4b --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/polyMesh/boundary @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class polyBoundaryMesh; + location "constant/polyMesh"; + object boundary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +5 +( + frontAndBack + { + type symmetryPlane; + nFaces 320; + startFace 3456; + } + inlet + { + type patch; + nFaces 64; + startFace 3776; + } + outlet + { + type patch; + nFaces 64; + startFace 3840; + } + lowerWall + { + type wall; + nFaces 160; + startFace 3904; + } + upperWall + { + type symmetryPlane; + nFaces 160; + startFace 4064; + } +) + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/transportProperties b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..9b4179188642faea47f9600747f3c6604a272fe7 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/transportProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +transportModel Newtonian; + +nu nu [0 2 -1 0 0 0 0] 1.5e-05; + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/triSurface/motorBike.stl b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/triSurface/motorBike.stl new file mode 100644 index 0000000000000000000000000000000000000000..ea9666fcf2db9cb1f0237ee80849acabf6b67dcf Binary files /dev/null and b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/constant/triSurface/motorBike.stl differ diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/controlDict b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..e252c42dda0a54fa639c81e801e6a68f59efca04 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/controlDict @@ -0,0 +1,112 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +libs ("libOpenFOAM.so" "libfieldFunctionObjects.so"); + +application simpleFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 500; + +deltaT 1; + +writeControl timeStep; + +writeInterval 500; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression compressed; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +functions +{ + readFields + { + functionObjectLibs ( "libfieldFunctionObjects.so" ); + type readFields; + fields ( p U ); + } + streamLines + { + type streamLine; + outputControl outputTime; + setFormat vtk; + U U; + trackForward true; + fields ( p U ); + lifeTime 10000; + nSubCycle 5; + cloudName particleTracks; + seedSampleSet uniform; + uniformCoeffs + { + type uniform; + axis x; + start ( -1.001 1e-07 0.0011 ); + end ( -1.001 1e-07 1.0011 ); + nPoints 20; + } + } + cuttingPlane + { + type surfaces; + functionObjectLibs ( "libsampling.so" ); + outputControl outputTime; + surfaceFormat vtk; + fields ( p U ); + interpolationScheme cellPoint; + surfaces ( yNormal { type cuttingPlane ; planeType pointAndNormal ; pointAndNormalDict { basePoint ( 0 0 0 ) ; normalVector ( 0 1 0 ) ; } interpolate true ; } ); + } + forces + { + type forceCoeffs; + functionObjectLibs ( "libforces.so" ); + outputControl timeStep; + outputInterval 1; + patches ( "motorBike.*" ); + pName p; + UName U; + rhoName rhoInf; + log true; + rhoInf 1; + liftDir ( 0 0 1 ); + dragDir ( 1 0 0 ); + CofR ( 0.72 0 0 ); + pitchAxis ( 0 1 0 ); + magUInf 20; + lRef 1.42; + Aref 0.75; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/cuttingPlane b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/cuttingPlane new file mode 100644 index 0000000000000000000000000000000000000000..140f824423cf0b244df6560bbe8f47c2ce8a1a9d --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/cuttingPlane @@ -0,0 +1,37 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +cuttingPlane +{ + type surfaces; + functionObjectLibs ("libsampling.so"); + outputControl outputTime; + + surfaceFormat vtk; + fields ( p U ); + + interpolationScheme cellPoint; + + surfaces + ( + yNormal + { + type cuttingPlane; + planeType pointAndNormal; + pointAndNormalDict + { + basePoint (0 0 0); + normalVector (0 1 0); + } + interpolate true; + } + ); +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/decomposeParDict b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..fd59ef09a0868db7cd5e8d515d5f1bf382708ed0 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/decomposeParDict @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 8; + +method hierarchical; + +simpleCoeffs +{ + n ( 4 1 1 ); + delta 0.001; +} + +hierarchicalCoeffs +{ + n ( 4 2 1 ); + delta 0.001; + order xyz; +} + +manualCoeffs +{ + dataFile "cellDecomposition"; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/decomposeParDict.hierarchical b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/decomposeParDict.hierarchical new file mode 100644 index 0000000000000000000000000000000000000000..fd59ef09a0868db7cd5e8d515d5f1bf382708ed0 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/decomposeParDict.hierarchical @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 8; + +method hierarchical; + +simpleCoeffs +{ + n ( 4 1 1 ); + delta 0.001; +} + +hierarchicalCoeffs +{ + n ( 4 2 1 ); + delta 0.001; + order xyz; +} + +manualCoeffs +{ + dataFile "cellDecomposition"; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/decomposeParDict.ptscotch b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/decomposeParDict.ptscotch new file mode 100644 index 0000000000000000000000000000000000000000..b5e57eb1124f0be3cd7a35a34e0af1bb1a389448 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/decomposeParDict.ptscotch @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 8; + +method ptscotch; + +simpleCoeffs +{ + n ( 4 1 1 ); + delta 0.001; +} + +hierarchicalCoeffs +{ + n ( 4 2 1 ); + delta 0.001; + order xyz; +} + +manualCoeffs +{ + dataFile "cellDecomposition"; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/forceCoeffs b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/forceCoeffs new file mode 100644 index 0000000000000000000000000000000000000000..8e8704743c969fa5c9d7423cb34807777b49e09b --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/forceCoeffs @@ -0,0 +1,32 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +forces +{ + type forceCoeffs; + functionObjectLibs ( "libforces.so" ); + outputControl timeStep; + outputInterval 1; + + patches ( "motorBike.*" ); + pName p; + UName U; + rhoName rhoInf; // Indicates incompressible + log true; + rhoInf 1; // Redundant for incompressible + liftDir (0 0 1); + dragDir (1 0 0); + CofR (0.72 0 0); // Axle midpoint on ground + pitchAxis (0 1 0); + magUInf 20; + lRef 1.42; // Wheelbase length + Aref 0.75; // Estimated +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/fvSchemes b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..9050cc767a2b1d7e49c827109723edea508b8060 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/fvSchemes @@ -0,0 +1,62 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; + grad(U) cellLimited Gauss linear 1; + grad(nuTilda) cellLimited Gauss linear 1; +} + +divSchemes +{ + default none; + div(phi,U) Gauss linearUpwindV grad(U); + div(phi,k) Gauss upwind; + div(phi,omega) Gauss upwind; + div((nuEff*dev(T(grad(U))))) Gauss linear; + div(phi,nuTilda) Gauss upwind; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p ; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/fvSolution b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..39eefb2cade5bfbb05f815119a09ee203e995f6e --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/fvSolution @@ -0,0 +1,92 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + p + { + solver GAMG; + tolerance 1e-07; + relTol 0.1; + smoother GaussSeidel; + nPreSweeps 0; + nPostSweeps 2; + cacheAgglomeration on; + agglomerator faceAreaPair; + nCellsInCoarsestLevel 10; + mergeLevels 1; + } + U + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-08; + relTol 0.1; + nSweeps 1; + } + k + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-08; + relTol 0.1; + nSweeps 1; + } + omega + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-08; + relTol 0.1; + nSweeps 1; + } + nuTilda + { + solver smoothSolver; + smoother GaussSeidel; + nSweeps 2; + tolerance 1e-08; + relT 0.1; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 2; +} + +potentialFlow +{ + nNonOrthogonalCorrectors 10; +} + +relaxationFactors +{ + p 0.3; + U 0.5; + k 0.7; + omega 0.7; + nuTilda 0.5; +} + +cache +{ + grad(U) ; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/readFields b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/readFields new file mode 100644 index 0000000000000000000000000000000000000000..74f082c98b6c093bc41a629875d1f4fb92d4beb8 --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/readFields @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +// Make sure all fields for functionObjects are loaded. Prevents any +// problems running with execFlowFunctionObjects. +readFields +{ + // Where to load it from (if not already in solver) + functionObjectLibs ("libfieldFunctionObjects.so"); + + type readFields; + fields (p U); +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/snappyHexMeshDict b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/snappyHexMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..7abc429117767d7f220684e57f939ed1ada70e4d --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/snappyHexMeshDict @@ -0,0 +1,332 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object snappyHexMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Which of the steps to run +castellatedMesh true; +snap true; +addLayers false; + + +// Geometry. Definition of all surfaces. All surfaces are of class +// searchableSurface. +// Surfaces are used +// - to specify refinement for any mesh cell intersecting it +// - to specify refinement for any mesh cell inside/outside/near +// - to 'snap' the mesh boundary to the surface +geometry +{ + motorBike.stl + { + type triSurfaceMesh; + name motorBike; + } + + // Analytical shape; cylinder, sphere + refinementBox + { + type searchableBox; + min (-1.0 -0.7 0.0); + max ( 8.0 0.7 2.5); + } +}; + + + +// Settings for the castellatedMesh generation. +castellatedMeshControls +{ + + // Refinement parameters + // ~~~~~~~~~~~~~~~~~~~~~ + + // If local number of cells is >= maxLocalCells on any processor + // switches from from refinement followed by balancing + // (current method) to (weighted) balancing before refinement. + maxLocalCells 100000; + + // Overall cell limit (approximately). Refinement will stop immediately + // upon reaching this number so a refinement level might not complete. + // Note that this is the number of cells before removing the part which + // is not 'visible' from the keepPoint. The final number of cells might + // actually be a lot less. + maxGlobalCells 7000000; + + // The surface refinement loop might spend lots of iterations refining just a + // few cells. This setting will cause refinement to stop if <= minimumRefine + // are selected for refinement. Note: it will at least do one iteration + // (unless the number of cells to refine is 0) + minRefinementCells 10; + + // Allow a certain level of imbalance during refining + // (since balancing is quite expensive) + // Expressed as fraction of perfect balance (= overall number of cells / + // nProcs). 0=balance always. + maxLoadUnbalance 0.10; + + + // Number of buffer layers between different levels. + // 1 means normal 2:1 refinement restriction, larger means slower + // refinement. + nCellsBetweenLevels 3; + + + + // Explicit feature edge refinement + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // Specifies a level for any cell intersected by its edges. + // This is a featureEdgeMesh, read from constant/triSurface for now. + features + ( + //{ + // file "someLine.eMesh"; + // level 2; + //} + ); + + + + // Surface based refinement + // ~~~~~~~~~~~~~~~~~~~~~~~~ + + // Specifies two levels for every surface. The first is the minimum level, + // every cell intersecting a surface gets refined up to the minimum level. + // The second level is the maximum level. Cells that 'see' multiple + // intersections where the intersections make an + // angle > resolveFeatureAngle get refined up to the maximum level. + + refinementSurfaces + { + motorBike + { + // Surface-wise min and max refinement level + level (6 8); + } + } + + // Resolve sharp angles + resolveFeatureAngle 60; + + + // Region-wise refinement + // ~~~~~~~~~~~~~~~~~~~~~~ + + // Specifies refinement level for cells in relation to a surface. One of + // three modes + // - distance. 'levels' specifies per distance to the surface the + // wanted refinement level. The distances need to be specified in + // descending order. + // - inside. 'levels' is only one entry and only the level is used. All + // cells inside the surface get refined up to the level. The surface + // needs to be closed for this to be possible. + // - outside. Same but cells outside. + + refinementRegions + { + refinementBox + { + mode inside; + levels ((1E15 5)); + } + } + + + // Mesh selection + // ~~~~~~~~~~~~~~ + + // After refinement patches get added for all refinementSurfaces and + // all cells intersecting the surfaces get put into these patches. The + // section reachable from the locationInMesh is kept. + // NOTE: This point should never be on a face, always inside a cell, even + // after refinement. + locationInMesh (3 3 0.43); + + + // Whether any faceZones (as specified in the refinementSurfaces) + // are only on the boundary of corresponding cellZones or also allow + // free-standing zone faces. Not used if there are no faceZones. + allowFreeStandingZoneFaces false; +} + + + +// Settings for the snapping. +snapControls +{ + //- Number of patch smoothing iterations before finding correspondence + // to surface + nSmoothPatch 3; + + //- Relative distance for points to be attracted by surface feature point + // or edge. True distance is this factor times local + // maximum edge length. + tolerance 4.0; + + //- Number of mesh displacement relaxation iterations. + nSolveIter 30; + + //- Maximum number of snapping relaxation iterations. Should stop + // before upon reaching a correct mesh. + nRelaxIter 5; +} + + + +// Settings for the layer addition. +addLayersControls +{ + // Are the thickness parameters below relative to the undistorted + // size of the refined cell outside layer (true) or absolute sizes (false). + relativeSizes true; + + // Per final patch (so not geometry!) the layer information + layers + { + "(lowerWall|motorBike).*" + { + nSurfaceLayers 1; + } + } + + // Expansion factor for layer mesh + expansionRatio 1.0; + + //- Wanted thickness of final added cell layer. If multiple layers + // is the thickness of the layer furthest away from the wall. + // See relativeSizes parameter. + finalLayerThickness 0.3; + + //- Minimum thickness of cell layer. If for any reason layer + // cannot be above minThickness do not add layer. + // Relative to undistorted size of cell outside layer. + minThickness 0.1; + + //- If points get not extruded do nGrow layers of connected faces that are + // also not grown. This helps convergence of the layer addition process + // close to features. + nGrow 0; + + + // Advanced settings + + //- When not to extrude surface. 0 is flat surface, 90 is when two faces + // make straight angle. + featureAngle 60; + + //- Maximum number of snapping relaxation iterations. Should stop + // before upon reaching a correct mesh. + nRelaxIter 3; + + // Number of smoothing iterations of surface normals + nSmoothSurfaceNormals 1; + + // Number of smoothing iterations of interior mesh movement direction + nSmoothNormals 3; + + // Smooth layer thickness over surface patches + nSmoothThickness 2; + + // Stop layer growth on highly warped cells + maxFaceThicknessRatio 0.5; + + // Reduce layer growth where ratio thickness to medial + // distance is large + maxThicknessToMedialRatio 0.3; + + // Angle used to pick up medial axis points + minMedianAxisAngle 90; + + // Create buffer region for new layer terminations + nBufferCellsNoExtrude 0; + + // Overall max number of layer addition iterations + nLayerIter 50; +} + + + +// Generic mesh quality settings. At any undoable phase these determine +// where to undo. +meshQualityControls +{ + //- Maximum non-orthogonality allowed. Set to 180 to disable. + maxNonOrtho 65; + + //- Max skewness allowed. Set to <0 to disable. + maxBoundarySkewness 20; + maxInternalSkewness 4; + + //- Max concaveness allowed. Is angle (in degrees) below which concavity + // is allowed. 0 is straight face, <0 would be convex face. + // Set to 180 to disable. + maxConcave 80; + + //- Minimum projected area v.s. actual area. Set to -1 to disable. + minFlatness 0.5; + + //- Minimum pyramid volume. Is absolute volume of cell pyramid. + // Set to a sensible fraction of the smallest cell volume expected. + // Set to very negative number (e.g. -1E30) to disable. + minVol 1e-13; + minTetQuality 1e-30; + + //- Minimum face area. Set to <0 to disable. + minArea -1; + + //- Minimum face twist. Set to <-1 to disable. dot product of face normal + //- and face centre triangles normal + minTwist 0.02; + + //- minimum normalised cell determinant + //- 1 = hex, <= 0 = folded or flattened illegal cell + minDeterminant 0.001; + + //- minFaceWeight (0 -> 0.5) + minFaceWeight 0.02; + + //- minVolRatio (0 -> 1) + minVolRatio 0.01; + + //must be >0 for Fluent compatibility + minTriangleTwist -1; + + + // Advanced + + //- Number of error distribution iterations + nSmoothScale 4; + //- amount to scale back displacement at error points + errorReduction 0.75; +} + + +// Advanced + +// Flags for optional output +// 0 : only write final meshes +// 1 : write intermediate meshes +// 2 : write volScalarField with cellLevel for postprocessing +// 4 : write current intersections as .obj files +debug 0; + + +// Merge tolerance. Is fraction of overall bounding box of initial mesh. +// Note: the write tolerance needs to be higher than this. +mergeTolerance 1E-6; + + +// ************************************************************************* // + diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/streamLines b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/streamLines new file mode 100644 index 0000000000000000000000000000000000000000..a8a0c377ccb47536f9ec3b687382794dbb1318dd --- /dev/null +++ b/tutorials/incompressible/pisoFoam/les/motorBike/motorBike/system/streamLines @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ + +streamLines +{ + type streamLine; + + // Output every + outputControl outputTime; + // outputInterval 10; + + setFormat vtk; //gnuplot; //xmgr; //raw; //jplot; + + // Velocity field to use for tracking. + U U; + + // Tracked forwards (+U) or backwards (-U) + trackForward true; + + // Names of fields to sample. Should contain above velocity field! + fields (p U); + + // Steps particles can travel before being removed + lifeTime 10000; + + // Number of steps per cell (estimate). Set to 1 to disable subcycling. + nSubCycle 5; + + // Cloud name to use + cloudName particleTracks; + + // Seeding method. See the sampleSets in sampleDict. + seedSampleSet uniform; //cloud;//triSurfaceMeshPointSet; + + uniformCoeffs + { + type uniform; + axis x; //distance; + + // Note: tracks slightly offset so as not to be on a face + start (-1.001 1e-7 0.0011); + end (-1.001 1e-7 1.0011); + nPoints 20; + } +} + + +// ************************************************************************* //