diff --git a/src/functionObjects/field/ddt2/ddt2.C b/src/functionObjects/field/ddt2/ddt2.C index 9fe5cb4728106b8ab13862149aa345c817bafa65..83998083541585fbcacf42a189368203c85d338d 100644 --- a/src/functionObjects/field/ddt2/ddt2.C +++ b/src/functionObjects/field/ddt2/ddt2.C @@ -50,13 +50,15 @@ namespace functionObjects // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::functionObjects::ddt2::checkFormatName(const word& str) +bool Foam::functionObjects::ddt2::checkFormatName +( + const std::string& str +) { - if (str.find("@@") == string::npos) + if (std::string::npos == str.find("@@")) { WarningInFunction - << "Bad result naming " - << "(no '@@' token found), deactivating." + << "Bad result naming (no '@@' token found)." << nl << endl; return false; @@ -64,10 +66,8 @@ bool Foam::functionObjects::ddt2::checkFormatName(const word& str) else if (str == "@@") { WarningInFunction - << "Bad result naming " - << "(only a '@@' token found), deactivating." - << nl - << endl; + << "Bad result naming (only a '@@' token found)." + << nl << endl; return false; } @@ -145,7 +145,12 @@ bool Foam::functionObjects::ddt2::read(const dictionary& dict) ( mag_ ? "mag(ddt(@@))" : "magSqr(ddt(@@))" ) ); - if (checkFormatName(resultName_)) + // Expect '@@' token for result, unless a single (non-regex) source field + if + ( + (selectFields_.size() == 1 && selectFields_.first().isLiteral()) + || checkFormatName(resultName_) + ) { blacklist_.set ( diff --git a/src/functionObjects/field/ddt2/ddt2.H b/src/functionObjects/field/ddt2/ddt2.H index cf50a8c1f2d3ed3b6a84e9ef75685c31f9308186..31f54e89a51467da862cda373eee0dda408b695c 100644 --- a/src/functionObjects/field/ddt2/ddt2.H +++ b/src/functionObjects/field/ddt2/ddt2.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -62,7 +62,8 @@ Usage A list of fields can contain exact names or regular expressions. The token '\@\@' in the result name is replaced by the name of the source - field. + field. In the special case of a single source field (specified as + a non-regex), the '\@\@' token checking is suppressed. The function object will skip over fields that appear to have already been processed (ie, their names are similar to the output names). @@ -100,7 +101,7 @@ class ddt2 { // Private data - //- Name of fields to process + //- Name of fields to process. wordRes selectFields_; //- Formatting for the result fields. @@ -120,8 +121,8 @@ class ddt2 // Private Member Functions - //- Check that the word contains the appropriate substitution token(s). - static bool checkFormatName(const word& str); + //- Check that string contains the appropriate substitution token(s). + static bool checkFormatName(const std::string& str); //- Accept unless field name appears to have already been processed diff --git a/src/functionObjects/field/zeroGradient/zeroGradient.C b/src/functionObjects/field/zeroGradient/zeroGradient.C index e1e79010c8e319e2690fd6f67c34c8575a5f86eb..3383c8f83c3ae3e5cb098aa53b9484c04be3f805 100644 --- a/src/functionObjects/field/zeroGradient/zeroGradient.C +++ b/src/functionObjects/field/zeroGradient/zeroGradient.C @@ -49,13 +49,15 @@ namespace functionObjects // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -bool Foam::functionObjects::zeroGradient::checkFormatName(const word& str) +bool Foam::functionObjects::zeroGradient::checkFormatName +( + const std::string& str +) { - if (str.find("@@") == string::npos) + if (std::string::npos == str.find("@@")) { WarningInFunction - << "Bad result naming " - << "(no '@@' token found), deactivating." + << "Bad result naming (no '@@' token found)." << nl << endl; return false; @@ -63,10 +65,8 @@ bool Foam::functionObjects::zeroGradient::checkFormatName(const word& str) else if (str == "@@") { WarningInFunction - << "Bad result naming " - << "(only a '@@' token found), deactivating." - << nl - << endl; + << "Bad result naming (only a '@@' token found)." + << nl << endl; return false; } @@ -118,7 +118,13 @@ bool Foam::functionObjects::zeroGradient::read(const dictionary& dict) Info<< type() << " fields: " << selectFields_ << nl; resultName_ = dict.lookupOrDefault<word>("result", type() + "(@@)"); - return checkFormatName(resultName_); + + // Require '@@' token for result, unless a single (non-regex) source field + return + ( + (selectFields_.size() == 1 && selectFields_.first().isLiteral()) + || checkFormatName(resultName_) + ); } diff --git a/src/functionObjects/field/zeroGradient/zeroGradient.H b/src/functionObjects/field/zeroGradient/zeroGradient.H index 04f610648c80cd6cc51b24de9109a30d0a546b58..da57e674ac52234fea6ce7a1ba0a5f9eadbe44dd 100644 --- a/src/functionObjects/field/zeroGradient/zeroGradient.H +++ b/src/functionObjects/field/zeroGradient/zeroGradient.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2016-2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2016-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -58,7 +58,8 @@ Usage A list of fields can contain exact names or regular expressions. The token '\@\@' in the result name is replaced by the name of the source - field. + field. In the special case of a single source field (specified as + a non-regex), the '\@\@' token checking is suppressed. The function object will skip over fields that would not benefit - ie, only processor, empty, zeroGradient, symmetry patches. @@ -95,20 +96,20 @@ class zeroGradient { // Private data - //- Name of fields to process + //- Name of fields to process. wordRes selectFields_; //- Formatting for the result fields. word resultName_; - //- Hashed names of result fields, and their type + //- Hashed names of result fields, and their type. HashTable<word> results_; // Private Member Functions - //- Check that the word contains the appropriate substitution token(s). - static bool checkFormatName(const word& str); + //- Check that string contains the appropriate substitution token(s). + static bool checkFormatName(const std::string& str); //- Accept unless field only has constraint patches