From 2e99db9c229a78b86be363e589f0768427221e5e Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 23 Apr 2014 15:00:00 +0200 Subject: [PATCH 01/24] ENH: OSspecific - softlink handling (fixes #164) Links are followed in most cases, with some notable exceptions: - mv, mvBak: renames the link, not the underlying file/directory - rmDir: remove the symlink to a directory, does not recurse into the underlying directory --- applications/test/fileName/Test-fileName.C | 95 ++++++++++++++++- src/OSspecific/POSIX/POSIX.C | 100 +++++++++++++----- src/OSspecific/POSIX/fileStat.C | 16 ++- src/OSspecific/POSIX/fileStat.H | 23 +++- src/OpenFOAM/include/OSspecific.H | 38 +++++-- .../primitives/strings/fileName/fileName.C | 7 +- .../primitives/strings/fileName/fileName.H | 5 +- 7 files changed, 229 insertions(+), 55 deletions(-) diff --git a/applications/test/fileName/Test-fileName.C b/applications/test/fileName/Test-fileName.C index fb87672743..37ad0c9039 100644 --- a/applications/test/fileName/Test-fileName.C +++ b/applications/test/fileName/Test-fileName.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,6 +34,7 @@ Description #include "IOobject.H" #include "IOstreams.H" #include "OSspecific.H" +#include "POSIX.H" using namespace Foam; @@ -99,6 +100,98 @@ int main() } + + // Test some copying and deletion + { + const fileName dirA("dirA"); + const fileName lnA("lnA"); + const fileName lnB("lnB"); + const fileName dirB("dirB"); + + Foam::rmDir(dirA); + Foam::rm(lnA); + Foam::rm(lnB); + Foam::rmDir(dirB); + + + Info<< "Creating directory " << dirA << endl; + Foam::mkDir(dirA); + + + const int oldPosix = POSIX::debug; + POSIX::debug = 1; + + + // Create link and test it + Info<< "Creating softlink " << lnA << endl; + Foam::ln(dirA, lnA); + + fileName::Type lnAType = lnA.type(false); + + if (lnAType != fileName::LINK) + { + FatalErrorIn("Test-fileName") << "Type of softlink " << lnA + << " should be " << fileName::LINK + << " but is " << lnAType << exit(FatalError); + } + + fileName::Type dirAType = lnA.type(true); + + if (dirAType != fileName::DIRECTORY) + { + FatalErrorIn("Test-fileName") << "Type of what softlink " << lnA + << " points to should be " << fileName::DIRECTORY + << " but is " << dirAType << exit(FatalError); + } + + // Copy link only + { + Info<< "Copying (non-follow) softlink " << lnA << " to " << lnB + << endl; + + Foam::cp(lnA, lnB, false); + if (lnB.type(false) != fileName::LINK) + { + FatalErrorIn("Test-fileName") << "Type of softlink " << lnB + << " should be " << fileName::LINK + << " but is " << lnB.type(false) << exit(FatalError); + } + if (lnB.type(true) != fileName::DIRECTORY) + { + FatalErrorIn("Test-fileName") << "Type of softlink " << lnB + << " should be " << fileName::DIRECTORY + << " but is " << lnB.type(true) << exit(FatalError); + } + + // Delete + Foam::rm(lnB); + } + + // Copy contents of link + { + Info<< "Copying (contents of) softlink " << lnA << " to " << lnB + << endl; + + Foam::cp(lnA, lnB, true); + if (lnB.type(false) != fileName::DIRECTORY) + { + FatalErrorIn("Test-fileName") << "Type of softlink " << lnB + << " should be " << fileName::DIRECTORY + << " but is " << lnB.type(false) << exit(FatalError); + } + + // Delete + Foam::rm(lnB); + } + + POSIX::debug = oldPosix; + + Foam::rmDir(dirA); + Foam::rm(lnA); + } + + + // test findEtcFile Info<< "\n\nfindEtcFile tests:" << nl << " controlDict => " << findEtcFile("controlDict") << nl diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index 0b9a541d94..41645bf736 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -593,9 +593,9 @@ bool Foam::chMod(const fileName& name, const mode_t m) } -mode_t Foam::mode(const fileName& name) +mode_t Foam::mode(const fileName& name, const bool followLink) { - fileStat fileStatus(name); + fileStat fileStatus(name, followLink); if (fileStatus.isValid()) { return fileStatus.status().st_mode; @@ -607,14 +607,18 @@ mode_t Foam::mode(const fileName& name) } -Foam::fileName::Type Foam::type(const fileName& name) +Foam::fileName::Type Foam::type(const fileName& name, const bool followLink) { - mode_t m = mode(name); + mode_t m = mode(name, followLink); if (S_ISREG(m)) { return fileName::FILE; } + else if (S_ISLNK(m)) + { + return fileName::LINK; + } else if (S_ISDIR(m)) { return fileName::DIRECTORY; @@ -626,27 +630,39 @@ Foam::fileName::Type Foam::type(const fileName& name) } -bool Foam::exists(const fileName& name, const bool checkGzip) +bool Foam::exists +( + const fileName& name, + const bool checkGzip, + const bool followLink +) { - return mode(name) || isFile(name, checkGzip); + return mode(name, followLink) || isFile(name, checkGzip, followLink); } -bool Foam::isDir(const fileName& name) +bool Foam::isDir(const fileName& name, const bool followLink) { - return S_ISDIR(mode(name)); + return S_ISDIR(mode(name, followLink)); } -bool Foam::isFile(const fileName& name, const bool checkGzip) +bool Foam::isFile +( + const fileName& name, + const bool checkGzip, + const bool followLink +) { - return S_ISREG(mode(name)) || (checkGzip && S_ISREG(mode(name + ".gz"))); + return + S_ISREG(mode(name, followLink)) + || (checkGzip && S_ISREG(mode(name + ".gz", followLink))); } -off_t Foam::fileSize(const fileName& name) +off_t Foam::fileSize(const fileName& name, const bool followLink) { - fileStat fileStatus(name); + fileStat fileStatus(name, followLink); if (fileStatus.isValid()) { return fileStatus.status().st_size; @@ -658,9 +674,9 @@ off_t Foam::fileSize(const fileName& name) } -time_t Foam::lastModified(const fileName& name) +time_t Foam::lastModified(const fileName& name, const bool followLink) { - fileStat fileStatus(name); + fileStat fileStatus(name, followLink); if (fileStatus.isValid()) { return fileStatus.status().st_mtime; @@ -676,7 +692,8 @@ Foam::fileNameList Foam::readDir ( const fileName& directory, const fileName::Type type, - const bool filtergz + const bool filtergz, + const bool followLink ) { // Initial filename list size @@ -717,10 +734,10 @@ Foam::fileNameList Foam::readDir { fileName fName(list->d_name); - // ignore files begining with ., i.e. '.', '..' and '.*' + // ignore files beginning with ., i.e. '.', '..' and '.*' if (fName.size() && fName[0] != '.') { - word fExt = fName.ext(); + const word fExt = fName.ext(); if ( @@ -736,7 +753,7 @@ Foam::fileNameList Foam::readDir ) ) { - if ((directory/fName).type() == type) + if ((directory/fName).type(followLink) == type) { if (nEntries >= dirEntries.size()) { @@ -766,7 +783,7 @@ Foam::fileNameList Foam::readDir } -bool Foam::cp(const fileName& src, const fileName& dest) +bool Foam::cp(const fileName& src, const fileName& dest, const bool followLink) { // Make sure source exists. if (!exists(src)) @@ -777,7 +794,8 @@ bool Foam::cp(const fileName& src, const fileName& dest) fileName destFile(dest); // Check type of source file. - if (src.type() == fileName::FILE) + const fileName::Type srcType = src.type(followLink); + if (srcType == fileName::FILE) { // If dest is a directory, create the destination file name. if (destFile.type() == fileName::DIRECTORY) @@ -817,7 +835,23 @@ bool Foam::cp(const fileName& src, const fileName& dest) return false; } } - else if (src.type() == fileName::DIRECTORY) + else if (srcType == fileName::LINK) + { + // If dest is a directory, create the destination file name. + if (destFile.type() == fileName::DIRECTORY) + { + destFile = destFile/src.name(); + } + + // Make sure the destination directory exists. + if (!isDir(destFile.path()) && !mkDir(destFile.path())) + { + return false; + } + + ln(src, destFile); + } + else if (srcType == fileName::DIRECTORY) { // If dest is a directory, create the destination file name. if (destFile.type() == fileName::DIRECTORY) @@ -832,7 +866,7 @@ bool Foam::cp(const fileName& src, const fileName& dest) } // Copy files - fileNameList contents = readDir(src, fileName::FILE, false); + fileNameList contents = readDir(src, fileName::FILE, false, followLink); forAll(contents, i) { if (POSIX::debug) @@ -843,11 +877,17 @@ bool Foam::cp(const fileName& src, const fileName& dest) } // File to file. - cp(src/contents[i], destFile/contents[i]); + cp(src/contents[i], destFile/contents[i], followLink); } // Copy sub directories. - fileNameList subdirs = readDir(src, fileName::DIRECTORY); + fileNameList subdirs = readDir + ( + src, + fileName::DIRECTORY, + false, + followLink + ); forAll(subdirs, i) { if (POSIX::debug) @@ -858,9 +898,13 @@ bool Foam::cp(const fileName& src, const fileName& dest) } // Dir to Dir. - cp(src/subdirs[i], destFile); + cp(src/subdirs[i], destFile, followLink); } } + else + { + return false; + } return true; } @@ -903,7 +947,7 @@ bool Foam::ln(const fileName& src, const fileName& dst) } -bool Foam::mv(const fileName& src, const fileName& dst) +bool Foam::mv(const fileName& src, const fileName& dst, const bool followLink) { if (POSIX::debug) { @@ -914,7 +958,7 @@ bool Foam::mv(const fileName& src, const fileName& dst) if ( dst.type() == fileName::DIRECTORY - && src.type() != fileName::DIRECTORY + && src.type(followLink) != fileName::DIRECTORY ) { const fileName dstName(dst/src.name()); @@ -1016,7 +1060,7 @@ bool Foam::rmDir(const fileName& directory) { fileName path = directory/fName; - if (path.type() == fileName::DIRECTORY) + if (path.type(false) == fileName::DIRECTORY) { if (!rmDir(path)) { diff --git a/src/OSspecific/POSIX/fileStat.C b/src/OSspecific/POSIX/fileStat.C index 9826983d64..f40192f03b 100644 --- a/src/OSspecific/POSIX/fileStat.C +++ b/src/OSspecific/POSIX/fileStat.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,6 +29,7 @@ License #include #include +#include // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // @@ -38,7 +39,12 @@ Foam::fileStat::fileStat() {} -Foam::fileStat::fileStat(const fileName& fName, const unsigned int maxTime) +Foam::fileStat::fileStat +( + const fileName& fName, + const bool followLink, + const unsigned int maxTime +) { // Work on volatile volatile bool locIsValid = false; @@ -47,13 +53,13 @@ Foam::fileStat::fileStat(const fileName& fName, const unsigned int maxTime) if (!timedOut(myTimer)) { - if (::stat(fName.c_str(), &status_) != 0) + if (followLink) { - locIsValid = false; + locIsValid = (::stat(fName.c_str(), &status_) == 0); } else { - locIsValid = true; + locIsValid = (::lstat(fName.c_str(), &status_) == 0); } } diff --git a/src/OSspecific/POSIX/fileStat.H b/src/OSspecific/POSIX/fileStat.H index fe16d20470..634d0f59bd 100644 --- a/src/OSspecific/POSIX/fileStat.H +++ b/src/OSspecific/POSIX/fileStat.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,7 +25,7 @@ Class Foam::fileStat Description - Wrapper for stat() system call. + Wrapper for stat() and lstat() system calls. Warning on Linux (an maybe on others) a stat() of an nfs mounted (remote) @@ -79,8 +79,21 @@ public: //- Empty constructor fileStat(); - //- Construct from components - fileStat(const fileName& fName, const unsigned int maxTime=0); + //- Construct from components. + // \param fName \n + // The file name or directory name to stat. + // + // \param followLink \n + // If it is a link, get the status of the source file/directory. + // + // \param maxTime \n + // The timeout value. + fileStat + ( + const fileName& fName, + const bool followLink = true, + const unsigned int maxTime = 0 + ); //- Construct from Istream fileStat(Istream&); @@ -96,7 +109,7 @@ public: return status_; } - //- Did constructor fail + //- Was file-stat successful? bool isValid() const { return isValid_; diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H index d190f67045..79a2417319 100644 --- a/src/OpenFOAM/include/OSspecific.H +++ b/src/OpenFOAM/include/OSspecific.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -132,44 +132,60 @@ bool mkDir(const fileName&, mode_t=0777); bool chMod(const fileName&, const mode_t); //- Return the file mode -mode_t mode(const fileName&); +mode_t mode(const fileName&, const bool followLink=true); //- Return the file type: DIRECTORY or FILE -fileName::Type type(const fileName&); +fileName::Type type(const fileName&, const bool followLink=true); //- Does the name exist (as DIRECTORY or FILE) in the file system? // Optionally enable/disable check for gzip file. -bool exists(const fileName&, const bool checkGzip=true); +bool exists +( + const fileName&, + const bool checkGzip=true, + const bool followLink=true +); //- Does the name exist as a DIRECTORY in the file system? -bool isDir(const fileName&); +bool isDir(const fileName&, const bool followLink=true); //- Does the name exist as a FILE in the file system? // Optionally enable/disable check for gzip file. -bool isFile(const fileName&, const bool checkGzip=true); +bool isFile +( + const fileName&, + const bool checkGzip=true, + const bool followLink=true +); //- Return size of file -off_t fileSize(const fileName&); +off_t fileSize(const fileName&, const bool followLink=true); //- Return time of last file modification -time_t lastModified(const fileName&); +time_t lastModified(const fileName&, const bool followLink=true); //- Read a directory and return the entries as a string list fileNameList readDir ( const fileName&, const fileName::Type=fileName::FILE, - const bool filtergz=true + const bool filtergz=true, + const bool followLink=true ); //- Copy, recursively if necessary, the source to the destination -bool cp(const fileName& src, const fileName& dst); +bool cp(const fileName& src, const fileName& dst, const bool followLink=true); //- Create a softlink. dst should not exist. Returns true if successful. bool ln(const fileName& src, const fileName& dst); //- Rename src to dst -bool mv(const fileName& src, const fileName& dst); +bool mv +( + const fileName& src, + const fileName& dst, + const bool followLink=false +); //- Rename to a corresponding backup file // If the backup file already exists, attempt with "01" .. "99" suffix diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.C b/src/OpenFOAM/primitives/strings/fileName/fileName.C index becb5db393..0dd888c737 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.C +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -48,9 +48,9 @@ Foam::fileName::fileName(const wordList& lst) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::fileName::Type Foam::fileName::type() const +Foam::fileName::Type Foam::fileName::type(const bool followLink) const { - return ::Foam::type(*this); + return ::Foam::type(*this, followLink); } @@ -94,6 +94,7 @@ bool Foam::fileName::clean() ( string::size_type src = nChar; src < maxLen; + /*nil*/ ) { char c = operator[](src++); diff --git a/src/OpenFOAM/primitives/strings/fileName/fileName.H b/src/OpenFOAM/primitives/strings/fileName/fileName.H index 288da061b8..e45844eaeb 100644 --- a/src/OpenFOAM/primitives/strings/fileName/fileName.H +++ b/src/OpenFOAM/primitives/strings/fileName/fileName.H @@ -154,8 +154,9 @@ public: // Interrogation - //- Return the file type: FILE, DIRECTORY or UNDEFINED - Type type() const; + //- Return the file type: FILE, DIRECTORY, UNDEFINED or + // LINK (only if followLink=false) + Type type(const bool followLink = true) const; //- Return true if file name is absolute bool isAbsolute() const; From aeb667e1f41929aa2c2c82e8e166c152970b8031 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 9 Jun 2016 16:13:04 +0100 Subject: [PATCH 02/24] STYLE/ENH: reduce code duplication for coded boundary conditions (issue #184) - relocate common dictionary output into codedBase class --- .../db/dynamicLibrary/codedBase/codedBase.C | 44 ++++++++++++++-- .../db/dynamicLibrary/codedBase/codedBase.H | 10 ++-- .../codedFixedValuePointPatchField.C | 52 +------------------ .../codedFixedValueFvPatchField.C | 52 +------------------ .../codedMixed/codedMixedFvPatchField.C | 52 +------------------ 5 files changed, 54 insertions(+), 156 deletions(-) diff --git a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C index 17aad06a00..da7c1766cd 100644 --- a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C +++ b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -30,6 +30,7 @@ License #include "dlLibraryTable.H" #include "PstreamReduceOps.H" #include "OSspecific.H" +#include "Ostream.H" #include "regIOobject.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -42,6 +43,45 @@ namespace Foam // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // +namespace Foam +{ +//! \cond fileScope +static inline void writeEntryIfPresent +( + Ostream& os, + const dictionary& dict, + const word& key +) +{ + // non-recursive like dictionary::found, but no pattern-match either + const entry* ptr = dict.lookupEntryPtr(key,false,false); + + if (ptr) + { + os.writeKeyword(key) + << token::HASH << token::BEGIN_BLOCK; + + os.writeQuoted(string(ptr->stream()), false) + << token::HASH << token::END_BLOCK + << token::END_STATEMENT << nl; + } +} +//! \endcond +} + + +void Foam::codedBase::writeCodeDict(Ostream& os, const dictionary& dict) +{ + writeEntryIfPresent(os, dict, "codeInclude"); + writeEntryIfPresent(os, dict, "localCode"); + writeEntryIfPresent(os, dict, "code"); + writeEntryIfPresent(os, dict, "codeOptions"); + writeEntryIfPresent(os, dict, "codeLibs"); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + void* Foam::codedBase::loadLibrary ( const fileName& libPath, @@ -165,8 +205,6 @@ void Foam::codedBase::unloadLibrary } -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - void Foam::codedBase::createLibrary ( dynamicCode& dynCode, diff --git a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H index 8ac7114ce6..1c03e71c09 100644 --- a/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H +++ b/src/OpenFOAM/db/dynamicLibrary/codedBase/codedBase.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -43,6 +43,7 @@ namespace Foam { // Forward declaration of classes +class Ostream; class dynamicCode; class dynamicCodeContext; class dlLibraryTable; @@ -83,14 +84,17 @@ class codedBase void createLibrary(dynamicCode&, const dynamicCodeContext&) const; //- Disallow default bitwise copy construct - codedBase(const codedBase&); + codedBase(const codedBase&) = delete; //- Disallow default bitwise assignment - void operator=(const codedBase&); + void operator=(const codedBase&) = delete; protected: + //- Write code-dictionary contents + static void writeCodeDict(Ostream&, const dictionary&); + //- Update library as required void updateLibrary ( diff --git a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C index f56a8cf1e7..a840d79482 100644 --- a/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C +++ b/src/OpenFOAM/fields/pointPatchFields/derived/codedFixedValue/codedFixedValuePointPatchField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -331,55 +331,7 @@ void Foam::codedFixedValuePointPatchField::write(Ostream& os) const os.writeKeyword("redirectType") << redirectType_ << token::END_STATEMENT << nl; - if (dict_.found("codeInclude")) - { - os.writeKeyword("codeInclude") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["codeInclude"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("localCode")) - { - os.writeKeyword("localCode") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["localCode"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("code")) - { - os.writeKeyword("code") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["code"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("codeOptions")) - { - os.writeKeyword("codeOptions") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["codeOptions"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("codeLibs")) - { - os.writeKeyword("codeLibs") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["codeLibs"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } + codedBase::writeCodeDict(os, dict_); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C index cfd6945420..5771972313 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -329,55 +329,7 @@ void Foam::codedFixedValueFvPatchField::write(Ostream& os) const os.writeKeyword("redirectType") << redirectType_ << token::END_STATEMENT << nl; - if (dict_.found("codeInclude")) - { - os.writeKeyword("codeInclude") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["codeInclude"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("localCode")) - { - os.writeKeyword("localCode") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["localCode"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("code")) - { - os.writeKeyword("code") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["code"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("codeOptions")) - { - os.writeKeyword("codeOptions") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["codeOptions"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("codeLibs")) - { - os.writeKeyword("codeLibs") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["codeLibs"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } + codedBase::writeCodeDict(os, dict_); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C index d1b53e144d..450aa8b9e6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedMixed/codedMixedFvPatchField.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -341,55 +341,7 @@ void Foam::codedMixedFvPatchField::write(Ostream& os) const os.writeKeyword("redirectType") << redirectType_ << token::END_STATEMENT << nl; - if (dict_.found("codeInclude")) - { - os.writeKeyword("codeInclude") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["codeInclude"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("localCode")) - { - os.writeKeyword("localCode") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["localCode"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("code")) - { - os.writeKeyword("code") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["code"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("codeOptions")) - { - os.writeKeyword("codeOptions") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["codeOptions"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } - - if (dict_.found("codeLibs")) - { - os.writeKeyword("codeLibs") - << token::HASH << token::BEGIN_BLOCK; - - os.writeQuoted(string(dict_["codeLibs"]), false) - << token::HASH << token::END_BLOCK - << token::END_STATEMENT << nl; - } + codedBase::writeCodeDict(os, dict_); } From 42b208668328852e226a2359355015725224983e Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 16 Jun 2016 08:22:53 +0200 Subject: [PATCH 03/24] ENH: adapter for a list of C++ strings <-> a list of C-style strings - Translate a list of C++ strings into C-style (argc, argv) pair. - Translate C-style (argc, argv) pair to list of C++ strings. Useful when interfacing to external C-code and some libraries --- applications/test/cstring/Make/files | 3 + applications/test/cstring/Make/options | 2 + applications/test/cstring/Test-cstring.C | 99 ++++++++++ .../primitives/strings/lists/CStringList.H | 175 ++++++++++++++++++ .../primitives/strings/lists/CStringListI.H | 106 +++++++++++ .../strings/lists/CStringListTemplates.C | 115 ++++++++++++ 6 files changed, 500 insertions(+) create mode 100644 applications/test/cstring/Make/files create mode 100644 applications/test/cstring/Make/options create mode 100644 applications/test/cstring/Test-cstring.C create mode 100644 src/OpenFOAM/primitives/strings/lists/CStringList.H create mode 100644 src/OpenFOAM/primitives/strings/lists/CStringListI.H create mode 100644 src/OpenFOAM/primitives/strings/lists/CStringListTemplates.C diff --git a/applications/test/cstring/Make/files b/applications/test/cstring/Make/files new file mode 100644 index 0000000000..eb7e33dc8b --- /dev/null +++ b/applications/test/cstring/Make/files @@ -0,0 +1,3 @@ +Test-cstring.C + +EXE = $(FOAM_USER_APPBIN)/Test-cstring diff --git a/applications/test/cstring/Make/options b/applications/test/cstring/Make/options new file mode 100644 index 0000000000..6a9e9810b3 --- /dev/null +++ b/applications/test/cstring/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */ +/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/cstring/Test-cstring.C b/applications/test/cstring/Test-cstring.C new file mode 100644 index 0000000000..fc4605cfa4 --- /dev/null +++ b/applications/test/cstring/Test-cstring.C @@ -0,0 +1,99 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Description + Test some string functionality + +\*---------------------------------------------------------------------------*/ + +#include "CStringList.H" +#include "DynamicList.H" +#include "IOstreams.H" +#include "fileNameList.H" +#include "stringList.H" +#include "wordList.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int print(int argc, char *argv[]) +{ + Info<< "argc=" << argc << endl; + for (int i=0; i dynlst; + dynlst.reserve(16); + + dynlst.append("string1 with content"); + dynlst.append("string2 other content"); + dynlst.append("string3 done"); + + { + CStringList inC(dynlst); + + Info<< "input: " << dynlst << endl; + print(inC); + } + + Info<<"command-line with " << CStringList::count(argv) << " items"<< endl; + + print(argc, argv); + { + dynlst.clear(); + for (int i=0; i. + +Class + Foam::CStringList + +Description + An adapter for copying a list of C++ strings into a list of C-style + strings for passing to C code that expects argc/argv parameters. + + In addition to providing a C-compatible list of C-strings, + the string lists are flattened into a single string of data that can be + also be passed en mass. + + Example use: + \code + wordList myStrings; ... + CStringList cstr(myStrings); + + // pass as argc, argv: + someMain(cstr.size(), cstr.strings()); + + // access the raw characters: + os.write(cstr.data(), cstr.length()); + \endcode + +\*---------------------------------------------------------------------------*/ + +#ifndef CStringList_H +#define CStringList_H + +#include "fileNameList.H" +#include "stringList.H" +#include "wordList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class CStringList Declaration +\*---------------------------------------------------------------------------*/ + +class CStringList +{ + // Private data + + //- Number of strings + int argc_; + + //- Overall length of the raw content + // Does not include the final nul-character + size_t len_; + + //- List of strings, including trailing NULL pointer + char** argv_; + + //- Flattened content with interspersed nul-characters + char* data_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + CStringList(const CStringList&) = delete; + + //- Disallow default bitwise assignment + void operator=(const CStringList&) = delete; + + +public: + + // Constructors + + //- Construct empty, adding content later (via reset). + inline CStringList(); + + + //- Construct from a list of strings + // Copies the input characters. + template + CStringList(const UList& input); + + + //- Destructor + inline ~CStringList(); + + + // Public Members + + //- Count the number of parameters until the first NULL pointer. + // Return 0 if argv is NULL. + static inline int count(const char * const argv[]); + + + // Access + + //- Return the number of C-strings (ie, argc) + inline int size() const; + + //- Return the list of C-strings (ie, argv) + // The position at argc is a NULL pointer + inline char** strings() const; + + + //- Overall length of the flattened character (data) content + inline size_t length() const; + + //- The flattened character content, with interspersed nul-chars + inline char* data() const; + + + // Edit + + //- Clear contents and free memory + inline void clear(); + + //- Copy the input list of strings. + template + void reset(const UList& input); + + + // Other + + //- Create a list from argc/argv parameters. + // A null pointer for argv is permissible when argc is zero. + template + static List asList(int argc, const char * const argv[]); + + //- Create a list from a NULL-terminated list of argv parameters. + // A null pointer for argv is permissible. + template + static inline List asList(const char * const argv[]); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "CStringListI.H" + +#ifdef NoRepository +# include "CStringListTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/strings/lists/CStringListI.H b/src/OpenFOAM/primitives/strings/lists/CStringListI.H new file mode 100644 index 0000000000..d91a9de646 --- /dev/null +++ b/src/OpenFOAM/primitives/strings/lists/CStringListI.H @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // + +inline int Foam::CStringList::count(const char * const argv[]) +{ + int nElem = 0; + if (argv) + { + while (argv[nElem]) + { + ++nElem; + } + } + + return nElem; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +inline Foam::CStringList::CStringList() +: + argc_(0), + len_(0), + argv_(0), + data_(0) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +inline Foam::CStringList::~CStringList() +{ + clear(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +inline void Foam::CStringList::clear() +{ + argc_ = 0; + len_ = 0; + + if (data_) + { + delete[] data_; + data_ = 0; + } + if (argv_) + { + delete[] argv_; + argv_ = 0; + } +} + + +inline int Foam::CStringList::size() const +{ + return argc_; +} + + +inline size_t Foam::CStringList::length() const +{ + return len_; +} + + +inline char** Foam::CStringList::strings() const +{ + return argv_; +} + + +inline char* Foam::CStringList::data() const +{ + return data_; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/strings/lists/CStringListTemplates.C b/src/OpenFOAM/primitives/strings/lists/CStringListTemplates.C new file mode 100644 index 0000000000..db0bb2e2ff --- /dev/null +++ b/src/OpenFOAM/primitives/strings/lists/CStringListTemplates.C @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::CStringList::CStringList +( + const UList& input +) +: + argc_(0), + len_(0), + argv_(0), + data_(0) +{ + reset(input); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::CStringList::reset +( + const UList& input +) +{ + clear(); + + argc_ = input.size(); + forAll(input, argI) + { + len_ += input[argI].size(); + ++len_; // nul terminator for C-strings + } + + argv_ = new char*[argc_+1]; + argv_[argc_] = NULL; // extra terminator + + if (argc_ > 0) + { + // allocation includes final nul terminator, + // but overall count does not + data_ = new char[len_--]; + + char* ptr = data_; + forAll(input, argI) + { + argv_[argI] = ptr; + + const std::string& str = + static_cast(input[argI]); + + for + ( + std::string::const_iterator iter = str.begin(); + iter != str.end(); + ++iter + ) + { + *(ptr++) = *iter; + } + *(ptr++) = '\0'; + } + } +} + + +template +Foam::List +Foam::CStringList::asList(int argc, const char * const argv[]) +{ + List lst(argc); + + for (int i=0; i < argc; ++i) + { + lst[i] = argv[i]; + } + + return lst; +} + + +template +Foam::List +Foam::CStringList::asList(const char * const argv[]) +{ + return asList(count(argv), argv); +} + + +// ************************************************************************* // From 6ed05f0cd32f5c45cc3473985993fb024ba2fc92 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 6 Jul 2016 07:43:05 +0200 Subject: [PATCH 04/24] STYLE: mention suppression of banner for surfaceMeshInfo, ... (issue #125) --- .../utilities/miscellaneous/foamInfoExec/foamInfoExec.C | 4 +++- .../miscellaneous/foamListTimes/foamListTimes.C | 4 +++- .../utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C b/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C index 3b336287f8..3b671c5b4c 100644 --- a/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C +++ b/applications/utilities/miscellaneous/foamInfoExec/foamInfoExec.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -23,6 +23,8 @@ License Application foamInfoExec + To simplify parsing of the output, The normal banner information + is suppressed. Group grpMiscUtilities diff --git a/applications/utilities/postProcessing/miscellaneous/foamListTimes/foamListTimes.C b/applications/utilities/postProcessing/miscellaneous/foamListTimes/foamListTimes.C index 553f9f7f52..3e20143e1b 100644 --- a/applications/utilities/postProcessing/miscellaneous/foamListTimes/foamListTimes.C +++ b/applications/utilities/postProcessing/miscellaneous/foamListTimes/foamListTimes.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,6 +29,8 @@ Group Description List times using timeSelector. + To simplify parsing of the output, the normal banner information + is suppressed. Usage diff --git a/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C b/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C index 3ea27c4f8b..0bc6fb5992 100644 --- a/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C +++ b/applications/utilities/surface/surfaceMeshInfo/surfaceMeshInfo.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -29,6 +29,8 @@ Group Description Miscellaneous information about surface meshes. + To simplify parsing of the output, the normal banner information + is suppressed. Usage - surfaceMeshInfo surfaceFile [OPTION] From 1a9112e1b261d12083f865590537e14763e8716f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 6 Jul 2016 08:11:42 +0200 Subject: [PATCH 05/24] CONFIG: rename config file to avoid premature filtering of its name --- applications/utilities/mesh/conversion/Optional/Allwmake | 2 +- etc/config.sh/{libccmio => ccmio} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename etc/config.sh/{libccmio => ccmio} (98%) diff --git a/applications/utilities/mesh/conversion/Optional/Allwmake b/applications/utilities/mesh/conversion/Optional/Allwmake index f84479c089..adf350c5c8 100755 --- a/applications/utilities/mesh/conversion/Optional/Allwmake +++ b/applications/utilities/mesh/conversion/Optional/Allwmake @@ -8,7 +8,7 @@ cd ${0%/*} || exit 1 # Run from this directory . $WM_PROJECT_DIR/wmake/scripts/AllwmakeParseArguments # Get version info and arch-path . $WM_PROJECT_DIR/etc/config.sh/functions -_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/libccmio) +_foamSource $($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio) set -x diff --git a/etc/config.sh/libccmio b/etc/config.sh/ccmio similarity index 98% rename from etc/config.sh/libccmio rename to etc/config.sh/ccmio index 1ef4205640..6bd6aa42ac 100644 --- a/etc/config.sh/libccmio +++ b/etc/config.sh/ccmio @@ -22,7 +22,7 @@ # along with OpenFOAM. If not, see . # # File -# etc/config.sh/libccmio +# etc/config.sh/ccmio # # Description # Setup file for libccmio include/libraries. From dc5c42701c74cae8a22baf32872b8da403a3f6a2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 6 Jul 2016 09:23:55 +0100 Subject: [PATCH 06/24] BUG: config.csh: wrong variable. Fixes #176 --- etc/config.csh/settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/etc/config.csh/settings b/etc/config.csh/settings index 24ef70ab9d..892f28fa37 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -208,7 +208,7 @@ unsetenv GMP_ARCH_PATH MPFR_ARCH_PATH # Location of compiler installation # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if ( ! $?WM_COMPILER_TYPE ) then - set WM_COMPILER_TYPE=system + setenv WM_COMPILER_TYPE system echo "Warning in $WM_PROJECT_DIR/etc/config.csh/settings:" echo " WM_COMPILER_TYPE not set, using '$WM_COMPILER_TYPE'" endif From 2ed6b4da9200df1cff354287e548e590b4133e0d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 6 Jul 2016 11:47:10 +0200 Subject: [PATCH 07/24] STYLE: documentation typo in EulerCoordinateRotation, add external reference --- .../coordinateRotation/EulerCoordinateRotation.H | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H index 6560a084a0..cdaee88232 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H @@ -25,12 +25,17 @@ Class Foam::EulerCoordinateRotation Description - A coordinateRotation defined in the z-x-y Euler convention. + A coordinateRotation defined in the z-x-z (intrinsic) Euler convention. + + The 3 rotations are defined in the Euler intrinsic convention + (around Z, around X' and around Z''). + The order of the parameter arguments matches this rotation order. - The 3 rotations are defined in the Euler convention - (around Z, around X' and around Z'). For reference and illustration, see http://mathworld.wolfram.com/EulerAngles.html + and + https://en.wikipedia.org/wiki/Euler_angles#Conventions + Note, however, that it is the reverse transformation (local->global) that is defined here. From e799329515cac197dc585b3ae7a37fbbfe05a318 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 7 Jul 2016 11:17:09 +0200 Subject: [PATCH 08/24] COMP: template ambiguity for 64-bit labels (issue #175) --- .../turbulentDFSEMInletFvPatchVectorField.C | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C index 5b229917ac..b0df476fe0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C @@ -80,7 +80,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::writeEddyOBJ() const // label i2 = ((i + 1) % nPoint) + nPoint; // os << "l " << i1 << " " << i2 << nl; //} - } + } { const Time& time = db().time(); @@ -95,7 +95,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::writeEddyOBJ() const const eddy& e = eddies_[eddyI]; pointOffset += e.writeSurfaceOBJ(pointOffset, patchNormal_, os); } - } + } } @@ -141,7 +141,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::writeLumleyCoeffs() const scalar eta = sqrt(-ii/3.0); os << xi << token::TAB << eta << token::TAB << ii << token::TAB << iii << endl; - } + } } // After interpolation @@ -1107,7 +1107,7 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::write(Ostream& os) const writeEntryIfDifferent(os, "d", 1.0, d_); writeEntryIfDifferent(os, "kappa", 0.41, kappa_); writeEntryIfDifferent(os, "perturb", 1e-5, perturb_); - writeEntryIfDifferent(os, "nCellPerEddy", 5, nCellPerEddy_); + writeEntryIfDifferent